help-bison
[Top][All Lists]
Advanced

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

Can I use separate the YYSTYPE for flex and bison?


From: Neo Jia
Subject: Can I use separate the YYSTYPE for flex and bison?
Date: Sun, 26 Nov 2006 23:16:06 -0600

hi,

I am trying to write a parser and lexer for a language, similar to general C
program. I would like to keep the pointer to the current AST node in "$$".
So my action looks like $$ = createAST($1); Since the $$ is defined as the
type of YYSTYPE, which will be used in lexer also, which including "char *"
and "float". I have to add another member to that union. My current looks
like the following:

typedef union {
  char * id;
  float value;
  void * tree;
} lexertype_t;

Now, I can use $<tree>$ = createAST($1). But the problem happens when I am
going to create sub-node for this AST node, which looks like, $<tree>$ =
createSubAST($<tree>$, $1); Since in this rule, the lexer is going to match
some tokens, the union value of the $<tree>$ (argument) is changed.

So, I am wondering if I can re-define the $$, which will not share the same
storage with the lexer token semantic value. Obviously, this problem can be
solved by using another global value, but I think the representation as
$<tree>$ makes the program readable and meaningful.

Thanks,
Neo

--
I would remember that if researchers were not ambitious
probably today we haven't the technology we are using!


reply via email to

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