Donate Now Goal amount for this month: 100 USD, Received: 0 USD (0%)
Donate to support this site and ThinBASIC project development

Results 1 to 7 of 7

Thread: Sample of parsing and translating code

  1. #1
    Super Moderator Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Leverkusen, Germany
    Age
    48
    Posts
    3,151
    Blog Entries
    2
    Rep Power
    323

    Sample of parsing and translating code

    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
    Attached Files Attached Files

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    47
    Posts
    7,556
    Blog Entries
    2
    Rep Power
    10

    Re: Sample of parsing and translating code

    You are an incredible man, Michael.
    For many days we didn't see you and than ... puff ... one gem from Michael

    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)
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  3. #3
    Super Moderator Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Leverkusen, Germany
    Age
    48
    Posts
    3,151
    Blog Entries
    2
    Rep Power
    323

    Re: Sample of parsing and translating code

    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

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,403
    Rep Power
    650

    Re: Sample of parsing and translating code

    Hi Mike,

    great program! And also good presentation of Dictionary and Tokenizer module.
    How is it possible you are ill again


    Thanks,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  5. #5
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Clearwater, Florida, USA
    Posts
    3,802
    Rep Power
    388

    Re: Sample of parsing and translating code

    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.

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    47
    Posts
    7,556
    Blog Entries
    2
    Rep Power
    10

    Re: Sample of parsing and translating code

    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.

    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  7. #7
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Clearwater, Florida, USA
    Posts
    3,802
    Rep Power
    388

    Re: Sample of parsing and translating code

    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!

Similar Threads

  1. sample code for automation
    By sgsong in forum thinBasic General
    Replies: 3
    Last Post: 20-07-2006, 13:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •