Skip to content

Instantly share code, notes, and snippets.

@kosamari
Created October 11, 2016 04:42
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kosamari/dbfa64a22482640f6ec717e6e445b544 to your computer and use it in GitHub Desktop.
lexer function for sbn compiler
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