PreprocessorDirectiveLexer.g4 1.73 KB
Newer Older
Elemer Lelik's avatar
Elemer Lelik committed
1
lexer grammar PreprocessorDirectiveLexer;
Elemer Lelik's avatar
Elemer Lelik committed
2
3
/*
******************************************************************************
balaskoa's avatar
balaskoa committed
4
 * Copyright (c) 2000-2016 Ericsson Telecom AB
Elemer Lelik's avatar
Elemer Lelik committed
5
6
7
8
9
10
11
12
13
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************
*/

/**
 * @author Laszlo Baji
14
15
 * @author Arpad Lovassy
 */
Elemer Lelik's avatar
Elemer Lelik committed
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

DIRECTIVE_IFDEF : 'ifdef'; DIRECTIVE_IFNDEF : 'ifndef'; DIRECTIVE_IF : 'if';
DIRECTIVE_ELSE : 'else'; DIRECTIVE_ELIF : 'elif'; DIRECTIVE_ENDIF : 'endif';
DIRECTIVE_DEFINE : 'define'; DIRECTIVE_UNDEF : 'undef'; OP_DEFINED : 'defined';	
DIRECTIVE_INCLUDE : 'include';
DIRECTIVE_LINECONTROL : 'line';

WS:
(  ' '
|  '\t'
|  '\n' 
|  '\u000B'
|  '\u000C'
) -> skip
;

SL_COMMENT:
'//' (~'\n')* -> skip
;


ML_COMMENT:
(
	'/*' (.*?) (ML_COMMENT)* '*/'
) -> skip
;

CSTRING:
(
'"'
	(
		'\"\"'
	|	~('"')
	)*
'"'
)
;

OCTINT:
'0' [0-7]*
;

DECINT:
[1-9][0-9]*
;

HEXINT:
'0x' [0-9a-fA-F]+
;

DIRECTIVE_PRAGMA : 'pragma' .*? EOF; 
DIRECTIVE_ERROR : 'error' .*? EOF; 
DIRECTIVE_WARNING :	'warning' .*? EOF;

70
71
NOT :	'not'|'NOT';

Elemer Lelik's avatar
Elemer Lelik committed
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
IDENTIFIER:
[A-Za-z_][A-Za-z0-9_]*
;

OP_EQ :		'==';
OP_NE :		'!=';
OP_GT :		'>';
OP_LT :		'<';
OP_GE :		'>=';
OP_LE :		'<=';

OP_MINUS :	'-';
OP_PLUS :	'+';
OP_MUL :	'*';
OP_DIV :	'/';
OP_MOD :	'%';

OP_AND :	'&&';
OP_OR :		'||';
OP_NOT :	'!';
OP_BITAND :	'&';
OP_BITOR :	'|';
OP_XOR :	'^';

OP_LSHIFT :	'<<';
OP_RSHIFT :	'>>';

LPAREN :	'(';
RPAREN :	')';

QUESTIONMARK :'?';
COLON :		':';