Files
RedBear-OS/local/recipes/kde/kf6-syntaxhighlighting/source/autotests/html/highlight.g4.dark.html
T

156 lines
7.1 KiB
HTML

<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>highlight.g4</title>
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (ANTLR) - Theme (Breeze Dark)"/>
</head><body style="background-color:#232629;color:#cfcfc2"><pre>
<span style="color:#7a7c7d">/* This test file tests Kate's ANTLR highlighting </span>
<span style="color:#7a7c7d"> compilable bt ANTLR although not directly:</span>
<span style="color:#7a7c7d"> grammar can be alone file for both parser and lexer</span>
<span style="color:#7a7c7d"> or two files</span>
<span style="color:#7a7c7d"> This file is merged TestParser.g4 and TestLexer.g4</span>
<span style="color:#7a7c7d"> this lines also tests regions of multiline comment</span>
<span style="color:#7a7c7d">*/</span>
<span style="color:#7a7c7d">//file TestParser.g4</span>
<span style="font-weight:bold">parser</span> <span style="font-weight:bold">grammar</span> TestParser<span style="color:#3f8058">;</span>
<span style="color:#2980b9">options</span> <span style="color:#3f8058">{</span> tokenVocab <span style="color:#3f8058">=</span> TestLexer<span style="color:#3f8058">;</span> <span style="color:#3f8058">}</span>
<span style="color:#7a7c7d">// The main entry point for parsing a grammar.</span>
startRule
<span style="color:#3f8058">:</span> <span style="color:#3f8058">(</span>expression <span style="color:#3f8058">|</span> STRING<span style="color:#3f8058">)+</span> EOF
<span style="color:#3f8058">;</span>
expression
<span style="color:#3f8058">:</span> expression PLUS mulExpr
<span style="color:#3f8058">|</span> expression MINUS mulExpr
<span style="color:#3f8058">|</span> mulExpr
<span style="color:#3f8058">;</span>
mulExpr
<span style="color:#3f8058">:</span> mulExpr MUL unaryExpr
<span style="color:#3f8058">|</span> mulExpr DIV unaryExpr
<span style="color:#3f8058">|</span> unaryExpr
<span style="color:#3f8058">;</span>
unaryExpr
<span style="color:#3f8058">:</span> atom
<span style="color:#3f8058">|</span> LPAR expression RPAR
<span style="color:#3f8058">;</span>
atom
<span style="color:#3f8058">:</span> IDENT
<span style="color:#3f8058">|</span> number
<span style="color:#3f8058">;</span>
number
<span style="color:#3f8058">:</span> INT
<span style="color:#3f8058">|</span> FLOAT
<span style="color:#3f8058">;</span>
<span style="color:#7a7c7d">//================================</span>
<span style="color:#7a7c7d">//file TestLexer.g4</span>
<span style="font-weight:bold">lexer</span> <span style="font-weight:bold">grammar</span> TestLexer<span style="color:#3f8058">;</span>
<span style="color:#7a7c7d">/*'channels' and '{' must be in one line</span>
<span style="color:#7a7c7d"> to correct highlighting, highlighter can't</span>
<span style="color:#7a7c7d"> recognize regular expression "(options|tokens|channels)(?=([\s]*{))"</span>
<span style="color:#7a7c7d"> where apart from \s whitrspaces are end of lines</span>
<span style="color:#7a7c7d"> */</span>
<span style="color:#2980b9">channels</span> <span style="color:#3f8058">{</span> OFF_CHANNEL <span style="color:#3f8058">,</span> COMMENT <span style="color:#3f8058">}</span>
PLUS
<span style="color:#3f8058">:</span> <span style="color:#f44f4f">'+'</span>
<span style="color:#3f8058">;</span>
MINUS
<span style="color:#3f8058">:</span> <span style="color:#f44f4f">'-'</span>
<span style="color:#3f8058">;</span>
MUL
<span style="color:#3f8058">:</span> <span style="color:#f44f4f">'*'</span>
<span style="color:#3f8058">;</span>
DIV
<span style="color:#3f8058">:</span> <span style="color:#f44f4f">'/'</span>
<span style="color:#3f8058">;</span>
LPAR
<span style="color:#3f8058">:</span> <span style="color:#f44f4f">'('</span>
<span style="color:#3f8058">;</span>
RPAR
<span style="color:#3f8058">:</span> <span style="color:#f44f4f">')'</span>
<span style="color:#3f8058">;</span>
IDENT
<span style="color:#3f8058">:</span> Nondigit
<span style="color:#3f8058">(</span> Nondigit
<span style="color:#3f8058">|</span> Digit
<span style="color:#3f8058">)*</span>
<span style="color:#3f8058">;</span>
<span style="font-weight:bold">fragment</span>
Digit
<span style="color:#3f8058">:</span> <span style="color:#3daee9">[0-9]</span>
<span style="color:#3f8058">;</span>
<span style="font-weight:bold">fragment</span>
NonzeroDigit
<span style="color:#3f8058">:</span> <span style="color:#3daee9">[1-9]</span>
<span style="color:#3f8058">;</span>
<span style="font-weight:bold">fragment</span>
Nondigit
<span style="color:#3f8058">:</span> <span style="color:#3daee9">[a-zA-Z_]</span>
<span style="color:#3f8058">;</span>
Sign
<span style="color:#3f8058">:</span> <span style="color:#f44f4f">'+'</span> <span style="color:#3f8058">|</span> <span style="color:#f44f4f">'-'</span>
<span style="color:#3f8058">;</span>
INT
<span style="color:#3f8058">:</span> Sign<span style="color:#3f8058">?</span> <span style="color:#3f8058">(</span>NonzeroDigit Digit<span style="color:#3f8058">*</span> <span style="color:#3f8058">|</span> <span style="color:#f44f4f">'0'</span><span style="color:#3f8058">)</span>
<span style="color:#3f8058">;</span>
<span style="font-weight:bold">fragment</span>
DigitSequence
<span style="color:#3f8058">:</span> Digit<span style="color:#3f8058">+</span>
<span style="color:#3f8058">;</span>
<span style="font-weight:bold">fragment</span>
ExponentPart
<span style="color:#3f8058">:</span> <span style="color:#3daee9">[eE]</span> Sign<span style="color:#3f8058">?</span> DigitSequence
<span style="color:#3f8058">;</span>
<span style="font-weight:bold">fragment</span>
FractionalConstant
<span style="color:#3f8058">:</span> DigitSequence<span style="color:#3f8058">?</span> <span style="color:#f44f4f">'.'</span> DigitSequence
<span style="color:#3f8058">|</span> DigitSequence <span style="color:#f44f4f">'.'</span>
<span style="color:#3f8058">;</span>
FLOAT
<span style="color:#3f8058">:</span> <span style="color:#3f8058">(</span>FractionalConstant ExponentPart<span style="color:#3f8058">?</span> <span style="color:#3f8058">|</span> DigitSequence ExponentPart<span style="color:#3f8058">)</span>
<span style="color:#3f8058">;</span>
<span style="font-weight:bold">fragment</span>
EscapeSequence
<span style="color:#3f8058">:</span> <span style="color:#f44f4f">'\\'</span> <span style="color:#3daee9">['"?abfnrtvhe\\]</span>
<span style="color:#3f8058">;</span>
<span style="color:#7a7c7d">//between [] is charset , test escape \</span>
<span style="color:#7a7c7d">fragment</span>
SChar
<span style="color:#3f8058">:</span> <span style="color:#3f8058">~</span><span style="color:#3daee9">["\\\r\n]</span>
<span style="color:#3f8058">|</span> EscapeSequence
<span style="color:#3f8058">;</span>
STRING
<span style="color:#3f8058">:</span> <span style="color:#f44f4f">'"'</span> SChar<span style="color:#3f8058">*</span> <span style="color:#f44f4f">'"'</span>
<span style="color:#3f8058">;</span>
</pre></body></html>