38 lines
781 B
Plaintext
38 lines
781 B
Plaintext
%option noyywrap
|
|
%{
|
|
#include <stdio.h>
|
|
#include "yacc.yy.h"
|
|
#define YYDEBUG 1
|
|
int yyLineNumber = 1;
|
|
%}
|
|
|
|
%%
|
|
\n yyLineNumber++;
|
|
0|[1-9][0-9]* return(Number); // integer numbers
|
|
"VAR"|"var" return(Variable);
|
|
"INT"|"int" return(Integer);
|
|
[a-zA-Z]+ return(Ident);
|
|
"," return(',');
|
|
":" return(':');
|
|
";" return(';');
|
|
"+" return('+');
|
|
"-" return('-');
|
|
"(" return('(');
|
|
")" return(')');
|
|
[ \t]
|
|
. print_stdout("unknown Symbol");
|
|
%%
|
|
|
|
/*
|
|
int main()
|
|
{
|
|
printf("Programm eingeben: \n");
|
|
yylex();
|
|
return 0;
|
|
}
|
|
*/
|
|
|
|
int print_stdout(char token[]) {
|
|
printf("\nFLEX/[INF] >>> Token (%d) AS %s ```%s```\n", yyLineNumber, token, yytext);
|
|
}
|