You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When generating a parser for the following file with location support:
%language "D"
%define api.parser.class {Parser}
%locations
/* Types the parser handles for return and input */
%union {
AST tast;
Declaration[] tdecls;
Declaration tdecl;
Statement[] tstmts;
Statement tstmt;
Type ttype;
string str;
char chr;
long lng;
double dbl;
}
/* Single-char token declarations */
%token SEMICOLON ";"
PERIOD "."
OPENPAREN "("
CLOSEPAREN ")"
OPENBRACE "{"
CLOSEBRACE "}"
OPENBRACKET "["
CLOSEBRACKET "]"
PLUS "+"
MINUS "-"
ASTERISK "*"
SLASH "/"
/* Keywords */
%token RETURN "return"
VOID "void"
INT "int"
FLOAT "float"
CHAR "char"
STRING "string"
/* Values */
%token <str> IDENTIFIER STRINGVALUE
%token <chr> CHARACTER
%token <lng> INTEGER
%token <dbl> FLOATVALUE
%%
ast : /* Empty*/
| declarations
;
declarations : declaration
| declaration declarations
;
declaration : type IDENTIFIER "(" ")" "{" statements "}"
;
statements : statement
| statement statements
;
statement : "return" ";"
;
type : "void"
;
%%
struct AST {}
class Declaration {}
class Statement {}
final class Function : Declaration {}
final class Return : Statement {}
enum Type {}
Compiling the generated code yields the following error, which does not happen when not enabling locations:
cdc.p/parser.d(764): Error: function `parser.Parser.YYStack.push(int state, YYSemanticType value, ref YYLocation loc)` is not callable using argument types `(int, immutable(YYSemanticType), YYLocation)`
cdc.p/parser.d(764): cannot pass argument `yy_semantic_null` of type `immutable(YYSemanticType)` to parameter `YYSemanticType value`
cdc.p/parser.d(765): Error: function `parser.Parser.YYStack.push(int state, YYSemanticType value, ref YYLocation loc)` is not callable using argument types `(int, immutable(YYSemanticType), YYLocation)`
cdc.p/parser.d(765): cannot pass argument `yy_semantic_null` of type `immutable(YYSemanticType)` to parameter `YYSemanticType value`
using ldc2.
Removing the user-defined classes from the union seems to fix it, but this cannot be done in the original code as they serve a purpose there.
What is there at fault here? What could be a fix for this issue? Thanks in advance.
The text was updated successfully, but these errors were encountered:
Hello,
When generating a parser for the following file with location support:
Compiling the generated code yields the following error, which does not happen when not enabling locations:
using
ldc2
.Removing the user-defined classes from the union seems to fix it, but this cannot be done in the original code as they serve a purpose there.
What is there at fault here? What could be a fix for this issue? Thanks in advance.
The text was updated successfully, but these errors were encountered: