yacc

what libraries should be linked in lex & yacc (solaris) to include YY_BUFFER_STATE

what libraries should be linked in lex & yacc (solaris) to include YY_BUFFER_STATE. when i use YY_BUFFER_STATE in lex and compile it .i get an error saying tat it is undeclared.but when i do it in unix i am getting the output so pls help me. ...

Compiling and executing the Shakespeare Programming Language translator spl2c on Mac OS X 10.6 results in warnings/errors

I wanted to experiment with the Shakespeare programming language, so I downloaded it from here and executed the Makefile using cd spl-1.2.1 Make. The compilation of spl2c executes with a couple warnings: scanner.l:600: warning, rule cannot be matched <stdout>:5808: warning: ‘yyunput’ defined but not used And then when it at...

How much time would it take to write a C++ compiler using flex/yacc?

How much time would it take to write a C++ compiler using lex/yacc? Where can I get started with it? ...

using union in yacc for structures

Hi I'm a little confused about how to specify my grammar member's type. I want to declare prog and decls as ASTNode. I'm gonna use these members for adding to a list or etc. But yacc can't recognize them as an ASTNode and I get type errors. Here my tIdent,tCharConst,tIntConstant have some types but, how to give ASTNode type to my membe...

declaring global variables in yacc

Hello, I have a few source code files, such hashtable.c and such. The main issue is that when I write my main.c as such: #include "tokens.h" #include <stdio.h> void yyerror(char *errorMsg) { fprintf(stderr, "%s\n", errorMsg); } main() { yyparse(); hsh = createHashtable(); } And at the top of my yacc file (parser.y), I want to ...

Javascript lexer / tokenizer (in Python?)

Does anyone know of a Javascript lexical analyzer or tokenizer (preferably in Python?) Basically, given an arbitrary Javascript file, I want to grab the tokens. e.g. foo = 1 becomes something like: variable name : "foo" whitespace operator : equals whitespace integer : 1 ...

Installing LEX/YACC or flex/bison on Windows, Visual C++ 2008

There's too much bytes and too few information in Internet, so I decided to ask if someone have already done such an installation. How to compile/where to download binaries? Where can I find a build rule? Where can I find a bunch of good samples (with associativity resolution, symbol tables etc.)? ...

How can I tell Bison I also expect reduce-reduce conflicts?

My C#-ish toy grammar now has its first reduce-reduce conflicts! I'm so proud of me. It seems all right to me, however (I switched off to a GLR parser for the occasion). The problem is, while I know the %expect directive can shut up Bison about shift/reduce conflicts, I can't find the equivalent for reduce/reduce conflicts. So what shou...

Lex and Yacc in PHP

Is there an implementation of Lex and Yacc in PHP? If not, can anyone suggest a lexical analyser and parser generator (ie, anything like Lex and Yacc) that will create PHP code. I'm not too worried about the performance of the resulting parser. I am sick of using regex to parse things that really shouldn't be parsed with regex... ...

How to write a bison file to automatically use a token enumeration list define in a C header file ?

Hi everyone, I am trying to build a parser with Bison/Yacc to be able to parse a flow of token done by another module. The token different token id are already listed in a enumeration type as follow: // C++ header file enum token_id { TokenType1 = 0x10000000, TokenType2 = 0x11000000, TokenType3 = 0x1110000...

Is there a good Emacs mode or method for lex/flex/yacc/bison files?

Editing lex or yacc files with Emacs is a nuisance: if I use C mode the indenting goes wrong, and if I don't use C mode I can't use indenting. Does anyone have a trick, a method, or an editing mode to get around it? ...

Is there rule of thumb for catching errors in Lex/Yacc parsing?

Should we catch errors while parsing general purpose language as early as possible (in Lex) or where it is more convenient and give us more information (in Yacc)? How various languages solve this problem? ...

Enable/disable grammar rules in Yacc/Bison

Like the title says, I would like to enable/disable certain grammar rules in a yacc or bison grammar file. Is there a way to do so? ...

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...

Should i write a Direct3D Shader Model language compiler using flex/yacc?

I am going to create a compiler for Direct3D's Shader Model language. The compiler's target platform and development environment are on Windows/VC++. For those who are not familiar with the Shader Model Language, here are examples of instructions which the language consists of (some of the instructions are a bit outdated, but the syntax...

yacc shift reduce problem

i have what i think is a simple part of my grammar this is getting an error from yacc. i know i need to add a %prec somewhere, but not really sure where. Assignment : Ref '=' Ref | Ref '=' Expression | Ref '=' Value | Ref '=' FunctionCall ; Ref : ID | ID '[' Expression ']' ; Value : ...

What is the difference between lex/yacc and fslex/fsyacc?

I'm learning F# because I'd like to write a lexer and parser. I have a tiny bit of experience with this sort of processing but really need to learn it properly as well as F#. When learning the lexing/parsing functionality of F#, is studying lex and yacc sufficient? Or are there some differences that means code for lex/yacc will not wor...

Problems with data types in flex

Hi everybody!!! I have a problem. I'm writing a program with flex and I'm using this code: %union { int entero; char *cadena; TipoDato tipo; } This code is for my data types. I want evaluate the next line: expresion SUM expresion where SUM is the operation sum for evaluate, for example 69 + 60 When I write this if...

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; } ...