Docsity

Syntax Analyzer: Understanding Context-Free Grammars and Parsing, Study notes of Object Oriented Programming

Partial preview of the text

Download Syntax Analyzer: Understanding Context-Free Grammars and Parsing and more Study notes Object Oriented Programming in PDF only on Docsity!

Syntax Analyzer

(Parser)

Syntax Analyzer

Parsers

Context-Free Grammars  (^) Context-free grammar is a quadruple (T, NT, P, S)  (^) T - a finite set of terminals (in our case, this will be the set of tokens)  (^) NT - a finite set of non-terminals (syntactic-variables)  (^) P - a finite set of productions rules (specifies the manner in which the terminals and non-terminals are combined to form strings) in the following form  (^) A -> α where A is a non-terminal and α is a string of terminals and non-terminals (including the empty string)  (^) S - a start symbol (one of the non-terminal symbol)

Derivation Example

Parse Tree

  • Ambiguity
  • Ambiguity
  • Ambiguity
  • Ambiguity
  • Ambiguity