Issues of the Parsing Error in the parser The parser must not only report an error message but it must recover from the error and continue parsing(to find as many errors as possible) parser may perform error repair Error recovery is the reporting of meaningful error messages and the resumption of parsing as close to the actual error as possible Back
Issues of the Parsing • Error in the parser – The parser must not only report an error message – but it must recover from the error and continue parsing (to find as many errors as possible) • A parser may perform error repair – Error recovery is the reporting of meaningful error messages and the resumption of parsing as close to the actual error as possible Back
3.2 Context-Free Grammars
3.2 Context-Free Grammars
Basic concept a context-free grammar is a specification for the syntactic structure of a programming language Similar to the specification of the lexical structure of a language using regular expressions Except involving recursive rules For example exp >exp op exp (exp)i number
Basic Concept • A context-free grammar is a specification for the syntactic structure of a programming language – Similar to the specification of the lexical structure of a language using regular expressions – Except involving recursive rules • For example: exp → exp op exp | (exp) | number op → + | – | *
3.2.1 Comparison to Regular Expression notation
3.2.1 Comparison to Regular Expression Notation
Comparing an example The context-free grammar exp >exp op exp(exp)number Qp→+|-|* The regular expression number= digit digit* digit=012314156789
Comparing an Example • The context-free grammar: exp → exp op exp | (exp) | number op → + | – | * • The regular expression: number = digit digit* digit = 0|1|2|3|4|5|6|7|8|9