Formal grammar for RAML


#1

Since RAMLs integration in various tools is becoming more and more popular, I think creating a formal grammer is necessary. A formal grammer will speed up parser development for different languages and makes it way easier to test and verify those implementations.

Furthermore a grammer will make clear what is allowed an what’s not. For example

/items/{some{interesting}construct}:
  ...

will parse just fine with the java-raml parser but doesn’t make too much sense.


#2

Agreed that would be nice, and there might be someone already doing it… will get back to you when I find out more. Any suggestions, in the meantime, for how to go about doing this, what type of grammar, whether to base it off a specific YAML grammar, etc?


#3

I guess it would be sufficient to rely on YAML and define stricter rules where necessary (as in the example above) using BNF or something easy and similar.


#4

How was the existing parser written without grammar? All by hand?


#5

The JavaScript parser was based on the Python PyYAML parser, which was translated to CoffeeScript and then evolved from there. Similarly, the Java parser was based on the Java SnakeYAML parser.