Related articles |
---|
Compiling expressions james.harris.1@gmail.com (James Harris) (2012-12-29) |
Re: Compiling expressions gah@ugcs.caltech.edu (glen herrmannsfeldt) (2012-12-29) |
Re: Compiling expressions mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2012-12-30) |
Re: Compiling expressions james.harris.1@gmail.com (James Harris) (2013-01-02) |
Re: Compiling expressions james.harris.1@gmail.com (James Harris) (2013-01-02) |
Re: Compiling expressions matzebraun@googlemail.com (matzebraun@googlemail.com) (2013-01-03) |
Re: Compiling expressions torbenm@diku.dk (2013-01-03) |
Re: Compiling expressions james.harris.1@gmail.com (James Harris) (2013-01-03) |
Re: Compiling expressions james.harris.1@gmail.com (James Harris) (2013-01-03) |
Re: Compiling expressions mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2013-01-04) |
Re: Compiling expressions james.harris.1@gmail.com (James Harris) (2013-01-06) |
Re: Compiling expressions vonbrand@inf.utfsm.cl (Horst von Brand) (2013-01-14) |
[1 later articles] |
From: | "matzebraun@googlemail.com" <matzebraun@googlemail.com> |
Newsgroups: | comp.compilers |
Date: | Thu, 3 Jan 2013 07:13:13 -0800 (PST) |
Organization: | Compilers Central |
References: | 12-12-035 12-12-036 13-01-006 |
Keywords: | parse, code |
Posted-Date: | 03 Jan 2013 15:16:22 EST |
> > > 3. Precedences (and possibly associativities) defined in tables.
>
> I would rather the result is easy to understand but I don't mind too
> much how the tables are generated.
Search for Shunting-yard algorithm/precedence climbing/precedence
parsing these should fulfill your requirements easily if implemented
properly. You basically have a pair of parsing function callback and
precedence level for each input token, if your ast is perfectly
regular and it's only infix operations, then you can leave out the
parsing function callback.
You may find an implementation in our c compiler (though keep in mind that
this is a complete c parser with semantic so there is a lot more code
"around"), you may find the relevant pieces here:
https://github.com/MatzeB/cparser/blob/master/parser.c (look for
parse_subexpression(), init_expression_parser(), struct
expression_parser_function_t)
Greetings,
Matthias Braun
Return to the
comp.compilers page.
Search the
comp.compilers archives again.