Here we learn some basic understanding of how compiler / interpreter pipeline work. Just the rough idea but decent enough for further understanding of the topic.
General pipeline of a language (in place of terms compiler / interpreter) are :
- Scanning / Lexing
- Parsing
- Static Analysis
- Intermediate Representation
- Optimisation
- Code Generation
From Root Project
./gradlew lox
java -jar build/libs/lox.jar
# https://docs.gradle.org/current/userguide/java_testing.html
./gradlew test
Convert source sequence of characters to sequence of tokens.
Example
# Source
var userName = "Hello World";
var age = 12;
# Lexemes
> var userName = "Hello World";
VAR var null
IDENTIFIER userName null
EQUAL = null
STRING "Hello World" Hello World
SEMICOLON ; null
EOF null
> var age = 12;
VAR var null
IDENTIFIER age null
EQUAL = null
NUMBER 12 12.0
SEMICOLON ; null
EOF null