README.md (1152B)
1 # SyntacticAnalysis 2 3 Lexical analyzer that tokenizes code to see if it follows the rules of a certain EBNF grammar. 4 5 The grammar in question: 6 7 ``` 8 <program> -> program begin <statement_list> end 9 <statement_list> -> <statement> {;<statement>} 10 <statement> -> <assignment_statement> | <if_statement> | <loop_statement> 11 <assignment_statement> -> <variable> = <expression> 12 <variable> -> identifier (An identifier is a string that begins with a letter followed by 0 or more letters and/or digits) 13 <expression> -> <term> {(+|-) <term>} 14 <term> -> <factor> {(* | /) <factor>} 15 <factor> -> identifier | int_constant | (<expr>) 16 <if_statement> -> if (<logic_expression>) then <statement> 17 <logic_expression> -> <variable> (< | >) <variable> (Assume logic expressions have only less than or greater than operators) 18 <loop_statement> -> loop (<logic_expression>) <statement> 19 ``` 20 The analyzer will prompt you for the name of the file which contains the code. It will then tell you whether or not there is one or more syntax errors. 21 22 `prog.txt` is an example of code that contains no syntax errors. 23 24 I wrote this back in 2020 for COSC3127, a course at Algoma University.