User loginNavigation |
Depends on what "is" isSounds like B. Clinton's evasive (but syntactically correct) answer to some deposition. But it's just a little lesson in associativity. We want "is" to be synonymous with "=". That sounds reasonable, right? We could do this at the lowest level, at the lexer, and really make things simple. But here comes "not". It's already an operator, and you want it to be so. And in (my) typeless world, "not" operates on integers just as happily as it does on booleans. There are two reasonable implementations for "not" on integers: multiplying by -1 or the function y = 1 - x. The first is sort of intuitive, the second makes not(1) equal to 0 and not(0) equal to 1. Either way, you lose. Choose the first, so "not x" => -1 * x and examine the expression 0 is not 0 You'd want this to be a false statement, but unfortunately, it might parse like this: 0 is (not 0) Yikes! Tell me that this is just an LL(2) thing and if I look ahead one more token I'll be OK. What I mean by that is: is my hack a canonical hack? When I see "is" I just greedily look ahead to see if the next token is "not". By andrewzboard at 2010-02-02 01:00 | LtU Forum | previous forum topic | next forum topic | other blogs | 5429 reads
|
Browse archives
Active forum topics |
Recent comments
16 weeks 4 days ago
16 weeks 4 days ago
16 weeks 4 days ago
38 weeks 5 days ago
43 weeks 8 hours ago
44 weeks 4 days ago
44 weeks 4 days ago
47 weeks 2 days ago
51 weeks 6 days ago
51 weeks 6 days ago