bison

Why Bison doesn't work properly in Windows (doesn't generate output file)?

Bison on windows does not produce an output file. This is the error message I get. m4_define([b4_percent_define(lr.keep_unreachable_states)], [[false]]) m4_define([b4_rhs_min], [[-1]]) m4_define([b4_pact_min], [[-5]]) m4_define([b4_conflicting_rules], [[ 0]]) I have solved this question myself, this is for others. ...

How to make Bison not exit when it calls yyerror

Hi, When my parser is scanning a source file and some syntax is incorrect, and it calls yyerror, I want it to display the error message, but continue parsing the file to potentially display more errors. However, every time the parser calls yyerror, it displays the error message and then exits? What can I do? ...

position.hh:46: error: expected unqualified-id before ‘namespace’

Here's my code: 34 35 /** 36 ** \file position.hh 37 ** Define the example::position class. 38 */ 39 40 #ifndef BISON_POSITION_HH 41 #define BISON_POSITION_HH 42 43 #include <iostream> 44 #include <string> 45 46 namespace example 47 { 48 /// Abstract a position. 49 class p...

Is there an alternative for flex/bison that is usable on 8-bit embedded systems?

Hi, I'm writing a small interpreter for a simple BASIC like language as an exercise on an AVR microcontroller in C using the avr-gcc toolchain. However, I'm wondering if there are any open source tools out there that could help me writing the lexer and parser. If I would write this to run on my Linux box, I could use flex/bison. Now th...

Getting types for multiple members

Hi all. I'm writing a program with Yacc/Flex and I'm using the following code (not exactly the same because I'm mixing code from other file): DataType datat; %union { int integer; char *string; DataType type; } Integer { yylval.type = INTEGER; return INT; } %type <type> INT data : INTNUM { yylval.type = INTEGER; } ...

How Can I Get a Flex Scanner To Return Bison's Error Token?

Bison uses a special error token (called 'error') that one can use in a Bison parser to recover from errors. Is there a way to return this specific token from a scanner generated by Flex? ...

Bison %code top error

%code top command doesn't include its contents in parser.tab.h file (It should do so, right?). Bison version is 2.4.1. What is the problem with this (simplified) code? %{ #include <stdlib.h> #include <string.h> #include <stdio.h> #include <io.h> #define YYDEBUG 0 int errors; %} %code top { struct DICT { char *Nam...

Parsing mathematical functions of custom types

I'm about to start developing a sub-component of an application to evaluate math functions with operands of C++ objects. This will be accessed via a user interface to provide drag and drop, feedback of appropriate types followed by an execute button. I'm quite interested in using flex and bison for this having looked at equation parsing...

Is it possible to factor out bin_op nonterminal in grammar specification?

Inconvenience in specifying grammars - we cannot factor out bin_op in following example (Bison): expr : expr bin_op expr ; bin_op : Add | Mul ; because of shift/reduce conflicts. Is there parsing technique or parser generator which allows such thing? ...

Filter y.output from bison or yacc?

I am using bison and its difficult to figure out the conflicts by looking at y.output. Is there a tool to make or filter y.output so its more useful? i would love to see the full path to the state with the conflict but anything helpful is what i would like. ...

rules precedence in bison

Hi Here is the grammar rules: ProcessExpression : EventExpression "->" ProcessExpression | ProcessName ; Please can you tell me how can I tell to bison that the first rule has the highest precedence than the second one? I have tried: %nonassoc PROC %right "->" ProcessExpression : EventExpression "->" Proces...

Flex/bison compile error on windows

Hi, i have a lex and yacc file which compiles fine on linux. When i try to compile it on windows using Visual c++ using the lex.yy.c & y.tab.c files i get the following error: program1.y(184) : error C2059: syntax error : '<' line 184 is #define YYLAST 95 ...

FLEX/BISON : Why my rule is not regonized ?

Hi, I am trying to do a little exercice in FLEX and BISON. Here is the code I wrote : calc_pol.y %{ #define YYSTYPE double #include "calc_pol.tab.h" #include <math.h> #include <stdlib.h> %} %start line %token NOMBRE %token FIN %% line: exp '\n' { printf("\t%.2lf\n", $1); }; exp: exp exp '+' { $$ = $1 + $2 ;} | exp exp '-' { $$ =...

LALR(1) or GLR on Windows - Alternatives to Bison++ / Flex++ that are current?

I have been using the same version of bison++ (1.21-8) and flex++ (2.3.8-7) since 2002. I'm not looking for an alternative to LALR(1) or GLR at this time, just looking for the most current options. Is anyone aware of any later ports of these than the original that aren't Cygwin dependent? What are other folks using in Windows environme...

Sharing memory among YACC, Lex, and C files

I have a YACC (Bison) grammar, a Lex (Flex) tokenizer, and a C program among which I need to share a struct (or really any variable). Currently, I declare the actual object in the grammar file and extern it wherever I need it (which is to say, my C source file), usually using a pointer to manipulate it. I have a shared header (and implem...

Accept a yacc-rule from an action.

Is it possible to accept a bison-rule from the action in combination with the %glr-parser directive active? Something like the following: aRule : 'a' 'b' 'c' { /* Do some calculations and depending on those you allow/disallow this rule and continue the parsing without returning from the yyparse function. */ } ; ...

How do I generate different yyparse functions from lex/yacc for use in the same program?

Hi, I want to generate two separate parsing functions from lex/yacc. Normally yacc gives you a function yyparse() that you can call when you need to do some parsing, but I need to have several different yyparses each associated with different lexers and grammars. The man page seems to suggest the -p (prefix) flag, but this didn't work f...

Yacc and Lex inclusion confusion

I am wondering how to correctly compile a program with a Makefile that has calls to yyparse in it? This is what I do: I have a Makefile that compiles all my regular files and they have no connections to y.tab.c or lex.yy.c (Am I supposed to have them?) I do this on top of my code: #include "y.tab.c" #include "lex.yy.c" #include "y.ta...

'whatever' has no declared type

i am developing parser using bison...in my grammar i am getting this error Here is a code extern NodePtr CreateNode(NodeType, ...); extern NodePtr ReplaceNode(NodeType, NodePtr); extern NodePtr MergeSubTrees(NodeType, ...); ................... NodePtr rootNodePtr = NULL; /* pointer to the root of the parse tree...

ANTLR grammar from bison

Hello, I'm trying to translate a grammar from bison to ANTLR. The grammar itself is pretty simple in bison but I cannot find a simple way for doing this. Grammar in bison: expr = expr or expr | expr and expr | (expr) Any hints/links/pointers are welcome. Thanks, Iulian ...