Child pages
  • List syntax

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Current list syntax:

Code Block
Properties = (Property; "," nl)*; 

or with optional separator after last element

Code Block
Properties = (Property; "," nl; ?)*; 

It is not very explicit about what happens. Semicolon reuse is so heavy, that using it here makes me think it is nested sequence rule or something. It doesn't convey they idea of separator explicitly, especially that it will have very different type in AST. Use of question mark, which is "optional" operator, is good but its placement is unclear. There is no other place where "?" is used without a rule before it.

Ideas:

Code Block
Properties = Property*:("," nl)
Properties = Property+:Separator=("," nl) // can use typed collection list<tuple<Property,Separator>> 

This tells that there are many Properties (Property* part), but somehow augmented.
Can extract to separate rule with clean syntax

Code Block
Parameters = "(" Parameter*:CommaSeparator ")"
TypeArguments = "<" (TypeIdentifier+:CommaSeparator | CommaSeparator+) ">"

Other potential benefits:

  • building list-driven additive and multiplicative expressions like this (+2 means 2 or more):
    Code Block
    Sum = Expression+2:Operator=("+"|"-");
    Mul = Expression+2:Operator=("*"|"/");