Go to the first, previous, next, last section, table of contents.
The <CODE>qtFlexC++</CODE> input file consists of three sections, separated by a line with just `%%' in it:
definitions %% rules %% user code
The <STRONG>definitions</STRONG> section contains declarations of simple <STRONG>name</STRONG> definitions to simplify the scanner specification, and declarations of <STRONG>start conditions</STRONG>, which are explained in a later section. Name definitions have the form:
name definition
The "name" is a word beginning with a letter or an underscore ('') followed by zero or more letters, digits, '', or '-' (dash). The definition is taken to begin at the first non-white-space character following the name and continuing to the end of the line. The definition can subsequently be referred to using "{name}", which will expand to "(definition)". For example,
DIGIT [0-9] ID [a-z][a-z0-9]*
defines "DIGIT" to be a regular expression which matches a single digit, and "ID" to be a regular expression which matches a letter followed by zero-or-more letters-or-digits. A subsequent reference to
{DIGIT}+"."{DIGIT}*
is identical to
([0-9])+"."([0-9])*
and matches one-or-more digits followed by a '.' followed by zero-or-more digits.
The <VAR>rules</VAR> section of the <CODE>qtFlexC++</CODE> input contains a series of rules of the form:
pattern action
where the pattern must be unindented and the action must begin on the same line.
See below for a further description of patterns and actions.
Finally, the user code section is simply copied to lexyy.cpp' verbatim. It is used for companion routines which call or are called by the scanner. The presence of this section is optional; if it is missing, the second
%%' in the input file may be skipped, too.
In the definitions and rules sections, any <EM>indented</EM> text or text enclosed in %x{' and
%}' is copied verbatim to the output files (with the %x{}''s removed). The
%x{}''s must appear unindented on lines by themselves. The parameter x represent the place where the code will be copied (include file part public, private, etc)
In the rules section, any indented appearing before the first rule may be used to declare variables which are local to the scanning routine and (after the declarations) code which is to be executed whenever the scanning routine is entered. Other indented text in the rule section is still copied to the output, but its meaning is not well-defined and it may well cause compile-time errors (this feature is present for <CODE>POSIX</CODE> compliance; see below for other such features).
Go to the first, previous, next, last section, table of contents.
Wiki: Home
Wiki: qtFlexC++_1
Wiki: qtFlexC++_13
Wiki: qtFlexC++_4
Wiki: qtFlexC++_6