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 8111059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:58:10+00:00 2026-06-06T01:58:10+00:00

I have a parser with me generated from yacc/lex. It is working fine for

  • 0

I have a parser with me generated from yacc/lex. It is working fine for all the rules I have set except one case.

If file is empty which this parser is parsing it gives error. I want to add rule so that it does not give error when file is empty. I have not added any checks for that in either of my .l/.y file.

How can this be done with YACC/LEX?

Thanks in advance !!

  • 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-06T01:58:12+00:00Added an answer on June 6, 2026 at 1:58 am

    The lexer should recognize the end of input and return a token accordingly (i.e. EOF).

    Your grammar’s start rule could look like this:

    %start program
    
    ...
    
    program : EOF 
            | instructions EOF
            ;
    

    As Ira Baxter pointed out a simple “empty” rule would also suffice. The GNU bison manual provides an example for this:

    input   : /* empty */
            | input line
            ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have lexer/parser (Generated from an ANTLR grammar file) which (for performance reasons) I
By default, a parser generated using ANTLR-3 extends from org.antlr.runtime.Parser. How do I have
i have a console application that generated from bison (a parser) and i want
I have an antlr generated Java parser that uses the C target and it
I have two tables table1 and table2. Table1 is generated by a parser and
I want to parse only RTP packets from a .pcap file generated from WireShark
I have a relatively simple lex/flex file and have been running it with flex's
I have a .NET web-service client that has been autogenerated from a wsdl-file using
ANTLR generates java source from the grammar file. Generated source has dependency to ANTLR
I would like to have something like this be generated from hbm2ddl: ______________ ______________

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.