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