https://github.com/djblue/mini-pascal-code-generation
Code generation for mini-pascal.
https://github.com/djblue/mini-pascal-code-generation
Last synced: 15 days ago
JSON representation
Code generation for mini-pascal.
- Host: GitHub
- URL: https://github.com/djblue/mini-pascal-code-generation
- Owner: djblue
- Created: 2014-11-09T23:04:37.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-12-04T00:42:18.000Z (about 11 years ago)
- Last Synced: 2025-01-19T13:37:21.038Z (12 months ago)
- Language: OpenEdge ABL
- Size: 370 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mini-pascal
[](https://travis-ci.org/djblue/mini-pascal-code-generation)
Simple code generation for mini object oriented pascal.
# Supported
The following language features are supported. The grammar is defined in the
`pascal.y` file.
### Types
- integer
- boolean
- static arrays[start..end]
- nested static arrays
- custom types via classes
### Statements
- print
- if-else
- while
- assignment
- object instantiation - no gc or delete :)
### Functions
- pass by value
- pass by reference
- local variables
- return values
- recursion via stack
### Classes
- constructor initialization (optional)
- inherited fields
- inherited methods
- method calls
### Expressions
- literals (numbers, this, true, false)
- function calls
- nested function calls
- logical (not, and, or)
- arithmetic (+, -, \*, /, mod)
# Stack Frame
The generated mips codes sets up the following stack frame for all
function/method calls.
```
| |
+------------+
| param[n] |
+------------+
| ... |
+------------+
| param[0] |
+------------+
| $ra |
+------------+
$fp -> | $fp |
+------------+
| local[0] |
+------------+
| ... |
+------------+
| local[n] |
+------------+
$sp -> | temp |
```
## Install
To install dependencies, do:
npm install
## Tests
To run all of the tests, do:
npm test