help-bison
[Top][All Lists]
Advanced

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

Re: how to solve this reduce/reduce conflict?


From: Lukas Arsalan
Subject: Re: how to solve this reduce/reduce conflict?
Date: Thu, 22 Sep 2022 14:52:21 +0000 (UTC)

On 2022-09-22T07:57:45UTC Hans Åberg <haberg-1@telia.com> wrote:
> On 22 Sep 2022, at 08:30, Lukas Arsalan <cptarse-luke@yahoo.com> wrote:
>> [1] -1 --> "num"
>> [2] 1-2 --> "num" "-" "num"
>> [3] (-1^-2) --> "(" "num" "^" "num" ")"
>> [4] 1--2 --> "num" "-" "num"
>> [5] 1---3 --> "num" "-" "-" "num"
>> [6] 1-2^3 --> "num" "-" "num" "^" "num"
>> I do not think that it is possible, to do that with regular expressions...
>>
> I think it is not possible, so therefore one expects -2⁴ to be parsed as 
> -(2⁴).
>
I found that `%s nosinum` for the ll-file...
Now I can do things like this:
"+"                     BEGIN(INITIAL); return yy::parser::make_ADD(loc);
"("                     BEGIN(INITIAL); return yy::parser::make_BROP(loc);
")"                     BEGIN(nosinum); return yy::parser::make_BRCL(loc);
{bint}                  BEGIN(nosinum); return make_INT(yytext,loc);
{float}                 BEGIN(nosinum); return make_FLOAT(yytext,loc);
<INITIAL>[+-]?{bint}    BEGIN(nosinum); return make_INT(yytext,loc);
<INITIAL>[+-]?{float}   BEGIN(nosinum); return make_FLOAT(yytext,loc);

and i removed the SNUM token...

now it seems to work just right.. 🥳

it even handles the whitespaces to my liking... 😋

but i do not know what kind of formal language that is now...

-arne


reply via email to

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