From 853bf09c96d4727f545b265a963f6641fe0ec9ce Mon Sep 17 00:00:00 2001 From: Filleo Date: Mon, 22 Apr 2024 10:43:33 +0200 Subject: [PATCH] changed Keyword for unsigned added debug message for lexer --- src/lex/lexer.l | 123 +++++++++++++++++++++++----------------------- src/yacc/parser.y | 2 +- 2 files changed, 63 insertions(+), 62 deletions(-) diff --git a/src/lex/lexer.l b/src/lex/lexer.l index a932b11..359ac96 100644 --- a/src/lex/lexer.l +++ b/src/lex/lexer.l @@ -1,6 +1,7 @@ %option noyywrap %{ #include + #include int yyLineNumber = 1; int yylex(); @@ -16,69 +17,69 @@ %% "\n" yyLineNumber++; -":" return(':'); -"=" return('='); -"+" return('+'); -"-" return('-'); -"*" return('*'); -"/" return('/'); -"," return(','); -";" return(';'); -"." return('.'); -"#" return('#'); +":" {DEBUG("\"%s\" tokenized with \':\'", yytext); return(':');}; +"=" {DEBUG("\"%s\" tokenized with \'=\'", yytext); return('=');}; +"+" {DEBUG("\"%s\" tokenized with \'+\'", yytext); return('+');}; +"-" {DEBUG("\"%s\" tokenized with \'-\'", yytext); return('-');}; +"*" {DEBUG("\"%s\" tokenized with \'*\'", yytext); return('*');}; +"/" {DEBUG("\"%s\" tokenized with \'/\'", yytext); return('/');}; +"," {DEBUG("\"%s\" tokenized with \',\'", yytext); return(',');}; +";" {DEBUG("\"%s\" tokenized with \';\'", yytext); return(';');}; +"." {DEBUG("\"%s\" tokenized with \'.\'", yytext); return('.');}; +"#" {DEBUG("\"%s\" tokenized with \'#\'", yytext); return('#');}; -"(" return('('); -")" return(')'); -"[" return('['); -"]" return(']'); -"{" return('{'); -"}" return('}'); -">" return('>'); -"<" return('<'); +"(" {DEBUG("\"%s\" tokenized with \'(\'", yytext); return('(');}; +")" {DEBUG("\"%s\" tokenized with \')\'", yytext); return(')');}; +"[" {DEBUG("\"%s\" tokenized with \'[\'", yytext); return('[');}; +"]" {DEBUG("\"%s\" tokenized with \']\'", yytext); return(']');}; +"{" {DEBUG("\"%s\" tokenized with \'{\'", yytext); return('{');}; +"}" {DEBUG("\"%s\" tokenized with \'}\'", yytext); return('}');}; +">" {DEBUG("\"%s\" tokenized with \'>\'", yytext); return('>');}; +"<" {DEBUG("\"%s\" tokenized with \'<\'", yytext); return('<');}; -"int" return(KeyInt); -"float" return(KeyFloat); -"as" return (KeyAs); -"short" return(KeyShort); -"long" return(KeyLong); -"half" return(KeyHalf); -"double" return(KeyDouble); -"signed" return(KeySigned); -"unsigned" return(Keyunsigned); -"ref" return(KeyRef); -"type" return(KeyType); -"local" return(KeyLocal); -"global" return(KeyGlobal); -"static" return(KeyStatic); -"if" return(KeyIf); -"else" return(KeyElse); -"while" return(KeyWhile); -"in" return(KeyIn); -"out" return(KeyOut); -"fun" return(KeyFun); -"==" return(OpEquals); -"&&" return(OpAnd); -"||" return(OpOr); -"!!" return(OpNot); -"^^" return(OpXor); -"&" return(OpBitand); -"|" return(OpBitor); -"!" return(OpBitnot); -"^" return(OpBitxor); -"import" return(KeyImport); -"silent" return(KeySilent); -"box" return(KeyBox); -"typeof" return(FunTypeof); -"sizeof" return(FunSizeof); -"filename" return(FunFilename); -"funname" return(FunFunname); -"lineno" return(FunLineno); -"extsupport" return(FunExtsupport); +"int" {DEBUG("\"%s\" tokenized with \'