[erlang-questions] problem making my first parser
Sat Sep 26 09:01:30 CEST 2015
I try to make a very easy parser to practice to make a json parser in
As first I try to make a parser which can calculate some basic things.
So far I have this :
scan(, List) ->
scan([Head | Rest], List_parse) when Head >= $0, Head =< $9 ->
scan(Rest, [(Head - 48) | List_parse]);
scan([Head | Rest], List_parse) when Head =:= "+" ->
scan(Rest, [Head | List_parse] ).
but when I try this code on scan("1+1") I see this error message :
** exception error: no function clause matching
number_parser:scan("+1",) (number_parser.erl, line 8)
Which does not make sense. +1 makes as far as I know [+, 1] so I have a
head and tail so the last clause schould work.
Why do I then see this error message ?
More information about the erlang-questions