3 /* disable unused functions so we don't
4 get compiler warnings about them */
6 %option noyywrap nounput noinput
8 /* change our prefix from yy to lisp */
12 /* use the pure parser calling convention */
14 %option reentrant bison-bridge
19 #define YY_EXIT_FAILURE ((void)yyscanner, EXIT_FAILURE)
21 /* XOPEN for strdup */
22 #define _XOPEN_SOURCE 600
27 /* seems like a bug that I have to do this, since flex
28 should know prefix=lisp and match bison's LISPSTYPE */
29 #define YYSTYPE LISPSTYPE
31 int lisperror(const char *msg);
36 [[:alpha:]][[:alnum:]]* {
37 /* The memory that yytext points to gets overwritten
38 each time a pattern matches. We need to give the caller
39 a copy. Also, if strdup fails and returns NULL, it's up
40 to the caller (the parser) to detect that.
42 Notice yylval is a pointer to union now. It's passed
43 as an arg to yylex in pure parsing mode */
45 yylval->str = strdup(yytext);
50 long n = strtol(yytext, NULL, 10);
52 if (n < INT_MIN || n > INT_MAX)
53 lisperror("Number out of range");
58 [[:space:]] ; /* ignore */