I am writing a parser for Modula-3 and this production puzzled me:
ObjectType = [TypeName | ObjectType] [Brand] OBJECT Fields
[METHODS Methods] [OVERRIDES Overrides] END.
This rule is single left recursive piece of Modula-3 grammar, IIRC.
And also, it does not look correct - I can't remember I've seen
anything except "TypeName" (meaning "qualId | [UNTRACED] ROOT")
denoting parent type anywhere in Modula-3 sources. It is also
illogical (to me, at least) to have anonymous type as parent of
anything, and we will have that if this is declared:
TYPE
My = OBJECT a: CARDINAL; END OBJECT b: CARDINAL; END;
This "My" is in proper syntax according to above production, but pm3
did not accept it. I have no reason to believe any Modula-3 compiler
will. Is there a reason? Do we have an ommision in Modula-3 syntax or
implementation restriction in our compilers?
TIA,
dd