- Types
- integer, boolean, char, real, string, text, array (must be in format: array[start..end] of type)
- built-in type conversion:
ORD()
,CHR()
- Logic blocks
- if, if-else, for, while, repeat-until, begin-end
- Literals
- characters and strings both enclosed in ''
- minimal support for scientific notation (example: epsilon := 1E-6)
- Constants
CONST
block as well as some pre-defined constants likemaxint
,true
, andfalse
- Variables
- Math
- all common operators
- built-in functions:
SQR()
,SQRT()
- Built-in procedures
READ()
,READLN()
,WRITE()
,WRITELN()
- Semicolons separate statements rather than end them
- Does not automatically initialize variables
Compile with:
cargo run -- program.pas program.s
gcc program.s -o program -lm
- String input limited to 255 bytes
- Doesn't sanitize strings, currently throws them into printf (ignored since I don't want to keep libc dependency)
- Blatant syntax error reporting seems pretty solid but need a nice looking warning/error reporting for other errors
- Error reporting for unrecognized identifiers just crashes program
- Calloc's every time a string is read in and free's none of it (after dropping libc dependency I'll store strings a different way entirely)
- Support for special characters like ≥ is poor and they should be avoided for now
- Expand scientific notation to allow for decimal before E
- Add more common math functions (ln, exp)
- Implement number formatting using colons in write calls
- Add procedures
- Add functions