diff --git a/assignments/PA3/Makefile b/assignments/PA3/Makefile index c85fef4..18f3168 100644 --- a/assignments/PA3/Makefile +++ b/assignments/PA3/Makefile @@ -78,7 +78,7 @@ clean-compile: TESTCASE = good.cl comparetest: parser - ./stdparser ${TESTCASE} > std.out - ./myparser ${TESTCASE} > my.out + -./stdparser ${TESTCASE} > std.out 2>&1 + -./myparser ${TESTCASE} > my.out 2>&1 diff std.out my.out rm std.out my.out \ No newline at end of file diff --git a/assignments/PA3/bad.cl b/assignments/PA3/bad.cl index c7102a2..0f84f7e 100644 --- a/assignments/PA3/bad.cl +++ b/assignments/PA3/bad.cl @@ -6,6 +6,8 @@ * execute "myparser bad.cl" to see the error messages that your parser * generates *) +-- lex_error +*) (* no error *) class A { @@ -24,6 +26,40 @@ Class D inherts A { }; (* error: closing brace is missing *) -Class E inherits A { +Class E inherits A } ; +class A { + F(x : Int) : Object { + self + }; +}; +class B { + Y : Int; +}; + +Class F inherits A { + scheisse: wrongtype ; + WrongType: scheisse; + scheisse <- "no type"; + err_method1(id1: t1); + err_method2(id1:T1, ); + err_method3(id1:T1):t1; + err_method4(id1:T1):T1; + err_method5(); + good_method() : T { hallo <- 2 }; + err_method6() { hallo <- 2 }; + err_block() : T { + let a:Int <- Broken in { + error(s:T); + hello; + err_(s:T); + wow(); + } + }; + err_let() : T { + { + let a:Int<-Bork, b:Int<-5, c:Int<-6 in a + B; + } + } +}; diff --git a/assignments/PA3/cool.y b/assignments/PA3/cool.y index 239ec7e..da9b106 100644 --- a/assignments/PA3/cool.y +++ b/assignments/PA3/cool.y @@ -181,6 +181,8 @@ { $$ = append_Classes($1,single_Classes($2)); parse_results = $$; } /* TODO: I guess `parse_results` is only needed in the top-most class_list*/ + | error ';' + { } ; /* If no parent is specified, the class inherits from the Object class. */ @@ -192,7 +194,6 @@ { $$ = class_($2,$4,$6,stringtable.add_string(curr_filename)); } | CLASS TYPEID INHERITS TYPEID '{' '}' ';' { $$ = class_($2,$4,nil_Features(),stringtable.add_string(curr_filename)); } - | CLASS error '{' error '}' ';' ; /* Feature list may be empty, but no empty features in list. */ @@ -200,6 +201,8 @@ { $$ = single_Features($1); } | feature_list feature ';' { $$ = append_Features($1, single_Features($2)); } + | error ';' + { } ; feature : OBJECTID ':' TYPEID @@ -241,6 +244,8 @@ { $$ = single_Expressions($1); } | expression_list_colon expression ';' { $$ = append_Expressions($1, single_Expressions($2)); } + | error ';' + { } ; expression : OBJECTID ASSIGN expression @@ -336,6 +341,10 @@ { $$ = let($1, $3, no_expr(), $5); } | OBJECTID ':' TYPEID ASSIGN expression IN expression %prec LETEXPR { $$ = let($1, $3, $5, $7); } + | error ',' nested_let + { $$ = $3; } + | error IN expression %prec LETEXPR + { $$ = $3; } ; /* end of grammar */ %%