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?
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.
Re: Parser & Symbol Table Generator
Quote:
Originally Posted by
mods_3
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>
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.
Re: Parser & Symbol Table Generator
Why not use an existing language for your scripts?
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!
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!