Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw new SyntaxError(`${unterminatedEscape} (${oct})`);
}
return {char: String.fromCodePoint(codePoint), newIndex: i + 3};
}
const unterminatedEscape = 'Unterminated escape sequence';
export type Token = {
value: string,
type: TokenType,
};
type TokenType = $Keys;
export const lexer = Moo.compile(lexerRules);
// Ignore whitespace and comment tokens
lexer.next = (next => () => {
let tok;
while ((tok = next.call(lexer)) && ['WS', 'comment'].includes(tok.type)) {}
return tok;
})(lexer.next);
export function Tokenize(input: string): Array {
lexer.reset(input);
const tokens = [];
let token;
while ((token = lexer.next())) {
tokens.push({value: token.value, type: token.type});
}
return tokens;
(function () {
function id(x) { return x[0]; }
const moo = require("moo"); // this 'require' creates a node dependency
const lexer = moo.compile({
oscMsg: ['oscIn'],
mlModel: ['mlmodel'],
osc: ['osc', '∞'],
sinosc: ['sin', '~'],
cososc: ['cos', '≈'],
triosc: ['tri', '∆'],
sawosc: ['saw', '◊'],
phasosc: ['phasor', 'Ø'],
squareosc: ['square', '∏'],
pulseosc: ['pulse', '^'],
gateosc: ['gate', '≠'],
patternosc: ['patt', '¶'],
bus: ['bus', '‡' ],
wnoise: ['wnoise', 'Ω'],
pnoise: ['pnoise'],
bnoise: ['bnoise'],
// @ts-ignore
function id(d: any[]): any { return d[0]; }
declare var parameter: any;
declare var semicolon: any;
declare var lparen: any;
declare var rparen: any;
declare var or: any;
declare var annot: any;
declare var pair: any;
declare var singleArgData: any;
declare var doubleArgData: any;
declare var data: any;
const moo = require("moo");
const lexer = moo.compile({
wspace: /[ \t]+/,
lparen: '(',
rparen: ')',
annot: /:[^ );]+|%[^ );]+/,
parameter: 'parameter',
or: 'or',
pair: 'pair',
data: ['bytes', 'int', 'nat', 'bool', 'string', 'timestamp', 'signature', 'key', 'key_hash', 'mutez', 'address', 'unit', 'operation'],
singleArgData: ['option', 'list', 'contract'],
doubleArgData: ['lambda', 'map', 'big_map'],
semicolon: ';'
});
import { Parameter, EntryPoint } from '../../../types/tezos/ContractIntrospectionTypes';
(function () {
function id(x) { return x[0]; }
const moo = require("moo"); // this 'require' creates a node dependency
const lexer = moo.compile({
separator: /,/,
paramEnd: /}/,
paramBegin: /{/,
sample: { match: /\\[a-zA-Z0-9]+/, lineBreaks: true, value: x => x.slice(0, x.length)},
variable: /:[a-zA-Z0-9]+:/,
oscAddress: /(?:\/[a-zA-Z0-9]+)+/,
sample2: /@[a-zA-Z0-9]+/,
number: /-?(?:[0-9]|[1-9][0-9]+)(?:\.[0-9]+)?(?:[eE][-+]?[0-9]+)?\b/,
add: /\+/,
mult: /\*/,
div: /\//,
dot: /\./,
hash: /\#/,
hyphen: /\-/,
ndash: /\–/,
mdash: /\—/,
(function () {
function id(x) { return x[0]; }
const moo = require("moo"); // this 'require' creates a node dependency
const lexer = moo.compile({
osc: ['osc'],
sinosc: ['sin'],
cososc: ['cos'],
sawosc: ['saw'],
triosc: ['tri'],
squareosc: ['square'],
pulseosc: ['pulse'],
wnoise: ['wnoise'],
pnoise: ['pnoise'],
bnoise: ['bnoise'],
phasosc: ['phasor'],
tpb: ['tpb'],
functionkeyword: ['gain', 'adsr', 'dyn', 'dist', 'filter', 'delay', 'flang', 'chorus', 'samp'],
o: /o/,
x: /x/,
at: /@/,
(function () {
function id(x) { return x[0]; }
const moo = require("moo"); // this 'require' creates a node dependency
const lexer = moo.compile({
separator: /,/,
paramEnd: /}/,
paramBegin: /{/,
oscAddress: /(?:\/[a-zA-Z0-9]+)+/,
sample: /(?:\\[a-zA-Z0-9]+)+/,
add: /\+/,
mult: /\*/,
div: /\//,
dot: /\./,
hash: /\#/,
hyphen: /\-/,
ndash: /\–/,
mdash: /\—/,
comma: /\,/,
colon: /\:/,
semicolon: /\;/,
import * as moo from 'moo';
let lexer = moo.compile({
lparen: '(',
word: /[a-z]+/,
rparen: ')',
keyword: ['while', 'if', 'else', 'moo', 'cows']
});
lexer = moo.states({
main: {
strstart: {match: '`', push: 'lit'},
ident: /\w+/,
lbrace: {match: '{', push: 'main'},
rbrace: {match: '}', pop: 1},
colon: ':',
space: {match: /\s+/, lineBreaks: true},
},
lit: {
function makeLexer() {
const mooLexer = moo.compile(tokens);
return {
current: null,
lines: [],
get line() {
return mooLexer.line;
},
get col() {
return mooLexer.col;
},
save() {
return mooLexer.save();
},
reset(chunk, info) {
this.lines = chunk.split('\n');
return mooLexer.reset(chunk, info);
const moo = require('moo')
const lexer = moo.compile({
percent: {
match: /(?:\+\/?-|±)?\s*\d+\.?\d*\s*%(?:\s+|$)/,
value: x => x.split(' ').join(''),
},
number: {
match: /\d+\.?\d*\s+[^0-9+±]\S*(?:\s+|$)/,
value: x => x.split(' ').join(''),
},
word: {
match: /\S+(?:\s+|$)/,
value: x => x.trim(),
},
})
module.exports = lexer
const moo = require('moo')
const lexer = moo.compile({
WS: /[ \t]+/,
pipe: '|',
lparen: '(',
rparen: ')',
asterisk: '*',
unknown: '???',
unknownIdentifier: '?',
absent: '---',
constant: /[^|()*\n \t]+/,
});
module.exports = lexer;