[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Dynamic tokens
From: |
Hans Åberg |
Subject: |
Re: Dynamic tokens |
Date: |
Mon, 3 Feb 2020 18:02:39 +0100 |
> On 3 Feb 2020, at 16:33, Ervin Hegedüs <address@hidden> 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.