This is a toy parser for a toy programming language called antor scripting language which is still in development.This project is purely educational as the language cannot be used for any industry work in its current form. Therefore, the sole aim of this project is to show and teach the skills required of designing computer languages and implementing them.
The Regular Grammar and Context-Free Grammar (written in EBNF format) can be found in the PARSER_ALGOS_AND_GRAMMAR.md (markdown) file as well as the details of the algorithm used to implement the recursive descent strategy of the parser.
What is a Regular Grammar ?
- A regular grammar is the set of all strings generated by a grammar which all contain characters of the alphabet (or other single-character symbols) as defined by that grammar and which result to tokens (terminal symbols).
What is a Context-Free Grammar ?
- A context-free grammar (CFG) is a set of recursive rewriting rules (or productions) used to generate patterns of strings. A CFG consists of the following components: a set of terminal symbols, which are the characters of the alphabet that appear in the strings generated by the grammar
require: "file.module";
require: "regex.module";
def: MAX 200;
begin:
main(void)
var ty = call: factorUpBy2(MAX);
print ty;
end;
method: convertToFactor(c, d){
retn c * d;
}
method: factorUpBy2(x){
var y, g = true;
if(x > 0){
y = (x / 2) * 4;
}else{
g = false;
}
y = call: convertToFactor(g, x);
retn y;
}
Though the above program doesn't do anything for now (i.e. the parser as currently written does not produce an Absract Syntax Tree - AST nor does it provide an Immediate Representation - IR), one can still get to understand the basics of what's going on.
This is released under the MIT license
Antro language design was inspired by Objective-C, Python and JavaScript combined