Created
May 5, 2022 05:34
-
-
Save yitonghe00/13b317de0e22e0d3216834c7d91ef092 to your computer and use it in GitHub Desktop.
This file contains 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
// Note that it's skipping spaces to the next valid expression | |
function skipSpace(string) { | |
let spacesAndComments = string.match(/^(\s|#.*)*/); | |
return string.slice(spacesAndComments[0].length); | |
} | |
console.log(parse("# hello\nx")); | |
// → {type: "word", name: "x"} | |
console.log(parse("a # one\n # two\n()")); | |
// → {type: "apply", | |
// operator: {type: "word", name: "a"}, | |
// args: []} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment