Skip to content

somerandomdev49/Necromantus

Repository files navigation

Necromantus Build Status

Necromantus is a simple scripting language for java.

Looks like this, nothing special:

write("Hello, World!");
write("Enter your name:");
let weird = func (x, y) {
	out = (x + y) * (x - y);
};
let name = read();
write("Hello, ", name);
write("two plus two is ", 2 + 2);
if name is "Admin" {
	write("ACCESS GRANTED!");
	let correct = true;
	while correct {
		write("What is (2 + 2) * (2 - 2)?");
		let answer = read();
		if 0 not (stof(answer)) {
			correct = false;
		}
	}
	write("INCORRECT!", " TWO PLUS TWO IS ", weird(2, 2));
} elseif name is "SomeRandomDev49" {
    write("Hello, God.");
} elseif name is "hehehe" {
    write("uh oh!");
} else {
    write("ACCESS DENIED!");
}

Simple java API and syntax.

class Example {
    public static void main(String[] args) {
        Tokenizer t = new Tokenizer(contents);
        parser = new Parser(t);
        Node dd = parser.parseSource();
        Scope scope = new Scope(null);
        Walker walker = new Walker(scope);
        walker.putNativeFunc(new NMNativeFunc("write", (ArrayList<Object> args) -> {
            for(Object arg : args)
                System.out.print(arg);
            System.out.println();
            return null;
        }));
        walker.putNativeFunc(new NMNativeFunc("read", (ArrayList<Object> args) -> 
            new Scanner(System.in).nextLine()
        ));
        for (Node statement : ((RootNode) src).children)
            walker.walk(statement);
    }
}

Note: this ⬆⬆⬆ is default stuff, so you can use these functions straight away.

[a0.9] To disable strange messages, remove an if statement in nextToken() of Tokenizer.java and recompile the program

[a0.9.1] Now it's ok :)

if some unexpected behaviour appears, make an issue.