Found from StackOverflow:

=============================================================================================

The following routines are available for setting up input buffers for scanning in-memory strings instead of files (as yy_create_buffer does):

  • YY_BUFFER_STATE yy_scan_string(const char *str): scans a NUL-terminated string`
  • YY_BUFFER_STATE yy_scan_bytes(const char *bytes, int len): scans len bytes (including possibly NULs) starting at location bytes

Note that both of these functions create, return a corresponding YY_BUFFER_STATE handle (which you must delete with yy_delete_buffer() when done with it) so yylex() scan a copy of the string or bytes. This behavior may be desirable since yylex() modifies the contents of the buffer it is scanning).

If you want avoid the copy (and yy_delete_buffer) using:

  • YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size)

sample main:

int main() {
yy_scan_buffer("a test string");
yylex();
}

Flex + Bison: Scanning from memory buffer的更多相关文章

  1. flex/bison 计算器

    flex %{ #include <stdio.h> #include "mycalc.tab.h" ;} %} %% "+" return ADD ...

  2. Flex & Bison 开始

    Flex 与 Bison 是为编译器和解释器的编程人员特别设计的工具: Flex 用于词法分析(lexical analysis,或称 scanning),把输入分割成一个个有意义的词块,称为记号(t ...

  3. OpenCASCADE Expression Interpreter by Flex & Bison

    OpenCASCADE Expression Interpreter by Flex & Bison eryar@163.com Abstract. OpenCASCADE provide d ...

  4. 编译器工具 Flex Bison for Windows 简单入门例子

    最近从事一个系统仿真软件的开发,里面定义了自己的描述性语言MSL, MSL语言经FlexBison转换成C语言,然后用C编译器来编译并计算仿真. 现在领域驱动开发比较热门,有机会定义自己的语言对程序员 ...

  5. 关于FIFO memory buffer模块的设计

    关于FIFO memory buffer模块的设计 FIFO memory `timescale 1ns / 1ps ///////////////////////////////////////// ...

  6. Windows下 flex + bison 小例子

    .下载flex和bison,网址是http://gnuwin32.sourceforge.net/packages/flex.htm 和http://gnuwin32.sourceforge.net/ ...

  7. 应注意的Flex&Bison潜规则

    1.Flex的二义性模式 语法分析器匹配输入时匹配尽可能多的字符串 如果两个模式都可以匹配的话,匹配在程序中更早出的模式. 针对这一点的理解,在语法分析文件当中,token的识别,应从特殊到一般的过程 ...

  8. flex&bison 1

    .   {ECHO;}-----单独的flex使用中有效 .   { yyerror();}--------flex和bison交叉使用,即使不调用yyerror函数,也会报错的 error: syn ...

  9. [flex & bison]编译器杂谈

    flex与bison是编译器设计工具.这里的编译器为广义,其中包括一般的编译器.脚本解析器等,需要进行语言结构解析来得出意义的程序. 当我们需要用一个语言来设计一款编译器时,需要考虑太多设计重心外的东 ...

随机推荐

  1. centOS安装openoffice的方法

    centOS安装openoffice的方法 分类: centOS 2012-06-15 10:24 2872人阅读 评论(0) 收藏 举报 centos测试 yum install openoffic ...

  2. java反射(Field的应用)

    //$Id: DirectPropertyAccessor.java 11405 2007-04-15 12:50:34Z max.andersen@jboss.com $ package org.h ...

  3. Plugins in Unity

    [Plugins in Unity] In Unity, you normally use scripts to create functionality but you can also inclu ...

  4. java实现文件的拷贝以及文件的删除

    /** * 将文件拷贝到指定目录 * @param oldAddress 文件所在目录(文件的全路径) * @param newAddress 指定目录(包含复制文件的全名称) * @throws E ...

  5. DBArtist之Oracle入门第1步: 如何安装Oracle 11g

    操作系统:  Windows 7 数据库   :  Oracle 11gR2 第一步: 下载Oracle安装包 Oracle官网:  https://www.oracle.com/index.html ...

  6. 基于Mybatis分页插件PageHelper

    基于Mybatis分页插件PageHelper 1.分页插件使用 1.POM依赖 PageHelper的依赖如下.需要新的版本可以去maven上自行选择 <!-- PageHelper 插件分页 ...

  7. g2o 图优化

    http://www.cnblogs.com/gaoxiang12/p/5244828.html 扩展里面csparse

  8. [Groovy]获取当前活动的Environment,获取response中节点的name和节点的value

    import com.eviware.soapui.support.GroovyUtils import com.eviware.soapui.support.XmlHolder import org ...

  9. 设计模式(java)--观察者模式

    转自:卡奴达摩http://blog.csdn.net/zhengzhb/article/details/7471978?reload#reply 定义:定义对象间一种一对多的依赖关系,使得当每一个对 ...

  10. Linux下软件常见安装方式

    pasting  分类: Linux2007-12-08 16:31 1909人阅读 评论(0) 收藏 举报 linuxredhat脚本文档managerfile        Linux下软件安装主 ...