bison

Objective-C ParseKit return value

半世苍凉 提交于 2020-01-03 03:09:06
问题 In flex/lex/bison/yacc (all of which I just started reading about), you can set "$$" to be equal to some value ($1,$2,$3) and that's the value that gets returned. At least I think that's how it works. In ParseKit, you are given a stack so I imagine that the ($1,$2,$3) would be the first three values on the stack for example. But then I think what you would want to do is pop those values off the stack and put your return value on the stack. I see that the stack comes with a push method. Do you

Objective-C ParseKit return value

▼魔方 西西 提交于 2020-01-03 03:09:03
问题 In flex/lex/bison/yacc (all of which I just started reading about), you can set "$$" to be equal to some value ($1,$2,$3) and that's the value that gets returned. At least I think that's how it works. In ParseKit, you are given a stack so I imagine that the ($1,$2,$3) would be the first three values on the stack for example. But then I think what you would want to do is pop those values off the stack and put your return value on the stack. I see that the stack comes with a push method. Do you

How to integrate flex and bison with Qt project?

删除回忆录丶 提交于 2020-01-02 07:30:33
问题 I am making a GUI program using Qt4, under git source control (Github page). Small part of project requires scanning and parsing. So I want to use flex and bison with the project. I can think of 3 ways- To keep flex and bison files out of project and source control. Generate the C source files and add it to project. Add flex and bison files to project, but run flex and bison commands separately. Integrate properly with IDE (Qt Creator on Ubuntu 12.04) and source control, so that when I build

Simple XML parser in bison/flex

ぐ巨炮叔叔 提交于 2020-01-02 06:15:09
问题 I would like to create simple xml parser using bison/flex. I don't need validation, comments, arguments, only <tag>value</tag> , where value can be number, string or other <tag>value</tag> . So for example: <div> <mul> <num>20</num> <add> <num>1</num> <num>5</num> </add> </mul> <id>test</id> </div> If it helps, I know the names of all tags that may occur. I know how many sub-tag can be hold by given tag. Is it possible to create bison parser that would do something like that: - new Tag("num",

Problems with reentrant Flex and Bison

白昼怎懂夜的黑 提交于 2020-01-01 10:08:33
问题 I'm learning how to use reentrant Bison and Flex together. I already got a simple calculator working without the reentrant capability. However when I activated the reentrant feature and made the necessary modifications, I couldn't get this to work. Here is the code: scanner.l %{ #include <stdio.h> #include "parser.tab.h" %} %option 8bit reentrant bison-bridge %option warn noyywrap nodefault %option header-file="lex.yy.h" DIGIT [0-9] %% "+" { return ADD; } "-" { return SUB; } "*" { return MUL;

YAML parsing - lex or hand-rolled?

本秂侑毒 提交于 2020-01-01 03:16:10
问题 I am trying to write a simple YAML parser, I read the spec from yaml.org, before I start, I was wondering if it is better to write a hand-rolled parser, or use lex ( flex/bison ). I looked at the libyaml (C library) - doesn't seem to use lex/yacc . YAML (excluding the flow styles ), seems to be more line-oriented, so, is it easier to write a hand-rolled parser, or use flex/bison Thanks. 回答1: This answer is basically an answer to the question: "Should I roll my own parser or use parser

Configuring Bison and Flex without global or static variable

∥☆過路亽.° 提交于 2019-12-31 13:49:11
问题 i am working in a small language/IDE. And I need to know how to configure flex and bison to work together but without using any global or static variable. I need to pass to bison my AST pointer. I also need that bison pass my AST to flex as well. It's a thread environment but i dont need any thread sync. And I need a separete yylineno variable for each yyparse() call. I read about %define api.pure , %parse-param and %option reentrant. But i don't know how to put them to work together... thx

Trouble linking against LLVM with project including Flex and Bison

主宰稳场 提交于 2019-12-30 09:39:07
问题 I've been working through a tutorial on writing compilers with Flex, Bison, and LLVM (http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/), and attempting to compile the final binary fails with many of the following "undefined reference" errors: g++ -o parser `llvm-config --libs core jit native --cxxflags --ldflags` *.cpp /tmp/ccl0CSyi.o: In function `NBinaryOperator::codeGen(CodeGenContext&)': codegen.cpp:(.text+0x2ce): undefined reference to `llvm::BinaryOperator::Create(llvm:

How to build an Array with Bison/Yacc and a Recursive Rule

吃可爱长大的小学妹 提交于 2019-12-30 05:23:07
问题 With Bison, I figured out how to get everything into one long string as follows: arg_list: WORD arg_list { strcat( $1, "IFS" ); $$ = strcat($1, $2); } | WORD ; and: WORD arg_list { printf("%s, %s\n", $1, $2); } But the problem is that I will then have to split up $2 in the second rule again to parse it. Is there a way to populate an array instead of just using concatenation? Am I going about this the wrong way? If I need to build something like a linked list that could make sense, just not

REPL for interpreter using Flex/Bison

断了今生、忘了曾经 提交于 2019-12-30 03:11:46
问题 I've written an interpreter for a C-like language, using Flex and Bison for the scanner/parser. It's working fine when executing full program files. Now I'm trying implement a REPL in the interpreter for interactive use. I want it to work like the command line interpreters in Ruby or ML: Show a prompt Accept one or more statements on the line If the expression is incomplete display a continuation prompt allow the user to continue entering lines When the line ends with a complete expression