Reputation: 11
So, I am writing a CFG body to generate compiler via SableCC, and the given samples have these "Start" and "End" at the beginning of the program and end of it, respectively.
Sample code
Start
Print 10;
int a,b;
End
I suppose they are also tokens, because are not going to appear on Productions. So i wrote them in the grammar like:
Tokens
number = ['0'...'9']+;
identifier = letter(letter|number)*;
opaddsub = '+' | '-';
opmuldiv = '*' | '/';
opsemicolon = ';';
opequal = '=';
parleft = '(';
parright = ')';
comma = ',';
blank = (' ' | 13 | 10 | 9 )+;
start = 'Start'
end = 'End'
Though I am not confident, and how i must write productions is still puzzling me, I want to get helped.
Upvotes: 1
Views: 38