Give a regular expression using flex notation that descibes the set of strings that start with a, end with c and have zero or more digits between them.
Write a program using flex that copies the standard input to the standard output, except that it replaces each sequence of consecutive blanks and tabs by a single blank.
Show that the following grammar is ambiguous.
S -> S c S |
S -> d |
Show a parse tree and leftmost derivation for string cccdd with respect to grammar
S -> c S d |
S -> c |
What are the First and Follow sets for the following grammar? The start nonterminal is E.
E -> A |
E -> L |
A -> n |
A -> i |
L -> ( S ) |
S -> E , S |
S -> E |
Left factor the grammar of the preceding question and then write a recursive descent parser for it. The parser should only read a string and tell whether it is in this language.
The tokens of this language are characters. Presume a lexical analyzer is available, and that statement match(c) will check the current lookahead token to see whether it is character c. If so, it will put the next token into variable lookahead. If not, it will print "no" and stop the program. Statement INIT_LEXER initializes the lexer, setting lookahead to the first token.