[Ometa] Re: Direct left recursion with specific ending

Maksym Trushyn trushin at gmail.com
Wed May 25 19:37:18 PDT 2011


Hi, Justin!
My example is little bit messy but I hope it is possible to get idea:

ometa MT <: Parser {
  id =3D <letter (letter | digit)*>,
  invoke =3D id:x "(" ")" -> x,
  reference =3D ~invoke id,
  callable =3D invoke | reference,

  expr_prefix =3D expr_prefix:x "." ~~(callable "." callable) callable:f ->
['FieldAccess', x, f]
       | invoke:x -> ['Call', x]
       | reference:x -> ['Var', x],

  valid_ending  =3D expr_prefix:x "." reference:f -> ['FieldAccess', x, f]

}

MT.matchAll('x.y.z()', "valid_ending")
MT.matchAll('x.y().z', "valid_ending")
MT.matchAll('x().y.z', "valid_ending")


Thanks,
Max
http://www.rulezzz.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://vpri.org/pipermail/ometa/attachments/20110525/aec61e7a/attachme=
nt.htm


More information about the OMeta mailing list