Find the number of lookahead characters, needed by Lex for given DFA, for scanning input.
by ajiten from LinuxQuestions.org on (#6CSD4)
This problem is taken from the book titled: Modern compiler implementation in C, by Appel; from page #38, problem #2.8.
https://www.google.co.in/books/editi...sec=frontcover
If the below DFA were used by Lex, to find tokens in a file; then:
a) How many characters past the end of a token might Lex have to examine before matching token.
b) Assume your answer to the part (a) is: k, show an input file containing at least two tokens, such that the first call to Lex will examine k characters past the end of the first token, before returning to the first token.
If answer to the part (a), i.e. k =0, then show an input file containing at least two tokens, and indicate the endpoint of each token.
==========================
Seems this DFA can recognize the following language (set of strings):
+ U - U [a-z]+[0-9]* U [0-9]+({+|-}[0-9]+ U [0-9]+)
But, cannot understand how to find any answer to part (a); and hence clueless about part (b).
P.S.: Here, in the language: +, stands for: at least occurring one time.
https://www.google.co.in/books/editi...sec=frontcover
If the below DFA were used by Lex, to find tokens in a file; then:
a) How many characters past the end of a token might Lex have to examine before matching token.
b) Assume your answer to the part (a) is: k, show an input file containing at least two tokens, such that the first call to Lex will examine k characters past the end of the first token, before returning to the first token.
If answer to the part (a), i.e. k =0, then show an input file containing at least two tokens, and indicate the endpoint of each token.
==========================
Seems this DFA can recognize the following language (set of strings):
+ U - U [a-z]+[0-9]* U [0-9]+({+|-}[0-9]+ U [0-9]+)
But, cannot understand how to find any answer to part (a); and hence clueless about part (b).
P.S.: Here, in the language: +, stands for: at least occurring one time.