ifRule = "if-statement := <if> <expression> | <list> <block> | <else> <block> <end>" //might convert to:
[12, 2, -1, 5, 9, -1, 13, 9, 14] // -1 representing 'OR'
ifRule = "if-statement := <if> <expression> | <list> <block> | <else> <block> <end>" //might convert to:
[12, 2, -1, 5, 9, -1, 13, 9, 14] // -1 representing 'OR'
After playing with Ruby (to get a feel for things), I'm now using C++ as my implementation language.
I've written a Lexer that scans the source code, looks for comments, lexical errors like unfinished strings etc,
and creates valid tokens with values.
Heres an output of the following code:
The Lexer was the easy part, now I need to parse the token list and analyze the grammar of the syntax.
I've been reading up on Backus-Naur Form and
like what I'm seeing. Before creating the AST, you would have to know what you are adding. Most resources online
have focused on Bison/Yacc. I'm wanting to use NFB or ENFB as a guideline in the "rules" section of my parser. I'm hoping some of you might have experience with this in C++? Or at least Java to give me an idea of how you have / would define the rules of the language.