Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/teverett/kpascal
A Pascal interpreter
https://github.com/teverett/kpascal
java pascal pascal-interpreter
Last synced: 9 days ago
JSON representation
A Pascal interpreter
- Host: GitHub
- URL: https://github.com/teverett/kpascal
- Owner: teverett
- Created: 2016-03-07T03:44:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-28T12:21:02.000Z (2 months ago)
- Last Synced: 2024-10-14T12:48:53.834Z (23 days ago)
- Topics: java, pascal, pascal-interpreter
- Language: Java
- Homepage:
- Size: 623 KB
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![CI](https://github.com/teverett/kPascal/workflows/CI/badge.svg)
[![DepShield Badge](https://depshield.sonatype.org/badges/teverett/kPascal/depshield.svg)](https://depshield.github.io)kPascal
========A Pascal Interpreter written in Java. kPascal is intended to be used as either a command-line Java interpreter, or as an embedded Pascal engine inside J2EE applications.
Maven Coordinates
-------------------```
com.khubla.kpascal
kpascal
1.1.0
jar
```License
---------kPascal is distributed until the GPL v3. For more information please see the [GPL](http://www.gnu.org/licenses/gpl.txt).
The grammar
---------kPascal uses [Antlr](http://www.antlr.org/). The Pascal grammar is [here](https://github.com/antlr/grammars-v4/blob/master/pascal/pascal.g4)
Using kPascal in code
---------Using a file:
````
FileInputStream fileInputStream = new FileInputStream("myprogram.pas");
Interpreter interpreter = new Interpreter();
interpreter.run(fileInputStream);
````Using a string:
````
String myProgram = "program HelloWorld; begin writeln('hello'); end."
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(myProgram.getBytes());
Interpreter interpreter = new Interpreter();
interpreter.run(byteArrayInputStream);
````Custom input and output streams
---------kPascal uses `System.in` and `System.out` as the console by default. However, it is possible to provide your own input and output IO streams.
````
public void runPascalProgram(InputStream pascalInputStream, InputStream consoleIn, PrintStream consoleOut){
Interpreter interpreter = new Interpreter(consoleIn, consoleOut);
interpreter.run(programInputStream);
}
````Using kPascal from the command line
---------````
java -jar kpascal.jar --file=myprogram.pas````