Skip to content

cyang/pascal-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pascal-compiler

This is a one-pass Pascal compiler using a stack-based representation of intermediate code written in Java.

TokenScanner.java - reads each character and creates a list of tokens

Token.java - class for the Token objects

Parser.java - proccesses/analyzes the list of tokens and and generates a byte array of instructions containing P-codes and addresses

Simulator.java - reads the instructions returned by the Parser and runs it on a stack data type

Emulator.java - main program that passes the token list returned from the TokenScanner to the Parser. Then the instruction array is passed to the Simulator to run the Pascal program and generate output.

SymbolTable.java - hash table to store symbols

Symbol.java - class for the objects stored in SymbolTable

keywords.txt - list of Pascal keywords

How to run:

  1. Change directory to src/
  2. Compile Emulator.java
  3. Provide a Pascal file as input to the Emulator program`

For example:

  1. cd src/
  2. javac Emulator.java
  3. java Emulator ../examples/array.pas

About

Pascal compiler written in Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages