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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:36:40+00:00 2026-05-24T15:36:40+00:00

I am learning bison through the standard calculator example, where I am trying to

  • 0

I am learning bison through the standard calculator example, where I am trying to add some new functionalities to already written calculator. I am trying to add a feature to my calc where a+1 = b would work.

in my .y file I have to declare terminal symbols :

%token <symbol> SYMBOL_NAME
%token <dval> NUMBER
%token LIST_VAR_COMMAND
%token LIST_CONST_COMMAND
%token LIST_FUNC_COMMAND
%token DELETE_COMMAND
%token QUIT_COMMAND
%token CLEAR_COMMAND
%token BINARY
%token OCTAL
%token DECIMAL
%token HEXADECIMAL
%token UNSIGNED
%token CHAR
%token SHORT
%token INT
%token LONG
%token FOR

I declare my statement to be like :

statement:      ';'
|       expression             { setp($1); print_universal_base($1, 0); }
|       expression BINARY      { setp($1); print_universal_base($1, 2); }
|       expression OCTAL       { setp($1); print_universal_base($1, 8); }
|       expression DECIMAL     { setp($1); print_universal_base($1, 10); }
|       expression HEXADECIMAL { setp($1); print_universal_base($1, 16); }

I declare my expression to be like :

expression:     expression ',' expression { $$ = $3; }
|       NUMBER { $$ = $1; }
|       CHAR { $$ =(int)$1; }

I get an error in line

|       CHAR { $$ =(int)$1; }

saying : $1 of `expression’ has no declared type

what am I doing wrong here?

Thanks.

  • 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-24T15:36:41+00:00Added an answer on May 24, 2026 at 3:36 pm

    To access the value of some symbol from the rule, that symbol needs to have a type, and its value needs to be set properly. So for the rule

    expression: CHAR { $$ = $1; }
    

    to work, CHAR needs to have a defined type, for example:

    %token<dval> CHAR
    

    and the lexer needs to provide the value in yylval.dval when it returns a CHAR token. Now depending on what you want the input a+1=b to actually do, (and assuming the lexer returns CHAR for a and b and not SYMBOL) this may or may not be what you want.

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

Sidebar

Related Questions

Learning my way through this stuff and could use some help. I'm trying to
Learning java server technologies, trying to clarify some things. There are few technologies that
Learning flex, What would be the appropriate way to add some AS in a
learning html/css here. I'm trying to add a border-bottom to my .menu ul li
Learning WPF nowadays. Found something new today with .Net dependency properties. What they bring
Learning Scala currently and needed to invert a Map to do some inverted value->key
Im learning lisp and im pretty new at this so i was wondering... if
When learning new languages such as C++ from PHP, does reading other language snippets
I would like to do some parsing and tokenizing in c++ for learning purposes.
Learning CasperJS Trying to understand why the following is not displaying my results in

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.