ometa Lisp { // Lexer identifier = +:id -> { type: "Id", value: id.join('') }, string = '"' (~'"' char)*:cs '"' -> { type: "String", value: cs.join('') }, punctuator = ( '(' | ')' | '\'' | '.' | ',' ):p -> { type: "Punctuator", value: p }, token :tt = spaces ( (punctuator):t ?(t.value == tt) -> t | (identifier | string):t ?(t.type == tt) -> t ), // Parser list = token("(") listOf(#start, ""):c token(")") -> { type: "List", content: c }, start = list | "Id" | "String" } console.log(Lisp.matchAll('(foo bar)', "start"))