1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 /* A Bison parser, made by GNU Bison 1.875. */
19 /* Skeleton parser for Yacc-like parsing with Bison,
20 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
22 This program is free software; you can redistribute it and/or modify
23 it under the terms of the GNU General Public License as published by
24 the Free Software Foundation; either version 2, or (at your option)
27 This program is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
32 You should have received a copy of the GNU General Public License
33 along with this program; if not, write to the Free Software
34 Foundation, Inc., 59 Temple Place - Suite 330,
35 Boston, MA 02111-1307, USA. */
37 /* As a special exception, when this file is copied by Bison into a
38 Bison output file, you may use that output file without restriction.
39 This special exception was added by the Free Software Foundation
40 in version 1.24 of Bison. */
42 /* Written by Richard Stallman by simplifying the original so called
43 ``semantic'' parser. */
45 /* All symbols defined below should begin with yy or YY, to avoid
46 infringing on user name space. This should be done even for local
47 variables, as they might otherwise be expanded by user macros.
48 There are some unavoidable exceptions within include files to
49 define necessary library symbols; they are noted "INFRINGES ON
50 USER NAME SPACE" below. */
52 /* Identify Bison output. */
56 #define YYSKELETON_NAME "yacc.c"
61 /* Using locations. */
62 #define YYLSP_NEEDED 0
64 /* If NAME_PREFIX is specified substitute the variables and functions
66 #define yyparse aiparse
68 #define yyerror aierror
71 #define yydebug aidebug
72 #define yynerrs ainerrs
78 /* Put the tokens into the symbol table, so that GDB and other debuggers
88 TOKEN_SEPARATOR
= 265,
95 TOKEN_ASSIGNATOR
= 272,
99 TOKEN_ONCHILDREN
= 276,
105 TOKEN_INCRDECR
= 282,
114 #define TOKEN_ELSE 259
115 #define TOKEN_WHILE 260
116 #define TOKEN_PRINT 261
117 #define TOKEN_LOG 262
118 #define TOKEN_CASE 263
119 #define TOKEN_POINT 264
120 #define TOKEN_SEPARATOR 265
127 #define TOKEN_ASSIGNATOR 272
128 #define TOKEN_SWITCH 273
129 #define TOKEN_RAND 274
130 #define TOKEN_NUMBER 275
131 #define TOKEN_ONCHILDREN 276
132 #define TOKEN_CHAIN 277
133 #define TOKEN_NAME 278
134 #define TOKEN_STRNAME 279
135 #define TOKEN_CTXNAME 280
136 #define TOKEN_LOGIC 281
137 #define TOKEN_INCRDECR 282
138 #define TOKEN_ADD 283
139 #define TOKEN_SUB 284
140 #define TOKEN_COMP 285
141 #define TOKEN_ASSIGN 286
142 #define TOKEN_FACTOR 287
147 /* Copy the first part of user declarations. */
148 #line 1 "ai_service/script_parser.yacc"
152 #include "script_compiler.h"
156 using namespace NLMISC
;
157 using namespace AIVM
;
158 using namespace AICOMP
;
160 // Define this to output verbose debug parsing info
161 //#define AI_COMP_DEBUG
163 extern int aierrorline (const char *s
, int);
164 extern int aierror (const char *s
);
166 extern int aiparse ();
167 extern void addSignature (char *dest
, char *src
);
168 extern int aiErrorCount
;
170 extern char aiFile
[512];
171 extern const char *aiInputScript
;
172 extern uint aiInputScriptLength
;
173 extern void aiClean ();
174 extern int aidebug
; /* nonzero means print parse trace */
175 #define fprintf myfprintf
176 int myfprintf (FILE *file
, const char *format
, ...)
180 va_start( args
, format
);
184 result
= vsnprintf(buffer
, 1024, format
, args
);
189 result
= vfprintf (file
, format
, args
);
195 std::vector
<size_t> *aiRoot
;
196 string aiErrorMessage
;
199 bool aiCompile (std::vector
<size_t> &dest
, const char *script
, const char *scriptName
, bool win32Report
= false)
203 #else // AI_COMP_DEBUG
205 #endif // AI_COMP_DEBUG
208 aiInputScript
= script
;
209 aiInputScriptLength
= strlen (script
);
210 strcpy (aiFile
, scriptName
);
213 nldebug("script compilation of %s", scriptName
);
214 aiErrorMessage
= toString ("script compilation of %s\n", scriptName
);
216 bool error
= err
|| aiErrorCount
;
219 nlwarning ("compilation failed for %s - %d error(s)", scriptName
, aiErrorCount
);
220 aiErrorMessage
+= toString ("compilation failed for %s - %d error(s)\n", scriptName
, aiErrorCount
);
225 nldebug ("compilation success. (code size %d)", aiRoot
->size()*4);
226 aiErrorMessage
+= toString ("compilation success. (code size %d)\n", aiRoot
->size()*4);
232 MessageBoxA (NULL
, aiErrorMessage
.c_str (), "AI Script Compiler", MB_OK
|(error
?MB_ICONEXCLAMATION
:MB_ICONINFORMATION
));
233 #endif // NL_OS_WINDOWS
240 /* The parsing tree is composed of different types of node:
241 - Opcode for terminal opcode node
242 - ByteCode for a bunch of code node
243 - ByteCodeList for bunch of code when maintening substructure is important (for rand)
244 - Case for storing case index and code
245 - Cases for storing list of case
247 Opcode, ByteCode and ByteCodeList can be appended to a ByteCode node.
251 vector
<vector
<size_t> *> NodeToClear
;
252 vector
<list
<vector
<size_t> *> *> ListToClear
;
253 vector
<CCase
*> CaseToClear
;
254 vector
<map
<size_t, CCase
*> *> SwitchToClear
;
259 for (i
=0; i
<NodeToClear
.size (); i
++)
260 delete NodeToClear
[i
];
261 for (i
=0; i
<SwitchToClear
.size (); i
++)
262 delete SwitchToClear
[i
];
263 for (i
=0; i
<CaseToClear
.size (); i
++)
264 delete CaseToClear
[i
];
265 for (i
=0; i
<ListToClear
.size (); i
++)
266 delete ListToClear
[i
];
267 NodeToClear
.clear ();
268 ListToClear
.clear ();
269 CaseToClear
.clear ();
270 SwitchToClear
.clear ();
273 void aiOutputError(int line
, const char *format
, ...)
277 va_start (args
, format
);
279 vsnprintf (buffer
, sizeof (buffer
), format
, args
);
281 nlwarning ("%s(%d):%s", aiFile
, line
, buffer
);
282 aiErrorMessage
+= toString ("%s(%d):%s\n", aiFile
, line
, buffer
);
287 void createNode (CByteCodeYacc
&dest
)
289 dest
.ByteCode
= new vector
<size_t>;
290 dest
.Signature
[0] = 0;
291 NodeToClear
.push_back (dest
.ByteCode
);
294 void addNode (CByteCodeYacc
&dest
, size_t src
)
296 dest
.ByteCode
->push_back (src
);
299 void addNode (CByteCodeYacc
&dest
, const AICOMP::COpcodeYacc
&src
)
301 dest
.ByteCode
->push_back (src
.Opcode
);
304 void addNode (CByteCodeYacc
&dest
, const CByteCodeYacc
&src
)
306 dest
.ByteCode
->insert (dest
.ByteCode
->end(), src
.ByteCode
->begin (), src
.ByteCode
->end ());
309 void addNode (CByteCodeYacc
&dest
, const CByteCodeListYacc
&src
)
311 list
<vector
<size_t> * >::iterator ite
= src
.ByteCodeList
->begin();
312 while (ite
!= src
.ByteCodeList
->end())
314 dest
.ByteCode
->insert (dest
.ByteCode
->end(), (*ite
)->begin (), (*ite
)->end ());
321 void createList (CByteCodeListYacc
&dest
)
323 dest
.ByteCodeList
= new list
<vector
<size_t> *>;
324 dest
.Signature
[0] = 0;
325 ListToClear
.push_back (dest
.ByteCodeList
);
328 void addNode (CByteCodeListYacc
&dest
, const CByteCodeYacc
&src
)
330 dest
.ByteCodeList
->push_back (src
.ByteCode
);
333 // Returns the size of the children bytecode
334 uint
getChildrenByteCodeSize (const list
<vector
<size_t> * > *l
)
337 list
<vector
<size_t> * >::const_iterator ite
= l
->begin();
338 while (ite
!= l
->end())
340 size
+= (*ite
)->size ();
348 void createCase (CCaseYacc
&dest
, COpcodeYacc
&_case
, CByteCodeYacc
&byteCode
)
350 dest
.Case
= new CCase
;
351 dest
.Case
->Case
= _case
.Opcode
;
352 dest
.Case
->ByteCode
= byteCode
.ByteCode
;
353 dest
.Case
->Line
= _case
.Line
;
354 strcpy (dest
.Signature
, _case
.Signature
);
355 strcpy (dest
.Case
->Signature
, _case
.Signature
);
356 CaseToClear
.push_back (dest
.Case
);
361 void createSwitch (CSwitchYacc
&dest
)
363 dest
.Cases
= new map
<size_t, CCase
*>;
364 dest
.Signature
[0] = 0;
365 SwitchToClear
.push_back (dest
.Cases
);
368 void addNode (CSwitchYacc
&dest
, CCase
*src
)
370 dest
.Cases
->insert (map
<size_t, CCase
*>::value_type (src
->Case
, src
));
373 // Returns the size of the children bytecode
374 uint
getChildrenByteCodeSize (const map
<size_t, CCase
*> *l
)
377 map
<size_t, CCase
*>::const_iterator ite
= l
->begin ();
378 while (ite
!= l
->end ())
380 size
+= ite
->second
->ByteCode
->size();
386 // Write native function code
387 void nativeFunc (CByteCodeYacc
&dest
, size_t name
, const char *in
, const char *out
)
389 string funcName
= CStringMapper::unmap ((TStringId
)name
);
390 string inParamsSig
= in
;
391 string outParamsSig
= out
;
393 // Get the native function
394 CScriptNativeFuncParams
*funcParam
=CCompiler::getNativeFunc(funcName
, inParamsSig
, outParamsSig
);
397 string signature
= funcName
+ "_" + inParamsSig
+ "_" + outParamsSig
;
398 aiOutputError (aiLine
, "Unknown function name or bad parameters %s", signature
.c_str ());
404 mode
|= 1; // :KLUDGE: Hardcoded 1 :TODO: replace with a named constant
408 inStrId
= CStringMapper::map(inParamsSig
);
409 outStrId
= CStringMapper::map(outParamsSig
);
412 addNode (dest
, CScriptVM::NATIVE_CALL
);
413 addNode (dest
, name
);
414 addNode (dest
, mode
);
415 addNode (dest
, *((size_t*)&inStrId
));
416 addNode (dest
, *((size_t*)&outStrId
));
420 #define NODE0(dest) createNode (dest);
421 #define NODE1(dest,a) createNode (dest); addNode (dest, a);
422 #define NODE2(dest,a,b) createNode (dest); addNode (dest, a); addNode (dest, b);
423 #define NODE3(dest,a,b,c) createNode (dest); addNode (dest, a); addNode (dest, b); addNode (dest, c);
424 #define NODE4(dest,a,b,c,d) createNode (dest); addNode (dest, a); addNode (dest, b); addNode (dest, c); addNode (dest, d);
425 #define NODE5(dest,a,b,c,d,e) createNode (dest); addNode (dest, a); addNode (dest, b); addNode (dest, c); addNode (dest, d); addNode (dest, e);
426 #define NODE6(dest,a,b,c,d,e,f) createNode (dest); addNode (dest, a); addNode (dest, b); addNode (dest, c); addNode (dest, d); addNode (dest, e); addNode (dest, f);
427 #define NODE7(dest,a,b,c,d,e,f,g) createNode (dest); addNode (dest, a); addNode (dest, b); addNode (dest, c); addNode (dest, d); addNode (dest, e); addNode (dest, f); addNode (dest, g);
428 #define NODE8(dest,a,b,c,d,e,f,g,h) createNode (dest); addNode (dest, a); addNode (dest, b); addNode (dest, c); addNode (dest, d); addNode (dest, e); addNode (dest, f); addNode (dest, g); addNode (dest, h);
430 #define TYPEF(dest) dest.Signature[0] = 'f'; dest.Signature[1] = 0;
431 #define TYPEL(dest) dest.Signature[0] = 'l'; dest.Signature[1] = 0;
432 #define TYPES(dest) dest.Signature[0] = 's'; dest.Signature[1] = 0;
433 #define TYPEC(dest) dest.Signature[0] = 'c'; dest.Signature[1] = 0;
434 #define TYPE1(dest,a) strcpy (dest.Signature, a.Signature);
435 #define TYPE2(dest,a,b) strcpy (dest.Signature, a.Signature); addSignature (dest.Signature, b.Signature);
437 #define ERROR_DETECTED(a,b) NODE0 (a); aiOutputError (aiLine, b)
441 /* Enabling traces. */
446 /* Enabling verbose error messages. */
447 #ifdef YYERROR_VERBOSE
448 # undef YYERROR_VERBOSE
449 # define YYERROR_VERBOSE 1
451 # define YYERROR_VERBOSE 0
454 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
455 #line 295 "ai_service/script_parser.yacc"
456 typedef union YYSTYPE
{
457 AICOMP::COpcodeYacc Opcode
;
458 AICOMP::COperatorYacc Operator
;
459 AICOMP::CByteCodeYacc ByteCode
;
460 AICOMP::CByteCodeListYacc ByteCodeList
;
461 AICOMP::CCaseYacc Case
;
462 AICOMP::CSwitchYacc Switch
;
465 /* Line 191 of yacc.c. */
466 #line 450 "ai_service/script_parser_yacc.cpp"
467 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
468 # define YYSTYPE_IS_DECLARED 1
469 # define YYSTYPE_IS_TRIVIAL 1
474 /* Copy the second part of user declarations. */
477 /* Line 214 of yacc.c. */
478 #line 462 "ai_service/script_parser_yacc.cpp"
480 #if ! defined (yyoverflow) || YYERROR_VERBOSE
482 /* The parser invokes alloca or malloc; define the necessary symbols. */
484 # if YYSTACK_USE_ALLOCA
485 # define YYSTACK_ALLOC alloca
487 # ifndef YYSTACK_USE_ALLOCA
488 # if defined (alloca) || defined (_ALLOCA_H)
489 # define YYSTACK_ALLOC alloca
492 # define YYSTACK_ALLOC __builtin_alloca
498 # ifdef YYSTACK_ALLOC
499 /* Pacify GCC's `empty if-body' warning. */
500 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
502 # if defined (__STDC__) || defined (__cplusplus)
503 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
504 # define YYSIZE_T size_t
506 # define YYSTACK_ALLOC malloc
507 # define YYSTACK_FREE free
509 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
512 #if (! defined (yyoverflow) \
513 && (! defined (__cplusplus) \
514 || (YYSTYPE_IS_TRIVIAL)))
516 /* A type that is properly aligned for any stack member. */
523 /* The size of the maximum gap between one aligned stack and the next. */
524 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
526 /* The size of an array large to enough to hold all stacks, each with
528 # define YYSTACK_BYTES(N) \
529 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
530 + YYSTACK_GAP_MAXIMUM)
532 /* Copy COUNT objects from FROM to TO. The source and destination do
536 # define YYCOPY(To, From, Count) \
537 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
539 # define YYCOPY(To, From, Count) \
542 register YYSIZE_T yyi; \
543 for (yyi = 0; yyi < (Count); yyi++) \
544 (To)[yyi] = (From)[yyi]; \
550 /* Relocate STACK from its old location to the new one. The
551 local variables YYSIZE and YYSTACKSIZE give the old and new number of
552 elements in the stack, and YYPTR gives the new location of the
553 stack. Advance YYPTR to a properly aligned location for the next
555 # define YYSTACK_RELOCATE(Stack) \
558 YYSIZE_T yynewbytes; \
559 YYCOPY (&yyptr->Stack, Stack, yysize); \
560 Stack = &yyptr->Stack; \
561 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
562 yyptr += yynewbytes / sizeof (*yyptr); \
568 #if defined (__STDC__) || defined (__cplusplus)
569 typedef signed char yysigned_char
;
571 typedef short yysigned_char
;
574 /* YYFINAL -- State number of the termination state. */
576 /* YYLAST -- Last index in YYTABLE. */
579 /* YYNTOKENS -- Number of terminals. */
581 /* YYNNTS -- Number of nonterminals. */
583 /* YYNRULES -- Number of rules. */
585 /* YYNRULES -- Number of states. */
586 #define YYNSTATES 227
588 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
590 #define YYMAXUTOK 287
592 #define YYTRANSLATE(YYX) \
593 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
595 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
596 static const unsigned char yytranslate
[] =
598 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
599 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
600 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
601 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
602 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
603 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
604 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
605 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
606 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
607 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
608 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
609 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
610 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
611 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
612 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
613 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
614 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
615 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
616 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
617 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
618 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
619 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
620 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
621 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
622 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
623 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
624 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
625 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
626 25, 26, 27, 28, 29, 30, 31, 32
630 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
632 static const unsigned short yyprhs
[] =
634 0, 0, 3, 5, 9, 13, 17, 21, 25, 29,
635 33, 35, 40, 46, 49, 52, 54, 57, 61, 64,
636 67, 72, 76, 80, 84, 89, 93, 98, 102, 107,
637 111, 115, 117, 121, 124, 126, 128, 130, 133, 135,
638 138, 140, 143, 145, 147, 149, 152, 154, 157, 159,
639 162, 166, 169, 171, 175, 178, 181, 185, 190, 195,
640 199, 201, 205, 207, 211, 213, 218, 223, 225, 227,
641 233, 238, 243, 251, 258, 265, 271, 276, 281, 289,
642 296, 303, 309, 314, 319, 322, 325, 328, 330, 333,
643 336, 339, 342, 344, 346, 348, 352, 356, 361, 366,
644 371, 377, 383, 389, 396, 403, 405, 408, 410, 413,
645 416, 418, 420, 425, 427, 430, 438, 445, 452, 459,
649 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
650 static const yysigned_char yyrhs
[] =
652 34, 0, -1, 60, -1, 35, 26, 35, -1, 13,
653 35, 15, -1, 36, 30, 36, -1, 36, 28, 36,
654 -1, 36, 29, 36, -1, 36, 32, 36, -1, 13,
655 36, 15, -1, 49, -1, 23, 13, 15, 66, -1,
656 23, 13, 15, 14, 16, -1, 23, 9, -1, 25,
657 9, -1, 37, -1, 38, 37, -1, 23, 13, 15,
658 -1, 23, 13, -1, 23, 15, -1, 38, 23, 13,
659 15, -1, 38, 23, 13, -1, 38, 23, 15, -1,
660 47, 23, 52, -1, 47, 38, 23, 52, -1, 23,
661 13, 15, -1, 38, 23, 13, 15, -1, 23, 13,
662 15, -1, 38, 23, 13, 15, -1, 44, 17, 43,
663 -1, 46, 10, 50, -1, 50, -1, 13, 46, 15,
664 -1, 13, 15, -1, 50, -1, 47, -1, 23, -1,
665 38, 23, -1, 24, -1, 38, 24, -1, 25, -1,
666 38, 25, -1, 22, -1, 20, -1, 23, -1, 38,
667 23, -1, 24, -1, 38, 24, -1, 25, -1, 38,
668 25, -1, 51, 10, 36, -1, 51, 36, -1, 36,
669 -1, 13, 51, 15, -1, 13, 51, -1, 13, 15,
670 -1, 48, 17, 36, -1, 48, 17, 13, 36, -1,
671 48, 17, 36, 15, -1, 54, 10, 22, -1, 22,
672 -1, 54, 10, 23, -1, 23, -1, 54, 10, 24,
673 -1, 24, -1, 6, 13, 54, 15, -1, 7, 13,
674 54, 15, -1, 58, -1, 59, -1, 3, 13, 35,
675 15, 57, -1, 3, 13, 35, 57, -1, 3, 35,
676 15, 57, -1, 3, 13, 35, 15, 59, 4, 58,
677 -1, 3, 13, 35, 59, 4, 58, -1, 3, 35,
678 15, 59, 4, 58, -1, 5, 13, 35, 15, 58,
679 -1, 5, 13, 35, 58, -1, 5, 35, 15, 58,
680 -1, 3, 13, 35, 15, 59, 4, 59, -1, 3,
681 13, 35, 59, 4, 59, -1, 3, 35, 15, 59,
682 4, 59, -1, 5, 13, 35, 15, 59, -1, 5,
683 13, 35, 59, -1, 5, 35, 15, 59, -1, 53,
684 11, -1, 55, 11, -1, 56, 11, -1, 39, -1,
685 40, 11, -1, 45, 11, -1, 41, 11, -1, 42,
686 11, -1, 61, -1, 67, -1, 65, -1, 23, 27,
687 11, -1, 27, 23, 11, -1, 38, 23, 27, 11,
688 -1, 27, 38, 23, 11, -1, 23, 31, 36, 11,
689 -1, 23, 31, 13, 36, 11, -1, 23, 31, 36,
690 15, 11, -1, 38, 23, 31, 36, 11, -1, 38,
691 23, 31, 13, 36, 11, -1, 38, 23, 31, 36,
692 15, 11, -1, 66, -1, 1, 11, -1, 57, -1,
693 60, 57, -1, 19, 66, -1, 22, -1, 20, -1,
694 8, 62, 12, 57, -1, 63, -1, 64, 63, -1,
695 18, 13, 36, 15, 14, 64, 16, -1, 18, 13,
696 36, 14, 64, 16, -1, 18, 36, 15, 14, 64,
697 16, -1, 18, 13, 36, 15, 64, 16, -1, 14,
698 60, 16, -1, 21, 13, 15, 66, -1
701 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
702 static const unsigned short yyrline
[] =
704 0, 360, 360, 362, 363, 364, 371, 375, 381, 387,
705 388, 390, 398, 404, 405, 407, 409, 411, 412, 413,
706 415, 417, 419, 422, 437, 445, 447, 449, 451, 453,
707 455, 456, 458, 459, 461, 462, 464, 474, 479, 489,
708 494, 504, 509, 514, 520, 522, 523, 525, 526, 528,
709 530, 531, 532, 534, 535, 536, 538, 543, 544, 546,
710 547, 548, 549, 550, 551, 553, 555, 557, 558, 560,
711 565, 566, 567, 573, 574, 575, 581, 582, 584, 590,
712 591, 592, 598, 599, 600, 601, 602, 603, 604, 605,
713 606, 607, 608, 609, 610, 611, 612, 614, 616, 617,
714 618, 619, 621, 623, 625, 626, 627, 629, 630, 632,
715 680, 681, 683, 688, 694, 700, 753, 754, 755, 758,
720 #if YYDEBUG || YYERROR_VERBOSE
721 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
722 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
723 static const char *const yytname
[] =
725 "$end", "error", "$undefined", "TOKEN_IF", "TOKEN_ELSE", "TOKEN_WHILE",
726 "TOKEN_PRINT", "TOKEN_LOG", "TOKEN_CASE", "TOKEN_POINT",
727 "TOKEN_SEPARATOR", "TOKEN_PV", "TOKEN_PP", "TOKEN_LP", "TOKEN_LA",
728 "TOKEN_RP", "TOKEN_RA", "TOKEN_ASSIGNATOR", "TOKEN_SWITCH",
729 "TOKEN_RAND", "TOKEN_NUMBER", "TOKEN_ONCHILDREN", "TOKEN_CHAIN",
730 "TOKEN_NAME", "TOKEN_STRNAME", "TOKEN_CTXNAME", "TOKEN_LOGIC",
731 "TOKEN_INCRDECR", "TOKEN_ADD", "TOKEN_SUB", "TOKEN_COMP",
732 "TOKEN_ASSIGN", "TOKEN_FACTOR", "$accept", "script", "condition",
733 "expression", "setFunction", "context", "function", "call",
734 "nativeFunc", "nativeOtherFunc", "setFromFuncGet", "setFromFuncSet",
735 "setFromFunction", "tupleElem", "tuple", "lValue", "readVar",
736 "writeVar", "expressions", "params", "exp", "printContent",
737 "printString", "logString", "statement", "openStatement",
738 "closedStatement", "statements", "randEx", "caseIndex", "case", "cases",
739 "switch", "statementBlock", "onChildren", 0
744 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
746 static const unsigned short yytoknum
[] =
748 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
749 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
750 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
755 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
756 static const unsigned char yyr1
[] =
758 0, 33, 34, 35, 35, 35, 36, 36, 36, 36,
759 36, 37, 37, 38, 38, 39, 39, 40, 40, 40,
760 40, 40, 40, 41, 42, 43, 43, 44, 44, 45,
761 46, 46, 47, 47, 48, 48, 49, 49, 49, 49,
762 49, 49, 49, 49, 50, 50, 50, 50, 50, 50,
763 51, 51, 51, 52, 52, 52, 53, 53, 53, 54,
764 54, 54, 54, 54, 54, 55, 56, 57, 57, 58,
765 58, 58, 58, 58, 58, 58, 58, 58, 59, 59,
766 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
767 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
768 59, 59, 59, 59, 59, 59, 59, 60, 60, 61,
769 62, 62, 63, 64, 64, 65, 65, 65, 65, 66,
773 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
774 static const unsigned char yyr2
[] =
776 0, 2, 1, 3, 3, 3, 3, 3, 3, 3,
777 1, 4, 5, 2, 2, 1, 2, 3, 2, 2,
778 4, 3, 3, 3, 4, 3, 4, 3, 4, 3,
779 3, 1, 3, 2, 1, 1, 1, 2, 1, 2,
780 1, 2, 1, 1, 1, 2, 1, 2, 1, 2,
781 3, 2, 1, 3, 2, 2, 3, 4, 4, 3,
782 1, 3, 1, 3, 1, 4, 4, 1, 1, 5,
783 4, 4, 7, 6, 6, 5, 4, 4, 7, 6,
784 6, 5, 4, 4, 2, 2, 2, 1, 2, 2,
785 2, 2, 1, 1, 1, 3, 3, 4, 4, 4,
786 5, 5, 5, 6, 6, 1, 2, 1, 2, 2,
787 1, 1, 4, 1, 2, 7, 6, 6, 6, 3,
791 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
792 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
793 means the default is an error. */
794 static const unsigned char yydefact
[] =
796 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
797 0, 44, 46, 48, 0, 0, 15, 0, 87, 0,
798 0, 0, 0, 0, 35, 0, 34, 0, 0, 0,
799 107, 67, 68, 0, 92, 94, 105, 93, 106, 0,
800 43, 42, 36, 38, 40, 0, 0, 0, 10, 0,
801 0, 0, 0, 33, 44, 0, 0, 31, 0, 0,
802 0, 109, 0, 13, 18, 19, 0, 0, 14, 0,
803 0, 0, 1, 45, 47, 49, 16, 88, 90, 91,
804 0, 89, 0, 0, 0, 84, 85, 86, 108, 0,
805 0, 0, 0, 0, 0, 0, 0, 0, 37, 39,
806 41, 0, 0, 60, 62, 64, 0, 0, 45, 0,
807 32, 119, 0, 0, 0, 0, 17, 95, 0, 0,
808 96, 0, 21, 22, 0, 0, 0, 0, 29, 0,
809 23, 0, 0, 56, 0, 0, 70, 68, 9, 71,
810 68, 3, 6, 7, 5, 8, 0, 76, 82, 77,
811 83, 0, 65, 66, 30, 0, 0, 9, 0, 120,
812 0, 11, 0, 99, 0, 98, 20, 97, 0, 0,
813 0, 0, 55, 52, 54, 24, 57, 58, 4, 69,
814 68, 0, 0, 75, 81, 59, 61, 63, 0, 113,
815 0, 0, 0, 0, 12, 100, 101, 0, 102, 0,
816 25, 0, 0, 53, 51, 0, 73, 79, 74, 80,
817 111, 110, 0, 116, 114, 0, 118, 117, 103, 104,
818 26, 50, 72, 78, 0, 115, 112
821 /* YYDEFGOTO[NTERM-NUM]. */
822 static const short yydefgoto
[] =
824 -1, 15, 45, 46, 16, 47, 18, 19, 20, 21,
825 128, 22, 23, 56, 24, 25, 48, 26, 174, 130,
826 27, 106, 28, 29, 30, 31, 32, 58, 34, 212,
830 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
832 #define YYPACT_NINF -176
833 static const short yypact
[] =
835 311, 5, 346, 352, 32, 54, 60, 311, 360, 18,
836 61, 37, -176, 10, 141, 77, -176, 246, -176, 82,
837 83, 92, 102, 111, 184, 130, -176, 137, 163, 173,
838 -176, -176, -176, 138, -176, -176, -176, -176, -176, 366,
839 -176, -176, 179, -176, 10, -13, 187, 271, -176, 366,
840 -4, 297, 297, -176, 179, 325, 19, -176, 261, 374,
841 50, -176, 177, -176, 185, -176, 190, 380, -176, 227,
842 10, 188, -176, 8, -176, -176, -176, -176, -176, -176,
843 240, -176, 91, 195, 388, -176, -176, -176, -176, 366,
844 172, 96, 311, 366, 374, 374, 374, 374, -176, -176,
845 -176, 207, 311, -176, -176, -176, 108, 127, -176, 397,
846 -176, -176, 374, 140, 209, 18, 166, -176, 374, 15,
847 -176, 216, 229, -176, 239, 394, 158, 222, -176, 338,
848 -176, 243, 374, 174, 16, 234, -176, 268, -176, -176,
849 269, -176, 249, 249, 101, -176, 234, -176, -176, -176,
850 -176, 401, -176, -176, -176, 214, 275, 40, 275, -176,
851 286, -176, 44, -176, 279, -176, 237, -176, 374, 121,
852 282, 285, -176, 101, 332, -176, 214, -176, -176, -176,
853 299, 311, 311, -176, -176, -176, -176, -176, 256, -176,
854 41, 275, 55, 79, -176, -176, -176, 312, -176, 290,
855 -176, 291, 374, -176, 101, 311, -176, -176, -176, -176,
856 -176, -176, 296, -176, -176, 105, -176, -176, -176, -176,
857 -176, 101, -176, -176, 311, -176, -176
860 /* YYPGOTO[NTERM-NUM]. */
861 static const short yypgoto
[] =
863 -176, -176, 17, 2, 298, 0, -176, -176, -176, -176,
864 -176, -176, -176, -176, -176, -176, -176, 6, -176, 191,
865 -176, 274, -176, -176, -30, -93, -65, 328, -176, -176,
866 -175, -153, -176, -8, -176
869 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
870 positive, shift that token. If negative, reduce the rule which
871 number is the opposite. If zero, do what YYDEFACT says.
872 If YYTABLE_NINF, syntax error. */
873 #define YYTABLE_NINF -29
874 static const short yytable
[] =
876 17, 61, 92, 88, 192, 193, 55, 17, 147, 149,
877 60, 102, 57, 93, 71, 214, 38, 214, 214, 68,
878 50, 122, 93, 123, 83, 137, 163, 140, 88, 109,
879 164, 178, 7, 17, 110, 124, 148, 150, 215, 125,
880 214, 91, 93, 94, 95, 51, 63, 97, 188, 188,
881 64, 91, 65, 183, 191, 195, 90, 213, 17, 138,
882 136, 113, 139, 188, 66, 114, 101, 52, 67, 119,
883 180, 216, 94, 95, 62, 53, 97, 72, 94, 95,
884 127, 184, 97, 54, 12, 13, 133, 188, 206, 208,
885 17, 91, 17, 77, 78, 217, 142, 143, 144, 145,
886 63, 17, 17, 79, 129, 179, 134, 159, 161, 55,
887 141, 138, 222, 188, 155, 154, 207, 209, 151, 80,
888 162, 225, 81, 152, 94, 95, 96, 169, 97, 94,
889 95, 173, 198, 97, 176, 17, 199, 151, -2, 1,
890 223, 2, 153, 3, 4, 5, 17, 84, 85, 94,
891 95, 6, 7, 97, 156, 157, 8, 9, 161, 10,
892 17, 11, 12, 13, 69, 14, 70, 63, 94, 95,
893 197, 170, 97, 1, 86, 2, 204, 3, 4, 5,
894 160, 17, 17, -27, 87, 6, 7, 135, 63, 177,
895 8, 9, 115, 10, 226, 11, 12, 13, 93, 14,
896 116, 117, 94, 95, 221, 17, 97, 82, 1, 70,
897 2, 121, 3, 4, 5, 94, 95, 96, 131, 97,
898 6, 7, 146, 158, 17, 8, 9, 165, 10, 138,
899 11, 12, 13, 93, 14, 1, 63, 2, 120, 3,
900 4, 5, 94, 95, 166, 171, 97, 6, 7, -4,
901 167, 160, 8, 9, -28, 10, 129, 11, 12, 13,
902 -4, 14, 1, 126, 2, 70, 3, 4, 5, 73,
903 74, 75, 181, 182, 6, 7, 210, 111, 211, 8,
904 9, 97, 10, 188, 11, 12, 13, 1, 14, 2,
905 196, 3, 4, 5, 98, 99, 100, 200, 201, 6,
906 7, 219, 194, 205, 8, 9, 220, 10, 224, 11,
907 12, 13, 1, 14, 2, 76, 3, 4, 5, 103,
908 104, 105, 175, 218, 6, 7, 107, 138, 33, 8,
909 9, 0, 10, 0, 11, 12, 13, 0, 14, 0,
910 94, 95, 202, 0, 97, 112, 0, 203, 108, 74,
911 75, 112, 40, 172, 41, 42, 43, 44, 40, 39,
912 41, 42, 43, 44, 0, 49, 40, 0, 41, 42,
913 43, 44, 40, 59, 41, 42, 43, 44, 0, 89,
914 40, 0, 41, 42, 43, 44, 40, 112, 41, 42,
915 43, 44, 0, 118, 40, 0, 41, 42, 43, 44,
916 40, 132, 41, 42, 43, 44, 0, 168, 40, 0,
917 41, 42, 43, 44, 40, 0, 41, 42, 43, 44,
918 54, 12, 13, 185, 186, 187
921 static const short yycheck
[] =
923 0, 9, 15, 33, 157, 158, 6, 7, 101, 102,
924 8, 15, 6, 26, 14, 190, 11, 192, 193, 9,
925 3, 13, 26, 15, 24, 90, 11, 92, 58, 10,
926 15, 15, 14, 33, 15, 27, 101, 102, 191, 31,
927 215, 39, 26, 28, 29, 13, 9, 32, 8, 8,
928 13, 49, 15, 146, 14, 11, 39, 16, 58, 15,
929 90, 59, 92, 8, 27, 15, 49, 13, 31, 67,
930 135, 16, 28, 29, 13, 15, 32, 0, 28, 29,
931 80, 146, 32, 23, 24, 25, 84, 8, 181, 182,
932 90, 89, 92, 11, 11, 16, 94, 95, 96, 97,
933 9, 101, 102, 11, 13, 135, 89, 115, 116, 109,
934 93, 15, 205, 8, 112, 109, 181, 182, 10, 17,
935 118, 16, 11, 15, 28, 29, 30, 125, 32, 28,
936 29, 129, 11, 32, 132, 135, 15, 10, 0, 1,
937 205, 3, 15, 5, 6, 7, 146, 17, 11, 28,
938 29, 13, 14, 32, 14, 15, 18, 19, 166, 21,
939 160, 23, 24, 25, 23, 27, 25, 9, 28, 29,
940 168, 13, 32, 1, 11, 3, 174, 5, 6, 7,
941 14, 181, 182, 17, 11, 13, 14, 15, 9, 15,
942 18, 19, 15, 21, 224, 23, 24, 25, 26, 27,
943 15, 11, 28, 29, 202, 205, 32, 23, 1, 25,
944 3, 23, 5, 6, 7, 28, 29, 30, 23, 32,
945 13, 14, 15, 14, 224, 18, 19, 11, 21, 15,
946 23, 24, 25, 26, 27, 1, 9, 3, 11, 5,
947 6, 7, 28, 29, 15, 23, 32, 13, 14, 15,
948 11, 14, 18, 19, 17, 21, 13, 23, 24, 25,
949 26, 27, 1, 23, 3, 25, 5, 6, 7, 23,
950 24, 25, 4, 4, 13, 14, 20, 16, 22, 18,
951 19, 32, 21, 8, 23, 24, 25, 1, 27, 3,
952 11, 5, 6, 7, 23, 24, 25, 15, 13, 13,
953 14, 11, 16, 4, 18, 19, 15, 21, 12, 23,
954 24, 25, 1, 27, 3, 17, 5, 6, 7, 22,
955 23, 24, 131, 11, 13, 14, 52, 15, 0, 18,
956 19, -1, 21, -1, 23, 24, 25, -1, 27, -1,
957 28, 29, 10, -1, 32, 13, -1, 15, 23, 24,
958 25, 13, 20, 15, 22, 23, 24, 25, 20, 13,
959 22, 23, 24, 25, -1, 13, 20, -1, 22, 23,
960 24, 25, 20, 13, 22, 23, 24, 25, -1, 13,
961 20, -1, 22, 23, 24, 25, 20, 13, 22, 23,
962 24, 25, -1, 13, 20, -1, 22, 23, 24, 25,
963 20, 13, 22, 23, 24, 25, -1, 13, 20, -1,
964 22, 23, 24, 25, 20, -1, 22, 23, 24, 25,
965 23, 24, 25, 22, 23, 24
968 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
969 symbol of state STATE-NUM. */
970 static const unsigned char yystos
[] =
972 0, 1, 3, 5, 6, 7, 13, 14, 18, 19,
973 21, 23, 24, 25, 27, 34, 37, 38, 39, 40,
974 41, 42, 44, 45, 47, 48, 50, 53, 55, 56,
975 57, 58, 59, 60, 61, 65, 66, 67, 11, 13,
976 20, 22, 23, 24, 25, 35, 36, 38, 49, 13,
977 35, 13, 13, 15, 23, 38, 46, 50, 60, 13,
978 36, 66, 13, 9, 13, 15, 27, 31, 9, 23,
979 25, 38, 0, 23, 24, 25, 37, 11, 11, 11,
980 17, 11, 23, 38, 17, 11, 11, 11, 57, 13,
981 35, 36, 15, 26, 28, 29, 30, 32, 23, 24,
982 25, 35, 15, 22, 23, 24, 54, 54, 23, 10,
983 15, 16, 13, 36, 15, 15, 15, 11, 13, 36,
984 11, 23, 13, 15, 27, 31, 23, 38, 43, 13,
985 52, 23, 13, 36, 35, 15, 57, 59, 15, 57,
986 59, 35, 36, 36, 36, 36, 15, 58, 59, 58,
987 59, 10, 15, 15, 50, 36, 14, 15, 14, 66,
988 14, 66, 36, 11, 15, 11, 15, 11, 13, 36,
989 13, 23, 15, 36, 51, 52, 36, 15, 15, 57,
990 59, 4, 4, 58, 59, 22, 23, 24, 8, 63,
991 64, 14, 64, 64, 16, 11, 11, 36, 11, 15,
992 15, 13, 10, 15, 36, 4, 58, 59, 58, 59,
993 20, 22, 62, 16, 63, 64, 16, 16, 11, 11,
994 15, 36, 58, 59, 12, 16, 57
997 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
998 # define YYSIZE_T __SIZE_TYPE__
1000 #if ! defined (YYSIZE_T) && defined (size_t)
1001 # define YYSIZE_T size_t
1003 #if ! defined (YYSIZE_T)
1004 # if defined (__STDC__) || defined (__cplusplus)
1005 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1006 # define YYSIZE_T size_t
1009 #if ! defined (YYSIZE_T)
1010 # define YYSIZE_T unsigned int
1013 #define yyerrok (yyerrstatus = 0)
1014 #define yyclearin (yychar = YYEMPTY)
1015 #define YYEMPTY (-2)
1018 #define YYACCEPT goto yyacceptlab
1019 #define YYABORT goto yyabortlab
1020 #define YYERROR goto yyerrlab1
1022 /* Like YYERROR except do call yyerror. This remains here temporarily
1023 to ease the transition to the new meaning of YYERROR, for GCC.
1024 Once GCC version 2 has supplanted version 1, this can go. */
1026 #define YYFAIL goto yyerrlab
1028 #define YYRECOVERING() (!!yyerrstatus)
1030 #define YYBACKUP(Token, Value) \
1032 if (yychar == YYEMPTY && yylen == 1) \
1036 yytoken = YYTRANSLATE (yychar); \
1042 yyerror ("syntax error: cannot back up");\
1048 #define YYERRCODE 256
1050 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
1053 #ifndef YYLLOC_DEFAULT
1054 # define YYLLOC_DEFAULT(Current, Rhs, N) \
1055 Current.first_line = Rhs[1].first_line; \
1056 Current.first_column = Rhs[1].first_column; \
1057 Current.last_line = Rhs[N].last_line; \
1058 Current.last_column = Rhs[N].last_column;
1061 /* YYLEX -- calling `yylex' with the right arguments. */
1064 # define YYLEX yylex (YYLEX_PARAM)
1066 # define YYLEX yylex ()
1069 /* Enable debugging if requested. */
1073 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1074 # define YYFPRINTF fprintf
1077 # define YYDPRINTF(Args) \
1083 # define YYDSYMPRINT(Args) \
1089 # define YYDSYMPRINTF(Title, Token, Value, Location) \
1093 YYFPRINTF (stderr, "%s ", Title); \
1094 yysymprint (stderr, \
1096 YYFPRINTF (stderr, "\n"); \
1100 /*------------------------------------------------------------------.
1101 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1103 `------------------------------------------------------------------*/
1105 #if defined (__STDC__) || defined (__cplusplus)
1107 yy_stack_print (short *bottom
, short *top
)
1110 yy_stack_print (bottom
, top
)
1115 YYFPRINTF (stderr
, "Stack now");
1116 for (/* Nothing. */; bottom
<= top
; ++bottom
)
1117 YYFPRINTF (stderr
, " %d", *bottom
);
1118 YYFPRINTF (stderr
, "\n");
1121 # define YY_STACK_PRINT(Bottom, Top) \
1124 yy_stack_print ((Bottom), (Top)); \
1128 /*------------------------------------------------.
1129 | Report that the YYRULE is going to be reduced. |
1130 `------------------------------------------------*/
1132 #if defined (__STDC__) || defined (__cplusplus)
1134 yy_reduce_print (int yyrule
)
1137 yy_reduce_print (yyrule
)
1142 unsigned int yylineno
= yyrline
[yyrule
];
1143 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %u), ",
1144 yyrule
- 1, yylineno
);
1145 /* Print the symbols being reduced, and their result. */
1146 for (yyi
= yyprhs
[yyrule
]; 0 <= yyrhs
[yyi
]; yyi
++)
1147 YYFPRINTF (stderr
, "%s ", yytname
[yyrhs
[yyi
]]);
1148 YYFPRINTF (stderr
, "-> %s\n", yytname
[yyr1
[yyrule
]]);
1151 # define YY_REDUCE_PRINT(Rule) \
1154 yy_reduce_print (Rule); \
1157 /* Nonzero means print parse trace. It is left uninitialized so that
1158 multiple parsers can coexist. */
1160 #else /* !YYDEBUG */
1161 # define YYDPRINTF(Args)
1162 # define YYDSYMPRINT(Args)
1163 # define YYDSYMPRINTF(Title, Token, Value, Location)
1164 # define YY_STACK_PRINT(Bottom, Top)
1165 # define YY_REDUCE_PRINT(Rule)
1166 #endif /* !YYDEBUG */
1169 /* YYINITDEPTH -- initial size of the parser's stacks. */
1171 # define YYINITDEPTH 200
1174 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1175 if the built-in stack extension method is used).
1177 Do not make this value too large; the results are undefined if
1178 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
1179 evaluated with infinite-precision integer arithmetic. */
1186 # define YYMAXDEPTH 10000
1194 # if defined (__GLIBC__) && defined (_STRING_H)
1195 # define yystrlen strlen
1197 /* Return the length of YYSTR. */
1199 # if defined (__STDC__) || defined (__cplusplus)
1200 yystrlen (const char *yystr
)
1206 register const char *yys
= yystr
;
1208 while (*yys
++ != '\0')
1211 return yys
- yystr
- 1;
1217 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
1218 # define yystpcpy stpcpy
1220 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1223 # if defined (__STDC__) || defined (__cplusplus)
1224 yystpcpy (char *yydest
, const char *yysrc
)
1226 yystpcpy (yydest
, yysrc
)
1231 register char *yyd
= yydest
;
1232 register const char *yys
= yysrc
;
1234 while ((*yyd
++ = *yys
++) != '\0')
1242 #endif /* !YYERROR_VERBOSE */
1247 /*--------------------------------.
1248 | Print this symbol on YYOUTPUT. |
1249 `--------------------------------*/
1251 #if defined (__STDC__) || defined (__cplusplus)
1253 yysymprint (FILE *yyoutput
, int yytype
, YYSTYPE
*yyvaluep
)
1256 yysymprint (yyoutput
, yytype
, yyvaluep
)
1262 /* Pacify ``unused variable'' warnings. */
1265 if (yytype
< YYNTOKENS
)
1267 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
1269 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
1273 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
1280 YYFPRINTF (yyoutput
, ")");
1283 #endif /* ! YYDEBUG */
1284 /*-----------------------------------------------.
1285 | Release the memory associated to this symbol. |
1286 `-----------------------------------------------*/
1288 #if defined (__STDC__) || defined (__cplusplus)
1290 yydestruct (int yytype
, YYSTYPE
*yyvaluep
)
1293 yydestruct (yytype
, yyvaluep
)
1298 /* Pacify ``unused variable'' warnings. */
1310 /* Prevent warnings from -Wmissing-prototypes. */
1312 #ifdef YYPARSE_PARAM
1313 # if defined (__STDC__) || defined (__cplusplus)
1314 int yyparse (void *YYPARSE_PARAM
);
1318 #else /* ! YYPARSE_PARAM */
1319 #if defined (__STDC__) || defined (__cplusplus)
1324 #endif /* ! YYPARSE_PARAM */
1328 /* The lookahead symbol. */
1331 /* The semantic value of the lookahead symbol. */
1334 /* Number of syntax errors so far. */
1343 #ifdef YYPARSE_PARAM
1344 # if defined (__STDC__) || defined (__cplusplus)
1345 int yyparse (void *YYPARSE_PARAM
)
1347 int yyparse (YYPARSE_PARAM
)
1348 void *YYPARSE_PARAM
;
1350 #else /* ! YYPARSE_PARAM */
1351 #if defined (__STDC__) || defined (__cplusplus)
1362 register int yystate
;
1365 /* Number of tokens to shift before error messages enabled. */
1367 /* Lookahead token as an internal (translated) token number. */
1370 /* Three stacks and their tools:
1371 `yyss': related to states,
1372 `yyvs': related to semantic values,
1373 `yyls': related to locations.
1375 Refer to the stacks thru separate pointers, to allow yyoverflow
1376 to reallocate them elsewhere. */
1378 /* The state stack. */
1379 short yyssa
[YYINITDEPTH
];
1380 short *yyss
= yyssa
;
1381 register short *yyssp
;
1383 /* The semantic value stack. */
1384 YYSTYPE yyvsa
[YYINITDEPTH
];
1385 YYSTYPE
*yyvs
= yyvsa
;
1386 register YYSTYPE
*yyvsp
;
1390 #define YYPOPSTACK (yyvsp--, yyssp--)
1392 YYSIZE_T yystacksize
= YYINITDEPTH
;
1394 /* The variables used to return semantic value and location from the
1399 /* When reducing, the number of symbols on the RHS of the reduced
1403 YYDPRINTF ((stderr
, "Starting parse\n"));
1408 yychar
= YYEMPTY
; /* Cause a token to be read. */
1410 /* Initialize stack pointers.
1411 Waste one element of value and location stack
1412 so that they stay on the same level as the state stack.
1413 The wasted elements are never initialized. */
1420 /*------------------------------------------------------------.
1421 | yynewstate -- Push a new state, which is found in yystate. |
1422 `------------------------------------------------------------*/
1424 /* In all cases, when you get here, the value and location stacks
1425 have just been pushed. so pushing a state here evens the stacks.
1432 if (yyss
+ yystacksize
- 1 <= yyssp
)
1434 /* Get the current used size of the three stacks, in elements. */
1435 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1439 /* Give user a chance to reallocate the stack. Use copies of
1440 these so that the &'s don't force the real ones into
1442 YYSTYPE
*yyvs1
= yyvs
;
1443 short *yyss1
= yyss
;
1446 /* Each stack pointer address is followed by the size of the
1447 data in use in that stack, in bytes. This used to be a
1448 conditional around just the two extra args, but that might
1449 be undefined if yyoverflow is a macro. */
1450 yyoverflow ("parser stack overflow",
1451 &yyss1
, yysize
* sizeof (*yyssp
),
1452 &yyvs1
, yysize
* sizeof (*yyvsp
),
1459 #else /* no yyoverflow */
1460 # ifndef YYSTACK_RELOCATE
1463 /* Extend the stack our own way. */
1464 if (YYMAXDEPTH
<= yystacksize
)
1467 if (YYMAXDEPTH
< yystacksize
)
1468 yystacksize
= YYMAXDEPTH
;
1471 short *yyss1
= yyss
;
1472 union yyalloc
*yyptr
=
1473 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1476 YYSTACK_RELOCATE (yyss
);
1477 YYSTACK_RELOCATE (yyvs
);
1479 # undef YYSTACK_RELOCATE
1481 YYSTACK_FREE (yyss1
);
1484 #endif /* no yyoverflow */
1486 yyssp
= yyss
+ yysize
- 1;
1487 yyvsp
= yyvs
+ yysize
- 1;
1490 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1491 (unsigned long int) yystacksize
));
1493 if (yyss
+ yystacksize
- 1 <= yyssp
)
1497 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1506 /* Do appropriate processing given the current state. */
1507 /* Read a lookahead token if we need one and don't already have one. */
1510 /* First try to decide what to do without reference to lookahead token. */
1512 yyn
= yypact
[yystate
];
1513 if (yyn
== YYPACT_NINF
)
1516 /* Not known => get a lookahead token if don't already have one. */
1518 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1519 if (yychar
== YYEMPTY
)
1521 YYDPRINTF ((stderr
, "Reading a token: "));
1525 if (yychar
<= YYEOF
)
1527 yychar
= yytoken
= YYEOF
;
1528 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1532 yytoken
= YYTRANSLATE (yychar
);
1533 YYDSYMPRINTF ("Next token is", yytoken
, &yylval
, &yylloc
);
1536 /* If the proper action on seeing token YYTOKEN is to reduce or to
1537 detect an error, take that action. */
1539 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1544 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1553 /* Shift the lookahead token. */
1554 YYDPRINTF ((stderr
, "Shifting token %s, ", yytname
[yytoken
]));
1556 /* Discard the token being shifted unless it is eof. */
1557 if (yychar
!= YYEOF
)
1563 /* Count tokens shifted since error; after three, turn off error
1572 /*-----------------------------------------------------------.
1573 | yydefault -- do the default action for the current state. |
1574 `-----------------------------------------------------------*/
1576 yyn
= yydefact
[yystate
];
1582 /*-----------------------------.
1583 | yyreduce -- Do a reduction. |
1584 `-----------------------------*/
1586 /* yyn is the number of a rule to reduce with. */
1589 /* If YYLEN is nonzero, implement the default value of the action:
1592 Otherwise, the following line sets YYVAL to garbage.
1593 This behavior is undocumented and Bison
1594 users should not rely upon it. Assigning to YYVAL
1595 unconditionally makes the parser a bit smaller, and it avoids a
1596 GCC warning that YYVAL may be used uninitialized. */
1597 yyval
= yyvsp
[1-yylen
];
1600 YY_REDUCE_PRINT (yyn
);
1604 #line 360 "ai_service/script_parser.yacc"
1605 { NODE1 (yyval
.ByteCode
, yyvsp
[0].ByteCodeList
); aiRoot
= yyval
.ByteCode
.ByteCode
; ;}
1609 #line 362 "ai_service/script_parser.yacc"
1610 { NODE3 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, yyvsp
[0].ByteCode
, yyvsp
[-1].Opcode
); TYPEL (yyval
.ByteCode
); ;}
1614 #line 363 "ai_service/script_parser.yacc"
1615 { yyval
.ByteCode
= yyvsp
[-1].ByteCode
; ;}
1619 #line 365 "ai_service/script_parser.yacc"
1621 if (yyvsp
[-2].ByteCode
.getType () != yyvsp
[0].ByteCode
.getType ()) aiOutputError (aiLine
, "the left and right '%s' expressions have not the same type : left is a %s and right is a %s",
1622 yyvsp
[-1].Operator
.Operator
, yyvsp
[-2].ByteCode
.getType (), yyvsp
[0].ByteCode
.getType ());
1623 NODE3 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, yyvsp
[0].ByteCode
, yyvsp
[-1].Operator
); TYPEL (yyval
.ByteCode
);
1628 #line 372 "ai_service/script_parser.yacc"
1630 NODE3 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, yyvsp
[0].ByteCode
, yyvsp
[-1].Opcode
); TYPEF (yyval
.ByteCode
);
1635 #line 376 "ai_service/script_parser.yacc"
1637 if (!yyvsp
[-2].ByteCode
.isFloat ()) aiOutputError (aiLine
, "the left '-' expression must be a float but it is a %s", yyvsp
[-2].ByteCode
.getType ());
1638 if (!yyvsp
[0].ByteCode
.isFloat ()) aiOutputError (aiLine
, "the right '-' expression must be a float but it is a %s", yyvsp
[0].ByteCode
.getType ());
1639 NODE3 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, yyvsp
[0].ByteCode
, yyvsp
[-1].Opcode
); TYPEF (yyval
.ByteCode
);
1644 #line 382 "ai_service/script_parser.yacc"
1646 if (!yyvsp
[-2].ByteCode
.isFloat ()) aiOutputError (aiLine
, "the left '%s' expression must be a float but it is a %s", yyvsp
[-1].Operator
.Operator
, yyvsp
[-2].ByteCode
.getType ());
1647 if (!yyvsp
[0].ByteCode
.isFloat ()) aiOutputError (aiLine
, "the right '%s' expression must be a float but it is a %s", yyvsp
[-1].Operator
.Operator
, yyvsp
[0].ByteCode
.getType ());
1648 NODE3 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, yyvsp
[0].ByteCode
, yyvsp
[-1].Operator
); TYPEF (yyval
.ByteCode
);
1653 #line 387 "ai_service/script_parser.yacc"
1654 { yyval
.ByteCode
= yyvsp
[-1].ByteCode
; ;}
1658 #line 388 "ai_service/script_parser.yacc"
1659 { yyval
.ByteCode
= yyvsp
[0].ByteCode
; ;}
1663 #line 391 "ai_service/script_parser.yacc"
1665 // Get the size of the total byte code of statementBlock
1666 int sizeToJump
= (int)getChildrenByteCodeSize (yyvsp
[0].ByteCodeList
.ByteCodeList
);
1667 sizeToJump
++; // 1 jump offset
1668 sizeToJump
++; // 1 final EOP to escape
1669 NODE6 (yyval
.ByteCode
, CScriptVM::FUNCTION
, yyvsp
[-3].Opcode
, CScriptVM::JUMP
, sizeToJump
, yyvsp
[0].ByteCodeList
, CScriptVM::EOP
);
1674 #line 399 "ai_service/script_parser.yacc"
1676 int sizeToJump
= + 2; // 1 jump instruction and EOP to escape
1677 NODE5 (yyval
.ByteCode
, CScriptVM::FUNCTION
, yyvsp
[-4].Opcode
, CScriptVM::JUMP
, sizeToJump
, CScriptVM::EOP
);
1682 #line 404 "ai_service/script_parser.yacc"
1683 { NODE2 (yyval
.ByteCode
, CScriptVM::PUSH_GROUP
, yyvsp
[-1].Opcode
); ;}
1687 #line 405 "ai_service/script_parser.yacc"
1688 { NODE2 (yyval
.ByteCode
, CScriptVM::PUSH_CTX_VAR_VAL
, yyvsp
[-1].Opcode
); ;}
1692 #line 407 "ai_service/script_parser.yacc"
1693 { NODE2 (yyval
.ByteCode
, CScriptVM::PUSH_THIS
, yyvsp
[0].ByteCode
); ;}
1697 #line 409 "ai_service/script_parser.yacc"
1698 { NODE2 (yyval
.ByteCode
, yyvsp
[-1].ByteCode
, yyvsp
[0].ByteCode
); ;}
1702 #line 411 "ai_service/script_parser.yacc"
1703 { NODE3 (yyval
.ByteCode
, CScriptVM::PUSH_THIS
, CScriptVM::CALL
, yyvsp
[-2].Opcode
); ;}
1707 #line 412 "ai_service/script_parser.yacc"
1708 { ERROR_DETECTED (yyval
.ByteCode
, "missing ')' after the function name"); ;}
1712 #line 413 "ai_service/script_parser.yacc"
1713 { ERROR_DETECTED (yyval
.ByteCode
, "missing '(' after the function name"); ;}
1717 #line 415 "ai_service/script_parser.yacc"
1718 { NODE3 (yyval
.ByteCode
, yyvsp
[-3].ByteCode
, CScriptVM::CALL
, yyvsp
[-2].Opcode
); ;}
1722 #line 417 "ai_service/script_parser.yacc"
1723 { ERROR_DETECTED (yyval
.ByteCode
, "missing ')' after the function name"); ;}
1727 #line 419 "ai_service/script_parser.yacc"
1728 { ERROR_DETECTED (yyval
.ByteCode
, "missinga '(' after the function name"); ;}
1732 #line 423 "ai_service/script_parser.yacc"
1734 NODE2 (yyval
.ByteCode
, yyvsp
[0].ByteCode
, CScriptVM::PUSH_THIS
);
1735 nativeFunc (yyval
.ByteCode
, yyvsp
[-1].Opcode
.Opcode
, yyvsp
[0].ByteCode
.Signature
, yyvsp
[-2].ByteCode
.Signature
);
1736 addNode (yyval
.ByteCode
, yyvsp
[-2].ByteCode
);
1737 TYPE1 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
);
1742 #line 438 "ai_service/script_parser.yacc"
1744 NODE2 (yyval
.ByteCode
, yyvsp
[0].ByteCode
, yyvsp
[-2].ByteCode
);
1745 nativeFunc (yyval
.ByteCode
, yyvsp
[-1].Opcode
.Opcode
, yyvsp
[0].ByteCode
.Signature
, yyvsp
[-3].ByteCode
.Signature
);
1746 addNode (yyval
.ByteCode
, yyvsp
[-3].ByteCode
);
1747 TYPE1 (yyval
.ByteCode
, yyvsp
[-3].ByteCode
);
1752 #line 445 "ai_service/script_parser.yacc"
1753 { NODE3 (yyval
.ByteCode
, CScriptVM::PUSH_THIS
, CScriptVM::PUSH_STRING
, yyvsp
[-2].Opcode
); ;}
1757 #line 447 "ai_service/script_parser.yacc"
1758 { NODE3 (yyval
.ByteCode
, yyvsp
[-3].ByteCode
, CScriptVM::PUSH_STRING
, yyvsp
[-2].Opcode
); ;}
1762 #line 449 "ai_service/script_parser.yacc"
1763 { NODE3 (yyval
.ByteCode
, CScriptVM::PUSH_THIS
, CScriptVM::PUSH_STRING
, yyvsp
[-2].Opcode
); ;}
1767 #line 451 "ai_service/script_parser.yacc"
1768 { NODE3 (yyval
.ByteCode
, yyvsp
[-3].ByteCode
, CScriptVM::PUSH_STRING
, yyvsp
[-2].Opcode
); ;}
1772 #line 453 "ai_service/script_parser.yacc"
1773 { NODE3 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, yyvsp
[0].ByteCode
, CScriptVM::ASSIGN_FUNC_FROM
); ;}
1777 #line 455 "ai_service/script_parser.yacc"
1778 { NODE2 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, yyvsp
[0].ByteCode
); TYPE2 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, yyvsp
[0].ByteCode
); ;}
1782 #line 456 "ai_service/script_parser.yacc"
1783 { yyval
.ByteCode
= yyvsp
[0].ByteCode
; ;}
1787 #line 458 "ai_service/script_parser.yacc"
1788 { yyval
.ByteCode
= yyvsp
[-1].ByteCode
; ;}
1792 #line 459 "ai_service/script_parser.yacc"
1793 { NODE0 (yyval
.ByteCode
); ;}
1797 #line 461 "ai_service/script_parser.yacc"
1798 { yyval
.ByteCode
= yyvsp
[0].ByteCode
; ;}
1802 #line 462 "ai_service/script_parser.yacc"
1803 { yyval
.ByteCode
= yyvsp
[0].ByteCode
; ;}
1807 #line 465 "ai_service/script_parser.yacc"
1809 NODE2 (yyval
.ByteCode
, CScriptVM::PUSH_VAR_VAL
, yyvsp
[0].Opcode
);
1810 TYPEF (yyval
.ByteCode
);
1815 #line 475 "ai_service/script_parser.yacc"
1817 NODE3 (yyval
.ByteCode
, yyvsp
[-1].ByteCode
, CScriptVM::PUSH_CONTEXT_VAR_VAL
, yyvsp
[0].Opcode
);
1818 TYPEF (yyval
.ByteCode
);
1823 #line 480 "ai_service/script_parser.yacc"
1825 NODE2 (yyval
.ByteCode
, CScriptVM::PUSH_STR_VAR_VAL
, yyvsp
[0].Opcode
);
1826 TYPES (yyval
.ByteCode
);
1831 #line 490 "ai_service/script_parser.yacc"
1833 NODE3 (yyval
.ByteCode
, yyvsp
[-1].ByteCode
, CScriptVM::PUSH_CONTEXT_STR_VAR_VAL
, yyvsp
[0].Opcode
);
1834 TYPES (yyval
.ByteCode
);
1839 #line 495 "ai_service/script_parser.yacc"
1841 NODE2 (yyval
.ByteCode
, CScriptVM::PUSH_CTX_VAR_VAL
, yyvsp
[0].Opcode
);
1842 TYPEC (yyval
.ByteCode
);
1847 #line 505 "ai_service/script_parser.yacc"
1849 NODE3 (yyval
.ByteCode
, yyvsp
[-1].ByteCode
, CScriptVM::PUSH_CONTEXT_CTX_VAR_VAL
, yyvsp
[0].Opcode
);
1850 TYPEC (yyval
.ByteCode
);
1855 #line 510 "ai_service/script_parser.yacc"
1857 NODE2 (yyval
.ByteCode
, CScriptVM::PUSH_STRING
, yyvsp
[0].Opcode
);
1858 TYPES (yyval
.ByteCode
);
1863 #line 515 "ai_service/script_parser.yacc"
1865 NODE2 (yyval
.ByteCode
, CScriptVM::PUSH_ON_STACK
, yyvsp
[0].Opcode
);
1866 TYPEF (yyval
.ByteCode
);
1871 #line 520 "ai_service/script_parser.yacc"
1872 { NODE2 (yyval
.ByteCode
, CScriptVM::SET_VAR_VAL
, yyvsp
[0].Opcode
); TYPEF (yyval
.ByteCode
); ;}
1876 #line 522 "ai_service/script_parser.yacc"
1877 { NODE3 (yyval
.ByteCode
, yyvsp
[-1].ByteCode
, CScriptVM::SET_CONTEXT_VAR_VAL
, yyvsp
[0].Opcode
); TYPEF (yyval
.ByteCode
); ;}
1881 #line 523 "ai_service/script_parser.yacc"
1882 { NODE2 (yyval
.ByteCode
, CScriptVM::SET_STR_VAR_VAL
, yyvsp
[0].Opcode
); TYPES (yyval
.ByteCode
); ;}
1886 #line 525 "ai_service/script_parser.yacc"
1887 { NODE3 (yyval
.ByteCode
, yyvsp
[-1].ByteCode
, CScriptVM::SET_CONTEXT_STR_VAR_VAL
, yyvsp
[0].Opcode
); TYPES (yyval
.ByteCode
); ;}
1891 #line 526 "ai_service/script_parser.yacc"
1892 { NODE2 (yyval
.ByteCode
, CScriptVM::SET_CTX_VAR_VAL
, yyvsp
[0].Opcode
); TYPEC (yyval
.ByteCode
); ;}
1896 #line 528 "ai_service/script_parser.yacc"
1897 { NODE3 (yyval
.ByteCode
, yyvsp
[-1].ByteCode
, CScriptVM::SET_CONTEXT_CTX_VAR_VAL
, yyvsp
[0].Opcode
); TYPEC (yyval
.ByteCode
); ;}
1901 #line 530 "ai_service/script_parser.yacc"
1902 { NODE2 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, yyvsp
[0].ByteCode
); TYPE2 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, yyvsp
[0].ByteCode
); ;}
1906 #line 531 "ai_service/script_parser.yacc"
1907 { ERROR_DETECTED (yyval
.ByteCode
, "missing ',' between two expressions"); ;}
1911 #line 532 "ai_service/script_parser.yacc"
1912 { yyval
.ByteCode
= yyvsp
[0].ByteCode
; ;}
1916 #line 534 "ai_service/script_parser.yacc"
1917 { yyval
.ByteCode
= yyvsp
[-1].ByteCode
; ;}
1921 #line 535 "ai_service/script_parser.yacc"
1922 { ERROR_DETECTED (yyval
.ByteCode
, "missing ')' at the end of the parameters"); ;}
1926 #line 536 "ai_service/script_parser.yacc"
1927 { NODE0 (yyval
.ByteCode
); ;}
1931 #line 539 "ai_service/script_parser.yacc"
1933 // No need to check the types. All assignations are possibles.
1934 NODE2 (yyval
.ByteCode
, yyvsp
[0].ByteCode
, yyvsp
[-2].ByteCode
);
1939 #line 543 "ai_service/script_parser.yacc"
1940 { ERROR_DETECTED (yyval
.ByteCode
, "missing ')' at the end of the expression"); ;}
1944 #line 544 "ai_service/script_parser.yacc"
1945 { ERROR_DETECTED (yyval
.ByteCode
, "missing '(' at the beginning of the expression");;}
1949 #line 546 "ai_service/script_parser.yacc"
1950 { NODE3 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, CScriptVM::PUSH_PRINT_STRING
, yyvsp
[0].Opcode
); ;}
1954 #line 547 "ai_service/script_parser.yacc"
1955 { NODE2 (yyval
.ByteCode
, CScriptVM::PUSH_PRINT_STRING
, yyvsp
[0].Opcode
); ;}
1959 #line 548 "ai_service/script_parser.yacc"
1960 { NODE3 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, CScriptVM::PUSH_PRINT_VAR
, yyvsp
[0].Opcode
); ;}
1964 #line 549 "ai_service/script_parser.yacc"
1965 { NODE2 (yyval
.ByteCode
, CScriptVM::PUSH_PRINT_VAR
, yyvsp
[0].Opcode
); ;}
1969 #line 550 "ai_service/script_parser.yacc"
1970 { NODE3 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, CScriptVM::PUSH_PRINT_STR_VAR
, yyvsp
[0].Opcode
); ;}
1974 #line 551 "ai_service/script_parser.yacc"
1975 { NODE2 (yyval
.ByteCode
, CScriptVM::PUSH_PRINT_STR_VAR
, yyvsp
[0].Opcode
); ;}
1979 #line 553 "ai_service/script_parser.yacc"
1980 { NODE2 (yyval
.ByteCode
, yyvsp
[-1].ByteCode
, CScriptVM::PRINT_STRING
); ;}
1984 #line 555 "ai_service/script_parser.yacc"
1985 { NODE2 (yyval
.ByteCode
, yyvsp
[-1].ByteCode
, CScriptVM::LOG_STRING
); ;}
1989 #line 557 "ai_service/script_parser.yacc"
1990 { yyval
.ByteCode
= yyvsp
[0].ByteCode
; ;}
1994 #line 558 "ai_service/script_parser.yacc"
1995 { yyval
.ByteCode
= yyvsp
[0].ByteCode
; ;}
1999 #line 561 "ai_service/script_parser.yacc"
2001 int sizeToJump
= yyvsp
[0].ByteCode
.ByteCode
->size() + 1; // 1 jump instruction to escape
2002 NODE4 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, CScriptVM::JE
, sizeToJump
, yyvsp
[0].ByteCode
);
2007 #line 565 "ai_service/script_parser.yacc"
2008 {ERROR_DETECTED (yyval
.ByteCode
, "missing ')' at the end of the if condition");;}
2012 #line 566 "ai_service/script_parser.yacc"
2013 {ERROR_DETECTED (yyval
.ByteCode
, "missing '(' at the beginning of the if condition");;}
2017 #line 568 "ai_service/script_parser.yacc"
2019 int sizeToJump0
= yyvsp
[-2].ByteCode
.ByteCode
->size() + 3; // 2 jump instructions to escape
2020 int sizeToJump1
= yyvsp
[0].ByteCode
.ByteCode
->size() + 1; // 1 jump instruction to escape
2021 NODE7 (yyval
.ByteCode
, yyvsp
[-4].ByteCode
, CScriptVM::JE
, sizeToJump0
, yyvsp
[-2].ByteCode
, CScriptVM::JUMP
, sizeToJump1
, yyvsp
[0].ByteCode
);
2026 #line 573 "ai_service/script_parser.yacc"
2027 { ERROR_DETECTED (yyval
.ByteCode
, "missing ')' at the end of the if condition");;}
2031 #line 574 "ai_service/script_parser.yacc"
2032 { ERROR_DETECTED (yyval
.ByteCode
, "missing '(' at the beginning of the if condition");;}
2036 #line 576 "ai_service/script_parser.yacc"
2038 int sizeToJump0
= yyvsp
[0].ByteCode
.ByteCode
->size() + 3; // 2 jump instructions to escape
2039 int sizeToJump1
= -(int)yyvsp
[0].ByteCode
.ByteCode
->size() - 3 - (int)yyvsp
[-2].ByteCode
.ByteCode
->size(); // 1 jump instruction to escape
2040 NODE6 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, CScriptVM::JE
, sizeToJump0
, yyvsp
[0].ByteCode
, CScriptVM::JUMP
, sizeToJump1
);
2045 #line 581 "ai_service/script_parser.yacc"
2046 { ERROR_DETECTED (yyval
.ByteCode
, "missing ')' at the end of the while condition");;}
2050 #line 582 "ai_service/script_parser.yacc"
2051 { ERROR_DETECTED (yyval
.ByteCode
, "missing '(' at the beginning of the while condition");;}
2055 #line 585 "ai_service/script_parser.yacc"
2057 int sizeToJump0
= yyvsp
[-2].ByteCode
.ByteCode
->size() + 3; // 2 jump instructions to escape
2058 int sizeToJump1
= yyvsp
[0].ByteCode
.ByteCode
->size() + 1; // 1 jump instruction to escape
2059 NODE7 (yyval
.ByteCode
, yyvsp
[-4].ByteCode
, CScriptVM::JE
, sizeToJump0
, yyvsp
[-2].ByteCode
, CScriptVM::JUMP
, sizeToJump1
, yyvsp
[0].ByteCode
);
2064 #line 590 "ai_service/script_parser.yacc"
2065 { ERROR_DETECTED (yyval
.ByteCode
, "missing ')' at the end of the if condition");;}
2069 #line 591 "ai_service/script_parser.yacc"
2070 { ERROR_DETECTED (yyval
.ByteCode
, "missing '(' at the end of the if condition");;}
2074 #line 593 "ai_service/script_parser.yacc"
2076 int sizeToJump0
= yyvsp
[0].ByteCode
.ByteCode
->size() + 3; // 2 jump instructions to escape
2077 int sizeToJump1
= -(int)yyvsp
[0].ByteCode
.ByteCode
->size() - 3 - (int)yyvsp
[-2].ByteCode
.ByteCode
->size(); // 1 jump instruction to escape
2078 NODE6 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, CScriptVM::JE
, sizeToJump0
, yyvsp
[0].ByteCode
, CScriptVM::JUMP
, sizeToJump1
);
2083 #line 598 "ai_service/script_parser.yacc"
2084 { ERROR_DETECTED (yyval
.ByteCode
, "missing ')' at the end of the while condition");;}
2088 #line 599 "ai_service/script_parser.yacc"
2089 { ERROR_DETECTED (yyval
.ByteCode
, "missing '(' at the beginning of the while condition");;}
2093 #line 600 "ai_service/script_parser.yacc"
2094 { yyval
.ByteCode
= yyvsp
[-1].ByteCode
; ;}
2098 #line 601 "ai_service/script_parser.yacc"
2099 { yyval
.ByteCode
= yyvsp
[-1].ByteCode
; ;}
2103 #line 602 "ai_service/script_parser.yacc"
2104 { yyval
.ByteCode
= yyvsp
[-1].ByteCode
; ;}
2108 #line 603 "ai_service/script_parser.yacc"
2109 { yyval
.ByteCode
= yyvsp
[0].ByteCode
; ;}
2113 #line 604 "ai_service/script_parser.yacc"
2114 { yyval
.ByteCode
= yyvsp
[-1].ByteCode
; ;}
2118 #line 605 "ai_service/script_parser.yacc"
2119 { yyval
.ByteCode
= yyvsp
[-1].ByteCode
; ;}
2123 #line 606 "ai_service/script_parser.yacc"
2124 { yyval
.ByteCode
= yyvsp
[-1].ByteCode
; ;}
2128 #line 607 "ai_service/script_parser.yacc"
2129 { yyval
.ByteCode
= yyvsp
[-1].ByteCode
; ;}
2133 #line 608 "ai_service/script_parser.yacc"
2134 { yyval
.ByteCode
= yyvsp
[0].ByteCode
; ;}
2138 #line 609 "ai_service/script_parser.yacc"
2139 { yyval
.ByteCode
= yyvsp
[0].ByteCode
; ;}
2143 #line 610 "ai_service/script_parser.yacc"
2144 { yyval
.ByteCode
= yyvsp
[0].ByteCode
; ;}
2148 #line 611 "ai_service/script_parser.yacc"
2149 { NODE5 (yyval
.ByteCode
, CScriptVM::PUSH_VAR_VAL
, yyvsp
[-2].Opcode
, yyvsp
[-1].Opcode
, CScriptVM::SET_VAR_VAL
, yyvsp
[-2].Opcode
); ;}
2153 #line 612 "ai_service/script_parser.yacc"
2154 { NODE5 (yyval
.ByteCode
, CScriptVM::PUSH_VAR_VAL
, yyvsp
[-1].Opcode
, yyvsp
[-2].Opcode
, CScriptVM::SET_VAR_VAL
, yyvsp
[-1].Opcode
); ;}
2158 #line 614 "ai_service/script_parser.yacc"
2159 { NODE7 (yyval
.ByteCode
, yyvsp
[-3].ByteCode
, CScriptVM::PUSH_CONTEXT_VAR_VAL
, yyvsp
[-2].Opcode
, yyvsp
[-1].Opcode
, yyvsp
[-3].ByteCode
, CScriptVM::SET_CONTEXT_VAR_VAL
, yyvsp
[-2].Opcode
); ;}
2163 #line 616 "ai_service/script_parser.yacc"
2164 { NODE7 (yyval
.ByteCode
, yyvsp
[-2].ByteCode
, CScriptVM::PUSH_CONTEXT_VAR_VAL
, yyvsp
[-1].Opcode
, yyvsp
[-3].Opcode
, yyvsp
[-2].ByteCode
, CScriptVM::SET_CONTEXT_VAR_VAL
, yyvsp
[-1].Opcode
); ;}
2168 #line 617 "ai_service/script_parser.yacc"
2169 { NODE6 (yyval
.ByteCode
, CScriptVM::PUSH_VAR_VAL
, yyvsp
[-3].Opcode
, yyvsp
[-1].ByteCode
, yyvsp
[-2].Operator
, CScriptVM::SET_VAR_VAL
, yyvsp
[-3].Opcode
); ;}
2173 #line 618 "ai_service/script_parser.yacc"
2174 { ERROR_DETECTED (yyval
.ByteCode
, "missing ')' at the end of the expression");;}
2178 #line 619 "ai_service/script_parser.yacc"
2179 { ERROR_DETECTED (yyval
.ByteCode
, "missing '(' at the beginning of the expression");;}
2183 #line 621 "ai_service/script_parser.yacc"
2184 { NODE8 (yyval
.ByteCode
, yyvsp
[-4].ByteCode
, CScriptVM::PUSH_CONTEXT_VAR_VAL
, yyvsp
[-4].ByteCode
, yyvsp
[-1].ByteCode
, yyvsp
[-2].Operator
, yyvsp
[-4].ByteCode
, CScriptVM::SET_CONTEXT_VAR_VAL
, yyvsp
[-3].Opcode
); ;}
2188 #line 623 "ai_service/script_parser.yacc"
2189 { ERROR_DETECTED (yyval
.ByteCode
, "missing ')' at the end of the expression");;}
2193 #line 625 "ai_service/script_parser.yacc"
2194 { ERROR_DETECTED (yyval
.ByteCode
, "missing '(' at the beginning of the expression");;}
2198 #line 626 "ai_service/script_parser.yacc"
2199 { NODE1 (yyval
.ByteCode
, yyvsp
[0].ByteCodeList
); ;}
2203 #line 627 "ai_service/script_parser.yacc"
2204 { NODE0 (yyval
.ByteCode
); ;}
2208 #line 629 "ai_service/script_parser.yacc"
2209 { createList (yyval
.ByteCodeList
); addNode (yyval
.ByteCodeList
, yyvsp
[0].ByteCode
); ;}
2213 #line 630 "ai_service/script_parser.yacc"
2214 { yyval
.ByteCodeList
= yyvsp
[-1].ByteCodeList
; addNode (yyval
.ByteCodeList
, yyvsp
[0].ByteCode
); ;}
2218 #line 633 "ai_service/script_parser.yacc"
2220 createNode (yyval
.ByteCode
);
2221 int childCount
= yyvsp
[0].ByteCodeList
.ByteCodeList
->size ();
2223 // Sum all the children size
2224 uint sizeToJump
= getChildrenByteCodeSize (yyvsp
[0].ByteCodeList
.ByteCodeList
);
2225 sizeToJump
+= 1*childCount
; // One for the JUMP
2226 sizeToJump
+= 1*childCount
; // One for the offset
2227 sizeToJump
+= 1*childCount
; // One for the RET
2229 sizeToJump
+= 1; // One for the additionnal jump offset
2230 sizeToJump
+= 1; // One for the RANDEND
2232 addNode (yyval
.ByteCode
, CScriptVM::RAND
);
2233 addNode (yyval
.ByteCode
, childCount
);
2234 addNode (yyval
.ByteCode
, CScriptVM::JUMP
);
2235 addNode (yyval
.ByteCode
, sizeToJump
);
2238 // Write the jump table
2239 list
<vector
<size_t> * >::reverse_iterator rite
= yyvsp
[0].ByteCodeList
.ByteCodeList
->rbegin();
2240 while (rite
!= yyvsp
[0].ByteCodeList
.ByteCodeList
->rend())
2242 sizeToJump
-= (*rite
)->size ();
2244 addNode (yyval
.ByteCode
, CScriptVM::JUMP
);
2245 addNode (yyval
.ByteCode
, sizeToJump
);
2246 sizeToJump
-= 1; // One for the JUMP
2247 sizeToJump
-= 1; // One for the offset
2248 sizeToJump
-= 1; // One for the RET
2254 list
<vector
<size_t> * >::iterator ite
= yyvsp
[0].ByteCodeList
.ByteCodeList
->begin();
2255 while (ite
!= yyvsp
[0].ByteCodeList
.ByteCodeList
->end())
2257 yyval
.ByteCode
.ByteCode
->insert (yyval
.ByteCode
.ByteCode
->end(), (*ite
)->begin(), (*ite
)->end());
2258 addNode (yyval
.ByteCode
, CScriptVM::RET
);
2263 addNode (yyval
.ByteCode
, CScriptVM::RANDEND
);
2268 #line 680 "ai_service/script_parser.yacc"
2269 { yyval
.Opcode
= yyvsp
[0].Opcode
; TYPES (yyval
.Opcode
); ;}
2273 #line 681 "ai_service/script_parser.yacc"
2274 { yyval
.Opcode
= yyvsp
[0].Opcode
; TYPEF (yyval
.Opcode
); ;}
2278 #line 684 "ai_service/script_parser.yacc"
2280 createCase (yyval
.Case
, yyvsp
[-2].Opcode
, yyvsp
[0].ByteCode
); // Create a two entry list to keep track of the case index and the case code
2285 #line 689 "ai_service/script_parser.yacc"
2287 createSwitch (yyval
.Switch
); // Create a new case list
2288 addNode (yyval
.Switch
, yyvsp
[0].Case
.Case
); // Add the first case
2289 TYPE1 (yyval
.Switch
, yyvsp
[0].Case
); // Propagate the key type
2294 #line 695 "ai_service/script_parser.yacc"
2296 yyval
.Switch
= yyvsp
[-1].Switch
;
2297 addNode (yyval
.Switch
, yyvsp
[0].Case
.Case
); // Add a case to the list
2302 #line 701 "ai_service/script_parser.yacc"
2305 createNode (yyval
.ByteCode
);
2306 addNode (yyval
.ByteCode
, yyvsp
[-4].ByteCode
);
2308 int childCount
= yyvsp
[-1].Switch
.Cases
->size ();
2310 // Sum all the children size
2311 uint sizeChild
= getChildrenByteCodeSize (yyvsp
[-1].Switch
.Cases
);
2312 sizeChild
+= 1*childCount
; // One for the RET
2314 uint sizeToJump
= 0;
2315 sizeToJump
+= 1*childCount
; // One for the case key
2316 sizeToJump
+= 1*childCount
; // One for the offset
2318 sizeToJump
+= 1; // One for the additionnal jump offset
2320 addNode (yyval
.ByteCode
, CScriptVM::SWITCH
); // Switch opcode
2321 addNode (yyval
.ByteCode
, childCount
); // Number of switch cases
2322 addNode (yyval
.ByteCode
, sizeToJump
+sizeChild
); // Return address
2325 // Write the jump table
2326 map
<size_t, CCase
*>::const_iterator ite
= yyvsp
[-1].Switch
.Cases
->begin ();
2327 while (ite
!= yyvsp
[-1].Switch
.Cases
->end ())
2329 const CCase
*_case
= ite
->second
;
2332 if (_case
->getType () != yyvsp
[-4].ByteCode
.getType ())
2333 aiOutputError (_case
->Line
, "case has not the same type than the switch expression: the case is %s and the switch is %s",
2334 _case
->getType (), yyvsp
[-4].ByteCode
.getType ());
2336 addNode (yyval
.ByteCode
, _case
->Case
);
2337 addNode (yyval
.ByteCode
, sizeToJump
);
2338 sizeToJump
+= _case
->ByteCode
->size ();
2339 sizeToJump
+= 1; // One for the RET
2340 sizeToJump
-= 1; // One for the case key
2341 sizeToJump
-= 1; // One for the offset
2346 ite
= yyvsp
[-1].Switch
.Cases
->begin ();
2347 while (ite
!= yyvsp
[-1].Switch
.Cases
->end ())
2349 const CCase
*_case
= ite
->second
;
2350 yyval
.ByteCode
.ByteCode
->insert (yyval
.ByteCode
.ByteCode
->end(), _case
->ByteCode
->begin(), _case
->ByteCode
->end());
2351 addNode (yyval
.ByteCode
, CScriptVM::RET
);
2358 #line 753 "ai_service/script_parser.yacc"
2359 {ERROR_DETECTED (yyval
.ByteCode
, "missing ')' at the end of the switch expression");;}
2363 #line 754 "ai_service/script_parser.yacc"
2364 {ERROR_DETECTED (yyval
.ByteCode
, "missing '(' at the beginning of the switch expression");;}
2368 #line 755 "ai_service/script_parser.yacc"
2369 {ERROR_DETECTED (yyval
.ByteCode
, "missing '{' at the beginning of the switch cases");;}
2373 #line 758 "ai_service/script_parser.yacc"
2374 { yyval
.ByteCodeList
= yyvsp
[-1].ByteCodeList
; ;}
2378 #line 761 "ai_service/script_parser.yacc"
2380 int sizeToJump
= getChildrenByteCodeSize (yyvsp
[0].ByteCodeList
.ByteCodeList
);
2381 sizeToJump
++; // One for the jump offset
2382 sizeToJump
++; // One for the EOP instruction
2383 NODE5 (yyval
.ByteCode
, CScriptVM::ONCHILDREN
, CScriptVM::JUMP
, sizeToJump
, yyvsp
[0].ByteCodeList
, CScriptVM::EOP
);
2390 /* Line 991 of yacc.c. */
2391 #line 2375 "ai_service/script_parser_yacc.cpp"
2397 YY_STACK_PRINT (yyss
, yyssp
);
2402 /* Now `shift' the result of the reduction. Determine what state
2403 that goes to, based on the state we popped back to and the rule
2404 number reduced by. */
2408 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
2409 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
2410 yystate
= yytable
[yystate
];
2412 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
2417 /*------------------------------------.
2418 | yyerrlab -- here on detecting error |
2419 `------------------------------------*/
2421 /* If not already recovering from an error, report this error. */
2426 yyn
= yypact
[yystate
];
2428 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
2430 YYSIZE_T yysize
= 0;
2431 int yytype
= YYTRANSLATE (yychar
);
2436 /* Start YYX at -YYN if negative to avoid negative indexes in
2438 for (yyx
= yyn
< 0 ? -yyn
: 0;
2439 yyx
< (int) (sizeof (yytname
) / sizeof (char *)); yyx
++)
2440 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
2441 yysize
+= yystrlen (yytname
[yyx
]) + 15, yycount
++;
2442 yysize
+= yystrlen ("syntax error, unexpected ") + 1;
2443 yysize
+= yystrlen (yytname
[yytype
]);
2444 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
2447 char *yyp
= yystpcpy (yymsg
, "syntax error, unexpected ");
2448 yyp
= yystpcpy (yyp
, yytname
[yytype
]);
2453 for (yyx
= yyn
< 0 ? -yyn
: 0;
2454 yyx
< (int) (sizeof (yytname
) / sizeof (char *));
2456 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
2458 const char *yyq
= ! yycount
? ", expecting " : " or ";
2459 yyp
= yystpcpy (yyp
, yyq
);
2460 yyp
= yystpcpy (yyp
, yytname
[yyx
]);
2465 YYSTACK_FREE (yymsg
);
2468 yyerror ("syntax error; also virtual memory exhausted");
2471 #endif /* YYERROR_VERBOSE */
2472 yyerror ("syntax error");
2477 if (yyerrstatus
== 3)
2479 /* If just tried and failed to reuse lookahead token after an
2480 error, discard it. */
2482 /* Return failure if at end of input. */
2483 if (yychar
== YYEOF
)
2485 /* Pop the error token. */
2487 /* Pop the rest of the stack. */
2488 while (yyss
< yyssp
)
2490 YYDSYMPRINTF ("Error: popping", yystos
[*yyssp
], yyvsp
, yylsp
);
2491 yydestruct (yystos
[*yyssp
], yyvsp
);
2497 YYDSYMPRINTF ("Error: discarding", yytoken
, &yylval
, &yylloc
);
2498 yydestruct (yytoken
, &yylval
);
2503 /* Else will try to reuse lookahead token after shifting the error
2508 /*----------------------------------------------------.
2509 | yyerrlab1 -- error raised explicitly by an action. |
2510 `----------------------------------------------------*/
2513 /* Suppress GCC warning that yyerrlab1 is unused when no action
2515 #if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
2516 // __attribute__ ((__unused__))
2523 /*---------------------------------------------------------------.
2524 | yyerrlab2 -- pop states until the error token can be shifted. |
2525 `---------------------------------------------------------------*/
2527 yyerrstatus
= 3; /* Each real token shifted decrements this. */
2531 yyn
= yypact
[yystate
];
2532 if (yyn
!= YYPACT_NINF
)
2535 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
2543 /* Pop the current state because it cannot handle the error token. */
2547 YYDSYMPRINTF ("Error: popping", yystos
[*yyssp
], yyvsp
, yylsp
);
2548 yydestruct (yystos
[yystate
], yyvsp
);
2552 YY_STACK_PRINT (yyss
, yyssp
);
2558 YYDPRINTF ((stderr
, "Shifting error token, "));
2567 /*-------------------------------------.
2568 | yyacceptlab -- YYACCEPT comes here. |
2569 `-------------------------------------*/
2574 /*-----------------------------------.
2575 | yyabortlab -- YYABORT comes here. |
2576 `-----------------------------------*/
2582 /*----------------------------------------------.
2583 | yyoverflowlab -- parser overflow comes here. |
2584 `----------------------------------------------*/
2586 yyerror ("parser stack overflow");
2594 YYSTACK_FREE (yyss
);
2600 #line 360 "ai_service/script_parser.yacc"
2603 int aierror (const char *s
)
2605 aiOutputError (aiLine
, s
);
2609 // This is just a compile fix for bison-1.875+gcc-3.2