The `flex' input file consists of three sections, separated by a line
containing only `%%'.
definitions
%%
rules
%%
user code
Some patterns:
`\123'
the character with octal value 123
`\x2a'
the character with hexadecimal value 2a
`(?r-s:pattern)'
apply option `r' and omit option `s' while interpreting pattern.
Options may be zero or more of the characters `i', `s', or `x'.
`(?# comment )'
omit everything within `()'. The first `)' character encountered
ends the pattern. It is not possible to for the comment to contain
a `)' character. The comment may span lines.\
`r/s'
an `r' but only if it is followed by an `s'.
`<s>r'
an `r', but only in start condition `s'
`<s1,s2,s3>r'
same, but in any of start conditions `s1', `s2', or `s3'.
`<<EOF>>'
an end-of-file.
`<s1,s2><<EOF>>'
an end-of-file when in start condition `s1' or `s2'
character class expressions:
[:alnum:] [:alpha:] [:blank:]
[:cntrl:] [:digit:] [:graph:]
[:lower:] [:print:] [:punct:]
[:space:] [:upper:] [:xdigit:]
[:^alnum:] [:^alpha:] [:^blank:]
[:^cntrl:] [:^digit:] [:^graph:]
[:^lower:] [:^print:] [:^punct:]
[:^space:] [:^upper:] [:^xdigit:]
The `{-}' operator computes the difference of two character classes, '{+}' does a union operation.
匹配方式是“最大长度优先”,长度一样时写在前面的优先。
每当匹配到一个token时,这个token能在全局char型指针'
yytext'中被找到,它的长度可以从全局int '
yyleng'里读到;这个token对应的action也在这个时候被执行;token之后的文本被继续扫描。
actions special directives:
`ECHO'
copies yytext to the scanner's output.
`BEGIN'
followed by the name of a start condition places the scanner in the
corresponding start condition
`REJECT'
directs the scanner to proceed on to the "second best" rule which
matched the input (or a prefix of the input).
`yymore()'
tells the scanner that the next time it matches a rule, the
corresponding token should be _appended_ onto the current value of
`yytext' rather than replacing it.
`yyless(n)' returns all but the first `n' characters of the current
token back to the input stream, where they will be rescanned when the
scanner looks for the next match. `yytext' and `yyleng' are adjusted
appropriately
`input()' reads the next character from the input stream.
`YY_FLUSH_BUFFER()' flushes the scanner's internal buffer
`yyterminate()' can be used in lieu of a return statement in an
action.
Start Conditions:
`%s' or '%x' represents "inclusive" start conditions or "exclusive" start conditions.
`BEGIN(INITIAL)' is equivalent to `BEGIN(0)'
We can access the current start condition using the integer-valued `YY_START' macro, and Flex provides `YYSTATE' as an alias for `YY_START'
Multiple Input Buffers:
-- Function: YY_BUFFER_STATE
yy_create_buffer ( FILE *file, int size )
which takes a `FILE' pointer and a size and creates a buffer associated with the given file and large enough to hold `size' characters (when in doubt, use `YY_BUF_SIZE' for the size).
-- Function: void
yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer )
The above function switches the scanner's input buffer so subsequent tokens will come from `new_buffer'.
-- Function: void
yy_delete_buffer ( YY_BUFFER_STATE buffer )
is used to reclaim the storage associated with a buffer.
-- Function: void
yypush_buffer_state ( YY_BUFFER_STATE buffer )
This function pushes the new buffer state onto an internal stack.
-- Function: void
yypop_buffer_state ( )
This function removes the current state from the top of the stack, and deletes it by calling `yy_delete_buffer'.
-- Function: void
yy_flush_buffer ( YY_BUFFER_STATE buffer )
This function discards the buffer's contents
-- Function: YY_BUFFER_STATE
yy_new_buffer ( FILE *file, int size )
is an alias for `yy_create_buffer()'
`YY_CURRENT_BUFFER' macro returns a `YY_BUFFER_STATE' handle to the current buffer. It should not be used as an lvalue.
-- Function: YY_BUFFER_STATE
yy_scan_string ( const char *str )
scans a NUL-terminated string.
-- Function: YY_BUFFER_STATE
yy_scan_bytes ( const char *bytes, int len )
scans `len' bytes (including possibly `NUL's) starting at location `bytes'.
Note that both of above two functions create and scan a _copy_ of the string or bytes.You can avoid the copy by using:
-- Function: YY_BUFFER_STATE
yy_scan_buffer (char *base, yy_size_t size)
the last two bytes of which _must_ be `YY_END_OF_BUFFER_CHAR' (ASCII NUL). These last two bytes are not scanned; thus, scanning consists of `base[0]' through `base[size-2]', inclusive.
-- Data type: yy_size_t
is an integral type to which you can cast an integer expression reflecting the size of the buffer.
分享到:
相关推荐
Arcgis for Flex 基础教程
flex基础教程实例源码 Array、数据绑定、事件机制等16个实例
Flex基础教程Flex基础教程Flex基础教程Flex基础教程Flex基础教程Flex基础教程Flex基础教程Flex基础教程
flex教程 Flex中文基础教程Flex中文基础教程Flex中文基础教程
强化flex基础知识,详细讲解了Flex的基础用法
flex中文基础教程,适合初学者
该文件基本包含了flex各种基本组件的使用,主要是以基础代码的形式展现。对初学者来说是很有帮助的。
Flex基础培训讲义.ppt Flex基础培训讲义.ppt
FLEX基础教程 其余部分
Flex事件解析以及Flex基础功能介绍
Flex3开发指南 flex3基础教程
含Lib 博文链接:https://uule.iteye.com/blog/2062064
1>一套Flex基础教程的PPT。 2>FLEX和JAVA整合的技术文档。 【适用于】 1>FLEX入门 2>具有FLEX基础的JAVA程序员 3>具有JAVA基础的FLEX程序员 4>JAVA程序员 4>FLEX程序员 【目录如下】 Flex大礼包 └─Flex教程 第01...
flex基础知识很重要,这实例可以加快学习flex的速度
《Foundation Flex for Designers》 FLEX设计师基础一书是对FLEX设计操作的入门书籍,通读本书你可以对FLEX设计有一个全面的认识并掌握一些常用技巧。本书并没有用大量篇幅描述设计细节,但本书基本涵盖了大部分常见...
关于Flex的入门基础资料,详细介绍了Flex的开发,是一部难得的Flex教程
很详细的Flex基础入门教程,从最简单的基础到开发实例.非常适合初学者.
flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图flex 地图...
编程基础语法 流程控制语句 控制语句和数据类型 面对对象编程 静态常量继承和接口 数组和类型转换
flex是妇科客户端编程的很好变现形式。