
Sample program:
int main: v = 10 for i: 1 to v write “hello”
The first step in the stabdard practice of implementing interpreters seems to be to tokenize input. This seems easy. Here are the tokens:
| Lexemes | Tokens |
| int | KEYWORD |
| main | KEYWORD |
| : | KEYWORD |
| v | IDENTIFIER |
| = | OPERATOR |
| 10 | VALUE |
| for | KEYWORD |
| i | IDENTIFIER |
| : | KEYWORD |
| 1 | VALUE |
| to | KEYWORD |
| v | IDENTIFIER |
| write | KEYWORD |
| “ | KEYWORD |
| hello | VALUE |
| “ | KEYWORD |
According to the information that I am referring to at, https://www.geeksforgeeks.org/compiler-design/introduction-of-lexical-analysis/, there 2 columns needed, first one is lexemes and second one is tokens. How these tokens are to be used seems to be the next step.
0 Comments.