lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>Perhaps it'd be an interesting exercise to add more lookahead to the lexer.
>I don't think it's hard, but I haven't tried.

Considering luaX_lookahead is only actually used once in lexing standard Lua
(I really must revise
the distinction between Lexing and parsing!) , and then only one token
ahead, there seems little 
reason for you to go further. Someone like me comes along wanting to screw
up your carefully designed
syntax (and it IS impressive that there is only one forward dependency in
the entire syntax) they should
probably expect to have to put in the work!

However I was puzzled why luaX_lookahead does continue moving forward
through the tokens if you call
it multiple times, it is just that it loses the current position if you do
it more than once. At first I expected it to
return the same value each time (the token after the 'current' one) and I
got very excited when I found it 
would actually look two ahead only to be dashed when I found the catch!
Looks a bit like multiple 
lookahead was half-implemented but you never got around to finishing it or
removing it when you found 
it was not needed!

- John


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus