diff options
| Commit | 4aa1f0d045a8940f4d3015737d56f2bdc5debb67 (patch) | |
|---|---|---|
| Author | 2023-11-08 19:43:34 +0200 | |
| Committer | 2023-11-08 19:43:34 +0200 | |
| Files | 246d2dcf237cf99709708c0453986836d8f3f396 | |
| uni-projects-4aa1f0d045a8940f4d3015737d56f2bdc5debb67.tar uni-projects-4aa1f0d045a8940f4d3015737d56f2bdc5debb67.tar.gz uni-projects-4aa1f0d045a8940f4d3015737d56f2bdc5debb67.zip | ||
| Parent | eed9bc719d1dd5be8e8dc36d5ec463eb450da59d (diff) | |
[CI/PA2] Fixed classes
1 files changed, 10 insertions, 2 deletions
| -rw-r--r-- | Year 3/Compilers, Introduction/coolc-spim/my-code/coursework/pa2/cool.y | 12 |
diff --git a/Year 3/Compilers, Introduction/coolc-spim/my-code/coursework/pa2/cool.y b/Year 3/Compilers, Introduction/coolc-spim/my-code/coursework/pa2/cool.y index 40a8a47..74ab0d6 100644 --- a/Year 3/Compilers, Introduction/coolc-spim/my-code/coursework/pa2/cool.y +++ b/Year 3/Compilers, Introduction/coolc-spim/my-code/coursework/pa2/cool.y @@ -150,10 +150,18 @@ ; /* If no parent is specified, the class inherits from the Object class. */ - class: CLASS TYPEID '{' dummy_feature_list '}' ';' { $$ = class_($2,idtable.add_string("Object"),$4, stringtable.add_string(curr_filename)); } - | CLASS TYPEID INHERITS TYPEID '{' dummy_feature_list '}' ';' { $$ = class_($2,$4,$6,stringtable.add_string(curr_filename)); } + class: CLASS TYPEID '{' feature_list '}' ';' { $$ = class_($2,idtable.add_string("Object"),$4, stringtable.add_string(curr_filename)); } + | CLASS TYPEID INHERITS TYPEID '{' feature_list '}' ';' { $$ = class_($2,$4,$6,stringtable.add_string(curr_filename)); } ; + feature_list: feature + | feature ';' feature_list + ; + + feature: attribute + | method + ; + attribute: OBJECTID ':' TYPEID | OBJECTID ':' TYPEID ASSIGN expression ';' ; |
