Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %{
- #include "scanner.h"
- /* --- Your code here ---
- *
- * This is where C declarations go. If you need to include
- * files for the actions below, this is where you do it.
- */
- /* --- End your code --- */
- extern void yyerror(char *);
- %}
- %option yylineno
- %option noyywrap
- %option 8bit
- %option caseless
- %option nodefault
- %option outfile="scanner.cc"
- /* --- Your code here ---
- *
- * This is where Flex declarations go. If you need to include
- * any such declarations, this is where you do it.
- */
- /* --- End your code --- */
- DIGIT [0-9]
- INTEGER ("-"|[1-9]){DIGIT}*
- REAL ({INTEGER}|"."){DIGIT}*(("E"|"E-"){DIGIT}+|{DIGIT}*)
- LITERAL ([a-z]|[A-Z])
- IDENTIFIER {LITERAL}+({LITERAL}|{DIGIT}|"_")*
- BADCOMMENT "//"[^"\n""/*"]*"/*"
- COMMENT "//"[^"\n"]*
- temp "*/"
- MCOMMENT "/*"[^("*\//)"]*"*/"
- %%
- if return IF;
- then return THEN;
- elseif return ELSEIF;
- else return ELSE;
- begin return XBEGIN;
- end return XEND;
- while return WHILE;
- function return FUNCTION;
- program return PROGRAM;
- return return RETURN;
- declare return DECLARE;
- do return DO;
- and return AND;
- or return OR;
- not return NOT;
- := return ASSIGN;
- ">=" return GE;
- "<=" return LE;
- == return EQ;
- "<>" return NE;
- array return ARRAY;
- of return OF;
- {INTEGER} return INTEGER;
- {REAL} return REAL;
- {IDENTIFIER} return ID;
- "\n" ;
- {BADCOMMENT} printf("\nWARNING: Multiline comment inside single line comment\n");
- {COMMENT} ;
- {MCOMMENT} ;
- <<EOF>> yyterminate();
- . return yytext[0];
- %%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement