Structure of A Lex File
The structure of a Lex file is intentionally similar to that of a yacc file; files are divided into three sections, separated by lines that contain only two percent signs, as follows:
Definition section %% Rules section %% C code section- The definition section defines macros and imports header files written in C. It is also possible to write any C code here, which will be copied verbatim into the generated source file.
- The rules section associates regular expression patterns with C statements. When the lexer sees text in the input matching a given pattern, it will execute the associated C code.
- The C code section contains C statements and functions that are copied verbatim to the generated source file. These statements presumably contain code called by the rules in the rules section. In large programs it is more convenient to place this code in a separate file linked in at compile time.
Read more about this topic: Lex (software)
Famous quotes containing the words structure of, structure and/or file:
“... the structure of our public morality crashed to earth. Above its grave a tombstone read, Be toleranteven of evil. Logically the next step would be to say to our commonwealths criminals, I disagree that its all right to rob and murder, but naturally I respect your opinion. Tolerance is only complacence when it makes no distinction between right and wrong.”
—Sarah Patton Boyle, U.S. civil rights activist and author. The Desegregated Heart, part 2, ch. 2 (1962)
“What is the structure of government that will best guard against the precipitate counsels and factious combinations for unjust purposes, without a sacrifice of the fundamental principle of republicanism?”
—James Madison (17511836)
“I have been a soreheaded occupant of a file drawer labeled Science Fiction ... and I would like out, particularly since so many serious critics regularly mistake the drawer for a urinal.”
—Kurt Vonnegut, Jr. (b. 1922)