Confusion about how to implement Project 11

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

Confusion about how to implement Project 11

harshchikorde1234@gmail.com
I am done with project 10 but I am a bit confused regarding how should I begin implementing project 11. My doubt is, how am I going to use the '.XML file' which arranges the tokens with indentations for each sub-sections, using this how should I identify variables, subroutines, expressions, etc. Also, I didn't get what the point of parsing is if I am using just the tokens to identify them and populate the symbol table. In general, how am I going to use the generated '.XML file' in project 11.
Reply | Threaded
Open this post in threaded view
|

Re: Confusion about how to implement Project 11

pmk21
The XML output of Project 10 was used to confirm the structure of your compiler is ready and to be used as a guide to build the recursive descent parser.  The XML describes the recursive nature of the parsed Jack program (like statements are all contained within functions/methods/constructors which are all contained within classes).  The starting code for Project 11 is, in general, a copy of Project 10.  As you implement Project 11, the XML text will be removed and replaced with VM statements.  Any XML related to structure (braces, commas, semicolons, etc) will completely go away for project 11.

I would recommend starting with a program like

class MyMain {
    function int f1 () {
        return 1;
    }
}

and then seeing what the JackVM compiler does.

function MyMain.fn 0
push constant 1
return

Then build up the above example with gradually more programming elements.  The symbol tables do not need to be implemented right away.  Start with functions, constant expressions, function calls to get going.