3 ms·
The unary minus operator is still different from the binary minus operator depending on context in languages that tackle it that way.
by Doxin 7y ago
The unary minus operator is still different from the binary minus operator depending on context in languages that tackle it that way.
- Sharlin 7y agoYes, but that's a parsing-time distinction. The lexer does not need to care. And even though the token's syntactic meaning "depends on the context", the grammar itself can be (and usually is) perfectly context-free!
- Doxin 7y agoThat depends a lot on your parser. Personally if I write a parser I don't generally bother with having a separate tokenizing/lexing stage. Tokenizing happens as-needed and inline.
- JoeAltmaier 7y agoE.g. in an RPN calculator, one is '-' and the other is a different key 'CHS' for 'CHange Sign'