bison

using qt : How To Build a Gui OnTop Of a Console Application?

白昼怎懂夜的黑 提交于 2019-12-04 22:15:22
问题 i have a console application that generated from bison (a parser) and i want to build a simple gui for it so i can send input from this gui to the console and get output from the console into the gui . i tried to do that using java process class but it doesnt work for me , please help me to do that using qt . 回答1: It depends on the complexity of the data you want to feed in/out of your console application. Low complexity Use some command switches that you pass from your Qt GUI to your console

Making bison/flex parser reentrant with integral YYSTYPE

送分小仙女□ 提交于 2019-12-04 18:23:23
I'm having trouble following the steps to make my bison/flex parser reentrant with a minimum amount of fuss. The problem appears to be in the lexer. Since everything parser is re-entrant, I can no longer assign yylval directly. Instead, according to the Flex manual , I have to call this function: void yyset_lval ( YYSTYPE * yylvalp , yyscan_t scanner ); But the problem is, YYSTYPE is an integral type. It isn't a dynamically allocated value, and it isn't an lvalue at all, so I can't pass a pointer to it! Am I missing something, and if not, how am I supposed to set yylvalue? I've never had this

Flex/Bison IDE? [closed]

偶尔善良 提交于 2019-12-04 18:07:38
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I'm looking for a good development environment in which to work on flex or bison or both. Are there any IDE's that have these capabilities and/or are suitable for this? (If not the next most general question is are there lexer/parser generators with IDE's?) Thanks ~Alex 回答1: ANTLR has several IDEs available,

Flex/Bison Error:request for member `str' in something not a structure or union

别说谁变了你拦得住时间么 提交于 2019-12-04 17:56:17
I'm learning flex/bison. I wrote the following program but getting errors. %{ #include <stdio.h> typedef struct node { struct node *left; struct node *right; char *token; }node; node *mknode( node *left, node *right, char *token); void printtree(node *tree); #define YYSTYPE struct node * %} %union { char* str; int num; } %start lines %token <str> WORD %token <str> PLUS MINUS TIMES DIVIDE POWER %token <str> LEFT_PARENTHESIS RIGHT_PARENTHESIS %token <str> END %left PLUS MINUS %left TIMES DIVIDE %right POWER %type <str> exp term factor line lines %% lines: /* empty */ | lines line; line: exp END

Flex/Bison-like functionality within PHP

百般思念 提交于 2019-12-04 17:52:08
问题 I'm looking for a way to get Flex/Bison (or Lex/Yacc, et. al.) support in PHP. Specifically, I'm implementing a boolean query parser in a web UI and would rather keep all operations inside of PHP (as opposed to calling a C parser, or passing things off to Python, etc.). 回答1: LIME Parser Generator for PHP: Complete LALR(1) parser generator and engine (like BISON or YACC) but it's all done in PHP, and the input grammar is easier and more maintainable. Write your actions in PHP. Generate PHP

bison shift instead of reduce. With reduce/reduce errors

天涯浪子 提交于 2019-12-04 17:38:26
In my language i can write a = 1 b = 2 if true { } else { } if true { } **Here is the problem** else {} My grammer doesnt support newlines between statements. An else can only be used with an if. When i add optionalNL in my rule IfExpr: IF rval optionalNL codeBlock optionalNL ELSE codeBlock | IF rval optionalNL codeBlock The optionalNL before the else causes 3 reduce/reduce. Reason is it can reduce using the 2nd rule in IfExpr or reduce to exprLoop where it allows many newlines between expressions. No matter what i do (i tried writing %prec before optionalNL and ELSE) it always reduces to

unistd.h related difficulty when compiling bison & flex program under vc++

谁说我不能喝 提交于 2019-12-04 15:27:48
问题 I'm using bison & flex (downloaded via cygwin) with vc++. When I compile the program I got an error: ...: fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory The corresponding code in the flex-generated file is: #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ /* %if-c-only */

bison/flex: Peek at the next letter or token

让人想犯罪 __ 提交于 2019-12-04 14:04:20
When dealing with strings (it has its own state like comments) i need to find out if the next letter is a " or not. If it is i dont end the string state. So what happens is i just dont end the string in my string state (i use <STRING_STATE>. and process it letter by letter). So what happens is, i mark if the last string was " and if the current isnt i exit the state and unput the last letter. This has a weird effect. When i get errors on lines with strings i see the letter (usually a ',' or ')') twice. and if it happens to be on the end of the line the side effect counts as two lines! (even if

Yacc/Bison: The pseudo-variables ($$, $1, $2,..) and how to print them using printf

我的未来我决定 提交于 2019-12-04 12:34:43
I have a lexical analyser written in flex that passes tokens to my parser written in bison. The following is a small part of my lexer: ID [a-z][a-z0-9]* %% rule { printf("A rule: %s\n", yytext); return RULE; } {ID} { printf( "An identifier: %s\n", yytext ); return ID; } "(" return LEFT; ")" return RIGHT; There are other bits for parsing whitespace etc too. Then part of the parser looks like this: %{ #include <stdio.h> #include <stdlib.h> #define YYSTYPE char* %} %token ID RULE %token LEFT RIGHT %% rule_decl : RULE LEFT ID RIGHT { printf("Parsing a rule, its identifier is: %s\n", $2); } ; %% It

semantic type checking analysis in bison

↘锁芯ラ 提交于 2019-12-04 12:34:18
I've been trying to find examples everywhere but it's been in vain. I am trying to write a basic Ruby interpreter. For this, I wrote a flex lexical file, containing token recognition sentences, and a grammar file. I wish for my grammar to contain semantic type checking. My grammar file contains, for example: arg : arg '+' arg This should be a valid rule for integers and floats. According to what I've read, I can specify type for a non terminal such as arg, like so: %type <intval> arg where "intval" is in the type union and corresponds to the int C type. But this is only for integers, I am not