vvoovv/pml

Syntax Checks

Closed this issue · 4 comments

Actually, the ANTLR4 parser checks only the syntax of the grammar given in the grammar file. However, additional checks could be required, for instance:

  • Existence and spelling of the attribute names (minHeight, roofShape, etc.)
  • Allowed attributes in a given context (for instance Footprint allows other attributes than Facade).
  • Existence and spelling of attribute values (roofShape -> "dome", "flat", "saltbox", etc.)
  • Eventually range limits of values (positive, non-negative, etc.)

Which checks like this could be required, helpful, ...?

In principle, I see three places where additional syntax checks could be realized:

  1. Add them to the grammar file and let the parser do the checks.
  2. Implement them in the PythonCoder.
  3. Develop an additional program SyntaxChecker, that does this job using the listener of ATNLR4.

The first one would be very difficult to implement, as every attribute requires its context an becomes a token. In any case, it could not be used to check ranges, if required.

The second could be realized. However, its task as reusable class by the node editor would not require this functionality, as names and ranges are already prescribed by the nodes. There, the user has not to care about syntax.

The third could be implemented independently from the other tasks. I would prefer this. It could maybe provide a first step towards for instance an editor with autocompletion.

Thoughts?

Items (footprint, facade, roof, etc) and their attributes can be extensible.
One can imagine using the PML to describe facades for fantasy worlds. PML could be also be used to describe interiors of a building. So the final validity check of the attributes and their values can be left to the application (e.g. blender-osm addon).

I agree that (1) and (2) aren't good options. It isn't quite clear for me how the SyntaxChecker should operate.

SyntaxChecker is maybe not a good name. The ANTLR4 parser already reports syntax errors to the console, for instance if the user for instance forgets to set a semicolon at the end of an attribute. My intention was to create a program that additionally reports errors detected by the checks that I mentioned in my original post. But you are right, these could be left to the application.

Ok