Context Free Grammar as a Schema

A schema is a set of rules that structures conforming to it must obey. Every schema in my visual programming editor is also a CFG generating a language out of symbols and strings.

I can automatically construct a parser for every schema that has been defined for my editor. The parser can be used to reconstruct or compose expressions.

Although many of my keyboard commands are incomplete I can already compose expressions. I'm opening a composition box, typing in few symobls like in the image below:

Before completion

The parsing is ambiguous, and the results are not weighted. Therefore pressing tab the first time will give me a wrong parse. Subsequent presses eventually give me the desired result:

After completion

I would like to implement the precedence awareness into the schema before implementing the layout, so we're looking at the 'unlayouted' output.

This thing is using the Earley parser algorithm because it turned out to be easy to implement and extend in practise. It's got some performance issues in practise, but I'll try to produce an incrementally evaluating version before trying an another.

Similar posts