11 TOK_TOP=1, TOK_AND, TOK_OR, TOK_NOT, TOK_LPAR, TOK_RPAR, TOK_LBRA,
12 TOK_RBRA, TOK_LCURL, TOK_RCURL, TOK_MUL, TOK_PLUS, TOK_MINUS, TOK_NEG,
13 TOK_DIV, TOK_CAT, TOK_COLON, TOK_DOT, TOK_COMMA, TOK_SEMI,
14 TOK_ASSIGN, TOK_LT, TOK_LTE, TOK_EQ, TOK_NEQ, TOK_GT, TOK_GTE,
15 TOK_IF, TOK_ELSIF, TOK_ELSE, TOK_FOR, TOK_FOREACH, TOK_WHILE,
16 TOK_RETURN, TOK_BREAK, TOK_CONTINUE, TOK_FUNC, TOK_SYMBOL,
17 TOK_LITERAL, TOK_EMPTY, TOK_NIL
29 struct Token* children;
30 struct Token* lastChild;
34 // Handle to the Nasal interpreter
35 struct Context* context;
41 // The parse tree ubernode
48 // Input file parameters (for generating pretty stack dumps)
52 // Chunk allocator. Throw away after parsing.
58 // Computed line number table for the lexer
62 struct CodeGenerator* cg;
65 struct CodeGenerator {
68 // Accumulated byte code array
69 unsigned char* byteCode;
73 // Stack of "loop" frames for break/continue statements
78 } loops[MAX_MARK_DEPTH];
81 // Dynamic storage for constants, to be compiled into a static table
82 naRef consts; // index -> naRef
83 naRef interned; // naRef -> index (scalars only!)
87 void naParseError(struct Parser* p, char* msg, int line);
88 void naParseInit(struct Parser* p);
89 void* naParseAlloc(struct Parser* p, int bytes);
90 void naParseDestroy(struct Parser* p);
91 void naLex(struct Parser* p);
92 naRef naCodeGen(struct Parser* p, struct Token* tok);
94 void naParse(struct Parser* p);