[Tinyos-help] How to use "pstate" in nesC compiler

David Gay dgay42 at gmail.com
Tue Dec 5 12:40:19 PST 2006


On 12/5/06, Sean Walton <swalton at cs.utah.edu> wrote:
>
>  David Gay wrote:
> On 12/5/06, Sean Walton <swalton at cs.utah.edu> wrote:
>
> I'm stumped.  I trying to figure out what pstate is and how to use it.
>  Can anyone help?
>
>  It's the parser state, as the name of its type ("parse_state") might
>  have suggested. It's all in one structure to make it simple to make
>  the parser reentrant (note that the parse function saves and restores
>  pstate).
>
>  As to the details of its contents, you'll need to look at the parser
>  rules. Documentation on gcc internals (pre version 4) may or may not
>  explain some of the weirdnesses there... (there's some amount of
>  parser hackery in gcc's C grammar...).
>
>  David Gay
>  Thanks for the reply.
>  I have added new production to the grammar to enable "intertype
> declarations" (ITD).  One ITD involves adding a new variable to a component.
>  I have tried to hook my grammar up to existing productions:
>
> anesc_intertype:
>          { testAspect = TRUE; } ANESC_INTERTYPE { inAspectITD = TRUE; }
> anesc_declaration
>              { inAspectITD = FALSE; $$ = $4; }
>      ;
>
>  anesc_declaration:
>          fndef
>      |    just_datadef
>      ;
>  I then test this with:
>
> intertype int CommandAttrM.commandCounter;
>  During the run (nesc compile), I get:
>
> ** **i**i**n**t**e**r**t**y**p**e** **i**n**t**
> *[kind=674273160]Error: [28793f10] 674273160
>  Assertion failed: (0), function parse_declarator, file semantics.c, line
> 763.
>  The first list is debugging code I inserted which first displays the
> char-by-char input stream and the "kind" value.  Clearly, the "spec->kind"
> is bogus.  In fact, I discovered it to be uninitialized, and testing it as a
> char* I get:
>
> gdb> p (char*)spec->kind
>  $1 = 0x28309788 "aspects/TestAspectM.anc"
>  Conclusion: somehow, I believe that I am not setting up the "pstate"
> correctly.  Do you have any ideas what I need to do?

Why do you assume that? W/o trying to debug your code for you, I will
suggest that you look at extdefs and check you are doing the magic
"$<u.telement>$ = NULL" assignment in an action before the use of
rules like fndef or just_datadef (it's necessary to make the setspecs
rule work when it's used at the beginning of a rule). However, I don't
think this is what's causing your problem, so you'll probably need to
get more friendly w/ gdb ;-)

David Gay


More information about the Tinyos-help mailing list