librelist archives

« back to archive

Give the arithmetic operators different precedences?

Give the arithmetic operators different precedences?

From:
Chris Corbyn
Date:
2011-11-04 @ 13:37
Hi,

For expressions like:  2 * 2 + 1

How do I ensure 2 * 2 is reduced before the " + 1" part is reduced?

Maybe an infix calculator in the examples/ directory would be a nice 
example, as tends to be the "hello world" of parsers :)

Cheers,

Chris

Re: Give the arithmetic operators different precedences?

From:
Kaspar Schiess
Date:
2011-11-07 @ 08:07
On 04.11.11 14:37, Chris Corbyn wrote:
> Maybe an infix calculator in the examples/ directory would be a nice 
example, as tends to be the "hello world" of parsers

I will pass on this hello world; I am not the king of hello worlds ;) 
Constructing an infix parser is what everyone should do first, by 
him-/herself... Understanding that will often lead to having a fun time 
with PEG.

But if you publish such a tutorial / example, I will gladly link to it / 
include it in the examples tree.

greetings,
kaspar