Warning, /frameworks/syntax-highlighting/autotests/input/highlight.g4 is written in an unsupported language. File is not indexed.
0001 /* This test file tests Kate's ANTLR highlighting 0002 compilable bt ANTLR although not directly: 0003 grammar can be alone file for both parser and lexer 0004 or two files 0005 This file is merged TestParser.g4 and TestLexer.g4 0006 this lines also tests regions of multiline comment 0007 */ 0008 //file TestParser.g4 0009 parser grammar TestParser; 0010 0011 options { tokenVocab = TestLexer; } 0012 0013 // The main entry point for parsing a grammar. 0014 0015 startRule 0016 : (expression | STRING)+ EOF 0017 ; 0018 0019 expression 0020 : expression PLUS mulExpr 0021 | expression MINUS mulExpr 0022 | mulExpr 0023 ; 0024 0025 mulExpr 0026 : mulExpr MUL unaryExpr 0027 | mulExpr DIV unaryExpr 0028 | unaryExpr 0029 ; 0030 0031 unaryExpr 0032 : atom 0033 | LPAR expression RPAR 0034 ; 0035 0036 atom 0037 : IDENT 0038 | number 0039 ; 0040 0041 number 0042 : INT 0043 | FLOAT 0044 ; 0045 0046 //================================ 0047 //file TestLexer.g4 0048 0049 lexer grammar TestLexer; 0050 0051 /*'channels' and '{' must be in one line 0052 to correct highlighting, highlighter can't 0053 recognize regular expression "(options|tokens|channels)(?=([\s]*{))" 0054 where apart from \s whitrspaces are end of lines 0055 */ 0056 channels { OFF_CHANNEL , COMMENT } 0057 0058 0059 PLUS 0060 : '+' 0061 ; 0062 0063 MINUS 0064 : '-' 0065 ; 0066 0067 MUL 0068 : '*' 0069 ; 0070 0071 DIV 0072 : '/' 0073 ; 0074 0075 LPAR 0076 : '(' 0077 ; 0078 0079 RPAR 0080 : ')' 0081 ; 0082 0083 IDENT 0084 : Nondigit 0085 ( Nondigit 0086 | Digit 0087 )* 0088 ; 0089 0090 fragment 0091 Digit 0092 : [0-9] 0093 ; 0094 0095 fragment 0096 NonzeroDigit 0097 : [1-9] 0098 ; 0099 0100 fragment 0101 Nondigit 0102 : [a-zA-Z_] 0103 ; 0104 0105 Sign 0106 : '+' | '-' 0107 ; 0108 0109 INT 0110 : Sign? (NonzeroDigit Digit* | '0') 0111 ; 0112 0113 fragment 0114 DigitSequence 0115 : Digit+ 0116 ; 0117 0118 fragment 0119 ExponentPart 0120 : [eE] Sign? DigitSequence 0121 ; 0122 0123 fragment 0124 FractionalConstant 0125 : DigitSequence? '.' DigitSequence 0126 | DigitSequence '.' 0127 ; 0128 0129 FLOAT 0130 : (FractionalConstant ExponentPart? | DigitSequence ExponentPart) 0131 ; 0132 0133 0134 fragment 0135 EscapeSequence 0136 : '\\' ['"?abfnrtvhe\\] 0137 ; 0138 0139 //between [] is charset , test escape \ 0140 fragment 0141 SChar 0142 : ~["\\\r\n] 0143 | EscapeSequence 0144 ; 0145 0146 STRING 0147 : '"' SChar* '"' 0148 ;