Lexical Analysis
Lexical analysis is the first phase of a compiler, the main task of the lexical analyzer is to read the input characters of the source program, group them into lexemes, and produce as output a sequence of tokens for each lexeme in the source program.Besides identification of lexemes, it contans other tasks. One such task is stripping out comments and whitespace. Another task is correlating error message generated by the compiler with the source program.
Sometimes.lexical analyzers are divided into two parts:
Operations on LanguagesLexical analysis is the first phase of a compiler, the main task of the lexical analyzer is to read the input characters of the source program, group them into lexemes, and produce as output a sequence of tokens for each lexeme in the source program.Besides identification of lexemes, it contans other tasks. One such task is stripping out comments and whitespace. Another task is correlating error message generated by the compiler with the source program.
Sometimes.lexical analyzers are divided into two parts:
- Scanning
- Lexical analysis
- Union of L and M
- Concatenation of L and M
- Kleene closure of L
- Positive closure of L
From NFA to DFA(Subset Construction Algorithm)
- At the first,e-closure(s0) is the only one state and not marked.
- If there is a unmarked state T, mark it
- For every input symbol a, U=,e-closure(move(T,a))
- If U is not in the Dstates, then Add U to Dstates as a unmarked state,else Dtran[T,a]=U
- Go to 3
- Go to 2
The grammar is A->Aa|b
Remove the Left Recrusive: A->bA' A'->aA'|e (e is empty string)
It only works in the case of grammar with no e-production and with no cycles.
No comments:
Post a Comment