Erlang/OTP Forums

Author Message

<  Erlang bugs mailing list  ~  typo in erl_scan.erl?

ulf.wiger at ericsson.com
Posted: Wed Jan 12, 2005 1:21 pm Reply with quote
Guest
The function erl_scan:scan/6 (OTP R10B-2) seems to contain a typo.
Consider the first argument of the fourth clause below (line 221 in the source).

Surely it should be "<" ++ Cs ?!!!

/Uffe

%% Punctuation characters and operators, first recognise multiples.
%% Clauses are rouped by first character (a short with the same head has
%% to come after a longer).
%%
%% << <- <=
scan("<<"++Cs, Stack, Toks, Pos, State, Errors) ->
scan(Cs, Stack, [{'<<',Pos}|Toks], Pos, State, Errors);
scan("<-"++Cs, Stack, Toks, Pos, State, Errors) ->
scan(Cs, Stack, [{'<-',Pos}|Toks], Pos, State, Errors);
scan("<="++Cs, Stack, Toks, Pos, State, Errors) ->
scan(Cs, Stack, [{'<=',Pos}|Toks], Pos, State, Errors);
scan("<"=Cs, Stack, Toks, Pos, State, Errors) ->
more(Cs, Stack, Toks, Pos, State, Errors, fun scan/6);


Post generated using Mail2Forum (http://m2f.sourceforge.net)
ulf.wiger at ericsson.com
Posted: Wed Jan 12, 2005 1:26 pm Reply with quote
Guest
Sorry, my bad. Not a bug Too much in a hurry.

/Uffe

> -----Original Message-----
> From: owner-erlang-bugs_at_erlang.org
> [mailto:owner-erlang-bugs_at_erlang.org]On Behalf Of Ulf Wiger (AL/EAB)
> Sent: den 12 januari 2005 14:22
> To: 'erlang-bugs_at_erlang.org'
> Subject: typo in erl_scan.erl?
>
>
>
> The function erl_scan:scan/6 (OTP R10B-2) seems to contain a typo.
> Consider the first argument of the fourth clause below (line
> 221 in the source).
>
> Surely it should be "<" ++ Cs ?!!!
>
> /Uffe
>
> %% Punctuation characters and operators, first recognise multiples.
> %% Clauses are rouped by first character (a short with the
> same head has
> %% to come after a longer).
> %%
> %% << <- <=
> scan("<<"++Cs, Stack, Toks, Pos, State, Errors) ->
> scan(Cs, Stack, [{'<<',Pos}|Toks], Pos, State, Errors);
> scan("<-"++Cs, Stack, Toks, Pos, State, Errors) ->
> scan(Cs, Stack, [{'<-',Pos}|Toks], Pos, State, Errors);
> scan("<="++Cs, Stack, Toks, Pos, State, Errors) ->
> scan(Cs, Stack, [{'<=',Pos}|Toks], Pos, State, Errors);
> scan("<"=Cs, Stack, Toks, Pos, State, Errors) ->
> more(Cs, Stack, Toks, Pos, State, Errors, fun scan/6);
>


Post generated using Mail2Forum (http://m2f.sourceforge.net)
raimo at erix.ericsson.se
Posted: Wed Jan 12, 2005 1:41 pm Reply with quote
Guest
No, it is not a typo.

The first three clauses takes care of 2-char operators with a
leading "<", the fourth clause takes care of the case when the
currently buffered data ends with "<". Then there might come
other interesting characters after, e.g "=". The function
more/7 is called which reads more characters into the buffer
and tail recursively eventually gets back to scan/6 to match
the third clause for "<=". The leading comment tried to
make a hint in this direction.

The "<" operator is taken care of with all other one-character
operators on line 275..277:

275 %% All single-char punctuation characters and operators (except '.')
276 scan([C|Cs], Stack, Toks, Pos, State, Errors) ->
277 scan(Cs, Stack, [{list_to_atom([C]),Pos}|Toks], Pos, State, Errors);

This means that all otherwise unrecognized single characters is
interpreted as one-character operators.



ulf.wiger_at_ericsson.com (Ulf Wiger AL/EAB) writes:

> The function erl_scan:scan/6 (OTP R10B-2) seems to contain a typo.
> Consider the first argument of the fourth clause below (line 221 in the source).
>
> Surely it should be "<" ++ Cs ?!!!
>
> /Uffe
>
> %% Punctuation characters and operators, first recognise multiples.
> %% Clauses are rouped by first character (a short with the same head has
> %% to come after a longer).
> %%
> %% << <- <=
> scan("<<"++Cs, Stack, Toks, Pos, State, Errors) ->
> scan(Cs, Stack, [{'<<',Pos}|Toks], Pos, State, Errors);
> scan("<-"++Cs, Stack, Toks, Pos, State, Errors) ->
> scan(Cs, Stack, [{'<-',Pos}|Toks], Pos, State, Errors);
> scan("<="++Cs, Stack, Toks, Pos, State, Errors) ->
> scan(Cs, Stack, [{'<=',Pos}|Toks], Pos, State, Errors);
> scan("<"=Cs, Stack, Toks, Pos, State, Errors) ->
> more(Cs, Stack, Toks, Pos, State, Errors, fun scan/6);

--

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


Post generated using Mail2Forum (http://m2f.sourceforge.net)
raimo at erix.ericsson.se
Posted: Wed Jan 12, 2005 1:42 pm Reply with quote
Guest
Rats! I have already taken the time to elaborate an answer.


ulf.wiger_at_ericsson.com (Ulf Wiger AL/EAB) writes:

> Sorry, my bad. Not a bug Too much in a hurry.
>
> /Uffe
>
> > -----Original Message-----
> > From: owner-erlang-bugs_at_erlang.org
> > [mailto:owner-erlang-bugs_at_erlang.org]On Behalf Of Ulf Wiger (AL/EAB)
> > Sent: den 12 januari 2005 14:22
> > To: 'erlang-bugs_at_erlang.org'
> > Subject: typo in erl_scan.erl?
> >
> >
> >
> > The function erl_scan:scan/6 (OTP R10B-2) seems to contain a typo.
> > Consider the first argument of the fourth clause below (line
> > 221 in the source).
> >
> > Surely it should be "<" ++ Cs ?!!!
> >
> > /Uffe
> >
> > %% Punctuation characters and operators, first recognise multiples.
> > %% Clauses are rouped by first character (a short with the
> > same head has
> > %% to come after a longer).
> > %%
> > %% << <- <=
> > scan("<<"++Cs, Stack, Toks, Pos, State, Errors) ->
> > scan(Cs, Stack, [{'<<',Pos}|Toks], Pos, State, Errors);
> > scan("<-"++Cs, Stack, Toks, Pos, State, Errors) ->
> > scan(Cs, Stack, [{'<-',Pos}|Toks], Pos, State, Errors);
> > scan("<="++Cs, Stack, Toks, Pos, State, Errors) ->
> > scan(Cs, Stack, [{'<=',Pos}|Toks], Pos, State, Errors);
> > scan("<"=Cs, Stack, Toks, Pos, State, Errors) ->
> > more(Cs, Stack, Toks, Pos, State, Errors, fun scan/6);
> >

--

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


Post generated using Mail2Forum (http://m2f.sourceforge.net)

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum