Results 1 to 7 of 7

Thread: Parser & Symbol Table Generator

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    4

    Resolved Parser & Symbol Table Generator

    Hello my favorites community!

    I know this post is puch-a-punched with heavy-duty coding algorithms and questions. Please bear with me.

    I am developing an application for which I need to implement a 'script' interpreter.

    I have in mind what the 'script' syntax would look like.

    Is there any way I could accelerate its development (books, free easy-to-use for noobs, ...) for developing such a small interpreter.

    This interpreter should have all basic functional programming levels capabilities, such as variable [types], methods (functions) calling (with parameters) and 'return'-like keyword, if-then-else, while, for-each, arrays, operators, basic one-level class implementation, ...

    I'm not asking about how to implement the whole thing. I just wanted to get started by a beautiful Parsed Symbol Table from which I can start executing (interpreting).

    I shall have input file (plain text) > output > SymTable Structure of some kind.

    In a nutshell, I need help with the "parsing" part of the interpreter, and I could do the rest.


    Any ideas?
    Last edited by mods_3; Jun 3rd, 2021 at 05:42 AM.

  2. #2
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,295

    Re: Parser & Symbol Table Generator

    There are open source ones you can study, I dont believe I have seen any written in VB though.

    ScriptBasic and duktape both come to mind (both written in C) .
    The .NET world might have some of its own as well.

    Unless your primary task is to write a script interpreter from scratch I would just use a pre-made one
    like the msscript control or one of the above. a from scratch implementation could take you a year
    or more for full features. Not a simple task.

  3. #3
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,167

    Re: Parser & Symbol Table Generator

    Quote Originally Posted by mods_3 View Post
    Any ideas?
    A LLVM's Kaleidoscope toy language VB6 port can be found here. It uses a VbPeg grammar to generate the parser.

    cheers,
    </wqw>

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    4

    Re: Parser & Symbol Table Generator

    Thank you all!

    Yes, I'm planning to write a 'simple' scripting language (interpreted) from scratch in VB6 with the help of a simple Grammar Generator and a VB6 Project Template.

  5. #5
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,945

    Re: Parser & Symbol Table Generator

    Why not use an existing language for your scripts?

  6. #6
    Frenzied Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    1,169

    Re: Parser & Symbol Table Generator

    As you're designing your own language, bear in mind that it's design can make it's implementation more or less difficult depending upon the syntax chosen. Possibly the easiest type of language to implement is LL(1) grammar which can be parsed using a Recursive Descent Parser (https://en.wikipedia.org/wiki/Recursive_descent_parser) with one token lookahead. I'd first formalise the language syntax using EBNF (https://en.wikipedia.org/wiki/Extend...80%93Naur_form) into a form suitable for RDP implementation.

    Once you have the EBNF, then parsing the input into tokens and say an Abstract Syntax Tree (https://en.wikipedia.org/wiki/Abstract_syntax_tree) is quite straightforward. Once you have that (or similar), then you can start interpretation etc.

    PS. Have a look at https://en.wikipedia.org/wiki/GOLD_(parser) which can produce a parser in Visual Basic (6?)

    Good luck!
    Last edited by 2kaud; Jun 3rd, 2021 at 06:02 AM.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    4

    Resolved Re: Parser & Symbol Table Generator

    @2kaud:

    Oh! GOLD Parser! I knew about it. And It seems to be the best way to go.

    I just had to ask. You know, maybe someone knows something that I'm not aware of.

    It's always best to ask, right?

    P.S. I'm writing my 'own' scripting (interpreted) language as a study example.

    As you may know, doing it myself is the way to go, if I really want to deepen my understanding and level-up my education in general!



    Thank you ALL!
    Last edited by mods_3; Jun 3rd, 2021 at 05:43 AM. Reason: Optimizing Post

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width