Saltycrane logo

Sofeng's Blog

Notes on Python, Django, and web development on Ubuntu Linux

     Posts tagged "bison_flex"

Example using bison and flex with cygwin on Windows


Here is an example of how to use bison and flex (yacc and lex) with cygwin on windows xp.
  1. Go to http://www.cygwin.com/, install Cygwin including bison 2.3-1, flex 2.5.4a-3, gcc-core 3.4.4-1, and make 3.81-1.

  2. Create a file called "simple.flex" in "c:\temp":
    %{                                                                                          
    #include "simple.tab.h"
    extern int line_number;
    %}
    %option noyywrap

    %%
    "float" { printf("FROM FLEX FLOAT %s\n", yytext); return FLOAT; }
    "int" { printf("FROM FLEX INT %s\n", yytext); return INT; }
    [;] { return *yytext; }
    [_a-zA-Z][_a-zA-Z0-9]* { printf("FROM FLEX IDENTIFIER: %s\n", yytext); return IDENTIFIER; }
    [ \t\r]+ /* eat up whitespace */
    [\n ...
Read more...
Created with Django | Hosted by Webfaction