|
From: | joe |
Subject: | My Flex/Bison process is stalling when trying to read a left bracket. |
Date: | Sun, 9 Aug 2009 05:30:13 +0100 (BST) |
User-agent: | SquirrelMail/1.4.13 |
The processes proceed well until the compiler generated encounters an opening bracket. I get the following output... This is the cln file Aug 2 2009 [sudo] password for joe: removing lex.yy.c rm: cannot remove `lex.yy.c': No such file or directory removing lex.yy.o rm: cannot remove `lex.yy.o': No such file or directory removing parse.tab.h removing parse.tab.c removing parse.tab.o ---> calling bison_program ---> calling flex_program lex.l:75: negative range in character class ---> compiling lexer gcc: lex.yy.c: No such file or directory gcc: no input files ---> compiling parser parse.tab.c: In function yyparse: parse.tab.c:1391: warning: implicit declaration of function yylex ---> linking gcc: lex.yy.o: No such file or directory V.1 started project Compiler (c) 2009 Initialising symbol table Calling yyparse(), there should be debug outputs domain line is D0 11 0 10 domain line is D1 10 11 20 ln 97. Constant line is X0 D0 1 ln 97. Constant line is X1 D1 12 ln 97. Constant line is X2 D0 2 ln 97. Constant line is X3 D1 15 ln 97. Constant line is X4 D0 6 ln 97. Constant line is X5 D1 20 In lex 40, found an OR syntax error Completed yyparse() ---------------------------------------- After 'Calling yyparse()...' the compiler reads infile.i and simply confirms the parsing of the domains and constants. Things get mysterious after 'In lex 40, found an OR'. This simply confirms that the first token of the predicates following the above domains and constants has started. But then as you see above, the program stalls with a 'syntax error'. At this point the next token in the input.i stream is and opening bracket. But it doesn't seem to get read. There is provision for the brackets in parse.y as... %token '(' ')' /* left parenthesis, r parenthesis @ line 59*/ and in lex.l as... "(" {printf("found a (\n");return '(';} /*line 48 */... but it never gets to this in lex.l There is a line of code at lex.l 75 which may or may not be causing a problem... address@hidden { /* error, unexpected char */.... it's an intended exclusion list. I have included all the relevant files associated with this small project, and if you copy them into a directory, then calling ./compile should cause execution of the shell scripts to build and execute the eventual compiler which is generated. The list of files attached are... lex.l THE SOURCE FOR THE LEXER parse.y THE SOURCE FOR THE PARSER symtable.h THE SYMBOL TABLE header file. infile.i THE SOURCE FILE TO FEED TO OUR GENERATED COMPILER IT COMPRISES 2 DOMAIN LINES, 6 CONSTANTS LINES followed by a LIST OF PREDICATES. cln WHICH CLEANS OFF THE OLD OBJECT FILES ETC READY FOR A NEW COMPILATION. compile WHICH PROCESSES THE FLEX AND BISON SOURCES THEN LINKS, AND EXECUTES. Once the files are into a separate directory, then simply entering 'compile' will attempt to build and execute the consequent files generated. You should get output same as down to the -------------------- separator. Any help is appreciated, thanks. Joe Garvey, Cork, Ireland
lex.l
Description: Binary data
parse.y
Description: Binary data
symtable.h
Description: Text Data
infile.i
Description: Binary data
cln
Description: Binary data
compile
Description: Binary data
[Prev in Thread] | Current Thread | [Next in Thread] |