4 ms·
I used to use gap! I'd love some examples of explicit choices that were made that allow one-character lookahead.
by tgb 10y ago
I used to use gap! I'd love some examples of explicit choices that were made that allow one-character lookahead.
- CJefferson 10y agoI can tell you some things where were rejected. One example of non-one-token lookahead is lambda functions, 'x -> x*2'. This means when you read an identifier, before you check if it valid in this scope you have to check if the next thing is '->'. If it is, this is a new identifer, if it's not, it's a variable reference and better be in scope. Now, let's consider multi-argument lambda functions. One possible notation is: (a,b,c) -> a+b+c. However, (a,b,c) is how GAP denotes permutations, and it was decided that parsing a whole permutation as "maybe this is a permutation, maybe it is the beginning of a lambda expression" would be too annoying, and would mean we couldn't print out some errors until we got to the end, and knew what type of object we had.