raml-spec icon indicating copy to clipboard operation
raml-spec copied to clipboard

Provide a formal grammar for type expressions

Open katmatt opened this issue 8 years ago • 2 comments

Theme Improve interoperability

Description

The current version of the RAML specification describes the grammar of type expressions with an informal grammar and some examples. Providing a more formal EBNF grammar would add more precision and would make it easier to write a standard compliant implementation.

I already created an initial version of a type expression antlr4 grammar and you can find it here: TypeExpression.g4.

For the specification it would be nice to use the "inoffical" W3C EBNF notation and there is an online tool (http://bottlecaps.de/convert/) that can generate such a grammar from an antlr3 grammar.

When I convert my slightly modified grammar, it looks like this:

type_expr
         ::= qualified_name
           | type_expr ( '[]' | '|' type_expr )
           | '(' type_expr ')'
qualified_name
         ::= ID ( '.' ID )?

katmatt avatar Jul 22 '17 09:07 katmatt

How is ID defined?

UPDATE

Sorry just saw your grammar where it's been defined. Still, I'd suggest to formally describe in anything that's appears inside the EBNF. What do you think?

sichvoge avatar Jul 22 '17 09:07 sichvoge

It would be great to define the ID token in the RAML spec!

Given that all of the examples in the RAML specification use the yaml Plain Style the ID rule should follow the nb-char rule of the yaml 1.2 specification (see Line Break Characters).

But this would overlap with annotation references, which are following this rule:

annotation_ref 
         ::= '(' ID ( ID+) ')'

Another question is: Does the RAML standard allow other yaml styles for type declaration names?

katmatt avatar Jul 23 '17 06:07 katmatt