NanoScript Compiler is a simple compiler for the NanoScript programming language, designed to help users and learners explore compiler design. Built with LLVM, Flex, and Bison, it supports variables, loops, conditionals, and more.
- LLVM (>=15 versions)
- Flex (for lexical analysis)
- Bison (for parsing)
- Clang or any C++ compiler (e.g., GCC)
- Clone the repository:
git clone https://github.com/VedaangNarkhede/Compiler.git
- Navigate to the project directory:
cd compiler_directory - Build the project:
make clean make
Here’s a basic NanoScript program:
number x = 10;
for number i = 0 to 4, 1
print(x + i);
end
- Save it as
demo.ns. - Compile it:
compiler.exe demo.ns
- Run the output:
out.exe
Expected Output:
10
11
12
13
14
- Variables:
number(int),letter(char),word(string) - Loops:
forandwhile - Conditionals:
if-else - Functions: Basic function support
- Operators: Arithmetic and comparison
| Component | Technology |
|---|---|
| IR Generation | LLVM |
| Lexical Analysis | Flex |
| Parsing | Bison |
| Executable | Clang |