help-bison
[Top][All Lists]
Advanced

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

Re: Purpose of $default and $end


From: Samkit Jain
Subject: Re: Purpose of $default and $end
Date: Sat, 2 May 2009 14:55:22 +0530

Small correction:

The 2 rules are:

sentence:   /* empty */
 |          sentence line optional_comma '$'        { printf("\nInput line:
>>>%s ::: %s <<<\n", $2, $3);   }
 ;


sentence:   line optional_comma '$'        { printf("\nInput line: >>>%s :::
%s <<<\n", $2, $3);   }
 ;



On Sat, May 2, 2009 at 2:51 PM, Samkit Jain <address@hidden> wrote:

> Hi,
>
> And I created a small program to test some small fundamentals and found
> that there is a lot of difference between the below 2 rules.
>
> sentence:   /* empty */
>  |          sentence line optional_comma '$'        { printf("\nInput line:
> >>>%s ::: %s <<<\n", $2, $3);   }
>  ;
>
>
> sentence:   sentence line optional_comma '$'        { printf("\nInput line:
> >>>%s ::: %s <<<\n", $2, $3);   }
>  ;
>
> I am using scanf in yylex (my own yylex), which always accepts some string.
>
> And now I am confused as to why is "/* empty */" necessary even when empty
> cannot be returned by yylex.
>
> When I checked the states generated by the parser, I found that there is a
> difference in the way $default and $end are created for some states.
>
> Can someone please tell me basic principle behind $end and $default
> terminal symbols.
>
>
> : Samkit Jain
>


reply via email to

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