help-bison
[Top][All Lists]
Advanced

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

Re: How to change the default action for selected rules?


From: Markus Elfring
Subject: Re: How to change the default action for selected rules?
Date: Fri, 04 Oct 2013 15:35:32 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0

>> - Is a conversion possible without the specification of a specific data type 
>> in
>> a directive like "%token"?
> 
> I'm not sure to understand what you mean.  If '0' is expected
> to have a value, then you should declare it

I added also the rule '. { return yy::my_parser::make_SINGLE_CHARACTER(yytext,
loc); }' and the specification '%token <std::string> SINGLE_CHARACTER
"uncategorised_character"' to my source file settings in the meantime.
Unfortunately, I stumble on the message "lexer.l:36: warning, rule cannot be
matched".
https://sourceforge.net/p/flex/bugs/161/


>> - The character list can become long in my use case here.
> 
> That's weird.  Maybe should have a single token type 'character',
> and store the character value in its semantic value.

I am also trying to use a similar data type ... ;-)


>> I would like to avoid
>> the repetition of similar actions behind them. It would be more "convenient" 
>> to
>> choose a different default action for selected rules, wouldn't it?
> 
> One usually does not need that, as this kind of job is typically
> left to the scanner/lexer, not to the parser.

I am also thinking about a design approach with a scannerless parser like the
way it is provided by the class library "Spirit".
http://stackoverflow.com/questions/2224373/scannerless-parser-generators

Regards,
Markus



reply via email to

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