Typo corrected
[deliverable/titan.core.git] / parser / parser.l
CommitLineData
970ed795 1/******************************************************************************
3abe9331 2 * Copyright (c) 2000-2015 Ericsson Telecom AB
970ed795
EL
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
16Tokenizer source code for TTCN-3 (input of flex)
17Rev: PA10
18Date: April 15 2005
19Author: Janos Zoltan Szabo (ejnosza)
20
21Revision history:
22
23Rev. Date Author Comments
24PA1 Nov 10 2000 tmpjsz Created from the prototype compiler.
25PA2 Dec 5 2000 tmpjsz Obsolete keywords removed.
26 Updated according to BNF v1.0.10.
27PA3 Dec 11 2000 tmpjsz No changes.
28
29PA5 Sep 20 2001 tmpjsz Updated according to BNF v1.1.2.
30PA6 Apr 16-17 2002 tmpjsz Upgrade to BNF v2.2.0 (Rev. 12.5)
31PA7 Nov 26-27 2002 tmpjsz Upgrade to BNF v2.2.1 (Rev. 12.7)
32PA8 May 10-13 2004 ejnosza Upgrade to BNF v3.0.0Mockupv1
33PA9 March 2005 ejnosza Added support for multi-dimension
34 sub-references in port/timer/component
35 operations.
36PA10 Apr 13-15 2005 ejnosza Upgrade to final BNF v3.0.0
37
38*/
39
40#include "parser.tab.h"
41
42int 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
58BIN 0|1
59BINORMATCH {BIN}|"\?"|"\*"
60HEX [0-9A-Fa-f]
61HEXORMATCH {HEX}|"\?"|"\*"
62OCT {HEX}{HEX}
63OCTORMATCH {OCT}|"\?"|"\*"
64CHAR [^\"]
65
66NUMBER 0|([1-9][0-9]*)
67
68FLOAT ({NUMBER}\.[0-9]+)|({NUMBER}(\.[0-9]+)?E-?{NUMBER})
69
70IDENTIFIER [A-Za-z][A-Za-z0-9_]*
71
72COMMENT \/\*[^\*]*(\*+[^\/\*][^\*]*)*\*+\/
73CPLUSPLUSCOMMENT \/\/[^\r\n]*
74
75WHITESPACE [ \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
90action RETURN(ActionKeyword);
91activate RETURN(ActivateKeyword);
92address RETURN(AddressKeyword);
93alive RETURN_DOT(AliveKeyword);
94all RETURN(AllKeyword);
95alt RETURN(AltKeyword);
96altstep RETURN(AltstepKeyword);
97any RETURN(AnyKeyword);
98anytype RETURN(AnyTypeKeyword);
99bitstring RETURN(BitStringKeyword);
100boolean RETURN(BooleanKeyword);
101call RETURN_DOT(CallOpKeyword);
102case RETURN(CaseKeyword);
103catch RETURN_DOT(CatchOpKeyword);
104char RETURN(CharKeyword);
105charstring RETURN(CharStringKeyword);
106check RETURN_DOT(CheckOpKeyword);
107clear RETURN_DOT(ClearOpKeyword);
108complement RETURN(ComplementKeyword);
109component RETURN(ComponentKeyword);
110connect RETURN(ConnectKeyword);
111const RETURN(ConstKeyword);
112control RETURN(ControlKeyword);
113create RETURN_DOT(CreateKeyword);
114default RETURN(DefaultKeyword);
115deactivate RETURN(DeactivateKeyword);
116disconnect RETURN(DisconnectKeyword);
117display RETURN(DisplayKeyword);
118do RETURN(DoKeyword);
119done RETURN_DOT(DoneKeyword);
120else RETURN(ElseKeyword);
121encode RETURN(EncodeKeyword);
122enumerated RETURN(EnumKeyword);
123except RETURN(ExceptKeyword);
124exception RETURN(ExceptionKeyword);
125execute RETURN(ExecuteKeyword);
126extends RETURN(ExtendsKeyword);
127extension RETURN(ExtensionKeyword);
128external RETURN(ExtKeyword);
129float RETURN(FloatKeyword);
130for RETURN(ForKeyword);
131from RETURN(FromKeyword);
132function RETURN(FunctionKeyword);
133getcall RETURN_DOT(GetCallOpKeyword);
134getreply RETURN_DOT(GetReplyOpKeyword);
135getverdict RETURN(GetVerdictKeyword);
136goto RETURN(GotoKeyword);
137group RETURN(GroupKeyword);
138hexstring RETURN(HexStringKeyword);
139if RETURN(IfKeyword);
140ifpresent RETURN(IfPresentKeyword);
141import RETURN(ImportKeyword);
142in RETURN(InParKeyword);
143infinity RETURN(InfinityKeyword);
144inout RETURN(InOutParKeyword);
145integer RETURN(IntegerKeyword);
146interleave RETURN(InterleavedKeyword);
147kill RETURN_DOT(KillKeyword);
148killed RETURN_DOT(KilledKeyword);
149label RETURN(LabelKeyword);
150language RETURN(LanguageKeyword);
151length RETURN(LengthKeyword);
152log RETURN(LogKeyword);
153map RETURN(MapKeyword);
154match RETURN(MatchKeyword);
155message RETURN(MessageKeyword);
156mixed RETURN(MixedKeyword);
157modifies RETURN(ModifiesKeyword);
158module RETURN(TTCN3ModuleKeyword);
159modulepar RETURN(ModuleParKeyword);
160mtc RETURN(MTCKeyword);
161noblock RETURN(NoBlockKeyword);
162nowait RETURN(NowaitKeyword);
163objid RETURN(ObjectIdentifierKeyword);
164octetstring RETURN(OctetStringKeyword);
165of RETURN(OfKeyword);
166omit RETURN(OmitKeyword);
167on RETURN(OnKeyword);
168optional RETURN(OptionalKeyword);
169out RETURN(OutParKeyword);
170override RETURN(OverrideKeyword);
171param RETURN(ParamKeyword);
172pattern RETURN(PatternKeyword);
173permutation RETURN(PermutationKeyword);
174port RETURN(PortKeyword);
175procedure RETURN(ProcedureKeyword);
176raise RETURN_DOT(RaiseKeyword);
177read RETURN_DOT(ReadKeyword);
178receive RETURN_DOT(ReceiveOpKeyword);
179record RETURN(RecordKeyword);
180recursive RETURN(RecursiveKeyword);
181reply RETURN_DOT(ReplyKeyword);
182repeat RETURN(RepeatKeyword);
183return RETURN(ReturnKeyword);
184running RETURN_DOT(RunningKeyword);
185runs RETURN(RunsKeyword);
186select RETURN(SelectKeyword);
187self RETURN(SelfOp);
188send RETURN_DOT(SendOpKeyword);
189sender RETURN(SenderKeyword);
190set RETURN(SetKeyword);
191setverdict RETURN(SetVerdictKeyword);
192signature RETURN(SignatureKeyword);
193start RETURN_DOT(StartKeyword);
194stop RETURN_DOT(StopKeyword);
195subset RETURN(SubsetKeyword);
196superset RETURN(SupersetKeyword);
197system RETURN(SystemKeyword);
198template RETURN(TemplateKeyword);
199testcase RETURN(TestcaseKeyword);
200timeout RETURN_DOT(TimeoutKeyword);
201timer RETURN(TimerKeyword);
202to RETURN(ToKeyword);
203trigger RETURN_DOT(TriggerOpKeyword);
204type RETURN(TypeDefKeyword);
205union RETURN(UnionKeyword);
206universal RETURN(UniversalKeyword);
207unmap RETURN(UnmapKeyword);
208value RETURN(ValueKeyword);
209valueof RETURN(ValueofKeyword);
210var RETURN(VarKeyword);
211variant RETURN(VariantKeyword);
212verdicttype RETURN(VerdictTypeKeyword);
213while RETURN(WhileKeyword);
214with RETURN(WithKeyword);
215
216 /* Values */
217
218{NUMBER} RETURN(Number);
219
220{FLOAT} RETURN(FloatValue);
221
222true|false RETURN(BooleanConst);
223
224pass|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
240null 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
257mod RETURN(Mod);
258rem RETURN(Rem);
259or RETURN(Or);
260or4b RETURN(Or4b);
261xor RETURN(Xor);
262xor4b RETURN(Xor4b);
263and RETURN(And);
264and4b RETURN(And4b);
265not RETURN(Not);
266not4b 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.035327 seconds and 5 git commands to generate.