From 7e8bcc75b6ae00248ad4f9ff9753be251d88a4ff Mon Sep 17 00:00:00 2001 From: dtagarev <92181714+dtagarev@users.noreply.github.com> Date: Thu, 3 Nov 2022 20:51:40 +0200 Subject: solution to first homework (#132) * Delete lex.yy.c * adding homework1 * Delete output * correction to the location of the folders Co-authored-by: dtrendafilov --- homework/9MI0800164/Homework1_9MI0800164/lua_lex.l | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 homework/9MI0800164/Homework1_9MI0800164/lua_lex.l (limited to 'homework/9MI0800164/Homework1_9MI0800164/lua_lex.l') diff --git a/homework/9MI0800164/Homework1_9MI0800164/lua_lex.l b/homework/9MI0800164/Homework1_9MI0800164/lua_lex.l new file mode 100644 index 0000000..e51f53c --- /dev/null +++ b/homework/9MI0800164/Homework1_9MI0800164/lua_lex.l @@ -0,0 +1,77 @@ +%{ + +%} + +DIGIT [0-9] +ID [a-zA-Z_0-9]* +KEYWORD and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while +OPERATOR "+"|"-"|"*"|"/"|"%"|"^"|"#"|"=="|"~="|"<="|">="|"<"|">"|"="|"("|")"|"{"|"}"|"["|"]"|"::"|";"|":"|","|"."|".."|"..."|"<<"|">>"|"&"|"|"|"//"|"~"|"'"|"--"|"?"|"\""|"\\n" + + +%% + +{DIGIT}+ { + printf("%s", yytext); + } +{KEYWORD} printf("%s", yytext); + +(".") printf("%s", yytext); + +{ID} printf("%s", yytext); + +(--.) printf("%s", yytext); + +{OPERATOR} printf("%s", yytext); + +[ \t\n]+ printf("%s", yytext); + +. printf( "Unrecognized character: %s\n", yytext ); + +%% +int yywrap() +{ + return 1; +} +int main(int argc, const char* argv[]) +{ + if ( argc > 0 ) + yyin = fopen( "markov_chain.lua", "r" ); + else + yyin = stdin; + puts( + "" + "" + "" + " markov_chain.lua" + " " + "" + "" + "
"
+        );
+    yylex();
+    puts("
"); + return 0; +} -- cgit v1.3.1-26-gb76a