lua-users home
lua-l archive

Re: OT(slightly): parser generator for expression with custom operators

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


On 29/06/2011 18.54, Wesley Smith wrote:
Sounds like there are a range of options for what you need. If you
can make do with the Lua metamethods and a little string substitution,
I would definitely stick with a pure Lua implementation. However, if
you need to define a syntax that can't be handled by existing Lua
mechanisms, you can write a simple grammar and interpret the AST
yourself.
Well, I'd love to have those skills, but as I said before: I'm CS-impaired :-)
That was the whole point of starting this thread in the first place!
I know enough about grammars and EBNF to be able to read and (mostly) understand a grammar (I even managed to use XML specification as a tool to learn and write XML some years ago ;-) But I'm far from being able to design a grammar based on which operator should have which precedence, which associativity, etc. etc.!
> I have had to do this for a couple of projects, which is
why I wrote the codepeg[1] module. It can automatically generate a
parser from a grammar specification.
Interesting, nevertheless. Thanks.
wes
[1] https://github.com/weshoke/codepeg
-- Lorenzo

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