|
 |
scott wrote:
>> Typically, it's done with regular expressions. And typically, "-37" is
>> two tokens in programming language compilers, at least.
>
> OK, and then is there only one token for "minus", or are there two for
> unary and binary minus? ie does the parser decide or the tokeniser?
Typically, it's one token. You can't tell (in a language like Pascal) as
you're parsing tokens. You have to get to the syntax tree before
figuring out whether it's a unary or binary minus.
In APL, there are two minus signs, one for the operator and one you put
in front of negative numbers. Which helps more than you'd think because
all operators are right-associative.
--
Darren New / San Diego, CA, USA (PST)
Post a reply to this message
|
 |