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