View Full Version : Sample of parsing and translating code
Michael Hartlef
21-05-2008, 14:41
Hi folks,
here is a sample script of parsing a programming language and translating it into another one. This parser translates thinBasic like code and translate it into PASCAL. The posted code is ment to be as a sample so don't expect it to produce compilable code. ;)
I will work further on it but wanted to share my results so far.
Cheers
Michael
ErosOlmi
21-05-2008, 15:29
You are an incredible man, Michael.
For many days we didn't see you and than ... puff ... one gem from Michael :D
Thanks
Eros
PS: worth to say script is expected to be executed from the command line passing some command line options (see source code for possible options)
Michael Hartlef
21-05-2008, 15:57
Thanks Eros,
the reason I'm not so visible are
1) I'm not allowed to use the internet so much anymore (better nto at all) at my job.
2) I'm fighting some colds and stuff like that
3) Family activities
4) Other little non thinBasic related projects
But I still try to come up with stuff for thinBasic.
Michael
Petr Schreiber
21-05-2008, 17:23
Hi Mike,
great program! And also good presentation of Dictionary and Tokenizer module.
How is it possible you are ill again :(
Thanks,
Petr
How do you run the program guys?
I went into console, with start:run:cmd and into a directory I made with a test script and Mike's script. But can't figure out how to run thinBasic via command window.
I tried thinBasicc thinpas.tabsic -s test.tbasic -o out.pas
thanks for any help.
ErosOlmi
22-05-2008, 00:15
Something like:
thinBasic.exe thinpas.tbasic -sthinpas.tbasic
where -s flag is together with the input file name.
Maybe this part can be optimized a bit.
Ok thanks Eros, I see that my paths are not setup for thinBasic and it gives me an unrecognized command message. But now that I know how it should be will get it going. Thanks.
How to set the paths in XP.
1. From the desktop, right-click My Computer and click properties.
2. In the System Properties window, click on the Advanced tab.
3. In the Advanced section, click the Environment Variables button.
4. Finally, in the Environment Variables window, highlight the path variable in the Systems Variable section and click edit. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon as shown below.
C:\Program Files;C:\Winnt;C:\Winnt\System32
Works great now. Thanks for the help Eros.
Mike, hope you get better and if you do something like this when not feeling well, wow we will see when nice and healthy again :) Thanks!