module.exports = grammar({ name: 'onotone', rules: { Source: $ => repeat($.Tag), Tag: $ => seq( optional($.WhiteSpaces), $.Id, optional($.TagClass), optional($.TagHook), optional($.WhiteSpaces), optional($.Attributes), optional($.WhiteSpaces), optional($.Content), optional($.WhiteSpaces), $.TagEnd ), Id: $ => /\w+/, TagHook: $ => seq($.HookSymbol, $.Id), TagClass: $ => seq($.ClassSymbol, $.Id), HookSymbol: $ => token("#"), ClassSymbol: $ => token(":"), LSquareBracket: $ => token("["), RSquareBracket: $ => token("]"), EqualsTo: $ => "->", Attribute: $ => seq($.Id, optional($.WhiteSpaces), $.EqualsTo, optional($.WhiteSpaces), $.Content), Attributes: $ => seq($.LSquareBracket, repeat1(seq(optional($.WhiteSpaces), $.Attribute, optional($.WhiteSpaces), optional($.Comma))), optional($.WhiteSpaces), $.RSquareBracket), Comma: $ => token(","), Content: $ => choice($.Single, $.Double), SingleQuote: $ => token("\'"), DoubleQuote: $ => token("\""), Single: $ => seq($.SingleQuote, $.Text, $.SingleQuote), Double: $ => seq($.DoubleQuote, $.Text, $.DoubleQuote), Text: $ => /[^'][^"]+/, TagEnd: $ => token("."), WhiteSpaces: $ => / +/, } });