Skip to content

{ Tag Archives } javascript

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

Stop infinity with the power of $.maxStop()

Tired of infinite loops? Infinite recursion got you stuck? Tired of introducing meaningless count variables just beat the scourge of an unresponsive script? Then I’ve got the tool for you. Hot off the assembly lines, tested thoroughly in rugged environments across the landscape, $.maxStop() will stop the horizontal eight in its tracks! To use: Kills [...]

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

Matryoshka, you $.russianDolls

So as I have been rewriting my code, I found that I wanted to add more and more behavior on top of each other. For example, as I create symbols, I want to have some of them process a value on startup. Or I want to have checking behavior added to the usual processing. So [...]

Also tagged

The rise of the .prototype

Today I have gotten to a point for another version in stone to go back to. It features a sequence of evaluations of an expression with boxes showing what will be evaluated, bolded numbers showing what was evaluated, and a grey last number showing that that number is where uncertainty lies. It also uses engineering [...]

Also tagged

DSLs, SCSS, htmPlus

I was reading a book on Domain Specific Languages on my Safari Online subscription on my iPad. I was trying to learn more about them and how to parse. I read a big chunk of it and I have to say it is a quick and enjoyable read. But I am not sure if I [...]

Also tagged

A real $.push over

How do we add an element to an array in JavaScript? If arr is an array, then arr.push(element) adds the element to the array. Nice and simple. But what if we have obj.arr? Well, then obj.arr.push(element) works. But what if arr might not exist? If we do the above and arr does not exist, then [...]

Also tagged