Skip to content

JVM Programming language inspired by the OCR Pseudocode Specification

Notifications You must be signed in to change notification settings

LlamaLad7/pseudo-kt

Repository files navigation

Pseudo

Pseudo is a programming language inspired by the specification outlined here: https://www.ocr.org.uk/Images/260952-pseudocode-guide.pdf.

It runs on the JVM, and you will soon be able to create a standalone jar from your source code. For now, Pseudo compiles to its own archive format (.psa), which must be executed using the Pseudo CLI.

Building

In order to build Pseudo, simply clone the project, import it as a gradle project into your preferred IDE, run the generateGrammarSource task, and finally the build task.

There should now be an executable jar file in your build/libs directory.

Usage

Here is a basic helloworld.psc program:

print("Hello, world!")

To run this program, we can do:

java -jar pseudo.jar compile helloworld.psc --run

The compile command will build a helloworld.psa archive, and the --run option tells Pseudo that we would also like to execute the program.

Precompiled archives can be executed using:

java -jar pseudo.jar run helloworld.psa

For more detailed examples, refer to the examples folder of this repository.

Features

function triple(x)
    return x*3
endfunction

print(triple(12))
print("Hello!")
name = input("What is your name? ")
global x = 10

function test()
    print(x)
endfunction

test()
  • Comments:
print("Hello!") // Greet the user
  • Ternary expressions
print(if a > b then a else b)

How it's made

Pseudo's parser and lexer are written in ANTLR, and the rest of the language is written in Kotlin.

It compiles to Java Bytecode (see JvmCompiler.kt), with the help of ObjectWeb's bytecode generation framework ASM and half-cambodian-hacker-man's Kotlin DSL Koffee.

Final Words

If you would like to suggest a feature, or have found a bug, please don't hesitate to open an issue.

Pseudo uses BigDecimalUtil from javadev's "calc" for some mathematical operations, and it is included in this project as per the Apache 2.0 license.

About

JVM Programming language inspired by the OCR Pseudocode Specification

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published