Algorithm used generate lexical analyzer

Generating a lexical analyzer algorithm is as follows:

RE: Regular Expressions

NFA: nondeterministic finite automaton

DFA: deterministic finite automaton

 

Thompson algorithm:

Thompson algorithm using regular expressions from the code to the NFA (limited non-deterministic finite state machine) process

Based structure for the induction of RE

  1. The basic structure of RE direct
  2. RE composite of recursive construction

For example: are several regular expression rules

When the process enters the state transition, it reads the first character string, verifies

  • [epsilon] (null character "")

  • E (character e "e")

  • e1 e2

  • e1 | e2

  • e*

When entering a rule as described above in accordance with the regular expression: a (a | b) *

 

Published 70 original articles · won praise 18 · views 50000 +

Guess you like

Origin blog.csdn.net/qq_40325734/article/details/84981533