Note that there are some explanatory texts on larger screens.

plurals
  1. PObison YYSTYPE: Trying to use char*
    primarykey
    data
    text
    <p>I need to use flex and bison to parse some code.</p> <p>The default type of YYSTYPE is <code>int</code>, even though I never declared it that way. Is that a default from bison?</p> <p>It would help me a lot to pass strings back. I read this: <a href="https://stackoverflow.com/questions/1014619/how-to-solve-bison-warning-has-no-declared-type"><a href="https://stackoverflow.com/questions/1014619/how-to-solve-bison-warning-has-no-declared-type">How to solve Bison warning &quot;... has no declared type&quot;</a></a> This looks like a good approach. (I don't need the full power of a union yet, just the char* part, but I might as well use the union because it might be helpful later.)</p> <p>It's not working for me. I get these errors:</p> <pre><code>y:111.37-38: $1 of `ConstExpression' has no declared type y:113.34-35: $1 of `ConstFactor' has no declared type y:114.35-36: $1 of `ConstFactor' has no declared type y:119.34-35: $1 of `Type' has no declared type y:109.23-48: warning: type clash on default action: &lt;str&gt; != &lt;&gt; y:115.23-27: warning: type clash on default action: &lt;str&gt; != &lt;&gt; [...more of the same snipped...] </code></pre> <p>Here are the declarations from my <code>y</code> grammar file:</p> <pre><code>%union { char *str; } %type&lt;str&gt; ConstExpression ConstFactor Type </code></pre> <p>Here is one line from my <code>.l</code> file:</p> <pre><code>[a-zA-Z]+[a-zA-Z0-9]* { yylval.str = strdup(yytext); return yident;} </code></pre> <p>What else do I need to do to resolve the errors?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload