AlbertHald / Minecraft-Turtle-Language

A beginner friendly programming language for a programmable turtle in Minecraft.
GNU General Public License v3.0
0 stars 0 forks source link

Allow method invocations on any expression #68

Open atjn opened 1 year ago

atjn commented 1 year ago

We currently only allow method expressions on ID's or string literals. This is an unnecessary limitation, but one we made to speed up our initial development of the feature.

We should remove this limitation, but be aware it could amount to significant work especially in the type checker. The related CFG rule is here: https://github.com/AlbertHald/Minecraft-Turtle-Language/blob/86822fd7fd9f15561bc3d3411ad1815215b49824/src/main/antlr4/dk/aau/p4/abaaja/mctl.g4#L65

BaBrixx commented 1 year ago

The way to make the grammar work with this change would probably be replacing the above mentioned CFG rule: https://github.com/AlbertHald/Minecraft-Turtle-Language/blob/86822fd7fd9f15561bc3d3411ad1815215b49824/src/main/antlr4/dk/aau/p4/abaaja/mctl.g4#L65

With the following line | expression DOT ID LPAR (actualParameters)? RPAR #varMethodInvoke

This change will still require significant changes in the type checker and minor changes in the astbuilder (And possibly interpreter?).