Project 9 Jack language operator precedence

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Project 9 Jack language operator precedence

Lozminda
Quoting the book "Elements of Computing Systems"

For example, the Jack grammar
does not mandate the usual operator precedence (O.P.) in expressions evaluation (multiplication before addition,
and so on). This has enabled us to avoid parsing algorithms that are more powerful yet much more
technical than the elegant top-down parsing techniques presented in the chapter.


If there's one tip I can give to help with project 9 is don't forget that there isn't any O.P !

The amount of times my if statements didn't behave as I expected were many, because i'd forgotten brackets (())!
eg

if ((startBlkNum > (MIDPOINT - 1)) & f1stNon_0Reslt)

Parentheses, Parentheses, Parentheses. Don't forget your Parentheses !

Good luck !





Reply | Threaded
Open this post in threaded view
|

Re: Project 9 Jack language operator precedence

WBahn
Administrator
An interesting program to right is one to determine the precedence and associativity of your compiler. To do this you do a series of tests to tease the information out. This is useful if you choose to implement a more rational compiler that imposes a defined set of order of operations as it gives you a nice test program to use.