Created
October 11, 2016 04:42
-
-
Save kosamari/dbfa64a22482640f6ec717e6e445b544 to your computer and use it in GitHub Desktop.
lexer function for sbn compiler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lexer (code) { | |
return code.split(/\s+/) | |
.filter(function (t) { return t.length > 0 }) | |
.map(function (t) { | |
return isNaN(t) | |
? {type: 'word', value: t} | |
: {type: 'number', value: t} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment