lua-users home
lua-l archive

Re: Overloading and extending operators, (l)PEGs and grammars

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I have mixed feelings about (ab)using operator overloading to support inline
> expression of grammars. I can see the appeal to somehow add grammars as
> elements of the language, rather than strings, but strings aren't so hard to
> use, and are fairly flexible. I wonder if it wouldn't be better to use lpeg to
> write something like:
> 
> equalcount = lpeg.grammar[[
> 	S = "0" B
> 	 / "1" A
> 	 / ""
> 	A = "0" S
> 	 / "1" A A
> 	B = "1" S
> 	 / "0" B B
> ]]
This seems exactly what the 're' module does (except that it cannot
handle complete grammars yet...).
-- Roberto

AltStyle によって変換されたページ (->オリジナル) /