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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:17:51+00:00 2026-06-13T07:17:51+00:00

Is there a known way to generate an Expected token list when a syntax

  • 0

Is there a known way to generate an “Expected token” list when a syntax error happens ? I’m using Lemon as parser generator.

  • 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-13T07:17:52+00:00Added an answer on June 13, 2026 at 7:17 am

    This seems to work:

    %syntax_error { 
            int n = sizeof(yyTokenName) / sizeof(yyTokenName[0]);
            for (int i = 0; i < n; ++i) {
                    int a = yy_find_shift_action(yypParser, (YYCODETYPE)i);
                    if (a < YYNSTATE + YYNRULE) {
                            printf("possible token: %s\n", yyTokenName[i]);
                    }
            }
    }
    

    It tries all possible tokens and prints those that are applicable in the current parser state.

    Note that when an incorrect token comes, the parser doesn’t immediately call syntax_error, but it tries to reduce what’s on stack hoping the token can be shifted afterwards. Only when nothing else can be reduced and the current token cannot be shifted, the parser calls syntax_error. The reductions will change parser state, which means that you may see less tokens than would have been applicable before the reductions. It should be sufficient for error reporting though.

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

Sidebar

Related Questions

Using jquery UI 1.8's autocomplete, is there any known way to take the results
Does anyone know if there is a way to generate different code in the
Hi I was wondering if there is any known way to get rid of
There is a widely known way of locking multiple locks, which relies on choosing
I need to know if there is some kind of known algorithm to generate
It there a well known way, how to implement in Coco/R tokenizing indents like
I know there is a way to extend a JLabel to paint 3D borders
I know there is a way to call Perl routines from C. As shown
I know there's a way, I know I've done it (a long time) before,
I know there is a simple way to do this but I can't seem

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.