uni

University stuff
git clone git://git.margiolis.net/uni.git
Log | Files | Refs | README | LICENSE

commit 049691a223a32b264e9eb34d08d1b4d4bdb81d04
parent b8350feec76cd459f94c1511783ceb2576ec84ed
Author: Christos Margiolis <christos@margiolis.net>
Date:   Tue, 24 May 2022 19:42:07 +0300

done

Diffstat:
Alex_yacc_compilers/part3/02_B1_PART_B2.pdf | 0
Mlex_yacc_compilers/part3/lex.l | 31+++++++++++++++++--------------
Mlex_yacc_compilers/part3/output.txt | 2+-
Mlex_yacc_compilers/part3/syntax.y | 8++++----
4 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/lex_yacc_compilers/part3/02_B1_PART_B2.pdf b/lex_yacc_compilers/part3/02_B1_PART_B2.pdf Binary files differ. diff --git a/lex_yacc_compilers/part3/lex.l b/lex_yacc_compilers/part3/lex.l @@ -2,6 +2,9 @@ %{ #include <stdlib.h> #include "syntax.tab.h" + +int cw = 0; /* correct words */ +int ww = 0; /* wrong words */ %} /* @@ -22,24 +25,24 @@ COMMENT ;.* * οποίο ανήκει */ %% -"deffacts" { return DEFFACTS; } -"defrule" { return DEFRULE; } -"bind" { return BIND; } -"read" { return READ; } -"printout" { return PRINT; } -"test" { return TEST; } -"=" { return COMP; } +"deffacts" { cw++; return DEFFACTS; } +"defrule" { cw++; return DEFRULE; } +"bind" { cw++; return BIND; } +"read" { cw++; return READ; } +"printout" { cw++; return PRINT; } +"test" { cw++; return TEST; } +"=" { cw++; return COMP; } "(" { return LPAR; } ")" { return RPAR; } "->" { return ARROW; } -{ARITH} { return ARITH; } -{INT} { return INT; } -{FLOAT} { return FLOAT;} -{STR} { return STR; } -{DEFIN} { return DEFIN; } -{VAR} { return VAR; } +{ARITH} { cw++; return ARITH; } +{INT} { cw++; return INT; } +{FLOAT} { cw++; return FLOAT;} +{STR} { cw++; return STR; } +{DEFIN} { cw++; return DEFIN; } +{VAR} { cw++; return VAR; } {DELIM} { /* ignore whitespace */ } {COMMENT} { /* skip comments */ } "\n" { return NEWLINE; } -. { return UNKNOWN; } +. { ww++; return UNKNOWN; } %% diff --git a/lex_yacc_compilers/part3/output.txt b/lex_yacc_compilers/part3/output.txt @@ -1,6 +1,6 @@ input.txt: success -correct words: 0 +correct words: 38 correct expressions: 12 wrong words: 0 wrong expressions: 0 diff --git a/lex_yacc_compilers/part3/syntax.y b/lex_yacc_compilers/part3/syntax.y @@ -9,10 +9,10 @@ extern int yylex(void); /* Input and output files. */ extern FILE *yyin, *yyout; -int cw = 0; /* correct words */ -int ce = 0; /* correct expressions */ -int ww = 0; /* wrong words */ -int we = 0; /* wrong expressions */ +extern int cw; /* correct words */ +extern int ww; /* wrong words */ +int ce = 0; /* correct expressions */ +int we = 0; /* wrong expressions */ void yyerror(const char *); %}