PA3 seems to be ok
This commit is contained in:
parent
54e92e49a4
commit
dcff1387d9
@ -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
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -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 */
|
||||
%%
|
||||
|
||||
Loading…
Reference in New Issue
Block a user