Skip to content

{ Tag Archives } parsing

Pratt parsing 2; same level associativity

Version 4 has an error in it. Try parsing 4^3^2. Parser 4 gives (4^3)^2 = 4096. Google gives 262144 as does Parser 5alpha. They parse it as 4^(3^2). So how does Pratt parsing handle this? First, note that it is only an issue for operators with the same binding power. Different binding powers are there [...]

Also tagged

Parsing Version 4

Skipping version 3 entirely (let’s just not go there, shall we?), I have now a version 4 on the web. It currently does arithmetic without parentheses. But what it does do is take the arithmetic expression(s) and parse them into trees, bottom-up with the computed values in the nodes and operations above. The graphics are [...]

Also tagged

Pratt Parsing 1

So I thought I would start a series on how Pratt parsing works. This is actually to help me understand this 3 months from now. This time, we will look at parsing -7+3*4 + 9 We first tokenize getting -,7, +, 3, *, 4, +, 9 One can use a regex for tokenizing such as [...]

Also tagged

tokenizer prototyped

So I refactored my tokenizer into a prototype construct. I am not sure if I did it completely optimally, but I think it is reasonable. Almost all of the properties are generic to all tokenizers in my vision, so that is encapsulated in the MasterTokenizer function. The prototype has all the methods that tokenizers need. [...]

Also tagged

prototyping code

So I am yet again refactoring my code. I hope this is the last time and then I can get into adding behavior. I did manage to separate all the behaviors and now have seeders, walkers, and shooters working in version 3. But I broke my index page; it is all in Firebug debugging. So [...]

Also tagged