Skip to content

djayke/Nimer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nimer

Nimer is my very own toy programming language. Im working on it as of today to fix many incomplete features. The language now support if, else, while, for, function that still need work. Im also working on a C# version of the project and a complete tutorial on how I did and for people that would like to make their own programming language from scratch. Ive been looking for nice and complete tutorial a lot on the intrnet over past years and after many attempt, im finally coming to something and I want to share what I learned in the process with people.

There is many things wrong with this current version.

Feel free to message me if you're the type to work on project like that or have any question on how to start!

Idea Setup

  1. Download ANTLR .jar -> https://www.antlr.org/download.html
  2. Add antlr.jar to project CTRL+ALT+SHIFT+S image
  3. Add ANTLR4 plugin
  4. Right Click on grammar file in tree explorer and then configure ANTLR... image
  5. [OPTIONAL] To apply change made to grammar right click on gramma file and then Generate ANTLT Recognizer

Language

Program take file that contains Nimer Script as input.

  1. Variable
a = true;
b = false;
  1. Print
log a;
  1. If Statement
if a && b {
  log "1 :: a=" + a +", b=" + b;
}
else if a || b {
  log "2 :: a=" + a +", b=" + b;
}
else {
  log "3 :: a=" + a +", b=" + b;
}

  1. For Statement
i = 1;
for i=0; i<7; i=i+1;
{
  log i;
}
  1. While Statement
x = 1;
while x < 5 {
    log x;
    x = x + 1;
}
  1. Function and Method
func recursive(a)
{
    if(a>1)
    {
        recursive(0);
    }
    return a;
}

i = recursive(3);
log i;

Useful Unix Command to use Antlr

Command Line Antlr Generic Usage

java -jar <antlr.jar> <grammar.g4> -Dlanguage=<language> -o <output_folder> -visitor
java -jar antlr.jar T.g4 -Dlanguage=Java -o Antlr -visitor

Bytecode

the part wher it translate the logical addressing into physical addressing for a compressed format such as hexadecimal is the only obvious part where the virtual machine handling the basic CISC instructions is held in such way that it can hold multiple stack pointer and frame counter at once to make it a parralel bytecode irtual machine! Somehow one day!