Hi :)
I'm doing some research on compiler development, and am wanting to understand more about how the system works parsing using DFA tables. I see the theory of the operation of DFA table with parsers LALR, LL, LR, but I just can not understand.
As I am studying, I do not want to use a compiler compiler, such as ANTLR ... I want to understand how can I mount a tebela, make analyze syntactically with it, and make the parser and code gen...
So, with much searching, I found some code on the internet...
#define TAM_SIGMA 45
...
...
int edges[][TAM_SIGMA] = { {8,8,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,0,0,0,0,0,5,4,2,3,9},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
};
...
...
for example, if I have a very simple language:
function teste
print("c")
return nil
function main
var b = 10;
print("a")
teste()
return nil
How do I make a syntactic and semantic analysis on it, using a table DFA, I just can not understand this, as each state to define this matrix, as each letter, number, or symbol, represents something in the code.
I just can not understand how the machine works using an array as a basis, and that's what I want to know, how to build a simple parser using a DFA table, and how the parser will work in conjunction with it all, if you can post a sample code, I appreciate it.