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...
[^a-ca-ce-ze-...@~\n]           { /* 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

Attachment: lex.l
Description: Binary data

Attachment: parse.y
Description: Binary data

/* symtable.h  has the symbol table for storing constants names and values*/

/* l & y 68 */
/****************************************************************************/

/*****************************************************************************
a symtab will contain a record for each variable whether Domain or Parameter.
Each variable will have a name D0, D1,for domains, or X0, V1 for parameters.
*****************************************************************************/
#define DOMAIN 0
#define INTEGRAL_CONSTANT 1
#define PREDICATE 2
#define NUM_SYMS 4096  /* size of the array of structures, pre any malloc approach.*/

struct domain_vals {	/*the values that make up a domain */
  unsigned int number_of_contiguous_values;
  int lowest_value;
  int highest_value;
};

struct constant_vals{   /* the values that make up an integral constant */
  char *domain_ref;  /* to which domain should this constant intersect with */
  int integral_constant_value; /*the value of the integral constant */
};

union domain_and_const_vals{ /* these may be either domain or constant values exclusive.*/
 struct domain_vals domain_vals;
 struct constant_vals constant_vals;
};

struct symtab{
  char *name;
  int domain_or_constant;
  union domain_and_const_vals domain_and_const_vals;
  struct symtab *next; /* needed for the linked list if we go that way */
} symtab[NUM_SYMS];

extern struct symtab *sym_start;  	/* start of the symtable list(s) */

/* check this in Lex&Yacc */
/*struct symtab *set_symbol(char *symbol_name, int value);*/ /* add a new symbol to the list */
struct symtab *symlook(char *symbol_name); /* prototype for the symbol table lookup fn */

Attachment: infile.i
Description: Binary data

Attachment: cln
Description: Binary data

Attachment: compile
Description: Binary data

_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to