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? ...
How much time would it take to write a C++ compiler using lex/yacc? Where can I get started with it? ...
I'm experimenting to learn flex and would like to match string literals. My code currently looks like: "\""([^\n\"\\]*(\\[.\n])*)*"\"" {/*matches string-literal*/;} I've been struggling with variations for an hour or so and can't get it working the way it should. I'm essentially hoping to match a string literal that can't conta...
I want to make a rule in flex to consume a c-style comment like /* */ i have the following c_comment "/*"[\n.]*"*/" But it doesn't ever get matched. Any idea why? if you need more of my code please let me know and I'll submit the whole thing. Thanks to anyone who replies. ...
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...
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...
Hi I am trying to build a lexical analyzer using flex. Following is a line which shows a regular expression and its corresponding action. [0-9] {printf("yada yada \n");} //regex1 Is there a way to reuse {printf("yada yada \n");} from regex1 by auto-completion features of vim, so that I don't need to write the whole thing again while ...
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...
I have a relatively simple lex/flex file and have been running it with flex's debug flag to make sure it's tokenizing properly. Unfortunately, I'm always running into one of two problems - either the program the flex generates stops just gives up silently after a couple of tokens, or the rule I'm using to recognize characters and strings...
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? ...
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 ...
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 '-' { $$ =...
Most of the posts that I read pertaining to these utilities usually suggest using some other method to obtain the same effect. For example, questions mentioning these tools usual have at least one answer containing some of the following: Use the boost library (insert appropriate boost library here) Don't create a DSL use (insert favor...
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...
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...
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...
I'm trying to install flex (the lexical analyzer, not the Adobe program) on my Windows computer. I have MSYS installed. I untar flex, ./configure it, but when I try to make it, I get this error: In file included from ccl.c:34: flexdef.h:94:19: error: regex.h: No such file or directory In file included from ccl.c:34: flexdef.h:1195: erro...
I'm totally new to flex. I'm getting a build error when using flex. That is, I've generated a .c file using flex, and, when running it, am getting this error: 1>lextest.obj : error LNK2001: unresolved external symbol "int __cdecl isatty(int)" (?isatty@@YAHH@Z) 1>C:\...\lextest.exe : fatal error LNK1120: 1 unresolved externals here i...
I'm writing a calculator with an ability to accept new function definitions. Being aware of the need of newbies to try recursive functions such as Fibonacci, I would like my calculator to be able to recognize Tail-recursive functions with Flex + Bison and convert code to an Iterative form. I'm using Flex & Bison to do the job. If you hav...
Hi there .. i'm using GNU Bison 2.4.2 to write a grammar for a new language i'm working on and i have a question. When i specify a rule, let's say : statement : T_CLASS T_IDENT '{' T_CLASS_MEMBERS '}' { // create a node for the statement ... } If i have a variation on the rule, for instance statement : T_CLASS T_IDENT T_E...
Is there a way to force bison and/or flex to restart scanning after I replace some token with something else? My particular example would be with replacement for a specific word/string. If I want a word of hello to be replaced by echo hello, how can I get flex or bison to replace hello and then start parsing again (to pick up 2 words i...