Mod 3 (Syntax analyzer) Flashcards

1
Q

Role of parser

A
  • obtains a string from the lexical analyser and verifies if the given string can be constructed using the given grammar
  • it should also be able to recover from common errors and must continue forward
  • constructs a parse tree and passes it to the rest of the compiler for further processing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Types of parsing

A
  • top down: constructs the parse tree from the top (root node) to the bottom (leaf node)
  • bottom up: constructs a syntax tree from the bottom (leaf node) to the top (root node)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Different errors in parsing

A
  • lexical: includes misspellings of identifiers
  • syntactic: includes misplaced semicolon and missing braces
  • semantic: includes type mismatch between operator and operands
  • logical: includes any thing from incorrect reasoning on the part of the programmer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Error recovery techniques

A
  • panic mode recoverywith this method, on discovering an error, the parser discards input symbols one at a time until one of the set of tokens is found
  • parse level recoveryon discovering an error, a parser performs a local correction on the remaining input. usually done by replacing the input by some string that allows the parsing to continue
  • error productionin this method, common errors that might be encountered can be add those productions into the grammar to perform the required action for the same
  • global correctionalgorithms that choose a minimal sequence of changes to obtain a globally least cost correction
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is a parse tree

A
  • it is a graphical representation of the derivation which shows the order in which the productions are applied to replace non-terminals
  • each interior node of the syntax tree represents the application of a particular production
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is ambiguity

A
  • any grammar that produces more than one parse tree for some given input.
  • in another way, an ambiguous grammar produces more than one leftmost or rightmost derived grammar for the same input
How well did you know this?
1
Not at all
2
3
4
5
Perfectly