5 #define uploc { yylloc->first_column = yylloc->last_column + 1; yylloc->last_column += yyleng; }
6 /*#define YY_DECL int yylex (YYSTYPE *yylval_param)*/
11 %option bison-locations
16 "Integer" { uploc; return T_INTEGER; }
17 "Var" { uploc; return T_VAR; }
18 "Begin" { uploc; return T_BEGIN; }
19 "End" { uploc; return T_END; }
21 "Procedure" { uploc; return T_PROCEDURE; }
22 "Function" { uploc; return T_FUNCTION; }
24 "printInt" { uploc; return T_PRINT_INT; }
25 "printBoolean" { uploc; return T_PRINT_BOOL; }
26 "println" { uploc; return T_PRINT_LINE; }
28 ":=" { uploc; return T_ASSIGNMENT; }
29 "(" { uploc; return T_LPAR; }
30 ")" { uploc; return T_RPAR; }
31 "+" { uploc; return T_ADD; }
32 "-" { uploc; return T_SUB; }
33 "*" { uploc; return T_MULT; }
34 "/" { uploc; return T_DIV; }
36 ">" { uploc; return T_MAJOR; }
37 "<" { uploc; return T_MINOR; }
38 "=" { uploc; return T_EQUAL; }
39 "<>" { uploc; return T_NOTEQUAL; }
40 ">=" { uploc; return T_MAJOREQUAL; }
41 "<=" { uploc; return T_MINOREQUAL; }
43 ";" { uploc; return T_SEMICOLON; }
44 ":" { uploc; return T_COLON; }
45 "." { uploc; return T_DOT; }
46 "," { uploc; return T_COMMA; }
48 "True"|"False" { uploc; yylval->boolean=strcmp(yytext, "False"); return BOOLEAN; }
49 [0-9]+ { uploc; yylval->integer=atoi(yytext); return NUMBER; }
50 [A-Za-z][A-Za-z0-9]* { uploc; yylval->lexeme=strdup(yytext); return IDENTIFIER; }
52 [ \t]+ /* ignora whitespace */;
53 [ \n] { yylloc->first_line = yylloc->last_line = yylineno; yylloc->first_column = 1; yylloc->last_column = 0; }
55 . { uploc; fprintf (stderr, "%d: syntax error: unexpected character ´%s´\n", yylloc->first_line, yytext); }