I am trying to play around with SableCC and was using the indrek alternative output package to generate c++ output. For the grammar, I simply copied and pasted the grammar from this site
http://improve.dk/writing-a-calculator-in-csharp-using-sablecc/
This is my shell script to make the project
find ./ -name "*.o" | xargs rm -f
java -jar sablecc-3-beta.3.altgen.20041114/lib/sablecc.jar -d src -t cxx grammar/simplecalc.sablecc
g++ -Isrc/SimpleCalc -c src/list.cpp src/node.cpp src/typeinfo.cpp src/analysis.cpp src/lexer.cpp src/parser.cpp src/main.cpp
This is main.cpp
#include<iostream>
#include<string>
#include "lexer.h"
#include "node.h"
#include "parser.h"
using namespace SimpleCalc;
int main(){
return 0;
}
Upon running the shell script I am getting the below error
In file included from src/main.cpp:10:0:
src/SimpleCalc/lexer.h:63:11: error: ‘Token’ does not name a type
src/SimpleCalc/lexer.h:64:11: error: ‘Token’ does not name a type
src/SimpleCalc/lexer.h:71:3: error: ‘Token’ does not name a type
src/SimpleCalc/lexer.h:73:16: error: ‘Token’ has not been declared
src/SimpleCalc/lexer.h:83:3: error: ‘Token’ does not name a type
src/SimpleCalc/lexer.h:88:41: error: expected class-name before ‘{’ token
src/SimpleCalc/lexer.h: In constructor ‘SimpleCalc::LexerException::LexerException(int, int, const string&)’:
src/SimpleCalc/lexer.h:90:71: error: class ‘SimpleCalc::LexerException’ does not have any field named ‘Exception’
In file included from src/main.cpp:12:0:
src/SimpleCalc/parser.h: At global scope:
src/SimpleCalc/parser.h:22:3: error: ‘Start’ does not name a type
src/SimpleCalc/parser.h:36:9: error: field ‘token’ has incomplete type
src/SimpleCalc/parser.h: In constructor ‘SimpleCalc::ParserException::ParserException(SimpleCalc::Token, const string&)’:
src/SimpleCalc/parser.h:32:10: error: ‘token’ has incomplete type
src/SimpleCalc/node.h:14:7: error: forward declaration of ‘struct SimpleCalc::Token’
src/SimpleCalc/parser.h:32:83: error: class ‘SimpleCalc::ParserException’ does not have any field named ‘token’
src/SimpleCalc/parser.h: In member function ‘SimpleCalc::Token SimpleCalc::ParserException::getToken() const’:
src/SimpleCalc/parser.h:33:27: error: return type ‘struct SimpleCalc::Token’ is incomplete
src/SimpleCalc/parser.h:33:36: error: ‘token’ was not declared in this scope
These are the files that are generated
- src/analysis.cpp
- src/lexer.cpp
- src/list.cpp
- src/node.cpp
- src/parser.cpp
- src/SimpleCalc
- src/typeinfo.cpp
- src/SimpleCalc/analysis.h
- src/SimpleCalc/lexer.h
- src/SimpleCalc/list.h
- src/SimpleCalc/node.h
- src/SimpleCalc/parser.h
- src/SimpleCalc/prod.h
- src/SimpleCalc/token.h
The file main.cpp is located in the src folder
I am not sure what I am doing wrong. Appreciate if anybody could guide me