Lazy Language Interpreter Design

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:

LexemesTokens
intKEYWORD
mainKEYWORD
:KEYWORD
vIDENTIFIER
=OPERATOR
10VALUE
forKEYWORD
iIDENTIFIER
:KEYWORD
1VALUE
toKEYWORD
vIDENTIFIER
writeKEYWORD
KEYWORD
helloVALUE
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.

Leave a Reply

Discover more from Amol's Code Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading