CSCI 316: Quiz 4 - Lexical and Syntax Analysis
Sign in to Google
to save your progress.
Learn more
* Indicates required question
Email
*
Your email
Last Name
*
Your answer
First Name
*
Your answer
Student Id
*
Your answer
The primary task of a lexical analyzer is to:
*
1 point
Check program semantics
Execute statements
Optimize code
Convert source code into tokens
Generate parse trees
A token consists of:
*
1 point
A. A grammar rule
B. A lexeme and its category
C. A parse tree node
D. A semantic action
E. A syntax error
A lexeme is best defined as:
*
1 point
A parse rule
A regular expression
A grammar symbol
The actual character sequence in the source program
A token category
Which of the following is typically not a token category?
*
1 point
Operator
Identifier
Keyword
Comment
Literal constant
Lexical analyzers are often generated from descriptions based on:
*
1 point
Attribute grammars
Denotational semantics
Regular expressions
Context-free grammars
Predicate logic
Which of the following is a typical responsibility of the lexical analyzer?
*
1 point
Removing comments and whitespace
Detecting missing parentheses
Generating intermediate code
Ensuring type compatibility
Enforcing operator precedence
A finite automaton is most closely associated with:
*
1 point
Semantic analysis
Optimization
Code generation
Lexical analysis
Parsing
The parsing process determines whether a program:
*
1 point
Is syntactically correct
Uses proper types
Is efficient
Is meaningful
Terminates
Syntax analysis is based on:
*
1 point
Attribute grammars
Context-free grammars
Regular expressions
Predicate logic
Finite automata
The output of a parser is typically a:
*
1 point
State machine
Abstract machine
Token list
Symbol table
Parse tree
A derivation is a sequence of:
*
1 point
Grammar rule applications
Semantic actions
Machine instructions
State transitions
Tokens
A leftmost derivation always expands the:
*
1 point
Root node only
Leftmost nonterminal
Leftmost terminal
Deepest nonterminal
Rightmost nonterminal
A grammar is ambiguous if:
*
1 point
It has left recursion
It cannot generate strings
A string has more than one parse tree
It includes terminals
It has too many rules
Top-down parsing begins with the:
*
1 point
Input tokens
Parse tree leaves
Start symbol
Lexemes
Grammar rules only
Which parsing technique is top-down?
*
1 point
LR parsing
Shift-reduce parsing
Recursive-descent parsing
Operator-precedence parsing
Bottom-up parsing
A major limitation of recursive-descent parsers is that they:
*
1 point
Are slow
Cannot detect syntax errors
Require left recursion elimination
Cannot handle tokens
Require bottom-up grammars
Which of the following is a bottom-up parsing technique?
*
1 point
Predictive parsing
LL parsing
Left factoring
Recursive descent
Shift-reduce parsing
In shift-reduce parsing, a shift operation:
*
1 point
Moves an input symbol onto the stack
Reduces a handle
Removes recursion
Signals an error
Expands a nonterminal
In shift-reduce parsing, a reduce operation:
*
1 point
Skips input
Reads a new token
Replaces a handle with a nonterminal
Pushes a terminal
Detects ambiguity
A handle is:
*
1 point
A token category
A parse tree root
A grammar symbol
A semantic rule
A substring matching a production’s right side
One advantage of bottom-up parsers is that they:
*
1 point
Can parse a larger class of grammars
Require no stack
Eliminate ambiguity
Are simpler to write by hand
Cannot handle left recursion
Which class of parsers is widely used in compiler generators?
*
1 point
Recursive-descent
LL(1) only
Operator-overloading parsers
LR parsers
Finite automata parsers
A panic-mode error recovery strategy:
*
1 point
Rewrites the grammar
Corrects all errors
Stops compilation immediately
Uses semantic rules
Discards input symbols until a synchronizing token
Phrase-level error recovery attempts to:
*
1 point
Make small local corrections
Ignore syntax errors
Restart parsing from the beginning
Modify the language definition
Skip the entire program
Lexical errors are usually caused by:
*
1 point
Incorrect operator precedence
Infinite loops
Type mismatches
Invalid character sequences
Missing semicolons
Syntax errors occur when:
*
1 point
Tokens violate grammar rules
A program produces wrong output
A variable is undeclared
Memory is exhausted
Types are incompatible
Which phase typically builds the symbol table entries for identifiers?
*
1 point
Optimization
Parsing only
Code generation
Lexical analysis
Semantic analysis
Context-free grammars are insufficient to describe:
*
1 point
Nested structures
Programming language syntax
Arithmetic expressions
Operator precedence
Token patterns
Removing left recursion is required for which parsing approach?
*
1 point
Recursive-descent parsing
Bottom-up parsing
Operator-precedence parsing
LR parsing
Shift-reduce parsing
In summary, lexical and syntax analysis are:
*
1 point
Hardware-specific
Foundational phases of compilation
Optional compiler components
Primarily semantic tasks
Independent of language design
A copy of your responses will be emailed to the address you provided.
Submit
Clear form
Never submit passwords through Google Forms.
reCAPTCHA
Privacy
Terms
This content is neither created nor endorsed by Google. -
Terms of Service
-
Privacy Policy
Does this form look suspicious?
Report
Forms
Help and feedback