Issue #5 invalid

string constants in rules

Henrik Vendelbo
created an issue
    Grammar = OMeta.makeGrammar(r"""

var = 'v' 'a' 'r' spaces letter+:name ';' -> ['var', ''.join(name)] """, {}) g = Grammar("var myvar;") result,error = g.apply("var") assert result == ['var', 'myvar']

works ok, but it doesn't seem to work if I write

var = 'var' spaces letter+:name ';' -> ['var', ''.join(name)]

As I understand the spec 'var' or ['v' 'a' 'r'] should work.

or is parsing a string done by chopping it into characters?

Comments (2)

  1. Waldemar Kornewald repo owner

    Double-quotes match a sequence of chars in the stream: "var" => 'v' 'a' 'r'

    Single-quotes match a whole string object in the stream: 'var' => 'var'

    Single-quotes should only be used when matching lists. E.g.: ['bla' foo bar]

  2. Log in to comment