/PredictiveParsing

SOSU CS4323 Predictive Parsing Project

Primary LanguagePython

Predictive Parsing

Converts infix notation single-digit operations to postfix notation using predictive parsing.

  • Example of valid expression: 1+3/4%3+(2-1)
  • Example of invalid expression: 1+23/3

College project for Programming Languages Class

Reference:

Grammar used:

  • expr → operation rest
  • rest → + operation {print (‘+’)} rest | - operation {print (‘-’)} rest | ε
  • operation → operand rest2
  • rest2 → * operand {print (‘*’)} rest2 | / operand {print (‘/’)} rest2 | ε
  • operand → factor rest3
  • rest3 → % factor {print (‘*’)} | ε
  • factor → digit | ( expr )
  • digit → 0 {print(‘0’)} (where 0 can be any digit from 0 to 9)