const moo = require("moo"); const lexer = moo.states({ main: { multiLineComment: {match: "/*", push: "multiLineComment"}, lineComment: /\/\/.*/, space: { match: /[ \r\n\t\f@]+/, lineBreaks: true }, pragma: /#.*/, ident: /[A-Za-z_][A-Za-z0-9_]*/, num: /0|(?:[1-9][0-9]*)|(?:0[xX][0-9a-zA-Z]*)/, chrlit: /'\\?[ -&(-~]'/, strlit: /"(?:(?:\\")|(?:\\?[ !#\s-~]))*"/, sep: /[!$%&\(\)*+,\-.\/:;<=>?\[\\\]^{\|}~]/ }, multiLineComment: { multiLineComment: { match: "/*", push: "multiLineComment" }, noclose: { match: /[^*]+/, lineBreaks: true} , end: {match: '*/', pop: 1 }, // uses rule ordering to pick between `end` and `noend` noend: [ '*' ], } }) lexer.reset('`'); lexer.next()