-Subproject commit 244613ffd2288f8d51ecab2c6743f1a1c28d6537
+Subproject commit dbd1bb9634cee2c271477bb32b8556f017be5559
# Macro Tests
#------------------------------------------------------------------------------
# Macro Definitions
-% if ( cond, branch1:Block ) {
- exec_if( cond, branch1 )
-}
-
-% ifelse ( cond, branch1:Block, branch2:Block ) {
- exec_if( cond, branch1, branch2 )
-}
-
-% foreach ( lst, fn:Block ) {
- for_each(fn, lst)
-}
+#% if ( cond, branch1:Block ) {
+# exec_if( cond, branch1 )
+#}
+#
+#% ifelse ( cond, branch1:Block, branch2:Block ) {
+# exec_if( cond, branch1, branch2 )
+#}
+#
+#% foreach ( lst, fn:Block ) {
+# for_each(fn, lst)
+#}
# Macro Uses
-if (1 == 1)
-{
- print("1 Hello, World!")
-}
-
-if (1 == 0)
-{
- print("Hello, World!")
-}
-
-ifelse (1 == 1)
-{
- print("2 Hello, World!")
-}{
- error("Incorrect branch was taken.")
-}
-
-ifelse (1 == 0)
-{
- error("Incorrect branch was taken.")
-}{
- print("3 Hello, World!")
-}
+#if (1 == 1)
+#{
+# print("1 Hello, World!")
+#}
+#
+#if (1 == 0)
+#{
+# print("Hello, World!")
+#}
+#
+#ifelse (1 == 1)
+#{
+# print("2 Hello, World!")
+#}{
+# error("Incorrect branch was taken.")
+#}
+#
+#ifelse (1 == 0)
+#{
+# error("Incorrect branch was taken.")
+#}{
+# print("3 Hello, World!")
+#}
#------------------------------------------------------------------------------
# Collection Access and Iteration Tests
#------------------------------------------------------------------------------
# Accessing elements of lists, vectors, and strings
-lst1 = `(4,5,6)
-print(lst1[0], " Hello, World!")
-
-vec1 = [4,5,6]
-print(vec1[1], " Hello, World!")
-
-str1 = "456"
-print(str1[2], " Hello, World!")
-
-# Iterating over lists, vectors, and strings
-lst_foo = `(7,8,9,10)
-foreach lst_foo { |a|
- print(a," Hello, World!")
-}
-
-vec_foo = [11,12,13,14,15]
-foreach vec_foo { |a,b|
- print(b," Hello, World!")
-}
-
-str_foo = "6789"
-foreach str_foo { |a|
- print(1,a," Hello, World!")
-}
+#lst1 = `(4,5,6)
+#print(lst1[0], " Hello, World!")
+#
+#vec1 = [4,5,6]
+#print(vec1[1], " Hello, World!")
+#
+#str1 = "456"
+#print(str1[2], " Hello, World!")
+#
+## Iterating over lists, vectors, and strings
+#lst_foo = `(7,8,9,10)
+#foreach lst_foo { |a|
+# print(a," Hello, World!")
+#}
+#
+#vec_foo = [11,12,13,14,15]
+#foreach vec_foo { |a,b|
+# print(b," Hello, World!")
+#}
+#
+#str_foo = "6789"
+#foreach str_foo { |a|
+# print(1,a," Hello, World!")
+#}
#------------------------------------------------------------------------------
# Delayed Evaluation
#------------------------------------------------------------------------------
% delay ( exp ) {
- make_promise({ exp })
+ make_promise({ exp })
}
% force ( prom ) {
- force( prom )
+ force( prom )
}
foo = delay nonexistent_var + 1
:name => 'dlang',
:output_dir => 'build/parser',
:compiler_options => [ '-c', '-Wall', '-Werror', '-o' ],
+ :static_libs => [ './deps/cork/build/static/bin/libcork.a' ],
:source_files => [ 'source/**/*.c*' ],
- :include_dirs => [ 'source/**/' ],
- :preprocessor_defines => [ 'DETECT_MEM_LEAKS' ]
+ :include_dirs => [
+ 'source/**/',
+ 'deps/cork/source/**/'
+ ],
+ #:preprocessor_defines => [ 'DETECT_MEM_LEAKS' ]
})
DLangParser.setup_default_rake_tasks()
+++ /dev/null
-#include "cork.h"
-
-#ifdef DETECT_MEM_LEAKS
-
-// We want to use the real malloc and free in this file
-#undef malloc
-#undef free
-
-#include <iostream>
-#include <exception> // for std::bad_alloc
-#include <cstdlib> // for malloc() and free()
-#include <string.h>
-
-// Set the namespace
-using namespace std;
-/******************************************************************************
- * Typedefs
- *****************************************************************************/
-typedef struct BlockTableEntry
-{
- void * ptr;
- unsigned int size;
- const char* file;
- int line;
- void * next;
-} BlockTableEntry_T;
-
-typedef struct BlockTable
-{
- unsigned int size;
- BlockTableEntry_T* blocks[TBL_SIZE];
-} BlockTable_T;
-
-/******************************************************************************
- * Prototypes
- *****************************************************************************/
-void insert_record(void * ptr, BlockTable_T* entry);
-void erase_record(void * ptr);
-
-/******************************************************************************
- * Globals
- *****************************************************************************/
-unsigned int allocated;
-static BlockTable_T Block_Table = { 0, {0} };
-
-/******************************************************************************
- * Function Definitions
- *****************************************************************************/
-void insert_record(void * ptr, BlockTableEntry_T* entry)
-{
- unsigned int index = ((unsigned int)ptr) % TBL_SIZE;
- BlockTableEntry_T* last = Block_Table.blocks[ index ];
- BlockTableEntry_T* curr = last;
-
- while (curr != NULL)
- {
- if ( curr->ptr == ptr )
- {
- curr->size = entry->size;
- free(entry);
- break;
- }
- last = curr;
- curr = (BlockTableEntry_T*)curr->next;
- }
-
- if(curr == NULL)
- {
- if (last != NULL)
- {
- last->next = entry;
- }
- else
- {
- Block_Table.blocks[index] = entry;
- }
- Block_Table.size++;
- }
-}
-
-void erase_record(void * ptr)
-{
- int depth = 0;
- unsigned int index = ((unsigned int)ptr) % TBL_SIZE;
- BlockTableEntry_T* last = Block_Table.blocks[ index ];
- BlockTableEntry_T* curr = last;
-
- while( curr != NULL )
- {
- depth = 1;
- if( curr->ptr == ptr )
- {
- depth = 2;
- if(last == curr)
- {
- depth = 3;
- Block_Table.blocks[ index ] = (BlockTableEntry_T*)curr->next;
- }
- else
- {
- depth = 4;
- last->next = curr->next;
- }
- free(curr);
- Block_Table.size--;
- break;
- }
- last = curr;
- curr = (BlockTableEntry_T*)curr->next;
- }
-}
-
-void Cork_ReportMemoryLeaks(void)
-{
- unsigned int index = 0;
- cout << "-----------------------------------------------------------------" << endl;
- cout << "Cork: Memory Allocation Analysis" << endl;
- cout << "-----------------------------------------------------------------" << endl;
- cout << "You have " << Block_Table.size << " Unclaimed objects." << endl;
-
- for(; index < TBL_SIZE; index++)
- {
- BlockTableEntry_T* entry = Block_Table.blocks[ index ];
- while(entry != NULL)
- {
- cout << "\t" << entry->size << "\t" << entry->ptr;
- if( entry->file != NULL )
- {
- cout << "\t" << entry->line << "\t" << entry->file;
- }
- cout << endl;
- entry = (BlockTableEntry_T*)entry->next;
- }
- }
-}
-
-void * operator new (size_t size, string file, unsigned int line)
-{
- void * ptr = malloc(size);
- char * fname = (char*)malloc(file.length());
- if(ptr == NULL)
- {
- throw bad_alloc();
- }
- else
- {
- BlockTableEntry_T* entry = (BlockTableEntry_T*)malloc(sizeof(BlockTableEntry_T));
- strcpy( fname, file.c_str() );
- entry->ptr = ptr;
- entry->size = size;
- entry->file = fname;
- entry->line = line;
- entry->next = NULL;
- insert_record(ptr,entry);
- }
- return ptr;
-}
-
-void * operator new(size_t size) throw(bad_alloc) {
- void * ptr = malloc(size);
- if(ptr == NULL)
- {
- throw bad_alloc();
- }
- else
- {
- BlockTableEntry_T* entry = (BlockTableEntry_T*)malloc(sizeof(BlockTableEntry_T));
- entry->ptr = ptr;
- entry->size = size;
- entry->file = NULL;
- entry->line = 0;
- entry->next = NULL;
- insert_record(ptr,entry);
- }
- return ptr;
-}
-
-void operator delete(void * p) {
- free(p);
- erase_record(p);
-}
-
-#endif
+++ /dev/null
-#ifndef CORK_H
-#define CORK_H
-
-#ifdef DETECT_MEM_LEAKS
- #include <string>
- typedef unsigned int size_t;
-
- void Cork_ReportMemoryLeaks(void);
- void * operator new (size_t size, std::string file, unsigned int line);
- #define TBL_SIZE 512
- #define REPORT_LEAKS() Cork_ReportMemoryLeaks()
- #define _new new (__FILE__,__LINE__)
-#else
- #define REPORT_LEAKS()
- #define _new new
-#endif
-
-#endif
&& (current != '\n'));
}
-Token* DLLexer::next(void)
+Token DLLexer::next(void)
{
- Token* ret = NULL;
- while ( (!input->eof()) && (ret == NULL) )
+ Token ret;
+ Token* temp = NULL;
+ while ( (!input->eof()) && (temp == NULL) )
{
if (isWhiteSpace())
{
}
else if (isLetter())
{
- ret = Id();
+ temp = Id();
}
else if( isOperator() )
{
- ret = MultiCharOp();
+ temp = MultiCharOp();
}
else if (isDigit())
{
- ret = Number();
+ temp = Number();
}
else if(current == '\'')
{
- ret = Char();
+ temp = Char();
}
else if(current == '"')
{
- ret = String();
+ temp = String();
}
else if(current == '$')
{
- ret = Symbol();
+ temp = Symbol();
}
else
{
- ret = SingleCharOp();
+ temp = SingleCharOp();
}
}
+
+ if(temp != NULL)
+ {
+ ret = *(temp);
+ delete temp;
+ }
+
return ret;
}
void WS(void);
void COMMENT(void);
- Token* next(void);
+ Token next(void);
Token* Id(void);
Token* Number(void);
Token* Decimal(std::ostringstream& oss);
#include "exception.h"
#include "cork.h"
-DLParser::DLParser() : BTParser(_new DLLexer()), ast(NULL)
+DLParser::DLParser() : BTParser(_new DLLexer())
{
}
-void DLParser::parse(void)
+DLParser::~DLParser()
{
- ast = Program();
+ std::map<std::string,Macro*>::iterator iter;
+ for (iter = macros.begin(); iter != macros.end(); ++iter) {
+ delete (iter->second);
+ }
}
-AST* DLParser::getAST(void)
+AST* DLParser::parse(void)
{
- return ast;
+ return Program();
}
-bool DLParser::isMacro( Token* token )
+bool DLParser::isMacro( Token& token )
{
bool ret = false;
- if( (token->type() == ID) && (macros.find(token->text()) != macros.end()) )
+ if( (token.type() == ID) && (macros.find(token.text()) != macros.end()) )
{
ret = true;
}
break;
default:
- Token* tok = lookaheadToken(1);
+ Token& tok = lookaheadToken(1);
ostringstream oss;
- oss << "Expected macro parameter type. Expected " << param->type() << ", received " << tok->type() << ".";
- Exception ex( tok->line(), tok->column() );
+ oss << "Expected macro parameter type. Expected " << param->type() << ", received " << tok.type() << ".";
+ Exception ex( tok.line(), tok.column() );
ex.setMessage(oss.str());
break;
}
AST* ret = NULL;
if((lookaheadType(1) == ID) && (lookaheadType(2) == ASSIGN))
{
- AST* id_node = _new AST( ID,(char*)(lookaheadToken(1)->text().c_str()) );
+ AST* id_node = _new AST( ID,(char*)(lookaheadToken(1).text().c_str()) );
consume();
match(ASSIGN);
ret = _new AST( ASSIGN, 2, id_node, Expression());
// Literal = ID
case ID:
- node = _new AST( ID, lookaheadToken(1)->text() );
+ node = _new AST( ID, lookaheadToken(1).text() );
consume();
break;
// Literal = NUM
case NUM:
- node = _new AST( NUM, lookaheadToken(1)->text() );
+ node = _new AST( NUM, lookaheadToken(1).text() );
consume();
break;
// Literal = CHAR
case CHAR:
- node = _new AST( CHAR, lookaheadToken(1)->text() );
+ node = _new AST( CHAR, lookaheadToken(1).text() );
consume();
break;
// Literal = STRING
case STRING:
- node = _new AST( STRING, lookaheadToken(1)->text() );
+ node = _new AST( STRING, lookaheadToken(1).text() );
consume();
break;
// Literal = SYMBOL
case SYMBOL:
- node = _new AST( SYMBOL, lookaheadToken(1)->text() );
+ node = _new AST( SYMBOL, lookaheadToken(1).text() );
consume();
break;
default:
- Token* tok = lookaheadToken(1);
+ Token& tok = lookaheadToken(1);
ostringstream oss;
- oss << "Expected literal type, recieved type " << tok->type() << ".";
- Exception ex( tok->line(), tok->column() );
+ oss << "Expected literal type, recieved type " << tok.type() << ".";
+ Exception ex( tok.line(), tok.column() );
ex.setMessage(oss.str());
throw ex;
}
Macro* macro = NULL;
match(MACRO);
- id = _new AST( ID, lookaheadToken(1)->text() );
+ id = _new AST( ID, lookaheadToken(1).text() );
consume();
match(LPAR);
params = MacroParamList();
AST* DLParser::MacroExpansion(void)
{
AST* ret = NULL;
- Macro* cur_macro = macros[ lookaheadToken(1)->text() ];
+ Macro* cur_macro = macros[ lookaheadToken(1).text() ];
list<Param*>::const_iterator it = cur_macro->params().begin();
consume();
// MacroParam = ID (':' ID)?
AST* DLParser::MacroParam(void)
{
- AST* ret = _new AST( ID, lookaheadToken(1)->text() );
+ AST* ret = _new AST( ID, lookaheadToken(1).text() );
consume();
if( lookaheadType(1) == SEP )
{
match(SEP);
- AST* type = _new AST( ID, lookaheadToken(1)->text() );
+ AST* type = _new AST( ID, lookaheadToken(1).text() );
consume();
ret = _new AST(SEP, 2, ret, type);
}
#ifndef DLPARSER_H
-#define DLPARSER_H
+#define DLPARSER_H
#include <map>
#include "btparser.h"
class DLParser : public BTParser
{
- private:
- AST* ast;
- std::map<std::string,Macro*> macros;
- public:
- DLParser();
- void parse(void);
- AST* getAST(void);
- bool isMacro(Token* token);
- AST* parseMacroParam(Param* param);
-
- /**********************************************************************
- * EBNF Syntax Grammar
- *********************************************************************/
- // Program = Expression*
- //
- // Expression = ID '=' LogicalExpr
- // | MacroDefinition
- // | $MacroExpansion$
- // | LogicalExpr
- //
- // LogicalExpr = CompExpr (('&&' | '||') CompExpr)*
- //
- // CompExpr = AddSubExpr (('==' | '!=' | '<' | '>' | '<=' | '>=') AddSubExpr)*
- //
- // AddSubExpr = MulDivExpr (('+' | '-') MulDivExpr)*
- //
- // MulDivExpr = UnaryExpr (('*' | '/') UnaryExpr)*
- //
- // UnaryExpr = '!' GroupExpr
- // | GroupExpr
- //
- // GroupExpr = '(' LogicalExpr ')'
- // | Literal '(' ExpList ')'
- // | Literal
- //
+ private:
+ std::map<std::string,Macro*> macros;
+ public:
+ DLParser();
+ ~DLParser();
+ AST* parse(void);
+ bool isMacro(Token& token);
+ AST* parseMacroParam(Param* param);
+
+ /**********************************************************************
+ * EBNF Syntax Grammar
+ *********************************************************************/
+ // Program = Expression*
+ //
+ // Expression = ID '=' LogicalExpr
+ // | MacroDefinition
+ // | $MacroExpansion$
+ // | LogicalExpr
+ //
+ // LogicalExpr = CompExpr (('&&' | '||') CompExpr)*
+ //
+ // CompExpr = AddSubExpr (('==' | '!=' | '<' | '>' | '<=' | '>=') AddSubExpr)*
+ //
+ // AddSubExpr = MulDivExpr (('+' | '-') MulDivExpr)*
+ //
+ // MulDivExpr = UnaryExpr (('*' | '/') UnaryExpr)*
+ //
+ // UnaryExpr = '!' GroupExpr
+ // | GroupExpr
+ //
+ // GroupExpr = '(' LogicalExpr ')'
+ // | Literal '(' ExpList ')'
+ // | Literal
+ //
// Literal = VectorLiteral
- // | ListLiteral
- // | FuncLiteral
- // | ID
- // | NUM
- // | CHAR
- // | STRING
- // | SYMBOL
- //
- // VectorLiteral = '[' ExpList ']'
- //
- // ListLiteral = '`' '(' ExpList ')'
- //
- // FuncLiteral = '{' ExpBlock '}'
- // | '{' '|' ExpList '|' ExpBlock '}'
- //
- // MacroDefinition = '%' ID '(' MacroParamList ')' '{' Expression '}'
- //
- // MacroParamList = MacroParam (',' MacroParam)*
- //
- // MacroParam = ID (':' ID)?
- //
- // ExpList = (GroupExpr (',' GroupExpr)*)?
- //
- // ExpBlock = Expression*
- private:
- AST* Program(void);
- AST* Expression(void);
- AST* LogicalExpr(void);
- AST* CompExpr(void);
- AST* AddSubExpr(void);
- AST* MulDivExpr(void);
- AST* UnaryExpr(void);
- AST* GroupExpr(void);
- AST* Literal(void);
- AST* VectorLiteral(void);
- AST* ListLiteral(void);
- AST* FuncLiteral(void);
- AST* MacroDefinition(void);
- AST* MacroExpansion(void);
- AST* MacroParamList(void);
- AST* MacroParam(void);
- AST* ExpList(TokenType_T node_type, TokenType_T terminator);
- AST* ExpBlock(TokenType_T node_type, TokenType_T terminator);
+ // | ListLiteral
+ // | FuncLiteral
+ // | ID
+ // | NUM
+ // | CHAR
+ // | STRING
+ // | SYMBOL
+ //
+ // VectorLiteral = '[' ExpList ']'
+ //
+ // ListLiteral = '`' '(' ExpList ')'
+ //
+ // FuncLiteral = '{' ExpBlock '}'
+ // | '{' '|' ExpList '|' ExpBlock '}'
+ //
+ // MacroDefinition = '%' ID '(' MacroParamList ')' '{' Expression '}'
+ //
+ // MacroParamList = MacroParam (',' MacroParam)*
+ //
+ // MacroParam = ID (':' ID)?
+ //
+ // ExpList = (GroupExpr (',' GroupExpr)*)?
+ //
+ // ExpBlock = Expression*
+ private:
+ AST* Program(void);
+ AST* Expression(void);
+ AST* LogicalExpr(void);
+ AST* CompExpr(void);
+ AST* AddSubExpr(void);
+ AST* MulDivExpr(void);
+ AST* UnaryExpr(void);
+ AST* GroupExpr(void);
+ AST* Literal(void);
+ AST* VectorLiteral(void);
+ AST* ListLiteral(void);
+ AST* FuncLiteral(void);
+ AST* MacroDefinition(void);
+ AST* MacroExpansion(void);
+ AST* MacroParamList(void);
+ AST* MacroParam(void);
+ AST* ExpList(TokenType_T node_type, TokenType_T terminator);
+ AST* ExpBlock(TokenType_T node_type, TokenType_T terminator);
};
#endif
Macro::~Macro()
{
+
+ std::list<Param*>::iterator iter;
+ for (iter = macro_params.begin(); iter != macro_params.end(); ++iter) {
+ delete *iter;
+ }
delete macro_body;
}
//string temp_fname = createTempFileName( input_fname );
//ifstream input(input_fname.c_str());
//DLLexer lexer;
+ //Token tok;
//lexer.setInput(&input);
- //lexer.next();
+ //while( tok.type() != EOF )
+ //{
+ // tok = lexer.next();
+ //}
//(void)temp_fname;
string input_fname(argv[1]);
string temp_fname = createTempFileName( input_fname );
(void)temp_fname;
DLParser parser;
- Scheme* visitor = NULL;
+ //Scheme* visitor = NULL;
AST* parse_tree = NULL;
// Open the input and output files
// Parse the file
parser.setInput(&input);
- parser.parse();
- parse_tree = parser.getAST();
+ parse_tree = parser.parse();
// Translate the AST
- visitor = _new Scheme( parse_tree );
+ //visitor = _new Scheme( parse_tree );
//visitor->visit();
// Write to a temp file
cerr << "Error: No input files." << endl;
}
- REPORT_LEAKS();
+ Cork_ReportMemoryLeaks();
return ret;
}
void setInput(std::string& in);
void setInput(std::istream* in);
- virtual Token* next(void) = 0;
+ virtual Token next(void) = 0;
};
#endif
+#include <stdio.h>
#include "token.h"
+Token::Token() : tok_type(EOF), tok_text(""), tok_line(-1), tok_col(-1)
+{
+}
+
Token::Token(TokenType_T ttype, std::string ttext, int line, int col) : tok_type(ttype), tok_text(ttext), tok_line(line), tok_col(col)
{
}
{
}
+void Token::type(TokenType_T typ)
+{
+ tok_type = typ;
+}
+
TokenType_T Token::type()
{
return tok_type;
}
+void Token::text(std::string txt)
+{
+ tok_text = txt;
+}
+
std::string Token::text()
{
return tok_text;
}
+void Token::line(int ln)
+{
+ tok_line = ln;
+}
+
int Token::line()
{
return tok_line;
}
+void Token::column(int col)
+{
+ tok_col = col;
+}
+
int Token::column()
{
return tok_col;
int tok_line;
int tok_col;
public:
+ Token();
Token(TokenType_T ttype, int line, int col);
Token(TokenType_T ttype, std::string ttext, int line, int col);
+
+ void type(TokenType_T typ);
TokenType_T type();
+
+ void text(std::string txt);
std::string text();
+
+ void line(int ln);
int line();
+
+ void column(int col);
int column();
};
}
else
{
- Token* tok = lookaheadToken(1);
+ Token& tok = lookaheadToken(1);
ostringstream oss;
- oss << "Expected token type. Expected " << type << ", received " << tok->type() << ".";
- Exception ex( tok->line(), tok->column() );
+ oss << "Expected token type. Expected " << type << ", received " << tok.type() << ".";
+ Exception ex( tok.line(), tok.column() );
ex.setMessage(oss.str());
}
}
-Token* BTParser::lookaheadToken(unsigned int i)
+Token& BTParser::lookaheadToken(unsigned int i)
{
sync(i);
return lookahead.at( current + i - 1 );
TokenType_T BTParser::lookaheadType(unsigned int i)
{
-
- Token* tok = lookaheadToken(i);
- return (tok != NULL) ? tok->type() : EOF;
+ return lookaheadToken(i).type();
}
unsigned int BTParser::mark(void)
ILexer* lexer;
unsigned int current;
std::vector<unsigned int> markers;
- std::vector<Token*> lookahead;
+ std::vector<Token> lookahead;
public:
BTParser(ILexer* lxer);
~BTParser();
void sync(unsigned int i);
void fill(unsigned int n);
void match(TokenType_T type);
- Token* lookaheadToken(unsigned int i);
+ Token& lookaheadToken(unsigned int i);
TokenType_T lookaheadType(unsigned int i);
unsigned int mark(void);
void release(void);
void seek(unsigned int index);
bool isSpeculating(void);
- virtual void parse(void) = 0;
+ virtual AST* parse(void) = 0;
};
#endif
public:
IParser();
virtual ~IParser();
- virtual void parse() = 0;
+ virtual AST* parse() = 0;
void setInput(char* in);
void setInput(string& in);
{
if ( lexer != NULL )
{
- lookahead = new Token*[k];
+ lookahead = new Token[k];
}
else
{
}
}
-Token* LLKParser::lookaheadToken(int i)
+Token& LLKParser::lookaheadToken(int i)
{
- Token* ret = NULL;
- if( lookahead != NULL )
- {
- ret = lookahead[(next + i - 1) % k];
- }
+ Token& ret = lookahead[(next + i - 1) % k];
return ret;
}
TokenType_T ret = EOF;
if( lookahead != NULL )
{
- Token* tok = lookaheadToken(i);
- ret = (tok != NULL) ? tok->type() : EOF;
+ ret = lookaheadToken(i).type();
}
return ret;
}
int k;
int next;
ILexer* lexer;
- Token** lookahead;
+ Token* lookahead;
public:
LLKParser(int k_val, ILexer* lxer);
~LLKParser();
void consume(void);
void match(TokenType_T type);
- Token* lookaheadToken(int i);
+ Token& lookaheadToken(int i);
TokenType_T lookaheadType(int i);
- virtual void parse(void) = 0;
+ virtual AST* parse(void) = 0;
};
#endif