Rubific

A strongly-typed string-interpolation language inspired by and compatible with Ruby.

String valued Rubific expressions can be expanded within template strings when enclosed in #{ ... } interpolations. A Template class provides values for specific variables referenced by Rubific names and will invoke the Rubific evaluators at appropriate times.

Example trace output to standard error. By convention grammar non-terminals are five letters so as to maintain text alignment in trace.

The language and its parser-evaluator are co-developed from examples. The implementation has sufficient error and trace handling that useful guidance can come from running examples during ongoing development.

Syntax errors are reported by echoing the template with a message in red inserted at the point of disagreement. One method writes these to standard error.

want(" ... ")

The parser's recursive descent is traced with similar reports inserted in context, this time in green, showing the entry and exit of production rules.

trace("( ... ") trace(" ... )")

The language is thus extended by the TDD heartbeat: red, green, refactor. The grammar plays the role of stories. Examples serve as test cases. The usual practice of returning expected literals to pass tests works well.

See Pegasm where I used bytecode rewriting to insert similar trace logic.