-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSPLLexer.g4
More file actions
141 lines (124 loc) · 3.98 KB
/
Copy pathSPLLexer.g4
File metadata and controls
141 lines (124 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
lexer grammar SPLLexer;
// Keywords (case-insensitive)
AND : [Aa][Nn][Dd] ;
OR : [Oo][Rr] ;
NOT : [Nn][Oo][Tt] ;
BY : [Bb][Yy] ;
AS : [Aa][Ss] ;
IN : [Ii][Nn] ;
WHERE : [Ww][Hh][Ee][Rr][Ee] ;
SEARCH : [Ss][Ee][Aa][Rr][Cc][Hh] ;
EVAL : [Ee][Vv][Aa][Ll] ;
STATS : [Ss][Tt][Aa][Tt][Ss] ;
TABLE : [Tt][Aa][Bb][Ll][Ee] ;
FIELDS : [Ff][Ii][Ee][Ll][Dd][Ss] ;
RENAME : [Rr][Ee][Nn][Aa][Mm][Ee] ;
REX : [Rr][Ee][Xx] ;
DEDUP : [Dd][Ee][Dd][Uu][Pp] ;
SORT : [Ss][Oo][Rr][Tt] ;
HEAD : [Hh][Ee][Aa][Dd] ;
TAIL : [Tt][Aa][Ii][Ll] ;
TOP : [Tt][Oo][Pp] ;
RARE : [Rr][Aa][Rr][Ee] ;
LOOKUP : [Ll][Oo][Oo][Kk][Uu][Pp] ;
JOIN : [Jj][Oo][Ii][Nn] ;
APPEND : [Aa][Pp][Pp][Ee][Nn][Dd] ;
TRANSACTION : [Tt][Rr][Aa][Nn][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' ;
LBRACKET : '[' ;
RBRACKET : ']' ;
LBRACE : '{' ;
RBRACE : '}' ;
COMMA : ',' ;
COLON : ':' ;
DQUOTE : '"' ;
PLUS : '+' ;
MINUS : '-' ;
SLASH : '/' ;
PERCENT : '%' ;
// String literals (allow embedded newlines for multiline regex in match() etc.)
QUOTED_STRING
: '"' (~["\\] | '\\' .)* '"'
| '\'' (~['\\] | '\\' .)* '\''
;
// Time span values (must be before NUMBER to match span=1h, -24h, etc.)
TIME_SPAN
: '-'? [0-9]+ [smhdwMy]
| '-'? [0-9]+ [smhdwMy] '@' [a-zA-Z]+
;
// Numbers (negative numbers handled in parser with MINUS token)
NUMBER
: DIGIT+ ('.' DIGIT+)?
| '.' DIGIT+
;
fragment DIGIT : [0-9] ;
// Wildcards and patterns
WILDCARD : '*' ;
// Special pattern suffix (for Windows account patterns like *$)
DOLLAR : '$' ;
// Template variables for foreach (e.g., <<FIELD>>, <<field>>)
TEMPLATE_VAR
: '<<' [a-zA-Z_] [a-zA-Z0-9_]* '>>'
;
// Field names and identifiers (allowing dots for nested fields)
IDENTIFIER
: [a-zA-Z_] [a-zA-Z0-9_]*
| [a-zA-Z_] [a-zA-Z0-9_]* ('.' [a-zA-Z_] [a-zA-Z0-9_]*)+
;
// Dot operator (must be after NUMBER and IDENTIFIER to not interfere with decimals and nested fields)
DOT : '.' ;
// REST API path (for rest command endpoints like /servicesNS/-/-/saved/searches)
// Must have at least two segments to avoid consuming /Operational in sourcetype values
// First segment must start with a letter to avoid consuming arithmetic like /60/60
// e.g., /services/endpoint NOT /60/60
REST_PATH
: '/' [a-zA-Z] [a-zA-Z0-9_\-]* '/' [a-zA-Z0-9_\-*]+ ('/' [a-zA-Z0-9_\-*]+)*
;
// Backtick macros
MACRO
: '`' (~[`])+ '`'
;
// Time alignment modifier (e.g., @d, @h)
TIME_MODIFIER
: '@' [a-zA-Z]+
;
// Whitespace
WS : [ \t\r\n]+ -> skip ;
// Line comments (useful for formatted queries)
LINE_COMMENT
: '```' ~[\r\n]* -> skip
;