[erlang-patches] Scan "=<<" as something useful
Raimo Niskanen
raimo+erlang-patches@REDACTED
Mon Apr 29 11:18:33 CEST 2013
On Mon, Apr 29, 2013 at 10:53:42AM +0200, Raimo Niskanen wrote:
> On Sun, Apr 21, 2013 at 10:15:28PM +0200, Anthony Ramine wrote:
> > Hello,
> >
> > I've noticed that Erlang/OTP own code tend to be space-free, e.g. {a,
> > b} is rather written as {a,b}. Then there is the occasional Bin=
> > <<42>> with a space because erl_scan will scans "=<<" as '=<','<'
> > instead of '=','<<'. This patch teaches erl_scan how to not do that.
> >
> > There is no backwards compatibility problem as '=<','<' can't appear
> > in valid code.
>
> When I tried to fix this years ago while rewriting the scanner just after
> the binary syntax was introduced I got lecutured (I think by Robert)
> that it was a bad change because it introduces syntax knowledge
> into the scanner.
>
> The scanner is today greedy so it collects as many characters as it
> can into a valid token, and "=<" is a valid token. When it is
> followed by "<" that becomes a syntax error in the parser.
>
> I kind of miss this argument this time around...
>
If I read your patch correctly you also fix this variant:
B=<<<<1>>/binary,2>>.
which means the scanner reads an arbitrary number of "<" after
"=<" and then based on if they are odd or even decides to be
greedy or not, and that is really much and ugly syntax knowledge
for a scanner...
I got a big NO for this change.
> >
> > git fetch https://github.com/nox/otp.git disambiguate-equal-binary
> >
> > https://github.com/nox/otp/compare/disambiguate-equal-binary
> > https://github.com/nox/otp/compare/disambiguate-equal-binary.patch
> >
> > Regards,
> >
> > --
> > Anthony Ramine
> > _______________________________________________
> > erlang-patches mailing list
> > erlang-patches@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-patches
>
> --
>
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
> _______________________________________________
> erlang-patches mailing list
> erlang-patches@REDACTED
> http://erlang.org/mailman/listinfo/erlang-patches
--
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-patches
mailing list