Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PL/0

This is a just-for-fun hobby implementation of the PL/0 programming language. This implementation can parse and evaluate PL/0 source files. It is not a full compiler implementation.

Build

This project uses Conan and CMake. Run the following to perform a release build:

conan install --build=missing
cmake --preset conan-default
cmake --build --preset conan-release

Run

Once built, you can run the executable directly from the build directory like so:

./build/src/Release/pl0

Grammar

program = block ".";

block = [ "const" identifier "=" number { "," identifier "=" number } ";" ]
        [ "var" identifier { "," identifier } ";" ]
        { "procedure" identifier ";" block ";" } statement ;

statement = [ identifier ":=" expression
            | "call" expression
            | "?" identifier
            | "!" expression
            | "begin" statement { ";" statement } "end"
            | "if" condition "then" statement
            | "while" condition "do" statement ] ;

condition = "odd" expression
          | expression ( "=" | "#" | "<" | "<=" | ">" | ">=" ) expression ;

expression = [ "+" | "-" ] term { ( "+" | "-" ) term } ;

term = factor { ( "*" | "/" ) factor } ;

factor = identifier | number | "(" expression ")" ;

number = ? [0-9]+ ? ;

identifier = ? [A-Za-z_][A-Za-z0-9_]* ? ;

Note

This implementation treats keywords as case-insensitive and identifiers as case-sensitive.

About

A just-for-fun implementation of PL/0 written in C++

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages