正在加载图片...
Conflicts During Shift-Reduce Parsing There are context-free grammars for which shift-reduce parsers cannot be used. Stack contents and the next input symbol may not decide action: shift/reduce conflict:Whether make a shift operation or a reduction. -reduce/reduce conflict:The parser cannot decide which of several reductions to make. If a shift-reduce parser cannot be used for a grammar,that grammar is called as non-LR(k grammar. left to right right-most k lookhead scanning derivation An ambiguous grammar can never be a LR grammar. CS308 Compiler Theory 10Conflicts During Shift-Reduce Parsing • There are context-free grammars for which shift-reduce parsers cannot b d e use d. • Stack contents and the next input symbol may not decide action: – shift/reduce conflict: Whether make a shift operation or a reduction. – reduce/reduce conflict: The parser cannot decide which of several red ti t k ductions to ma ke. • If a shift-reduce parser cannot be used for a grammar, that grammar is called as non called as non -LR(k) grammar LR(k) grammar. left to ri ght ri ght-most k lookhea d scanning derivation • An ambiguous grammar can never be a LR grammar CS308 Compiler Theory 10 An ambiguous grammar can never be a LR grammar
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有