Results 1 to 7 of 7

Thread: Sample of parsing and translating code

  1. #1
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Germany
    Age
    58
    Posts
    3,299
    Rep Power
    348

    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
    57
    Posts
    8,818
    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/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Germany
    Age
    58
    Posts
    3,299
    Rep Power
    348

    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
    7,155
    Rep Power
    736

    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 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  5. #5
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405

    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.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,818
    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/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405

    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!
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

Similar Threads

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

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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