All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
compile.cc File Reference
#include <iostream>
#include <string.h>
#include <cassert>
#include "compile.h"
#include "scanner.h"

Go to the source code of this file.

Functions

static bool identifiersEqual (uscript::Token *a, uscript::Token *b)
 
static void PrintErrorAt (uscript::Token &token, const char *message, const char *source)
 

Function Documentation

static bool identifiersEqual ( uscript::Token a,
uscript::Token b 
)
static

Definition at line 74 of file compile.cc.

74  {
75  if (a->length != b->length) return false;
76  return memcmp(a->start, b->start, a->length) == 0;
77 }
const char * start
Definition: scanner.h:40
static void PrintErrorAt ( uscript::Token token,
const char *  message,
const char *  source 
)
static

Definition at line 368 of file compile.cc.

368  {
369  std::cerr << "Error";
370  if (token.type == uscript::TOKEN_EOF) {
371  std::cerr << " at end";
372  }
373  else if (token.type == uscript::TOKEN_ERROR) {
374  // nothing
375  }
376  else {
377  std::string error(token.start, token.start + token.length);
378  std::cerr << " at " << error ;
379  }
380 
381  std::cerr << ": " << message << std::endl;
382  std::cerr << "In script: " << source << std::endl;
383  return;
384 }
BEGIN_PROLOG could also be cerr
do source
TokenType type
Definition: scanner.h:39
const char * start
Definition: scanner.h:40