cupl: $(MODULES)
$(CC) $(MODULES) -lm -o cupl
+# You can use either lex or flex
+#LEX = lex
+LEX = flex
+
+# You can use either bison or yacc
+#YACC = yacc
+YACC = bison -y
+
lexer.c: cupl.l
- lex $(LFLAGS) cupl.l
+ $(LEX) $(LFLAGS) cupl.l
mv lex.yy.c lexer.c
grammar.c tokens.h y.output: cupl.y
static node *intern_number(char *);
static node *intern_identifier(char *);
static node *intern_string(char *);
+
+#ifdef FLEX_SCANNER
+int yylineno;
+#endif /* FLEX_SCANNER */
%}
D [0-9][0-9]*
"**" {return(POWER);}
[+*/().,=-] {return(yytext[0]);}
-[ \t\n] ;
+[ \t] ;
+\n {
+#ifdef FLEX_SCANNER
+ yylineno++;
+#endif /* FLEX_SCANNER */
+ }
%%
#ifdef PARSEDEBUG
static int statement_count;
#endif /* PARSEDEBUG */
+
+#include "cupl.h"
+
+#ifdef YYBISON
+int yydebug;
+#endif /* YYBISON */
%}
%start program
{$$ = cons(ISLICE, $1, $5);}
;
%%
-#include "cupl.h"
node *cons(op, left, right)
/* make a cons for a binary operation */