Skip to content
Python Stack Machine and Tokenizer for my programming languages class at SDSU
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
StackMachine.py
prog4_1.py
prog4_2.py

README.md

Assignment 4

This assignment builds a stack machine and reads from an external file that instructs the program what to do (ie push, pop, add, etc).

Prog4_1.py

Prog4_1.py opens and reads a file, and then tokenizes each line of the file. It then prints each line that was tokenized to stdout.

StackMachine.py

StackMachine.py creates a stack machine. It instantiates an empty list, which can then be pushed into, popped, added to, subtracted from, multplied to, divided from, and modded from.

Prog4_2.py

Prog4_2.py opens and reads a file, tokizes each line of the file, and then loops through those lines. If the there is a line of 2 tokenized items, and the first token is "push", the number following is pushed. If it is of length 1, the stack is either popped, added, subbed, multiplied, divided, or modded. If the stack is attempted to pop with nothing on it, "None" is returned as the value.

You can’t perform that action at this time.