Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4247956
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:10:57+00:00 2026-05-21T04:10:57+00:00

I’m having Lex and YACC files to parse my files ( .l file and

  • 0

I’m having Lex and YACC files to parse my files (.l file and .y file).

How to compile those files and how to make equivalent .c file for them in windows platform?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:10:58+00:00Added an answer on May 21, 2026 at 4:10 am

    As for today (2011-04-05, updated 2017-11-29) you will need the lastest versions of:

    1. flex-2.5.4a-1.exe

    2. bison-2.4.1-setup.exe

    3. After that, do a full install in a directory of your preference without spaces in the name. I suggest C:\GnuWin32. Do not install it in the default (C:\Program Files (x86)\GnuWin32) because bison has problems with spaces in directory names, not to say parenthesis.

    4. Also, consider installing Dev-CPP in the default directory (C:\Dev-Cpp)

    5. After that, set the PATH variable to include the bin directories of gcc (in C:\Dev-Cpp\bin) and flex\bison (in C:\GnuWin32\bin). To do that, copy this: ;C:\Dev-Cpp\bin;C:\GnuWin32\bin and append it to the end of the PATH variable, defined in the place show by this figure:
      step-by-step to set PATH variable under Win-7.
      If the figure is not in good resolution, you can see a step-by-step here.

    6. Open a prompt, cd to the directory where your “.l” and “.y” are, and compile them with:

      1. flex hello.l
      2. bison -dy hello.y
      3. gcc lex.yy.c y.tab.c -o hello.exe

    Commands to create lexical analyzer, parser and executable.

    You will be able to run the program. I made the sources for a simple test (the infamous Hello World):

    Hello.l

    %{
    
    #include "y.tab.h"
    int yyerror(char *errormsg);
    
    %}
    
    %%
    
    ("hi"|"oi")"\n"       { return HI;  }
    ("tchau"|"bye")"\n"   { return BYE; }
    .                     { yyerror("Unknown char");  }
    
    %%
    
    int main(void)
    {
       yyparse();
       return 0;
    }
    
    int yywrap(void)
    {
       return 0;
    }
    
    int yyerror(char *errormsg)
    {
        fprintf(stderr, "%s\n", errormsg);
        exit(1);
    }
    

    Hello.y

    %{
    
    #include <stdio.h>
    #include <stdlib.h>
    int yylex(void);
    int yyerror(const char *s);
    
    %}
    
    %token HI BYE
    
    %%
    
    program: 
             hi bye
            ;
    
    hi:     
            HI     { printf("Hello World\n");   }
            ;
    bye:    
            BYE    { printf("Bye World\n"); exit(0); }
             ;
    

    Edited: avoiding “warning: implicit definition of yyerror and yylex”.

    Disclaimer: remember, this answer is very old (since 2011!) and if you run into problems due to versions and features changing, you might need more research, because I can’t update this answer to reflect new itens. Thanks and I hope this will be a good entry point for you as it was for many.

    Updates: if something (really small changes) needs to be done, please check out the official repository at github: https://github.com/drbeco/hellex

    Happy hacking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
i want to parse a xhtml file and display in UITableView. what is the
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.