Re: Dynamic tokens

Hans Åberg <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
> On 3 Feb 2020, at 16:33, Ervin Hegedüs <[email protected]> wrote:
…
>>> Example from the language:
>>> @eq 1
>>> @lt 2
>>> @streq foo
>>> 
>>> The problem is that the LANG_OP_ARGUMENT could be anything - for example,
>>> that could be also starts with "@". So, the next expression is valid:
>>> 
>>> @streq @streq
>> 
>> So here you might have a context switch that is set when the operator token comes, that says that the next token, even if it is a valid operator name, should be treated as an argument. It when the argument is finished, set the switch back.
>> 
>>> Now I'm using this rules:
>>> @[a-z][a-zA-Z0-9]+     { BEGIN(ST_LANG_OP); return LANG_OP; }
>>> <ST_LANG_OP>....
>>> 
>>> but now the operator isn't optional.
>> 
>> Something must follow in the grammar, so the switch may be set back in the grammar. Check in the .output file for clues.
> 
> so, you think (if I understand correctly) something like this:
> 
> @[a-z][a-zA-Z0-9]+      { BEGIN(ST_LANG_OP); if(op_valid(yytext); { return LANG_OP; } else { ... } }
> <ST_LANG_OP>….

Something like that.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.