Skip to content

A simple interpreted programming language and expression evaluator.

License

Notifications You must be signed in to change notification settings

fededevi/DeScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DeScript

An interpreted language

Howto:

In order to build the parser you need to preprocess the deocl.jj file with javacc and put the output files in the parser.jj package. Download javacc from javacc.org, then just call:

java -cp javacc.jar javacc deocla.jj

This will generate a bunch of .java files including the parser class.

Examples:

DeoclaParser p= new DeoclaParser(new FileReader("\\path\\to\\your\\program.dol"));
//Parse program and create the AST, returns the first statement of the program.
Statement stat = p.Start();
//Run the program with a context containing a println() function to print stuff. 
stat.execute(new SystemContext());

If you want to just parse expressions then:

DeoclaParser p = new DeoclaParser(new StringReader("5 / 2"));
Expression exp = p.expressionParse();
exp = exp.evaluate(new Context());
System.out.println(exp);

About

A simple interpreted programming language and expression evaluator.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published