[Top][All Lists]

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

Re: Bison's semantic parser

From: Davy Durham
Subject: Re: Bison's semantic parser
Date: Wed, 18 Oct 2000 10:40:17 -0500

I don't know if you ever did this.... but I took out %semantic_parser (And
made necessary tiny changes) and it didn't have the problem where you have to
press return several times....   So it seems to be a bug (or intentional
action) when the %sematic_parser option....    Either that, or there's
something that needs to be happening in each action or something to do with
gaurds.....  I'm still playing with it....

Hans Aberg wrote:

> I attach some code using Bison's semantic parser that I was able to get at
> least some working output from, even though it is buggy.
> It is a variation of the RPN calculator in the Bisosn manual. I can type
>    2 2 + <return> ... <return>
> with several <return> to finally get 4 as output.
> The idea I have in mind is once the bugs have been ironed out, to modify
> tit with a hashtable for names, and insert a new command say
>     define <name>
> in order to create a semantic dependance. The one insert a syntax variable
>     expression: NAME '=' expression %guard { check_name_defined(); }
>                                { /* Assign variable value to variable */ }
> where check_name_defined() should set yyerror to 1 if the name is not
> defined and also some yyguard penalty recovering value.
> Some observations:
> The C-code before the Bsion definitions seems to be put in a header, the
> stuff after in the .tab.c file.
> yyerror is here an int. Instead it has yyabort, which seems to correspond
> to yyerror of the non-semantic parsers. One also has to define the
> following:
>  yyrecover() -- Don't know what this is for, set to nothing here.
>  char* yymsg -- Don't know how this should be used; just a generic default
> here.
>  int timeclock -- Don't know how this is used.
> struct mytype {
>         clock_t timestamp;    -- Measuerd in favorite time units.
>         int first_line, last_line, first_column, last_column;
>         char* text;
> };
> typedef struct mytype mytype;
> #define YYLTYPE mytype
>   ------------------------------------------------------------------------
>    rpcalc_semantic.yName: rpcalc_semantic.y
>                     Type: Plain Text (text/plain)
>   ------------------------------------------------------------------------
>   Hans Aberg

reply via email to

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