DOC PREVIEW
CSU CS 453 - LECTURE NOTES

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS453 Intro and PA1 1CS453 Lecture Ambiguous Grammars 1Plan for Today Ambiguous Grammars– Due to associativity– Due to precedence Making Grammars Non-Ambiguous– example related to PA3 What do the SableCC errors look like for ambiguous grammars?CS453 Lecture Ambiguous Grammars 2Example Ambiguous Grammars: AssociativityProductions stm = exp ; exp = {minus_rule} [left]:exp minus [right]:exp | {num_rule} num ;Productions stm = exp ; exp = {assign_rule} [left]:exp assign [right]:exp | {id_rule} id ;CS453 Lecture Ambiguous Grammars 3Example Ambiguous Grammars: PrecedenceProductions stm = exp ; exp = {or_rule} [left]:exp or [right]:exp | {and_rule} [left]:exp and [right]:exp | {true_rule} true | {false_rule} false ;CS453 Lecture Ambiguous Grammars 4Example Ambiguous Grammars: BothTokens pow = ‘^’; dot = ‘.’;Productions stm = exp ; exp = {pow_rule} [left]:exp pow [right]:exp | {field_rule} exp dot id | {paren_rule} lparen exp rparen | {plus_rule} [left]:exp plus [right]:exp | {id_rule} id ;Precedence (high to low)() id.^+CS453 Intro and PA1 2CS453 Lecture Ambiguous Grammars 5Example Ambiguous Grammars: SableCC errorsProductions stm = exp ; exp = {minus_rule} exp minus exp | {num_rule} num ;Verifying identifiers.java.lang.RuntimeException: [30,35] Redefinition of AMinusRuleExp.Exp.Productions stm = exp ; exp = {minus_rule} [left]:exp minus [right]:exp | {num_rule} num ;shift/reduce conflict in state [stack: PExp TMinus PExp *] on TMinus in { [ PExp = PExp * TMinus PExp ] (shift), [ PExp = PExp TMinus PExp * ] followed by TMinus


View Full Document

CSU CS 453 - LECTURE NOTES

Download LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?