help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cannot print correct values in Bison code


From: M. P. D Productions
Subject: Cannot print correct values in Bison code
Date: Fri, 29 May 2020 19:59:41 -0500

*BISON VERSION: 3.6.2*

Hey! I'm very new to Flex/Bison, so please go easy on me. I am trying to
declare the syntax of an "array" as follows:
*array: '[' array_vals ']'*

*array_vals:*
*| vals*

*vals: STRING //String values defined in my lexer*
*| FLOAT //Float values defined in my lexer*
*| INT //Integer values defined in my lexer*

I feel like this is pretty self explanatory, but there's just *one *problem:
Wherever I print the "array_vals", using this:  *array: '[' array_vals ']'
{ cout << $2 << endl; }* I get only the first value of the array in my
source code, so if I have this in my source file: "[10, 20, 30, 40]" then
it only prints "10." I've tried printing the "vals" in "array_vals", and
it's even weirder and inconsistent. I know that this isn't a bug since I
went from Bison version 3.5.1 to 3.6.2 and there was no difference. If
someone knows, then thank you, but once again, I am new to this, so please
go easy on me.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]