Merge pull request #24 from Servostar/21-add-debug-print-into-tokenizer
21 add debug print into tokenizer
This commit is contained in:
commit
c38abad400
125
src/lex/lexer.l
125
src/lex/lexer.l
|
@ -1,84 +1,83 @@
|
||||||
%option noyywrap
|
%option noyywrap
|
||||||
%{
|
%{
|
||||||
#include <yacc/parser.tab.h>
|
#include <yacc/parser.tab.h>
|
||||||
|
#include <sys/log.h>
|
||||||
|
|
||||||
int yyLineNumber = 1;
|
int yyLineNumber = 1;
|
||||||
int yylex();
|
int yylex();
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
/* disable the following functions */
|
/* disable the following functions */
|
||||||
/* to avoid failing code check */
|
/* to avoid failing code check */
|
||||||
%option nounput
|
%option nounput
|
||||||
%option noinput
|
%option noinput
|
||||||
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
"\n" yyLineNumber++;
|
"\n" yyLineNumber++;
|
||||||
|
|
||||||
":" return(':');
|
":" {DEBUG("\"%s\" tokenized with \':\'", yytext); return(':');};
|
||||||
"=" return('=');
|
"=" {DEBUG("\"%s\" tokenized with \'=\'", yytext); return('=');};
|
||||||
"+" return('+');
|
"+" {DEBUG("\"%s\" tokenized with \'+\'", yytext); return('+');};
|
||||||
"-" return('-');
|
"-" {DEBUG("\"%s\" tokenized with \'-\'", yytext); return('-');};
|
||||||
"*" return('*');
|
"*" {DEBUG("\"%s\" tokenized with \'*\'", yytext); return('*');};
|
||||||
"/" return('/');
|
"/" {DEBUG("\"%s\" tokenized with \'/\'", yytext); return('/');};
|
||||||
"," return(',');
|
"," {DEBUG("\"%s\" tokenized with \',\'", yytext); return(',');};
|
||||||
";" return(';');
|
";" {DEBUG("\"%s\" tokenized with \';\'", yytext); return(';');};
|
||||||
"." return('.');
|
"." {DEBUG("\"%s\" tokenized with \'.\'", yytext); return('.');};
|
||||||
"#" return('#');
|
"#" {DEBUG("\"%s\" tokenized with \'#\'", yytext); return('#');};
|
||||||
|
|
||||||
"(" return('(');
|
"(" {DEBUG("\"%s\" tokenized with \'(\'", yytext); return('(');};
|
||||||
")" return(')');
|
")" {DEBUG("\"%s\" tokenized with \')\'", yytext); return(')');};
|
||||||
"[" return('[');
|
"[" {DEBUG("\"%s\" tokenized with \'[\'", yytext); return('[');};
|
||||||
"]" return(']');
|
"]" {DEBUG("\"%s\" tokenized with \']\'", yytext); return(']');};
|
||||||
"{" return('{');
|
"{" {DEBUG("\"%s\" tokenized with \'{\'", yytext); return('{');};
|
||||||
"}" return('}');
|
"}" {DEBUG("\"%s\" tokenized with \'}\'", yytext); return('}');};
|
||||||
">" return('>');
|
">" {DEBUG("\"%s\" tokenized with \'>\'", yytext); return('>');};
|
||||||
"<" return('<');
|
"<" {DEBUG("\"%s\" tokenized with \'<\'", yytext); return('<');};
|
||||||
|
|
||||||
"int" return(KeyInt);
|
"int" {DEBUG("\"%s\" tokenized with \'<KeyInt'", yytext); return(KeyInt);};
|
||||||
"float" return(KeyFloat);
|
"float" {DEBUG("\"%s\" tokenized with \'KeyFloat\'", yytext); return(KeyFloat);};
|
||||||
"as" return (KeyAs);
|
"as" {DEBUG("\"%s\" tokenized with \'<KeyAs'", yytext); return (KeyAs);};
|
||||||
"short" return(KeyShort);
|
"short" {DEBUG("\"%s\" tokenized with \'KeyShort\'", yytext); return(KeyShort);};
|
||||||
"long" return(KeyLong);
|
"long" {DEBUG("\"%s\" tokenized with \'KeyLong\'", yytext); return(KeyLong);};
|
||||||
"half" return(KeyHalf);
|
"half" {DEBUG("\"%s\" tokenized with \'KeyHalf\'", yytext); return(KeyHalf);};
|
||||||
"double" return(KeyDouble);
|
"double" {DEBUG("\"%s\" tokenized with \'KeyDouble\'", yytext); return(KeyDouble);};
|
||||||
"signed" return(KeySigned);
|
"signed" {DEBUG("\"%s\" tokenized with \'KeySigned\'", yytext); return(KeySigned);};
|
||||||
"unsigned" return(Keyunsigned);
|
"unsigned" {DEBUG("\"%s\" tokenized with \'KeyUnsigned\'", yytext); return(KeyUnsigned);};
|
||||||
"ref" return(KeyRef);
|
"ref" {DEBUG("\"%s\" tokenized with \'KeyRef\'", yytext); return(KeyRef);};
|
||||||
"type" return(KeyType);
|
"type" {DEBUG("\"%s\" tokenized with \'KeyType\'", yytext); return(KeyType);};
|
||||||
"local" return(KeyLocal);
|
"local" {DEBUG("\"%s\" tokenized with \'KeyLocal\'", yytext); return(KeyLocal);};
|
||||||
"global" return(KeyGlobal);
|
"global" {DEBUG("\"%s\" tokenized with \'KeyGlobal\'", yytext); return(KeyGlobal);};
|
||||||
"static" return(KeyStatic);
|
"static" {DEBUG("\"%s\" tokenized with \'KeyStatic\'", yytext); return(KeyStatic);};
|
||||||
"if" return(KeyIf);
|
"if" {DEBUG("\"%s\" tokenized with \'KeyIf\'", yytext); return(KeyIf);};
|
||||||
"else" return(KeyElse);
|
"else" {DEBUG("\"%s\" tokenized with \'KeyElse\'", yytext); return(KeyElse);};
|
||||||
"while" return(KeyWhile);
|
"while" {DEBUG("\"%s\" tokenized with \'KeyWhile\'", yytext); return(KeyWhile);};
|
||||||
"in" return(KeyIn);
|
"in" {DEBUG("\"%s\" tokenized with \'KeyIn\'", yytext); return(KeyIn);};
|
||||||
"out" return(KeyOut);
|
"out" {DEBUG("\"%s\" tokenized with \'KeyOut\'", yytext); return(KeyOut);};
|
||||||
"fun" return(KeyFun);
|
"fun" {DEBUG("\"%s\" tokenized with \'KeyFun\'", yytext); return(KeyFun);};
|
||||||
"==" return(OpEquals);
|
"==" {DEBUG("\"%s\" tokenized with \'OpEquals\'", yytext); return(OpEquals);};
|
||||||
"&&" return(OpAnd);
|
"&&" {DEBUG("\"%s\" tokenized with \'OpAnd\'", yytext); return(OpAnd);};
|
||||||
"||" return(OpOr);
|
"||" {DEBUG("\"%s\" tokenized with \'OpOr\'", yytext); return(OpOr);};
|
||||||
"!!" return(OpNot);
|
"!!" {DEBUG("\"%s\" tokenized with \'OpNot\'", yytext); return(OpNot);};
|
||||||
"^^" return(OpXor);
|
"^^" {DEBUG("\"%s\" tokenized with \'OpXor\'", yytext); return(OpXor);};
|
||||||
"&" return(OpBitand);
|
"&" {DEBUG("\"%s\" tokenized with \'OpBitand\'", yytext); return(OpBitand);};
|
||||||
"|" return(OpBitor);
|
"|" {DEBUG("\"%s\" tokenized with \'OpBitor\'", yytext); return(OpBitor);};
|
||||||
"!" return(OpBitnot);
|
"!" {DEBUG("\"%s\" tokenized with \'OpBitnot\'", yytext); return(OpBitnot);};
|
||||||
"^" return(OpBitxor);
|
"^" {DEBUG("\"%s\" tokenized with \'OpBitxor\'", yytext); return(OpBitxor);};
|
||||||
"import" return(KeyImport);
|
"import" {DEBUG("\"%s\" tokenized with \'KeyImport\'", yytext); return(KeyImport);};
|
||||||
"silent" return(KeySilent);
|
"silent" {DEBUG("\"%s\" tokenized with \'KeySilent\'", yytext); return(KeySilent);};
|
||||||
"box" return(KeyBox);
|
"box" {DEBUG("\"%s\" tokenized with \'KeyBox\'", yytext); return(KeyBox);};
|
||||||
"typeof" return(FunTypeof);
|
"typeof" {DEBUG("\"%s\" tokenized with \'FunTypeof\'", yytext); return(FunTypeof);};
|
||||||
"sizeof" return(FunSizeof);
|
"sizeof" {DEBUG("\"%s\" tokenized with \'FunSizeof\'", yytext); return(FunSizeof);};
|
||||||
"filename" return(FunFilename);
|
"filename" {DEBUG("\"%s\" tokenized with \'FunFilename\'", yytext); return(FunFilename);};
|
||||||
"funname" return(FunFunname);
|
"funname" {DEBUG("\"%s\" tokenized with \'FunFunname\'", yytext); return(FunFunname);};
|
||||||
"lineno" return(FunLineno);
|
"lineno" {DEBUG("\"%s\" tokenized with \'FunLineno\'", yytext); return(FunLineno);};
|
||||||
"extsupport" return(FunExtsupport);
|
"extsupport" {DEBUG("\"%s\" tokenized with \'FunExtsupport\'", yytext); return(FunExtsupport);};
|
||||||
|
|
||||||
[a-zA-Z_]+ { yylval.string = strdup(yytext); return(Ident); };
|
[0-9]+ {DEBUG("\"%s\" tokenized with \'ValInt\'", yytext); yylval.string = strdup(yytext); return(ValInt); };
|
||||||
[0-9]+ { yylval.string = strdup(yytext); return(ValInt); };
|
[0-9]*\.[0-9]+ {DEBUG("\"%s\" tokenized with \'ValFloat\'", yytext); yylval.string = strdup(yytext); return(ValFloat);};
|
||||||
\"([^\"\n])*\" {yylval.string = strdup(yytext); return(ValStr);};
|
[a-zA-Z_0-9]+ {DEBUG("\"%s\" tokenized with \'Ident\'", yytext); yylval.string = strdup(yytext); return(Ident); };
|
||||||
\"\"\"([^\"\n]|\\\n)*\"\"\" {yylval.string = strdup(yytext); return(ValMultistr);};
|
\"([^\"\n])*\" {DEBUG("\"%s\" tokenized with \'ValStr\'", yytext); yylval.string = strdup(yytext); return(ValStr);};
|
||||||
[0-9]*\.[0-9]+ {yylval.string = strdup(yytext); return(ValFloat);};
|
\"\"\"([^\"\n]|\\\n)*\"\"\" {DEBUG("\"%s\" tokenized with \'ValMultistr\'", yytext); yylval.string = strdup(yytext); return(ValMultistr);};
|
||||||
.;
|
.;
|
||||||
%%
|
%%
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
%token KeyHalf
|
%token KeyHalf
|
||||||
%token KeyDouble
|
%token KeyDouble
|
||||||
%token KeySigned
|
%token KeySigned
|
||||||
%token Keyunsigned
|
%token KeyUnsigned
|
||||||
%token KeyRef
|
%token KeyRef
|
||||||
%token KeyType
|
%token KeyType
|
||||||
%token KeyLocal
|
%token KeyLocal
|
||||||
|
|
Loading…
Reference in New Issue