Sync with 5.4.0
[deliverable/titan.core.git] / parser / parser.l
1 /******************************************************************************
2 * Copyright (c) 2000-2015 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 ******************************************************************************/
8
9 %option noyywrap
10 %option yylineno
11 %option nounput
12 %{
13
14 /*
15
16 Tokenizer source code for TTCN-3 (input of flex)
17 Rev: PA10
18 Date: April 15 2005
19 Author: Janos Zoltan Szabo (ejnosza)
20
21 Revision history:
22
23 Rev. Date Author Comments
24 PA1 Nov 10 2000 tmpjsz Created from the prototype compiler.
25 PA2 Dec 5 2000 tmpjsz Obsolete keywords removed.
26 Updated according to BNF v1.0.10.
27 PA3 Dec 11 2000 tmpjsz No changes.
28
29 PA5 Sep 20 2001 tmpjsz Updated according to BNF v1.1.2.
30 PA6 Apr 16-17 2002 tmpjsz Upgrade to BNF v2.2.0 (Rev. 12.5)
31 PA7 Nov 26-27 2002 tmpjsz Upgrade to BNF v2.2.1 (Rev. 12.7)
32 PA8 May 10-13 2004 ejnosza Upgrade to BNF v3.0.0Mockupv1
33 PA9 March 2005 ejnosza Added support for multi-dimension
34 sub-references in port/timer/component
35 operations.
36 PA10 Apr 13-15 2005 ejnosza Upgrade to final BNF v3.0.0
37
38 */
39
40 #include "parser.tab.h"
41
42 int dot_flag = 0;
43
44 #define RETURN(ret_val) \
45 if (dot_flag) { \
46 backup_token = ret_val; \
47 return '.'; \
48 } else return ret_val
49
50 #define RETURN_DOT(ret_val) \
51 if (dot_flag) { \
52 dot_flag = 0; \
53 return Dot##ret_val; \
54 } else return ret_val
55
56 %}
57
58 BIN 0|1
59 BINORMATCH {BIN}|"\?"|"\*"
60 HEX [0-9A-Fa-f]
61 HEXORMATCH {HEX}|"\?"|"\*"
62 OCT {HEX}{HEX}
63 OCTORMATCH {OCT}|"\?"|"\*"
64 CHAR [^\"]
65
66 NUMBER 0|([1-9][0-9]*)
67
68 FLOAT ({NUMBER}\.[0-9]+)|({NUMBER}(\.[0-9]+)?E-?{NUMBER})
69
70 IDENTIFIER [A-Za-z][A-Za-z0-9_]*
71
72 COMMENT \/\*[^\*]*(\*+[^\/\*][^\*]*)*\*+\/
73 CPLUSPLUSCOMMENT \/\/[^\r\n]*
74
75 WHITESPACE [ \t\r\n]+
76
77 %%
78 static int backup_token;
79 if (dot_flag) {
80 dot_flag = 0;
81 return backup_token;
82 }
83
84 {WHITESPACE} { /* Drop whitespaces */ }
85
86 {COMMENT}|{CPLUSPLUSCOMMENT} { /* Drop comments */ }
87
88 /* Keywords */
89
90 action RETURN(ActionKeyword);
91 activate RETURN(ActivateKeyword);
92 address RETURN(AddressKeyword);
93 alive RETURN_DOT(AliveKeyword);
94 all RETURN(AllKeyword);
95 alt RETURN(AltKeyword);
96 altstep RETURN(AltstepKeyword);
97 any RETURN(AnyKeyword);
98 anytype RETURN(AnyTypeKeyword);
99 bitstring RETURN(BitStringKeyword);
100 boolean RETURN(BooleanKeyword);
101 call RETURN_DOT(CallOpKeyword);
102 case RETURN(CaseKeyword);
103 catch RETURN_DOT(CatchOpKeyword);
104 char RETURN(CharKeyword);
105 charstring RETURN(CharStringKeyword);
106 check RETURN_DOT(CheckOpKeyword);
107 clear RETURN_DOT(ClearOpKeyword);
108 complement RETURN(ComplementKeyword);
109 component RETURN(ComponentKeyword);
110 connect RETURN(ConnectKeyword);
111 const RETURN(ConstKeyword);
112 control RETURN(ControlKeyword);
113 create RETURN_DOT(CreateKeyword);
114 default RETURN(DefaultKeyword);
115 deactivate RETURN(DeactivateKeyword);
116 disconnect RETURN(DisconnectKeyword);
117 display RETURN(DisplayKeyword);
118 do RETURN(DoKeyword);
119 done RETURN_DOT(DoneKeyword);
120 else RETURN(ElseKeyword);
121 encode RETURN(EncodeKeyword);
122 enumerated RETURN(EnumKeyword);
123 except RETURN(ExceptKeyword);
124 exception RETURN(ExceptionKeyword);
125 execute RETURN(ExecuteKeyword);
126 extends RETURN(ExtendsKeyword);
127 extension RETURN(ExtensionKeyword);
128 external RETURN(ExtKeyword);
129 float RETURN(FloatKeyword);
130 for RETURN(ForKeyword);
131 from RETURN(FromKeyword);
132 function RETURN(FunctionKeyword);
133 getcall RETURN_DOT(GetCallOpKeyword);
134 getreply RETURN_DOT(GetReplyOpKeyword);
135 getverdict RETURN(GetVerdictKeyword);
136 goto RETURN(GotoKeyword);
137 group RETURN(GroupKeyword);
138 hexstring RETURN(HexStringKeyword);
139 if RETURN(IfKeyword);
140 ifpresent RETURN(IfPresentKeyword);
141 import RETURN(ImportKeyword);
142 in RETURN(InParKeyword);
143 infinity RETURN(InfinityKeyword);
144 inout RETURN(InOutParKeyword);
145 integer RETURN(IntegerKeyword);
146 interleave RETURN(InterleavedKeyword);
147 kill RETURN_DOT(KillKeyword);
148 killed RETURN_DOT(KilledKeyword);
149 label RETURN(LabelKeyword);
150 language RETURN(LanguageKeyword);
151 length RETURN(LengthKeyword);
152 log RETURN(LogKeyword);
153 map RETURN(MapKeyword);
154 match RETURN(MatchKeyword);
155 message RETURN(MessageKeyword);
156 mixed RETURN(MixedKeyword);
157 modifies RETURN(ModifiesKeyword);
158 module RETURN(TTCN3ModuleKeyword);
159 modulepar RETURN(ModuleParKeyword);
160 mtc RETURN(MTCKeyword);
161 noblock RETURN(NoBlockKeyword);
162 nowait RETURN(NowaitKeyword);
163 objid RETURN(ObjectIdentifierKeyword);
164 octetstring RETURN(OctetStringKeyword);
165 of RETURN(OfKeyword);
166 omit RETURN(OmitKeyword);
167 on RETURN(OnKeyword);
168 optional RETURN(OptionalKeyword);
169 out RETURN(OutParKeyword);
170 override RETURN(OverrideKeyword);
171 param RETURN(ParamKeyword);
172 pattern RETURN(PatternKeyword);
173 permutation RETURN(PermutationKeyword);
174 port RETURN(PortKeyword);
175 procedure RETURN(ProcedureKeyword);
176 raise RETURN_DOT(RaiseKeyword);
177 read RETURN_DOT(ReadKeyword);
178 receive RETURN_DOT(ReceiveOpKeyword);
179 record RETURN(RecordKeyword);
180 recursive RETURN(RecursiveKeyword);
181 reply RETURN_DOT(ReplyKeyword);
182 repeat RETURN(RepeatKeyword);
183 return RETURN(ReturnKeyword);
184 running RETURN_DOT(RunningKeyword);
185 runs RETURN(RunsKeyword);
186 select RETURN(SelectKeyword);
187 self RETURN(SelfOp);
188 send RETURN_DOT(SendOpKeyword);
189 sender RETURN(SenderKeyword);
190 set RETURN(SetKeyword);
191 setverdict RETURN(SetVerdictKeyword);
192 signature RETURN(SignatureKeyword);
193 start RETURN_DOT(StartKeyword);
194 stop RETURN_DOT(StopKeyword);
195 subset RETURN(SubsetKeyword);
196 superset RETURN(SupersetKeyword);
197 system RETURN(SystemKeyword);
198 template RETURN(TemplateKeyword);
199 testcase RETURN(TestcaseKeyword);
200 timeout RETURN_DOT(TimeoutKeyword);
201 timer RETURN(TimerKeyword);
202 to RETURN(ToKeyword);
203 trigger RETURN_DOT(TriggerOpKeyword);
204 type RETURN(TypeDefKeyword);
205 union RETURN(UnionKeyword);
206 universal RETURN(UniversalKeyword);
207 unmap RETURN(UnmapKeyword);
208 value RETURN(ValueKeyword);
209 valueof RETURN(ValueofKeyword);
210 var RETURN(VarKeyword);
211 variant RETURN(VariantKeyword);
212 verdicttype RETURN(VerdictTypeKeyword);
213 while RETURN(WhileKeyword);
214 with RETURN(WithKeyword);
215
216 /* Values */
217
218 {NUMBER} RETURN(Number);
219
220 {FLOAT} RETURN(FloatValue);
221
222 true|false RETURN(BooleanConst);
223
224 pass|fail|inconc|none|error RETURN(VerdictConst);
225
226 \'{BIN}*\'B RETURN(Bstring);
227
228 \'{BINORMATCH}*\'B RETURN(BitStringMatch);
229
230 \'{HEX}*\'H RETURN(Hstring);
231
232 \'{HEXORMATCH}*\'H RETURN(HexStringMatch);
233
234 \'{OCT}*\'O RETURN(Ostring);
235
236 \'{OCTORMATCH}*\'O RETURN(OctetStringMatch);
237
238 (\"{CHAR}*\"|"<\">")+ RETURN(Cstring);
239
240 null RETURN(NullKeyword);
241
242 /* Multi-character operators */
243
244 ":=" RETURN(AssignmentChar);
245 ".." RETURN(DotDot);
246 "->" RETURN(PortRedirectSymbol);
247 "==" RETURN(EQ);
248 "!=" RETURN(NE);
249 ">=" RETURN(GE);
250 "<=" RETURN(LE);
251
252 "<<" RETURN(SL);
253 ">>" RETURN(SR);
254 "<@" RETURN(RL);
255 "@>" RETURN(RR);
256
257 mod RETURN(Mod);
258 rem RETURN(Rem);
259 or RETURN(Or);
260 or4b RETURN(Or4b);
261 xor RETURN(Xor);
262 xor4b RETURN(Xor4b);
263 and RETURN(And);
264 and4b RETURN(And4b);
265 not RETURN(Not);
266 not4b RETURN(Not4b);
267
268 /* Identifiers */
269
270 {IDENTIFIER} RETURN(Identifier);
271
272 /* Single character literals */
273
274 \. if (dot_flag) {
275 backup_token = '.';
276 return '.';
277 } else dot_flag = 1;
278
279 . return yytext[0];
280
281 <<EOF>> if (dot_flag) {
282 dot_flag = 0;
283 return '.';
284 } else return EOF;
285
286 %%
287
This page took 0.05986 seconds and 5 git commands to generate.