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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:26:10+00:00 2026-06-15T22:26:10+00:00

I have got the runtime message: syntax error, unexpected VARIABLE, expecting ‘:’ or ‘\n’

  • 0

I have got the runtime message: syntax error, unexpected VARIABLE, expecting ‘:’ or ‘\n’
I suppose it is due to my wrong bison source, but what’s the matter?
In my lex source I have

'mod'       return MOD;
[-+()=/*\n:]    { return *yytext; }

but while a=55/4 runs fine, a=55mod4 exits with error report written before.
Thanks forward for any appointment.
Here is my full bison file:

%{
    #include <stdio.h>
    void yyerror(char *);
    int yylex(void);
    #include "y.tab.h"
    #include "bas.h"

    #define YYDEBUG 1
    #define YYERROR_VERBOSE 1
    #define YYTOKEN_TABLE 1
%}
%debug
%error-verbose
%token INTEGER VARIABLE PRINT
%left '+' '-'
%left '*' '/'
%left MOD
%%
program:
    program statement ':'       {
                        if (stackptr>0)
                            {
                            printf("stack underflow !\n");
                            }
                        else if (stackptr<0)
                            {
                            printf("stack overflow !\n");
                            }
                        }
    |
        program statement '\n'      {
                        if (stackptr>0)
                            {
                            printf("stack underflow !\n");
                            }
                        else if (stackptr<0)
                            {
                            printf("stack overflow !\n");
                            }
                        else    {
            /* send basictoken[] array to micro*/
                            printf("OK.\n");
                            debugprint();
                            }
                        resetbuffer();
                    stackptr=0;                     
                        }
        | /* NULL */
        ;
statement:
        expression
        | VARIABLE '=' expression       {
                        put_token(avr_tovar);
                        put_token($1);
                        stackptr--;
                        }
        | PRINT expression      {
                        put_token(avr_tos);
                        stackptr--;
                        }
        ;
expression:
    INTEGER             {
                    put_token(avr_const);
                    put_token(yylval);
                    stackptr++;
                        }
        | VARIABLE              {
                        put_token(avr_fromvar);
                        put_token(yyval);
                        stackptr++;
                            }
        | expression '+' expression     {
                        put_token(avr_add);                     
                        stackptr--;
                            }
        | expression '-' expression     {
                        put_token(avr_sub);                     
                        stackptr--;
                        }
        | expression '*' expression     {
                        put_token(avr_mul);                     
                        stackptr--;
                        }
        | expression '/' expression     {
                        put_token(avr_div);                     
                        stackptr--;
                        }
        | expression MOD expression     {
                        put_token(avr_mod);                     
                        stackptr--;
                        }
        | '(' expression ')'
        ;
%%
void yyerror(char *s)
{
    fprintf(stderr, "%s\n", s);
}
  • 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-15T22:26:12+00:00Added an answer on June 15, 2026 at 10:26 pm

    Flex/lex does not support single quotes to denote strings, it uses double quotes to this end. So your scanner is actually waiting for you to enter a=55'mod'4. Either remove the single quotes, or use double quotes.

    Also, don’t use yylval in the parser’s actions, use $1 and so forth. I don’t know if your code works, but if it does, that’s pure luck: yylval is about the lookahead, which does not need to be the same as the last of the reduced symbols.

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

Sidebar

Related Questions

Buiding MVC3 solution went well but have got an error in browser: Compiler Error
I have this on my .gitignore file: /nbproject/ /app/runtime/ /app/runtime/application.log* /app/runtime/error.log* /app/config/localdev.php* .DS_Store 1)
everyone, I got a strange problem, please help. the error message is: Run-time error
I have enabled NSZombie and i got the message as message sent to deallocated
I have got 5 user controls placed in some Control folder, at run time
I have the next code: Process p = Runtime.getRuntime().exec(args); and I want my program
Have got an NSString *str = @12345.6789 and want to find out if there
I have got the requirement to find the core file in multiple box/machine and
I have got this code: function init(){ if (typeof window.jQuery !== 'function') { var
I have got a form into which information is entered, and a drop down

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.