Completed scanner
parent
4b69ab87c6
commit
c3c5c8850d
|
@ -0,0 +1,34 @@
|
|||
%{
|
||||
#include <vslc.h>
|
||||
%}
|
||||
%option noyywrap
|
||||
%option array
|
||||
%option yylineno
|
||||
|
||||
WHITESPACE [\ \t\v\r\n]
|
||||
COMMENT \/\/[^\n]+
|
||||
NUMBERS [0-9]+
|
||||
STRING \"[\ !#-~]*\"
|
||||
IDENTIFIERS [A-Za-z_][A-Za-z0-9_]*
|
||||
%%
|
||||
{WHITESPACE}+ { /* Eliminate whitespace */ }
|
||||
{COMMENT} { /* Eliminate comments */ }
|
||||
|
||||
"func" { /*printf("FUNC\n");*/ return FUNC; }
|
||||
"print" { /*printf("PRINT\n");*/ return PRINT; }
|
||||
"return" { /*printf("RETURN\n");*/ return RETURN; }
|
||||
"begin" { /*printf("OPENBLOCK\n");*/ return OPENBLOCK; }
|
||||
"end" { /*printf("CLOSEBLOCK\n");*/ return CLOSEBLOCK; }
|
||||
"continue" { /*printf("CONTINUE\n");*/ return CONTINUE; }
|
||||
"if" { /*printf("IF\n");*/ return IF; }
|
||||
"then" { /*printf("THEN\n");*/ return THEN; }
|
||||
"else" { /*printf("ELSE\n");*/ return ELSE; }
|
||||
"while" { /*printf("WHILE\n");*/ return WHILE; }
|
||||
"do" { /*printf("DO\n");*/ return DO; }
|
||||
"var" { /*printf("VAR\n");*/ return VAR; }
|
||||
|
||||
{NUMBERS} { /*printf("NUMBER\n");*/ return NUMBER; }
|
||||
{STRING} { /*printf("STRING\n");*/ return STRING; }
|
||||
{IDENTIFIERS} { /*printf("IDENTIFIER\n");*/ return IDENTIFIER; }
|
||||
. { /*printf("'%c'\n", yytext[0]);*/ return yytext[0]; }
|
||||
%%
|
Loading…
Reference in New Issue