|
 |
>> 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?
>
> Varies depending on the rules of whatever you're trying to process, but
> typically it's the parser.
I'm just curious, because I made a parser like this in C++ once (it was very
hacky and basically just stepped along the string trying to identify what
each byte was). Anyway, it worked ok for things like "-5*(4+2)" etc, but
crashed with "-(4+2)". I guess the minus operator should be encoded as its
own token and then let the parser sort out what it should do. Maybe I'll
try a rewrite one day.
Post a reply to this message
|
 |