flex and bison

Record some useful things personally think

lex program consists of three parts

statement

%%

Translation rules

%%

Auxiliary process

 

Part of the declaration and% {} are copied to the beginning of the generated C language portion between percent.

Translation rules:

  Mode in the beginning of each line, followed by the C code is executed when the matching, using {} enclose. (Mode must be beginning of a line, starting with a blank line will be copied)

  yytext always point to this match input text.

Mode Example

  [A-Za-z] + is used to match a word, denoted as a character class brackets, which matches one or more + class.

  .        Dot represents any one character.

  [^ \ T \ n] + at the symbol start portion of the character class ^ refers not match any character which character class.

  "+" Is generally used to indicate a specific character or string matching.

Guess you like

Origin www.cnblogs.com/wshr007/p/10932031.html