[erlang-questions] Binaries in records syntax error
Sat Jul 31 15:53:24 CEST 2010
Somebody claiming to be Robert Virding wrote:
> It's not just setting binaries in records, you always need a space
> between an '=' and the << otherwise the parser groups them
This is a general principle that applies to other operators and
other languages as well.
In a typical two-stage lex-and-parse language implementation it
happens in the lexer, before the parser sees it; the lexer will
identify the longest prefix of the input that forms a legal token
and convert that into the next token it gives the parser (the
"maximal munch" rule).
> There is nothing really which can be done about this as you scan from
This kind of surprise is why starting with the second language I
learned I got in the habit of putting spaces around all the operators.
It might be an interesting experiment to try building a parser that
can recognize problems of this sort and ask the lexer to rescan
with a non-maximal munch, but I suspect getting something like that
to behave predictably would be harder than just forcing programmers
to use whitespace to help the lexer.
Plan your future! Make God laugh!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 195 bytes
Desc: not available
More information about the erlang-questions