Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yitonghe00/13b317de0e22e0d3216834c7d91ef092 to your computer and use it in GitHub Desktop.
Save yitonghe00/13b317de0e22e0d3216834c7d91ef092 to your computer and use it in GitHub Desktop.
// 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