TC-1 Improvements¶
Possible improvements include:
- configure.ac
Customize your compiler’s version and group’s name in the AC_INIT macro at the start of the configure.ac.
- Using
%destructor You may use
%destructorto reclaim the memory lost during the error recovery. It is mandatory in TC-2, see TC-2 FAQ.- Handling object-related constructs
Your scanner and parser are not required to support OO constructs but you can implement them in your LALR(1) parser if you want (fully supporting them at TC-2 is highly recommended though, during the conversion of your LALR(1) parser to a GLR one).
Object-related productions from the Syntactic Specifications:
ty = (* Class definition (canonical form). *) "class" [ "extends" type-id ] "{" classfields "}" ; dec = (* Class definition (alternative form). *) "class" id [ "extends" type-id ] "{" classfields "}" ; classfields = { classfield } ; (* Class fields. *) classfield = (* Attribute declaration. *) vardec (* Method declaration. *) | "method" id "(" tyfields ")" [ ":" type-id ] "=" exp ; exp = (* Object creation. *) "new" type-id (* Method call. *) | lvalue "." id "(" [ exp { "," exp }] ")"