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.
分享到:
相关推荐
Flex基础是Adobe公司开发的一种开放源码的框架,主要用于构建富互联网应用程序(Rich Internet Applications,简称RIA)。这个框架基于ActionScript编程语言和MXML标记语言,允许开发者创建具有交互性、响应性和动态...
Flex基础教程:富客户端技术详解 Flex是一种强大的富互联网应用程序(RIA)开发框架,由Adobe公司推出,专门用于创建交互式、动态的Web应用程序。它以其丰富的用户界面组件和强大的数据处理能力,为妇科客户端编程...
这个“Flex基础教程实例源码”压缩包提供了学习Flex开发的基础知识和实践经验,涵盖了Array、数据绑定以及事件机制等多个核心概念。 1. **Array**: 在ActionScript中,Array类是用于存储有序集合的基本数据结构。你...
在本压缩包"Flex实例 Flex基础 Web+Flex+LCDS Flex跟Java交互"中,我们可以深入探讨Flex的基础知识、Web与Flex的集成、LCDS的使用以及Flex如何与Java进行数据交互。 1. **Flex基础**:Flex提供了一整套组件库,包括...
Flex基础编程实例主要涵盖了几大核心概念,这些概念是构建Flex应用程序的基础。下面将逐一详细介绍这些知识点。 1. **编程基础语法**:Flex是基于ActionScript语言,它是一种基于ECMAScript(JavaScript的标准化...
在“学习flex基础知识”这个主题中,我们首先需要理解Flex的基本概念。Flex框架包括了开发工具、运行时环境和组件库。开发工具如Adobe Flex Builder或IntelliJ IDEA等,提供了一整套集成开发环境(IDE)来编写、调试...
该文件基本包含了flex各种基本组件的使用,主要是以基础代码的形式展现。对初学者来说是很有帮助的。
Flex是Adobe公司开发的一种用于创建富互联网应用程序(RIA)的技术,它主要基于...通过深入学习以上知识点,并结合实际项目实践,开发者能够牢固掌握Flex基础,进而创建出高效、用户体验良好的富互联网应用程序。
Flex3开发指南 flex3基础教程
1. **Flex基础概念**:Flex是一种开源框架,主要用于构建基于Flash Player或Adobe AIR运行时的交互式、动态Web应用。它包含Flex SDK,提供了编译Flex应用所需的组件、类库和服务。 2. **ActionScript**:Flex的核心...
1>一套Flex基础教程的PPT。 2>FLEX和JAVA整合的技术文档。 【适用于】 1>FLEX入门 2>具有FLEX基础的JAVA程序员 3>具有JAVA基础的FLEX程序员 4>JAVA程序员 4>FLEX程序员 【目录如下】 Flex大礼包 └─Flex教程 第01...
总的来说,Flex基础教程涵盖了从创建基本的用户界面到实现复杂业务逻辑的全过程。通过学习和实践,开发者能够掌握构建富互联网应用的技能,为用户提供更加直观、互动的网络体验。示例代码则提供了具体的实现案例,...
### Flex事件解析以及Flex基础功能介绍 #### 一、Flex:终结B/S架构下的界面噩梦 在企业级应用开发领域,B/S架构因其易于部署、维护和强大的可扩展性,逐渐占据了主导地位。JavaEE作为B/S架构的中流砥柱,凭借其...
《Foundation Flex for Designers》 FLEX设计师基础一书是对FLEX设计操作的入门书籍,通读本书你可以对FLEX设计有一个全面的认识并掌握一些常用技巧。本书并没有用大量篇幅描述设计细节,但本书基本涵盖了大部分常见...
1. **Flex基础**:介绍Flex的基本概念,包括MXML和ActionScript,以及它们在构建用户界面中的作用。 2. **J2EE基础**:简述J2EE平台,包括Servlet、JSP、EJB等组件,以及它们在后端服务中的角色。 3. **通信机制**...
Flex教程详解:初识Flex与基础应用 Flex是由Adobe公司开发的一种开源框架,主要用于构建富互联网应用程序(RIA,Rich Internet Applications)。它结合了MXML和ActionScript两种语言,为开发者提供了一个强大的工具...
FLEX4基础文档 FLEX 是一个基于 Adobe Flash 平台的开源框架,用于构建丰富的互联网应用程序。FLEX4 是 FLEX 框架的最新版本,提供了许多新的特性和改进。 1. FLEX 项目的基本结构 FLEX 项目的基本结构包括三个...