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

  • Home
  • SEARCH
  • 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 8808259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:34:38+00:00 2026-06-14T02:34:38+00:00

I have a simple code in lex language and i generate lex.yy.c with Flex.

  • 0

I have a simple code in lex language and i generate lex.yy.c with Flex.
when i want to compile lex.yy.c to .exe file i get some error like “undeclared (first use in this function) ” ! when i search in web i understand i need a Const.h file, so i want to generate that file.
how i can do this ?

Some Errors:

35 C:\Users\Majid\Desktop\win\lex.l STRING' undeclared (first use in this function)
38 C:\Users\Majid\Desktop\win\lex.l
LC’ undeclared (first use in this function)
39 C:\Users\Majid\Desktop\win\lex.l `LP’ undeclared (first use in this function)
….

Beginnig of The Code is :

%{int stk[20],stk1[20];
int lbl=0,wlbl=0;
int lineno=0;
int pcount=1;
int lcount=0,wlcount=0;
int token=100;
int dtype=0;
int count=0;
int fexe=0;
char c,str[20],str1[10],idename[10];
char a[100];
void eatcom();
void eatWS();
int set(int);
void check(char);
void checkop();
int chfunction(char *);%}

 Digit  [0-9]
 Letter [a-zA-Z]
ID     {letter}({letter}|{digit})*
NUM    {digit}+
 Delim  [ \t]
 A     [A-Za-z]]
%%



 "/*"               eatcom();
 "//"(.)*
 \"(\\.|[^\"])*\"       return (STRING);
 \"(\\.|[^\"])*\n       printf("Adding missing \" to sting constant");

 "{"                {a[count++]='{';fexe=0;eatWS();return LC;}
 "("                {a[count++]='(';eatWS();return LP;}
 "["                {a[count++]='[';eatWS();return LB;}
 "}"                {check('{');eatWS();
                if(cflag)
                {
                    //stk[lbl++]=lcount++;
                    fprintf(fc,"lbl%d:\n",stk[--lbl]);
                    //stk[lbl++]=lcount++;
                    printf("%d\n",stk[lbl]);
                    cflag=0;
                }
                return RC;
            }
    "]"             {check('[');eatWS();return RB;}
    ")"             {check('(');eatWS();return RP;}
    "++" | "--"         return INCOP;
    [~!]                return UNOP;
     "*"                {eatWS();return STAR;}
    [/%]            {eatWS();return DIVOP;}
    "+"             {eatWS();return PLUS;}
     "-"                {eatWS();return MINUS;}
  • 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-06-14T02:34:39+00:00Added an answer on June 14, 2026 at 2:34 am

    You need a .h file with the definitions. You can write it by hand, but typically this file is generated by Bison. The two tools Flex and Bison are very often used together.

    Bison is a parser-generator. Its input is a file where you have written a grammar that describes the syntax of a language, and Bison generates a parser. The parser (or “syntactical analyzer”) is the part of a compiler (or similar tool) that analyzes input according to the syntax of the language. For example, it is the parser that knows that an if statement can, but doesn’t have to, have an else part.

    Flex is a scanner-generator, and from a file with regular expressions it creates a scanner. The scanner (or “lexical analyzer”) is the part of a compiler (or similar tool) that analyzes input and divides it up into “tokens”. A token can be a keyword such as if, an operator such as +, an integer constant, etcetera. It is the scanner that for example knows that an integer constant is written as a sequence of one or more digits.

    The scanner reports to the parser when it has found a token. For example, if the input starts with 123, the scanner might recognize that this is an integer constant, and report this to the parser. In the case of Flex and Bison, it does this by returning the token code for integer constant, which might (just as an example) be 17. But since the scanner and parser must agree on these token codes, they need common definitions. Bison will generate token codes, and if given the flag -d it will output them in a .h file.

    Thomas Niemann’s A Compact Guide to Lex & Yacc gives a good introduction to how to use Flex and Bison. (Lex and Yacc are the old, original tools, and Flex and Bison are new, free versions of the same tools.)

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

Sidebar

Related Questions

I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have simple code in GoogleOauth2.js file function storedAccsessToken(token) { $.ajax({ type: GET, url:
I have some simple code like this: <?php setcookie(user,test, time() + 3600); echo $_REQUEST['user'].<br>;
I have written some very simple trial-and-error code in Sage (a computer algebra system
I have this simple code that speaks for itself. <script language='javascript"> function check() {}
I have simple WebView code like this: WebView wv = (WebView) findViewById(R.id.webview1); wv.loadUrl(http://en.wikipedia.org/wiki/Book); But
i have this simple code i just can't get it working. <html> <head> <script
I have some simple code in a class: private ITemplate _content1 = null; [TemplateContainer(typeof(ContentContainer))]
Basic C++ class question: I have simple code currently that looks like something like
I have some simple code below: <script> $(function() { $(h1).click(function(){ console.log((this)); $(p).toggle(); }); });

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.