answersLogoWhite

0


Best Answer

In a parsing table for an expression grammar, the reduce action is used to combine grammar rules to reduce a portion of the input string into a non-terminal symbol. When the parser encounters a reduce action in the parsing table, it replaces a set of symbols on the top of the stack with the non-terminal symbol that corresponds to the grammar rule being applied. This helps in simplifying the input string and moving towards the final goal of parsing the entire input.

User Avatar

AnswerBot

5d ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you reduce in parsing table for expression grammar in compiler course. i under stand the shift action but unable to understand reduce action please help?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Want context free grammar for c language compiler?

we use context free grammer in compiler consctrtion to cheack the validati of input in parsing.


What has the author Seppo Sippu written?

Seppo Sippu has written: 'Parsing theory' -- subject(s): Formal languages, Parsing (Computer grammar)


What has the author Paola Merlo written?

Paola Merlo has written: 'Parsing with principles and classes of information' -- subject(s): Computational linguistics, Parsing (Computer grammar)


What has the author J van de Koot written?

J. van de Koot has written: 'An essay on grammar-parser relations' -- subject(s): Competence and performance (Linguistics), Generative grammar, Parsing (Computer grammar)


How do you construct the LR(0) automaton and SLR parsing table for the given grammar G: S -> CC, C->cB|d, B->CB|ε?

We start with an empty stack and with a complete S$ sentence on input ... We call this a state: state 0, the start state with an empty prefix (V[ε]). CS453. Shift-reduce Parsing. 3. Page 4. Shift, reduce, goto actions in LR(0) table construction ... Build an SLR parser for our expression grammar. 0: .


How do you show that a grammar is LALR but not SLR?

To show that a grammar is LALR but not SLR, you can construct a parsing table for the grammar and demonstrate that there are conflicts present in the SLR parsing table that are resolved in the LALR parsing table. Specifically, LALR parsers have larger look-ahead sets than SLR parsers which can resolve these conflicts. In other words, LALR parsers are able to distinguish between more parser states compared to SLR parsers, allowing them to handle more complex grammars.


What has the author Anton Nijholt written?

Anton Nijholt has written: 'Context-free grammars' -- subject(s): Formal languages, Parsing (Computer grammar)


What has the author Cheryl Zoll written?

Cheryl Zoll has written: 'Parsing below the segment in a constraint-based framework' -- subject(s): Autosegmental theory (Linguistics), Comparative and general Grammar, Grammar, Comparative and general, Phonology


What is the role of parser in compiler design?

· In the compiler model, the parser obtains a string of tokens from the lexical analyser, and verifies that the string can be generated by the grammar for the source language.· The parser returns any syntax error for the source language.· There are three general types' parsers for grammars.· Universal parsing methods such as the Cocke-Younger-Kasami algorithm andEarley's algorithm can parse any grammar. These methods are too inefficient to use in production compilers.· The methods commonly used in compilers are classified as either top-down parsing or bottom-up parsing.· Top-down parsers build parse trees from the top (root) to the bottom (leaves).· Bottom-up parsers build parse trees from the leaves and work up to the root.· In both case input to the parser is scanned from left to right, one symbol at a time.· The output of the parser is some representation of the parse tree for the stream of tokens.· There are number of tasks that might be conducted during parsing. Such as;o Collecting information about various tokens into the symbol table.o Performing type checking and other kinds of semantic analysis.o Generating intermediate code.


What is the role of a parser in compiler design?

· In the compiler model, the parser obtains a string of tokens from the lexical analyser, and verifies that the string can be generated by the grammar for the source language.· The parser returns any syntax error for the source language.· There are three general types' parsers for grammars.· Universal parsing methods such as the Cocke-Younger-Kasami algorithm andEarley's algorithm can parse any grammar. These methods are too inefficient to use in production compilers.· The methods commonly used in compilers are classified as either top-down parsing or bottom-up parsing.· Top-down parsers build parse trees from the top (root) to the bottom (leaves).· Bottom-up parsers build parse trees from the leaves and work up to the root.· In both case input to the parser is scanned from left to right, one symbol at a time.· The output of the parser is some representation of the parse tree for the stream of tokens.· There are number of tasks that might be conducted during parsing. Such as;o Collecting information about various tokens into the symbol table.o Performing type checking and other kinds of semantic analysis.o Generating intermediate code.


What does reached end of file while parsing mean?

Found this on the web, hopes it helps: tarbo Posts: 219 Re: reached end of file while parsing error Posted: May 3, 2007 5:49 AM in response to: jlnickymaster Reply The compiler was parsing your code and was expecting another token--in this case, likely an ending brace: '}'--but instead reached the end of the stream. In layman's terms, you're missing a brace to close your class definition.


What has the author Howard W Trickey written?

Howard W. Trickey has written: 'Terminal context grammars' -- subject(s): Electronic data processing, Parsing (Computer grammar)