Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- declare
- Key = ["local" "in" "if" "then" "else" "end"]
- Op = ["-" "+" "*" "/" "=" "=="]
- fun {Tokenize Xs}
- case Xs of H|T then
- Token =
- if {Member H Key} then
- key({String.toAtom H})
- elseif {Member H Op} then
- op({String.toAtom H})
- elseif {List.length H} > 1 then
- feil({String.toAtom H})
- else case H of F|L then
- if F >= &A andthen F =< &Z then
- id({String.toAtom H})
- elseif F >= &a andthen F =< &z then
- atom({String.toAtom H})
- else
- feil({String.toAtom H})
- end
- end
- end in
- Token|{Tokenize T}
- else nil
- end
- end
- {Browse {Tokenize ["local" "x" "A" "==" "wdawdew" "(" "end"]}}
Add Comment
Please, Sign In to add comment