How to extract xml codes of the Tokenizer in each Compilexxx methods?

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

How to extract xml codes of the Tokenizer in each Compilexxx methods?

Ichiro
Hi,

I implemented the compileclass method by the following. I prepared the attached simple XML file for a test.

MainT.xml

1. write <class>
2. read the first 3 lines of codes from the Tokenizer excluding <tokens>
3. Because the next token is 'field', call the compileClassVarDec

I used the 'readlines' function to read the Tokenizer. In the 2nd step, I specified a line of the Tokenizer by an index and write it on the new XML file. The output in the command prompt is the same as the Tokenizer.xml. However, the output in the new XML file excluded the type of the terminal such as <keyword> or <identifier>. Please refer to the attached file below.

MainMyreadlines.xml

Could you tell me how to write the line as it is by using the readlines? Or is there any better way to implement each compilation method?

Regards,
Ichiro
Reply | Threaded
Open this post in threaded view
|

Re: How to extract xml codes of the Tokenizer in each Compilexxx methods?

WBahn
Administrator
While you could use the XML from the tokenizer as the input to your compiler, that is not the intent. The idea is that having it produce the token list is the first step, but once that is working, you have it instead output the compiled code.