Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A python lexical analyser due for a "Principles of Programming Languages" assignment.
tree: c03e1f0d15

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
provided-skeleton
.gitignore
README
calc.py
lexical_analyzer.py

README

To use just enter
> python calc.py

Tested with Python 2.7


Calculator Grammar
        <statement> → <command> | <expr> | id | id = <expr>
        <command> → ‘list’ | ‘clear’ | ‘exit’ | ‘quit’
        <expr> → <expr> ‘+’ <term> | <expr> ‘-‘ <term> | <term>
        <term> → <term> ‘*’ <factor> | <term> ‘/’ <factor> | <factor>
        <factor> → <unary_op> <base> <exponent>
        <unary_op> → ‘+’ | ‘-‘ | ε
        <base> → ( <expr> ) | id | int_number | real_number
        <exponent> → ‘^’ <factor> | ε

Terminal symbols
        id = <alpha> (<alpha>|<digit>)*
        int_number = <digit>+
        real_number = (<digit> ‘.’ | ‘.’ <digit>) <number>* [ (‘e’|’E’) [‘+’|’-‘] <digit>+ ]
        <alpha>: A-Z a-z _              [ x ] means x is optional
        <digit>: 0-9

Something went wrong with that request. Please try again.