|
| 1 | +package lexers |
| 2 | + |
| 3 | +import ( |
| 4 | + . "github.com/alecthomas/chroma" // nolint |
| 5 | + "github.com/alecthomas/chroma/lexers/internal" |
| 6 | +) |
| 7 | + |
| 8 | +// Qml lexer. |
| 9 | +var Qml = internal.Register(MustNewLexer( |
| 10 | + &Config{ |
| 11 | + Name: "QML", |
| 12 | + Aliases: []string{"qml", "qbs"}, |
| 13 | + Filenames: []string{"*.qml", "*.qbs"}, |
| 14 | + MimeTypes: []string{"application/x-qml", "application/x-qt.qbs+qml"}, |
| 15 | + DotAll: true, |
| 16 | + }, |
| 17 | + Rules{ |
| 18 | + "commentsandwhitespace": { |
| 19 | + {`\s+`, Text, nil}, |
| 20 | + {`<!--`, Comment, nil}, |
| 21 | + {`//.*?\n`, CommentSingle, nil}, |
| 22 | + {`/\*.*?\*/`, CommentMultiline, nil}, |
| 23 | + }, |
| 24 | + "slashstartsregex": { |
| 25 | + Include("commentsandwhitespace"), |
| 26 | + {`/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/([gim]+\b|\B)`, LiteralStringRegex, Pop(1)}, |
| 27 | + {`(?=/)`, Text, Push("#pop", "badregex")}, |
| 28 | + Default(Pop(1)), |
| 29 | + }, |
| 30 | + "badregex": { |
| 31 | + {`\n`, Text, Pop(1)}, |
| 32 | + }, |
| 33 | + "root": { |
| 34 | + {`^(?=\s|/|<!--)`, Text, Push("slashstartsregex")}, |
| 35 | + Include("commentsandwhitespace"), |
| 36 | + {`\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?`, Operator, Push("slashstartsregex")}, |
| 37 | + {`[{(\[;,]`, Punctuation, Push("slashstartsregex")}, |
| 38 | + {`[})\].]`, Punctuation, nil}, |
| 39 | + {`\bid\s*:\s*[A-Za-z][\w.]*`, KeywordDeclaration, Push("slashstartsregex")}, |
| 40 | + {`\b[A-Za-z][\w.]*\s*:`, Keyword, Push("slashstartsregex")}, |
| 41 | + {`(for|in|while|do|break|return|continue|switch|case|default|if|else|throw|try|catch|finally|new|delete|typeof|instanceof|void|this)\b`, Keyword, Push("slashstartsregex")}, |
| 42 | + {`(var|let|with|function)\b`, KeywordDeclaration, Push("slashstartsregex")}, |
| 43 | + {`(abstract|boolean|byte|char|class|const|debugger|double|enum|export|extends|final|float|goto|implements|import|int|interface|long|native|package|private|protected|public|short|static|super|synchronized|throws|transient|volatile)\b`, KeywordReserved, nil}, |
| 44 | + {`(true|false|null|NaN|Infinity|undefined)\b`, KeywordConstant, nil}, |
| 45 | + {`(Array|Boolean|Date|Error|Function|Math|netscape|Number|Object|Packages|RegExp|String|sun|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|window)\b`, NameBuiltin, nil}, |
| 46 | + {`[$a-zA-Z_]\w*`, NameOther, nil}, |
| 47 | + {`[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?`, LiteralNumberFloat, nil}, |
| 48 | + {`0x[0-9a-fA-F]+`, LiteralNumberHex, nil}, |
| 49 | + {`[0-9]+`, LiteralNumberInteger, nil}, |
| 50 | + {`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil}, |
| 51 | + {`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil}, |
| 52 | + }, |
| 53 | + }, |
| 54 | +)) |
0 commit comments