001/* Generated By:JJTree&JavaCC: Do not edit this line. PtParser.java */ 002/* 003 Copyright (c) 1998-2015 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 027Created : May 1998 028 */ 029 030package ptolemy.data.expr; 031 032import java.io.Reader; 033import java.io.StringReader; 034import java.util.ArrayList; 035import java.util.Collections; 036import java.util.LinkedHashMap; 037import java.util.LinkedList; 038import java.util.List; 039import java.util.Map; 040import java.util.Set; 041import java.util.StringTokenizer; 042 043import ptolemy.data.BooleanToken; 044import ptolemy.data.ComplexToken; 045import ptolemy.data.DoubleToken; 046import ptolemy.data.FloatToken; 047import ptolemy.data.IntToken; 048import ptolemy.data.LongToken; 049import ptolemy.data.PetiteToken; 050import ptolemy.data.ShortToken; 051import ptolemy.data.StringToken; 052import ptolemy.data.UnsignedByteToken; 053import ptolemy.kernel.util.IllegalActionException; 054import ptolemy.math.Complex; 055import ptolemy.util.StringUtilities; 056 057////////////////////////////////////////////////////////////////////// 058//// PTParser.jjt 059/** 060This file implements an expression parser for Ptolemy II using the 061JavaCC parser generator. It can handle all the basic arithmetic operators 062(*, /, +, -, %, ^), relational operators (<, ≤, >, ≥, == !=), logical 063operators(&&, ||, !), bitwise operators (&, |, #, ~) and, using 064reflection, all of the functionality available in the java.lang.Math 065package. 066<p> 067By editing the ASTFunctionNode file it is also relatively 068easy to allow references to other functions. This provides an easy mechanism 069to extend the range to the parser e.g. have a tcl(...) function 070that passes the string to a Tcl interpreter and returns the result.</p>? 071<p> 072Functional if is supported via the following syntax:</p>? 073<pre> 074 (boolean) ? (value1) : (value2) 075</pre> 076<p> 077Extensibility is also supported by allowing method calls on the Tokens, 078the syntax is </p>? 079<pre> 080 (value1).method(comma separated arguments) 081</pre> 082<p> 083JavaCC by itself simply generates a file (and support files) that allow an 084input to be parsed, it does not return a parse tree. For the purposes of 085type checking we require a parse tree, and this is obtained using JJTree, a 086preprocessor for JavaCC. </p>? 087<p> 088JJtree operates by annotating the grammar file to support the generation 089of the parse tree. Thus the process is</p>? 090<pre> 091X.jjt --> JJTREE --> X.jj --> JAVACC --> X.java + support files 092</pre> 093<p> 094The parser can also be passed a symbol table of ptolemy.data.expr.Variables 095which the expression to be parsed can reference.</p> 096 097<p>Anything between quotes(") or apostrophes(') is taken to be one string. 098Strings are allowed to contain newlines or carriage returns. In 099addition, these characters, as well as other special characters, can 100be escaped using the standard Java syntax (\n, \t, \077, etc.).</p> 101 102<p>The expressions recognized follow as close as possible the syntax of Java. 103In particular the operator precedences implemented here follow exactly 104those in Java. Any type conversions that are performed are lossless. If 105the user wants lossy conversions, explicit casts will be necessary.</p> 106 107<p> 108Complex number are specified by an i or j after the imaginary part 109of the number. Long numbers are specified by an l or L after an 110integer number.</p> 111 112<p> 113Users can register constants with the parser and also register classes 114where functions that may be called are defined. For a more 115thorough description of what the Parser is designed to do, 116please consult the Ptolemy II design document.</p> 117 118<p> 119Note that the parsers created by JavaCC generally have quite a bit of 120internal state. On the other hand, the parse trees generated by this 121parser are much smaller. It is also fairly cheap to traverse a parse 122tree in order to evaluate it. Thus it is usually preferable to cache 123parse trees and create a new parser when the cached parse tree becomes 124invalid.</p> 125 126@author Neil Smyth, Steve Neuendorffer 127@version $Id$ 128@since Ptolemy II 1.0 129@Pt.ProposedRating Yellow (nsmyth) 130@Pt.AcceptedRating Yellow (yuhong) 131@see ptolemy.data.expr.ASTPtBitwiseNode 132@see ptolemy.data.expr.ASTPtFunctionApplicationNode 133@see ptolemy.data.expr.ASTPtFunctionDefinitionNode 134@see ptolemy.data.expr.ASTPtFunctionalIfNode 135@see ptolemy.data.expr.ASTPtLeafNode 136@see ptolemy.data.expr.ASTPtLogicalNode 137@see ptolemy.data.expr.ASTPtMethodCallNode 138@see ptolemy.data.expr.ASTPtProductNode 139@see ptolemy.data.expr.ASTPtRelationalNode 140@see ptolemy.data.expr.ASTPtRootNode 141@see ptolemy.data.expr.ASTPtSumNode 142@see ptolemy.data.expr.ASTPtUnaryNode 143@see ptolemy.data.Token 144 */ 145@SuppressWarnings("unused") 146public class PtParser/*@bgen(jjtree)*/ implements PtParserTreeConstants, 147 PtParserConstants {/*@bgen(jjtree)*/ 148 protected JJTPtParserState jjtree = new JJTPtParserState(); 149 // IMPORTANT: If this file is named PtParser.jj or PtParser.java, 150 // then *DO NOT* edit this file. Instead, install JavaCC-5.0 (see 151 // $PTII/doc/install.htm) and edit PtParser.jjt 152 153 boolean debug = false; 154 155 public PtParser() { 156 this(new StringReader("")); 157 _initialize(); 158 } 159 160 /** Returns the list of undefined variables after parsing the given String. 161 * @param stringIn The expression to be parsed 162 * @exception IllegalActionException If the parse fails. 163 * @return The list of undefined variables. 164 * @deprecated Use a visitor with a ParseTreeFreeVariableCollector 165 * instead. 166 */ 167 @Deprecated 168 public LinkedList getUndefinedList(String stringIn) 169 throws IllegalActionException { 170 ASTPtRootNode rootNode = generateParseTree(stringIn); 171 ParseTreeFreeVariableCollector collector = new ParseTreeFreeVariableCollector(); 172 173 Set vars = collector.collectFreeVariables(rootNode); 174 return new LinkedList(vars); 175 } 176 177 /** Generates a parse tree from the given String. The root node is 178 * returned. To evaluate the parse tree, use a ParseTreeEvaluator. 179 * @param stringIn The expression to be parsed. 180 * @exception IllegalActionException If the parse fails. 181 * @return The root node of the parse tree. 182 */ 183 public ASTPtRootNode generateParseTree(String stringIn) 184 throws IllegalActionException { 185 186 Reader reader = new StringReader(stringIn); 187 this.ReInit(reader); 188 ASTPtRootNode rootNode; 189 try { 190 // Parse the expression to obtain the parse tree 191 // start() can generate a TokenMgrError if we parse a "\0" 192 rootNode = start(); 193 if (debug) { 194 rootNode.displayParseTree(" "); 195 } 196 } catch (Throwable throwable) { 197 throw new IllegalActionException(null, throwable, 198 "Error parsing expression:\n\"" 199 + StringUtilities.truncateString(stringIn, 80, 1) 200 + "\""); 201 } 202 ASTPtRootNode primary = (ASTPtRootNode) rootNode.jjtGetChild(0); 203 primary.jjtSetParent(null); 204 return primary; 205 } 206 207 /** Generates a parse tree from the given String, which may optionally 208 * contain an assignment. The root node is 209 * returned. If the string represents an assignment, then the 210 * toplevel node will be an ASTPtAssignmentNode. 211 * @param stringIn The expression to be parsed. 212 * @exception IllegalActionException If the parse fails. 213 * @return The root node of the parse tree. 214 */ 215 public ASTPtRootNode generateSimpleAssignmentParseTree(String stringIn) 216 throws IllegalActionException { 217 218 Reader reader = new StringReader(stringIn); 219 this.ReInit(reader); 220 ASTPtRootNode rootNode; 221 try { 222 // Parse the expression to obtain the parse tree 223 rootNode = startSimpleAssignment(); 224 if (debug) { 225 rootNode.displayParseTree(" "); 226 } 227 } catch (Throwable throwable) { 228 throw new IllegalActionException(null, throwable, 229 "Error parsing expression:\n\"" 230 + StringUtilities.truncateString(stringIn, 80, 1) 231 + "\""); 232 } 233 ASTPtRootNode primary = (ASTPtRootNode) rootNode.jjtGetChild(0); 234 primary.jjtSetParent(null); 235 return primary; 236 } 237 238 /** Generates a parse tree from the given String, which is interpreted 239 * in "String Mode" instead of as an operator expression. In 240 * string mode, the expression is a literal string, except for 241 * identifiers which are denoted by $param. The root node is 242 * returned. To evaluate the parse tree, use a ParseTreeEvaluator. 243 * @param stringIn The expression to be parsed. 244 * @exception IllegalActionException If the parse fails. 245 * @return The root node of the parse tree. 246 */ 247 public ASTPtRootNode generateStringParseTree(String stringIn) 248 throws IllegalActionException { 249 250 Reader reader = new StringReader(stringIn); 251 this.ReInit(reader); 252 ASTPtRootNode rootNode; 253 try { 254 // Parse the expression to obtain the parse tree 255 token_source.SwitchTo(StringMode); 256 // startString() can generate a TokenMgrError 257 rootNode = startString(); 258 if (debug) { 259 rootNode.displayParseTree(" "); 260 } 261 } catch (Throwable throwable) { 262 throw new IllegalActionException(null, throwable, 263 "Error parsing expression:\n\"" 264 + StringUtilities.truncateString(stringIn, 80, 1) 265 + "\""); 266 } finally { 267 token_source.SwitchTo(DEFAULT); 268 } 269 ASTPtRootNode primary = (ASTPtRootNode) rootNode.jjtGetChild(0); 270 primary.jjtSetParent(null); 271 return primary; 272 } 273 274 /** Generates a parse tree from the given String. 275 * The string will be parsed according to rules for assignment lists. 276 * The returned node is a RootNode containing one assignment 277 * node for each assignment in the expression. 278 * 279 * @param stringIn The expression to be parsed. 280 * @exception IllegalActionException If the parse fails. 281 * @return The root node of the parse tree. 282 */ 283 public Map generateAssignmentMap(String stringIn) 284 throws IllegalActionException { 285 286 Reader reader = new StringReader(stringIn); 287 this.ReInit(reader); 288 Map map; 289 try { 290 // Parse the expression to obtain the parse tree. 291 // startAssignmentList() might throw TokenMgrError which is 292 // an Error, not an Exception, so we catch Throwables here. 293 map = startAssignmentList(); 294 } catch (Throwable throwable) { 295 throw new IllegalActionException(null, throwable, 296 "Error parsing expression:\n\"" 297 + StringUtilities.truncateString(stringIn, 80, 1) 298 + "\""); 299 } 300 return map; 301 } 302 303 public String cleanupString(String str) throws ParseException { 304 // Check to see that the start and the end are the same. 305 String start = str.substring(0, 1); 306 if (!token.image.endsWith(start)) { 307 throw new ParseException( 308 "Found unterminated string: " + token.image); 309 } 310 311 // Now cut the " from each end of the string. 312 int len = token.image.length(); 313 String tidied = token.image.substring(1, (len - 1)); 314 315 // Resolve escape sequences in the string. 316 StringTokenizer st = new StringTokenizer(tidied, "\u005c\u005c", true); 317 boolean escape = false; 318 String x = new String(); 319 while (st.hasMoreTokens()) { 320 String tok = st.nextToken(); 321 if (escape) { 322 // The previous character was a backslash that started 323 // an escape sequence. 324 escape = false; 325 int trailingCharIndex = 1; 326 switch (tok.charAt(0)) { 327 case 'n': 328 x += "\u005cn"; 329 break; 330 case 't': 331 x += "\u005ct"; 332 break; 333 case 'b': 334 x += "\u005cb"; 335 break; 336 case 'r': 337 x += "\u005cr"; 338 break; 339 case 'f': 340 x += "\u005cf"; 341 break; 342 case '\u005c\u005c': 343 x += "\u005c\u005c"; 344 break; 345 case '\u005c'': 346 x += "\u005c'"; 347 break; 348 case '"': 349 x += "\u005c""; 350 break; 351 case '0': 352 case '1': 353 case '2': 354 case '3': 355 case '4': 356 case '5': 357 case '6': 358 case '7': 359 // The escape sequence is a character 360 // specified in octal. 361 int i; 362 for (i = 1; i < tok.length(); i++) { 363 // The octal sequence stops at the first 364 // non-octal character. 365 char c = tok.charAt(i); 366 if (!(c == '0' || c == '1' || c == '2' || c == '3' 367 || c == '4' || c == '5' || c == '6' 368 || c == '7')) { 369 break; 370 } 371 } 372 trailingCharIndex = i; 373 int octVal = Integer 374 .parseInt(tok.substring(0, trailingCharIndex), 8); 375 x += (char) octVal; 376 break; 377 default: 378 throw new ParseException("Unknown backslash sequence: " 379 + "\u005c\u005c" + tok); 380 } 381 if (trailingCharIndex < tok.length()) { 382 // Keep any remaining characters. 383 x += tok.substring(trailingCharIndex); 384 } 385 } else if (tok.equals("\u005c\u005c")) { 386 // Start an escape sequence. 387 escape = true; 388 } else { 389 // Keep regular text. 390 x += tok; 391 } 392 } 393 if (escape) { 394 throw new ParseException("Unterminated backslash sequence in " 395 + "string: " + token.image); 396 } 397 398 return x; 399 } 400 401 /** Return the list of classes the parser searches 402 * when a function call is encountered. The 403 * classes are searched in the same order that they were registered 404 * with the parser, so the classes that are most likely to be 405 * searched should be registered first. This method is synchronized 406 * so that it can be called safely from multiple parsers. 407 * @return An unmodifiable list that can be iterated over. 408 */ 409 public static synchronized List getRegisteredClasses() { 410 if (_classesSearched == null) { 411 return new ArrayList(); 412 } 413 return Collections.unmodifiableList(new ArrayList(_classesSearched)); 414 } 415 416 /** Add a constant to the list of constants that the parser recognizes. 417 * It is a static method. The constants are stored in a hash table by 418 * the Constants class. The entry for each name is a ptolemy.data.Token 419 * of the appropriate type. The value for the constant can be given 420 * in a ptolemy.data.Token or in one of the data wrapper classes 421 * in java.lang. 422 * @param name The string name that the parser will recognize. 423 * @param value An Object constraining the value associated with 424 * the constant. 425 * @exception IllegalArgumentException If the constant cannot 426 * be registered with the parser. 427 */ 428 public static void registerConstant(String name, Object value) 429 throws IllegalArgumentException { 430 if ((value == null) || (name == null)) { 431 throw new IllegalArgumentException("PtParser: cannot register " 432 + "a constant if either the name or value object is null."); 433 } 434 ptolemy.data.Token tmp; 435 if (value instanceof ptolemy.data.Token) { 436 tmp = (ptolemy.data.Token) value; 437 } else if (value instanceof Integer) { 438 tmp = new IntToken(((Integer) value).intValue()); 439 } else if (value instanceof Double) { 440 tmp = new DoubleToken(((Double) value).doubleValue()); 441 } else if (value instanceof Long) { 442 tmp = new LongToken(((Long) value).longValue()); 443 } else if (value instanceof String) { 444 tmp = new StringToken((String) value); 445 } else if (value instanceof Boolean) { 446 tmp = new BooleanToken(((Boolean) value).booleanValue()); 447 } else if (value instanceof Complex) { 448 tmp = new ComplexToken((Complex) value); 449 } else { 450 throw new IllegalArgumentException("PtParser: cannot register " 451 + name + " as a constant of the parser."); 452 } 453 Constants.add(name, tmp); 454 return; 455 } 456 457 /** Add a class to the list of classes that the parser searches 458 * when a function call is encountered. 459 * It is a static method. It stores the classes in a LinkedList. The 460 * classes are searched in the same order that they were registered 461 * with the parser, so the classes that are most likely to be 462 * searched should be registered first. This method is synchronized 463 * so that it can be called safely from multiple parsers. 464 * @param newClassName The fully qualified name of the Class to 465 * be added to the search path for functions. 466 * @exception IllegalArgumentException If the Class named by the 467 * argument cannot not be found. 468 */ 469 public static synchronized void registerFunctionClass(String newClassName) 470 throws IllegalArgumentException { 471 if (_classesSearched == null) { 472 _classesSearched = new ArrayList(); 473 } 474 try { 475 Class newClass = Class.forName(newClassName); 476 if (!_classesSearched.contains(newClass)) { 477 _classesSearched.add(newClass); 478 } 479 } catch (ClassNotFoundException ex) { 480 throw new IllegalArgumentException( 481 "Could not find " + newClassName + "."); 482 } 483 CachedMethod.clear(); 484 } 485 486 /** Initialize the static variable containing the classes searched by 487 * the parser upon encountering a function call. 488 */ 489 private void _initialize() { 490 if (!_alreadyInitialized) { 491 _alreadyInitialized = true; 492 // IMPORTANT: If this file is named PtParser.jj or 493 // PtParser.java, then *DO NOT* edit this file. 494 // Instead, install JavaCC-5.0 (see $PTII/doc/install.htm) 495 // and edit PtParser.jjt 496 registerFunctionClass("java.lang.Math"); 497 registerFunctionClass("java.lang.Double"); 498 registerFunctionClass("java.lang.Integer"); 499 registerFunctionClass("java.lang.Long"); 500 registerFunctionClass("java.lang.String"); 501 registerFunctionClass("ptolemy.data.MatrixToken"); 502 registerFunctionClass("ptolemy.data.RecordToken"); 503 registerFunctionClass("ptolemy.data.SmoothToken"); 504 registerFunctionClass("ptolemy.data.expr.UtilityFunctions"); 505 registerFunctionClass("ptolemy.data.expr.FixPointFunctions"); 506 registerFunctionClass("ptolemy.math.Complex"); 507 registerFunctionClass("ptolemy.math.ExtendedMath"); 508 registerFunctionClass("ptolemy.math.IntegerMatrixMath"); 509 registerFunctionClass("ptolemy.math.DoubleMatrixMath"); 510 registerFunctionClass("ptolemy.math.ComplexMatrixMath"); 511 registerFunctionClass("ptolemy.math.LongMatrixMath"); 512 registerFunctionClass("ptolemy.math.IntegerArrayMath"); 513 registerFunctionClass("ptolemy.math.DoubleArrayStat"); 514 registerFunctionClass("ptolemy.math.ComplexArrayMath"); 515 registerFunctionClass("ptolemy.math.LongArrayMath"); 516 registerFunctionClass("ptolemy.math.SignalProcessing"); 517 registerFunctionClass("ptolemy.math.FixPoint"); 518 registerFunctionClass("ptolemy.data.ObjectToken"); 519 registerFunctionClass("ptolemy.data.DateToken"); 520 } 521 } 522 523 /* Flag indicating whether the default set of classes searched 524 * by the parser has already been loaded. 525 */ 526 private static boolean _alreadyInitialized = false; 527 528 /* Stores the classes that are searched by the parser when a 529 * function call is parsed. It is static, and by default only 530 * contains the java.lang.Math class. 531 */ 532 private static List _classesSearched; 533 534 // A simple, optional assigment used by the expression evaluator 535 final public ASTPtRootNode startSimpleAssignment() throws ParseException { 536 /*@bgen(jjtree) PtRootNode */ 537 ASTPtRootNode jjtn000 = new ASTPtRootNode(JJTPTROOTNODE); 538 boolean jjtc000 = true; 539 jjtree.openNodeScope(jjtn000); 540 try { 541 if (jj_2_1(2147483647)) { 542 assignment(); 543 } else if (jj_2_2(1)) { 544 expression(); 545 } else { 546 jj_consume_token(-1); 547 throw new ParseException(); 548 } 549 jj_consume_token(0); 550 jjtree.closeNodeScope(jjtn000, true); 551 jjtc000 = false; 552 { 553 if (true) { 554 return jjtn000; 555 } 556 } 557 } catch (Throwable jjte000) { 558 if (jjtc000) { 559 jjtree.clearNodeScope(jjtn000); 560 jjtc000 = false; 561 } else { 562 jjtree.popNode(); 563 } 564 if (jjte000 instanceof RuntimeException) { 565 { 566 if (true) { 567 throw (RuntimeException) jjte000; 568 } 569 } 570 } 571 if (jjte000 instanceof ParseException) { 572 { 573 if (true) { 574 throw (ParseException) jjte000; 575 } 576 } 577 } 578 { 579 if (true) { 580 throw (Error) jjte000; 581 } 582 } 583 } finally { 584 if (jjtc000) { 585 jjtree.closeNodeScope(jjtn000, true); 586 } 587 } 588 throw new Error("Missing return statement in function"); 589 } 590 591 final public Map startAssignmentList() throws ParseException { 592 /*@bgen(jjtree) PtRootNode */ 593 ASTPtRootNode jjtn000 = new ASTPtRootNode(JJTPTROOTNODE); 594 boolean jjtc000 = true; 595 jjtree.openNodeScope(jjtn000); 596 Map map = new LinkedHashMap(); 597 try { 598 assignment(); 599 ASTPtAssignmentNode node = (ASTPtAssignmentNode) jjtree.popNode(); 600 map.put(node.getIdentifier(), node); 601 label_1: while (true) { 602 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 603 case SEPARATOR: 604 ; 605 break; 606 default: 607 jj_la1[0] = jj_gen; 608 break label_1; 609 } 610 jj_consume_token(SEPARATOR); 611 assignment(); 612 ASTPtAssignmentNode node2 = (ASTPtAssignmentNode) jjtree 613 .popNode(); 614 map.put(node2.getIdentifier(), node2); 615 } 616 jj_consume_token(0); 617 jjtree.closeNodeScope(jjtn000, true); 618 jjtc000 = false; 619 { 620 if (true) { 621 return map; 622 } 623 } 624 } catch (Throwable jjte000) { 625 if (jjtc000) { 626 jjtree.clearNodeScope(jjtn000); 627 jjtc000 = false; 628 } else { 629 jjtree.popNode(); 630 } 631 if (jjte000 instanceof RuntimeException) { 632 { 633 if (true) { 634 throw (RuntimeException) jjte000; 635 } 636 } 637 } 638 if (jjte000 instanceof ParseException) { 639 { 640 if (true) { 641 throw (ParseException) jjte000; 642 } 643 } 644 } 645 { 646 if (true) { 647 throw (Error) jjte000; 648 } 649 } 650 } finally { 651 if (jjtc000) { 652 jjtree.closeNodeScope(jjtn000, true); 653 } 654 } 655 throw new Error("Missing return statement in function"); 656 } 657 658 final public void assignment() throws ParseException { 659 /*@bgen(jjtree) PtAssignmentNode */ 660 ASTPtAssignmentNode jjtn000 = new ASTPtAssignmentNode( 661 JJTPTASSIGNMENTNODE); 662 boolean jjtc000 = true; 663 jjtree.openNodeScope(jjtn000); 664 try { 665 assignmentIdentifier(); 666 jj_consume_token(SETEQUALS); 667 expression(); 668 } catch (Throwable jjte000) { 669 if (jjtc000) { 670 jjtree.clearNodeScope(jjtn000); 671 jjtc000 = false; 672 } else { 673 jjtree.popNode(); 674 } 675 if (jjte000 instanceof RuntimeException) { 676 { 677 if (true) { 678 throw (RuntimeException) jjte000; 679 } 680 } 681 } 682 if (jjte000 instanceof ParseException) { 683 { 684 if (true) { 685 throw (ParseException) jjte000; 686 } 687 } 688 } 689 { 690 if (true) { 691 throw (Error) jjte000; 692 } 693 } 694 } finally { 695 if (jjtc000) { 696 jjtree.closeNodeScope(jjtn000, true); 697 } 698 } 699 } 700 701 // A string mode expression, using $parameter substitution. 702 final public ASTPtRootNode startString() throws ParseException { 703 /*@bgen(jjtree) PtRootNode */ 704 ASTPtRootNode jjtn000 = new ASTPtRootNode(JJTPTROOTNODE); 705 boolean jjtc000 = true; 706 jjtree.openNodeScope(jjtn000); 707 try { 708 ASTPtSumNode jjtn001 = new ASTPtSumNode(JJTPTSUMNODE); 709 boolean jjtc001 = true; 710 jjtree.openNodeScope(jjtn001); 711 try { 712 stringModeElement(); 713 label_2: while (true) { 714 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 715 case SMSTRING: 716 case SMDOLLAR: 717 case SMDOLLARBRACE: 718 case SMDOLLARPAREN: 719 ; 720 break; 721 default: 722 jj_la1[1] = jj_gen; 723 break label_2; 724 } 725 stringModeElement(); 726 Token token = Token.newToken(PtParserConstants.PLUS); 727 token.kind = PtParserConstants.PLUS; 728 jjtn001._lexicalTokens.add(token); 729 } 730 } catch (Throwable jjte001) { 731 if (jjtc001) { 732 jjtree.clearNodeScope(jjtn001); 733 jjtc001 = false; 734 } else { 735 jjtree.popNode(); 736 } 737 if (jjte001 instanceof RuntimeException) { 738 { 739 if (true) { 740 throw (RuntimeException) jjte001; 741 } 742 } 743 } 744 if (jjte001 instanceof ParseException) { 745 { 746 if (true) { 747 throw (ParseException) jjte001; 748 } 749 } 750 } 751 { 752 if (true) { 753 throw (Error) jjte001; 754 } 755 } 756 } finally { 757 if (jjtc001) { 758 jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); 759 } 760 } 761 jj_consume_token(0); 762 jjtree.closeNodeScope(jjtn000, true); 763 jjtc000 = false; 764 { 765 if (true) { 766 return jjtn000; 767 } 768 } 769 } catch (Throwable jjte000) { 770 if (jjtc000) { 771 jjtree.clearNodeScope(jjtn000); 772 jjtc000 = false; 773 } else { 774 jjtree.popNode(); 775 } 776 if (jjte000 instanceof RuntimeException) { 777 { 778 if (true) { 779 throw (RuntimeException) jjte000; 780 } 781 } 782 } 783 if (jjte000 instanceof ParseException) { 784 { 785 if (true) { 786 throw (ParseException) jjte000; 787 } 788 } 789 } 790 { 791 if (true) { 792 throw (Error) jjte000; 793 } 794 } 795 } finally { 796 if (jjtc000) { 797 jjtree.closeNodeScope(jjtn000, true); 798 } 799 } 800 throw new Error("Missing return statement in function"); 801 } 802 803 final public void stringModeElement() throws ParseException { 804 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 805 case SMSTRING: 806 stringModeString(); 807 break; 808 case SMDOLLAR: 809 jj_consume_token(SMDOLLAR); 810 identifier(); 811 break; 812 case SMDOLLARBRACE: 813 jj_consume_token(SMDOLLARBRACE); 814 identifier(); 815 jj_consume_token(SMBRACE); 816 break; 817 case SMDOLLARPAREN: 818 ASTPtSumNode jjtn001 = new ASTPtSumNode(JJTPTSUMNODE); 819 boolean jjtc001 = true; 820 jjtree.openNodeScope(jjtn001); 821 try { 822 jj_consume_token(SMDOLLARPAREN); 823 token_source.SwitchTo(DEFAULT); 824 expression(); 825 jj_consume_token(CLOSEPAREN); 826 jjtree.closeNodeScope(jjtn001, true); 827 jjtc001 = false; 828 token_source.SwitchTo(StringMode); 829 } catch (Throwable jjte001) { 830 if (jjtc001) { 831 jjtree.clearNodeScope(jjtn001); 832 jjtc001 = false; 833 } else { 834 jjtree.popNode(); 835 } 836 if (jjte001 instanceof RuntimeException) { 837 { 838 if (true) { 839 throw (RuntimeException) jjte001; 840 } 841 } 842 } 843 if (jjte001 instanceof ParseException) { 844 { 845 if (true) { 846 throw (ParseException) jjte001; 847 } 848 } 849 } 850 { 851 if (true) { 852 throw (Error) jjte001; 853 } 854 } 855 } finally { 856 if (jjtc001) { 857 jjtree.closeNodeScope(jjtn001, true); 858 } 859 } 860 break; 861 default: 862 jj_la1[2] = jj_gen; 863 jj_consume_token(-1); 864 throw new ParseException(); 865 } 866 } 867 868 final public void stringModeString() throws ParseException { 869 jj_consume_token(SMSTRING); 870 ASTPtLeafNode jjtn001 = new ASTPtLeafNode(JJTPTLEAFNODE); 871 boolean jjtc001 = true; 872 jjtree.openNodeScope(jjtn001); 873 try { 874 jjtree.closeNodeScope(jjtn001, true); 875 jjtc001 = false; 876 jjtn001._ptToken = new StringToken(token.image 877 .replaceAll("\u005c\u005c$\u005c\u005c$", "\u005c\u005c$")); 878 jjtn001._isConstant = true; 879 } finally { 880 if (jjtc001) { 881 jjtree.closeNodeScope(jjtn001, true); 882 } 883 } 884 } 885 886 final public ASTPtRootNode start() throws ParseException { 887 /*@bgen(jjtree) PtRootNode */ 888 ASTPtRootNode jjtn000 = new ASTPtRootNode(JJTPTROOTNODE); 889 boolean jjtc000 = true; 890 jjtree.openNodeScope(jjtn000); 891 try { 892 expression(); 893 jj_consume_token(0); 894 jjtree.closeNodeScope(jjtn000, true); 895 jjtc000 = false; 896 { 897 if (true) { 898 return jjtn000; 899 } 900 } 901 } catch (Throwable jjte000) { 902 if (jjtc000) { 903 jjtree.clearNodeScope(jjtn000); 904 jjtc000 = false; 905 } else { 906 jjtree.popNode(); 907 } 908 if (jjte000 instanceof RuntimeException) { 909 { 910 if (true) { 911 throw (RuntimeException) jjte000; 912 } 913 } 914 } 915 if (jjte000 instanceof ParseException) { 916 { 917 if (true) { 918 throw (ParseException) jjte000; 919 } 920 } 921 } 922 { 923 if (true) { 924 throw (Error) jjte000; 925 } 926 } 927 } finally { 928 if (jjtc000) { 929 jjtree.closeNodeScope(jjtn000, true); 930 } 931 } 932 throw new Error("Missing return statement in function"); 933 } 934 935 final public void expression() throws ParseException { 936 if (jj_2_3(2147483647)) { 937 functionDefinition(); 938 } else if (jj_2_4(1)) { 939 funcIf(); 940 } else { 941 jj_consume_token(-1); 942 throw new ParseException(); 943 } 944 } 945 946 final public void funcIf() throws ParseException { 947 ASTPtFunctionalIfNode jjtn001 = new ASTPtFunctionalIfNode( 948 JJTPTFUNCTIONALIFNODE); 949 boolean jjtc001 = true; 950 jjtree.openNodeScope(jjtn001); 951 try { 952 logicalOr(); 953 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 954 case QUESTION: 955 jj_consume_token(QUESTION); 956 expression(); 957 jj_consume_token(COLON); 958 expression(); 959 break; 960 default: 961 jj_la1[3] = jj_gen; 962 ; 963 } 964 } catch (Throwable jjte001) { 965 if (jjtc001) { 966 jjtree.clearNodeScope(jjtn001); 967 jjtc001 = false; 968 } else { 969 jjtree.popNode(); 970 } 971 if (jjte001 instanceof RuntimeException) { 972 { 973 if (true) { 974 throw (RuntimeException) jjte001; 975 } 976 } 977 } 978 if (jjte001 instanceof ParseException) { 979 { 980 if (true) { 981 throw (ParseException) jjte001; 982 } 983 } 984 } 985 { 986 if (true) { 987 throw (Error) jjte001; 988 } 989 } 990 } finally { 991 if (jjtc001) { 992 jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); 993 } 994 } 995 } 996 997 final public void logicalOr() throws ParseException { 998 Token x; 999 ASTPtLogicalNode jjtn001 = new ASTPtLogicalNode(JJTPTLOGICALNODE); 1000 boolean jjtc001 = true; 1001 jjtree.openNodeScope(jjtn001); 1002 try { 1003 logicalAnd(); 1004 label_3: while (true) { 1005 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1006 case COND_OR: 1007 ; 1008 break; 1009 default: 1010 jj_la1[4] = jj_gen; 1011 break label_3; 1012 } 1013 x = jj_consume_token(COND_OR); 1014 logicalAnd(); 1015 jjtn001._lexicalToken = x; 1016 } 1017 } catch (Throwable jjte001) { 1018 if (jjtc001) { 1019 jjtree.clearNodeScope(jjtn001); 1020 jjtc001 = false; 1021 } else { 1022 jjtree.popNode(); 1023 } 1024 if (jjte001 instanceof RuntimeException) { 1025 { 1026 if (true) { 1027 throw (RuntimeException) jjte001; 1028 } 1029 } 1030 } 1031 if (jjte001 instanceof ParseException) { 1032 { 1033 if (true) { 1034 throw (ParseException) jjte001; 1035 } 1036 } 1037 } 1038 { 1039 if (true) { 1040 throw (Error) jjte001; 1041 } 1042 } 1043 } finally { 1044 if (jjtc001) { 1045 jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); 1046 } 1047 } 1048 } 1049 1050 final public void logicalAnd() throws ParseException { 1051 Token x; 1052 ASTPtLogicalNode jjtn001 = new ASTPtLogicalNode(JJTPTLOGICALNODE); 1053 boolean jjtc001 = true; 1054 jjtree.openNodeScope(jjtn001); 1055 try { 1056 bitwiseOr(); 1057 label_4: while (true) { 1058 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1059 case COND_AND: 1060 ; 1061 break; 1062 default: 1063 jj_la1[5] = jj_gen; 1064 break label_4; 1065 } 1066 x = jj_consume_token(COND_AND); 1067 bitwiseOr(); 1068 jjtn001._lexicalToken = x; 1069 } 1070 } catch (Throwable jjte001) { 1071 if (jjtc001) { 1072 jjtree.clearNodeScope(jjtn001); 1073 jjtc001 = false; 1074 } else { 1075 jjtree.popNode(); 1076 } 1077 if (jjte001 instanceof RuntimeException) { 1078 { 1079 if (true) { 1080 throw (RuntimeException) jjte001; 1081 } 1082 } 1083 } 1084 if (jjte001 instanceof ParseException) { 1085 { 1086 if (true) { 1087 throw (ParseException) jjte001; 1088 } 1089 } 1090 } 1091 { 1092 if (true) { 1093 throw (Error) jjte001; 1094 } 1095 } 1096 } finally { 1097 if (jjtc001) { 1098 jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); 1099 } 1100 } 1101 } 1102 1103 final public void bitwiseOr() throws ParseException { 1104 Token x; 1105 ASTPtBitwiseNode jjtn001 = new ASTPtBitwiseNode(JJTPTBITWISENODE); 1106 boolean jjtc001 = true; 1107 jjtree.openNodeScope(jjtn001); 1108 try { 1109 bitwiseXor(); 1110 label_5: while (true) { 1111 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1112 case OR: 1113 ; 1114 break; 1115 default: 1116 jj_la1[6] = jj_gen; 1117 break label_5; 1118 } 1119 x = jj_consume_token(OR); 1120 bitwiseXor(); 1121 jjtn001._lexicalToken = x; 1122 } 1123 } catch (Throwable jjte001) { 1124 if (jjtc001) { 1125 jjtree.clearNodeScope(jjtn001); 1126 jjtc001 = false; 1127 } else { 1128 jjtree.popNode(); 1129 } 1130 if (jjte001 instanceof RuntimeException) { 1131 { 1132 if (true) { 1133 throw (RuntimeException) jjte001; 1134 } 1135 } 1136 } 1137 if (jjte001 instanceof ParseException) { 1138 { 1139 if (true) { 1140 throw (ParseException) jjte001; 1141 } 1142 } 1143 } 1144 { 1145 if (true) { 1146 throw (Error) jjte001; 1147 } 1148 } 1149 } finally { 1150 if (jjtc001) { 1151 jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); 1152 } 1153 } 1154 } 1155 1156 final public void bitwiseXor() throws ParseException { 1157 Token x; 1158 ASTPtBitwiseNode jjtn001 = new ASTPtBitwiseNode(JJTPTBITWISENODE); 1159 boolean jjtc001 = true; 1160 jjtree.openNodeScope(jjtn001); 1161 try { 1162 bitwiseAnd(); 1163 label_6: while (true) { 1164 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1165 case XOR: 1166 ; 1167 break; 1168 default: 1169 jj_la1[7] = jj_gen; 1170 break label_6; 1171 } 1172 x = jj_consume_token(XOR); 1173 bitwiseAnd(); 1174 jjtn001._lexicalToken = x; 1175 } 1176 } catch (Throwable jjte001) { 1177 if (jjtc001) { 1178 jjtree.clearNodeScope(jjtn001); 1179 jjtc001 = false; 1180 } else { 1181 jjtree.popNode(); 1182 } 1183 if (jjte001 instanceof RuntimeException) { 1184 { 1185 if (true) { 1186 throw (RuntimeException) jjte001; 1187 } 1188 } 1189 } 1190 if (jjte001 instanceof ParseException) { 1191 { 1192 if (true) { 1193 throw (ParseException) jjte001; 1194 } 1195 } 1196 } 1197 { 1198 if (true) { 1199 throw (Error) jjte001; 1200 } 1201 } 1202 } finally { 1203 if (jjtc001) { 1204 jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); 1205 } 1206 } 1207 } 1208 1209 final public void bitwiseAnd() throws ParseException { 1210 Token x; 1211 ASTPtBitwiseNode jjtn001 = new ASTPtBitwiseNode(JJTPTBITWISENODE); 1212 boolean jjtc001 = true; 1213 jjtree.openNodeScope(jjtn001); 1214 try { 1215 logicalEquals(); 1216 label_7: while (true) { 1217 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1218 case AND: 1219 ; 1220 break; 1221 default: 1222 jj_la1[8] = jj_gen; 1223 break label_7; 1224 } 1225 x = jj_consume_token(AND); 1226 logicalEquals(); 1227 jjtn001._lexicalToken = x; 1228 } 1229 } catch (Throwable jjte001) { 1230 if (jjtc001) { 1231 jjtree.clearNodeScope(jjtn001); 1232 jjtc001 = false; 1233 } else { 1234 jjtree.popNode(); 1235 } 1236 if (jjte001 instanceof RuntimeException) { 1237 { 1238 if (true) { 1239 throw (RuntimeException) jjte001; 1240 } 1241 } 1242 } 1243 if (jjte001 instanceof ParseException) { 1244 { 1245 if (true) { 1246 throw (ParseException) jjte001; 1247 } 1248 } 1249 } 1250 { 1251 if (true) { 1252 throw (Error) jjte001; 1253 } 1254 } 1255 } finally { 1256 if (jjtc001) { 1257 jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); 1258 } 1259 } 1260 } 1261 1262 final public void logicalEquals() throws ParseException { 1263 Token x; 1264 ASTPtRelationalNode jjtn001 = new ASTPtRelationalNode( 1265 JJTPTRELATIONALNODE); 1266 boolean jjtc001 = true; 1267 jjtree.openNodeScope(jjtn001); 1268 try { 1269 relational(); 1270 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1271 case NOTEQUALS: 1272 case EQUALS: 1273 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1274 case EQUALS: 1275 x = jj_consume_token(EQUALS); 1276 break; 1277 case NOTEQUALS: 1278 x = jj_consume_token(NOTEQUALS); 1279 break; 1280 default: 1281 jj_la1[9] = jj_gen; 1282 jj_consume_token(-1); 1283 throw new ParseException(); 1284 } 1285 relational(); 1286 jjtn001._lexicalToken = x; 1287 break; 1288 default: 1289 jj_la1[10] = jj_gen; 1290 ; 1291 } 1292 } catch (Throwable jjte001) { 1293 if (jjtc001) { 1294 jjtree.clearNodeScope(jjtn001); 1295 jjtc001 = false; 1296 } else { 1297 jjtree.popNode(); 1298 } 1299 if (jjte001 instanceof RuntimeException) { 1300 { 1301 if (true) { 1302 throw (RuntimeException) jjte001; 1303 } 1304 } 1305 } 1306 if (jjte001 instanceof ParseException) { 1307 { 1308 if (true) { 1309 throw (ParseException) jjte001; 1310 } 1311 } 1312 } 1313 { 1314 if (true) { 1315 throw (Error) jjte001; 1316 } 1317 } 1318 } finally { 1319 if (jjtc001) { 1320 jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); 1321 } 1322 } 1323 } 1324 1325 final public void power() throws ParseException { 1326 ASTPtPowerNode jjtn001 = new ASTPtPowerNode(JJTPTPOWERNODE); 1327 boolean jjtc001 = true; 1328 jjtree.openNodeScope(jjtn001); 1329 try { 1330 unary(); 1331 label_8: while (true) { 1332 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1333 case POWER: 1334 ; 1335 break; 1336 default: 1337 jj_la1[11] = jj_gen; 1338 break label_8; 1339 } 1340 jj_consume_token(POWER); 1341 unary(); 1342 } 1343 } catch (Throwable jjte001) { 1344 if (jjtc001) { 1345 jjtree.clearNodeScope(jjtn001); 1346 jjtc001 = false; 1347 } else { 1348 jjtree.popNode(); 1349 } 1350 if (jjte001 instanceof RuntimeException) { 1351 { 1352 if (true) { 1353 throw (RuntimeException) jjte001; 1354 } 1355 } 1356 } 1357 if (jjte001 instanceof ParseException) { 1358 { 1359 if (true) { 1360 throw (ParseException) jjte001; 1361 } 1362 } 1363 } 1364 { 1365 if (true) { 1366 throw (Error) jjte001; 1367 } 1368 } 1369 } finally { 1370 if (jjtc001) { 1371 jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); 1372 } 1373 } 1374 } 1375 1376 final public void relational() throws ParseException { 1377 Token x; 1378 ASTPtRelationalNode jjtn001 = new ASTPtRelationalNode( 1379 JJTPTRELATIONALNODE); 1380 boolean jjtc001 = true; 1381 jjtree.openNodeScope(jjtn001); 1382 try { 1383 shift(); 1384 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1385 case GT: 1386 case LT: 1387 case GTE: 1388 case LTE: 1389 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1390 case GT: 1391 x = jj_consume_token(GT); 1392 break; 1393 case GTE: 1394 x = jj_consume_token(GTE); 1395 break; 1396 case LT: 1397 x = jj_consume_token(LT); 1398 break; 1399 case LTE: 1400 x = jj_consume_token(LTE); 1401 break; 1402 default: 1403 jj_la1[12] = jj_gen; 1404 jj_consume_token(-1); 1405 throw new ParseException(); 1406 } 1407 shift(); 1408 jjtn001._lexicalToken = x; 1409 break; 1410 default: 1411 jj_la1[13] = jj_gen; 1412 ; 1413 } 1414 } catch (Throwable jjte001) { 1415 if (jjtc001) { 1416 jjtree.clearNodeScope(jjtn001); 1417 jjtc001 = false; 1418 } else { 1419 jjtree.popNode(); 1420 } 1421 if (jjte001 instanceof RuntimeException) { 1422 { 1423 if (true) { 1424 throw (RuntimeException) jjte001; 1425 } 1426 } 1427 } 1428 if (jjte001 instanceof ParseException) { 1429 { 1430 if (true) { 1431 throw (ParseException) jjte001; 1432 } 1433 } 1434 } 1435 { 1436 if (true) { 1437 throw (Error) jjte001; 1438 } 1439 } 1440 } finally { 1441 if (jjtc001) { 1442 jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); 1443 } 1444 } 1445 } 1446 1447 final public void shift() throws ParseException { 1448 Token x; 1449 ASTPtShiftNode jjtn001 = new ASTPtShiftNode(JJTPTSHIFTNODE); 1450 boolean jjtc001 = true; 1451 jjtree.openNodeScope(jjtn001); 1452 try { 1453 sum(); 1454 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1455 case SHL: 1456 case SHR: 1457 case LSHR: 1458 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1459 case SHL: 1460 x = jj_consume_token(SHL); 1461 break; 1462 case SHR: 1463 x = jj_consume_token(SHR); 1464 break; 1465 case LSHR: 1466 x = jj_consume_token(LSHR); 1467 break; 1468 default: 1469 jj_la1[14] = jj_gen; 1470 jj_consume_token(-1); 1471 throw new ParseException(); 1472 } 1473 sum(); 1474 jjtn001._lexicalToken = x; 1475 break; 1476 default: 1477 jj_la1[15] = jj_gen; 1478 ; 1479 } 1480 } catch (Throwable jjte001) { 1481 if (jjtc001) { 1482 jjtree.clearNodeScope(jjtn001); 1483 jjtc001 = false; 1484 } else { 1485 jjtree.popNode(); 1486 } 1487 if (jjte001 instanceof RuntimeException) { 1488 { 1489 if (true) { 1490 throw (RuntimeException) jjte001; 1491 } 1492 } 1493 } 1494 if (jjte001 instanceof ParseException) { 1495 { 1496 if (true) { 1497 throw (ParseException) jjte001; 1498 } 1499 } 1500 } 1501 { 1502 if (true) { 1503 throw (Error) jjte001; 1504 } 1505 } 1506 } finally { 1507 if (jjtc001) { 1508 jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); 1509 } 1510 } 1511 } 1512 1513 final public void sum() throws ParseException { 1514 Token x; 1515 ASTPtSumNode jjtn001 = new ASTPtSumNode(JJTPTSUMNODE); 1516 boolean jjtc001 = true; 1517 jjtree.openNodeScope(jjtn001); 1518 try { 1519 term(); 1520 label_9: while (true) { 1521 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1522 case PLUS: 1523 case MINUS: 1524 ; 1525 break; 1526 default: 1527 jj_la1[16] = jj_gen; 1528 break label_9; 1529 } 1530 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1531 case PLUS: 1532 x = jj_consume_token(PLUS); 1533 break; 1534 case MINUS: 1535 x = jj_consume_token(MINUS); 1536 break; 1537 default: 1538 jj_la1[17] = jj_gen; 1539 jj_consume_token(-1); 1540 throw new ParseException(); 1541 } 1542 term(); 1543 jjtn001._lexicalTokens.add(x); 1544 } 1545 } catch (Throwable jjte001) { 1546 if (jjtc001) { 1547 jjtree.clearNodeScope(jjtn001); 1548 jjtc001 = false; 1549 } else { 1550 jjtree.popNode(); 1551 } 1552 if (jjte001 instanceof RuntimeException) { 1553 { 1554 if (true) { 1555 throw (RuntimeException) jjte001; 1556 } 1557 } 1558 } 1559 if (jjte001 instanceof ParseException) { 1560 { 1561 if (true) { 1562 throw (ParseException) jjte001; 1563 } 1564 } 1565 } 1566 { 1567 if (true) { 1568 throw (Error) jjte001; 1569 } 1570 } 1571 } finally { 1572 if (jjtc001) { 1573 jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); 1574 } 1575 } 1576 } 1577 1578 final public void term() throws ParseException { 1579 Token x; 1580 ASTPtProductNode jjtn001 = new ASTPtProductNode(JJTPTPRODUCTNODE); 1581 boolean jjtc001 = true; 1582 jjtree.openNodeScope(jjtn001); 1583 try { 1584 power(); 1585 label_10: while (true) { 1586 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1587 case MULTIPLY: 1588 case DIVIDE: 1589 case MODULO: 1590 ; 1591 break; 1592 default: 1593 jj_la1[18] = jj_gen; 1594 break label_10; 1595 } 1596 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1597 case MULTIPLY: 1598 x = jj_consume_token(MULTIPLY); 1599 break; 1600 case DIVIDE: 1601 x = jj_consume_token(DIVIDE); 1602 break; 1603 case MODULO: 1604 x = jj_consume_token(MODULO); 1605 break; 1606 default: 1607 jj_la1[19] = jj_gen; 1608 jj_consume_token(-1); 1609 throw new ParseException(); 1610 } 1611 power(); 1612 jjtn001._lexicalTokens.add(x); 1613 } 1614 } catch (Throwable jjte001) { 1615 if (jjtc001) { 1616 jjtree.clearNodeScope(jjtn001); 1617 jjtc001 = false; 1618 } else { 1619 jjtree.popNode(); 1620 } 1621 if (jjte001 instanceof RuntimeException) { 1622 { 1623 if (true) { 1624 throw (RuntimeException) jjte001; 1625 } 1626 } 1627 } 1628 if (jjte001 instanceof ParseException) { 1629 { 1630 if (true) { 1631 throw (ParseException) jjte001; 1632 } 1633 } 1634 } 1635 { 1636 if (true) { 1637 throw (Error) jjte001; 1638 } 1639 } 1640 } finally { 1641 if (jjtc001) { 1642 jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); 1643 } 1644 } 1645 } 1646 1647 final public void unary() throws ParseException { 1648 Token x; 1649 if (getToken(1).kind == MINUS && getToken(2).kind != INTEGER) { 1650 ASTPtUnaryNode jjtn001 = new ASTPtUnaryNode(JJTPTUNARYNODE); 1651 boolean jjtc001 = true; 1652 jjtree.openNodeScope(jjtn001); 1653 try { 1654 x = jj_consume_token(MINUS); 1655 element(); 1656 jjtree.closeNodeScope(jjtn001, true); 1657 jjtc001 = false; 1658 jjtn001._isMinus = true; 1659 jjtn001._lexicalToken = x; 1660 } catch (Throwable jjte001) { 1661 if (jjtc001) { 1662 jjtree.clearNodeScope(jjtn001); 1663 jjtc001 = false; 1664 } else { 1665 jjtree.popNode(); 1666 } 1667 if (jjte001 instanceof RuntimeException) { 1668 { 1669 if (true) { 1670 throw (RuntimeException) jjte001; 1671 } 1672 } 1673 } 1674 if (jjte001 instanceof ParseException) { 1675 { 1676 if (true) { 1677 throw (ParseException) jjte001; 1678 } 1679 } 1680 } 1681 { 1682 if (true) { 1683 throw (Error) jjte001; 1684 } 1685 } 1686 } finally { 1687 if (jjtc001) { 1688 jjtree.closeNodeScope(jjtn001, true); 1689 } 1690 } 1691 } else { 1692 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1693 case BOOL_NOT: 1694 ASTPtUnaryNode jjtn002 = new ASTPtUnaryNode(JJTPTUNARYNODE); 1695 boolean jjtc002 = true; 1696 jjtree.openNodeScope(jjtn002); 1697 try { 1698 x = jj_consume_token(BOOL_NOT); 1699 element(); 1700 jjtree.closeNodeScope(jjtn002, true); 1701 jjtc002 = false; 1702 jjtn002._isNot = true; 1703 jjtn002._lexicalToken = x; 1704 } catch (Throwable jjte002) { 1705 if (jjtc002) { 1706 jjtree.clearNodeScope(jjtn002); 1707 jjtc002 = false; 1708 } else { 1709 jjtree.popNode(); 1710 } 1711 if (jjte002 instanceof RuntimeException) { 1712 { 1713 if (true) { 1714 throw (RuntimeException) jjte002; 1715 } 1716 } 1717 } 1718 if (jjte002 instanceof ParseException) { 1719 { 1720 if (true) { 1721 throw (ParseException) jjte002; 1722 } 1723 } 1724 } 1725 { 1726 if (true) { 1727 throw (Error) jjte002; 1728 } 1729 } 1730 } finally { 1731 if (jjtc002) { 1732 jjtree.closeNodeScope(jjtn002, true); 1733 } 1734 } 1735 break; 1736 case BITWISE_NOT: 1737 ASTPtUnaryNode jjtn003 = new ASTPtUnaryNode(JJTPTUNARYNODE); 1738 boolean jjtc003 = true; 1739 jjtree.openNodeScope(jjtn003); 1740 try { 1741 x = jj_consume_token(BITWISE_NOT); 1742 element(); 1743 jjtree.closeNodeScope(jjtn003, true); 1744 jjtc003 = false; 1745 jjtn003._isBitwiseNot = true; 1746 jjtn003._lexicalToken = x; 1747 } catch (Throwable jjte003) { 1748 if (jjtc003) { 1749 jjtree.clearNodeScope(jjtn003); 1750 jjtc003 = false; 1751 } else { 1752 jjtree.popNode(); 1753 } 1754 if (jjte003 instanceof RuntimeException) { 1755 { 1756 if (true) { 1757 throw (RuntimeException) jjte003; 1758 } 1759 } 1760 } 1761 if (jjte003 instanceof ParseException) { 1762 { 1763 if (true) { 1764 throw (ParseException) jjte003; 1765 } 1766 } 1767 } 1768 { 1769 if (true) { 1770 throw (Error) jjte003; 1771 } 1772 } 1773 } finally { 1774 if (jjtc003) { 1775 jjtree.closeNodeScope(jjtn003, true); 1776 } 1777 } 1778 break; 1779 case MINUS: 1780 case OPENPAREN: 1781 case OPENBRACE: 1782 case OPENBRACKET: 1783 case OPENUNION: 1784 case INTEGER: 1785 case DOUBLE: 1786 case COMPLEX: 1787 case BOOLEAN: 1788 case ID: 1789 case STRING: 1790 case SMID: 1791 case SMIDBRACE: 1792 case SMIDPAREN: 1793 element(); 1794 break; 1795 default: 1796 jj_la1[20] = jj_gen; 1797 jj_consume_token(-1); 1798 throw new ParseException(); 1799 } 1800 } 1801 } 1802 1803 /* 1804 void element() #void : 1805 { 1806 boolean isMethodCall = false; 1807 } 1808 { 1809 // Note that omitting the parens is possible for a record... 1810 ( primaryElement() 1811 [ <PERIOD> <ID> {jjtThis._methodName = token.image; isMethodCall = true;} 1812 ( <OPENPAREN> [ funcIf() ( <COMMA> funcIf() )* ] <CLOSEPAREN> )? ] 1813 ) #PtMethodCallNode(isMethodCall) 1814 } 1815 */ 1816 1817 /*void element() #void : 1818 { 1819 boolean hasName = false; 1820 boolean hasCall = false; 1821 String name = null; 1822 } 1823 { 1824 ( 1825 ( 1826 primaryElement() 1827 1828 [ 1829 <PERIOD> <ID> 1830 { 1831 name = token.image; 1832 hasName = true; 1833 } 1834 ] 1835 1836 [ 1837 <OPENPAREN> [ expression() ( <COMMA> expression() )* ] <CLOSEPAREN> 1838 { 1839 hasCall = true; 1840 } 1841 ] 1842 { 1843 jjtThis._methodName = name; 1844 } 1845 ) #PtMethodCallNode(hasName) 1846 ) #PtFunctionApplicationNode(!hasName && hasCall) 1847 }*/ 1848 final public void element() throws ParseException { 1849 String name = null; 1850 ASTPtRootNode child; 1851 primaryElement(); 1852 child = (ASTPtRootNode) jjtree.popNode(); 1853 label_11: while (true) { 1854 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1855 case OPENPAREN: 1856 case PERIOD: 1857 ; 1858 break; 1859 default: 1860 jj_la1[21] = jj_gen; 1861 break label_11; 1862 } 1863 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1864 case PERIOD: 1865 ASTPtMethodCallNode jjtn001 = new ASTPtMethodCallNode( 1866 JJTPTMETHODCALLNODE); 1867 boolean jjtc001 = true; 1868 jjtree.openNodeScope(jjtn001); 1869 try { 1870 jj_consume_token(PERIOD); 1871 jj_consume_token(ID); 1872 jjtree.pushNode(child); 1873 name = token.image; 1874 if (jj_2_6(2147483647)) { 1875 jj_consume_token(OPENPAREN); 1876 if (jj_2_5(1)) { 1877 expression(); 1878 label_12: while (true) { 1879 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1880 case COMMA: 1881 ; 1882 break; 1883 default: 1884 jj_la1[22] = jj_gen; 1885 break label_12; 1886 } 1887 jj_consume_token(COMMA); 1888 expression(); 1889 } 1890 } else { 1891 ; 1892 } 1893 jj_consume_token(CLOSEPAREN); 1894 } else { 1895 ; 1896 } 1897 } catch (Throwable jjte001) { 1898 if (jjtc001) { 1899 jjtree.clearNodeScope(jjtn001); 1900 jjtc001 = false; 1901 } else { 1902 jjtree.popNode(); 1903 } 1904 if (jjte001 instanceof RuntimeException) { 1905 { 1906 if (true) { 1907 throw (RuntimeException) jjte001; 1908 } 1909 } 1910 } 1911 if (jjte001 instanceof ParseException) { 1912 { 1913 if (true) { 1914 throw (ParseException) jjte001; 1915 } 1916 } 1917 } 1918 { 1919 if (true) { 1920 throw (Error) jjte001; 1921 } 1922 } 1923 } finally { 1924 if (jjtc001) { 1925 jjtree.closeNodeScope(jjtn001, true); 1926 } 1927 } 1928 child = (ASTPtRootNode) jjtree.popNode(); 1929 ((ASTPtMethodCallNode) child)._methodName = name; 1930 break; 1931 case OPENPAREN: 1932 ASTPtFunctionApplicationNode jjtn002 = new ASTPtFunctionApplicationNode( 1933 JJTPTFUNCTIONAPPLICATIONNODE); 1934 boolean jjtc002 = true; 1935 jjtree.openNodeScope(jjtn002); 1936 try { 1937 jj_consume_token(OPENPAREN); 1938 jjtree.pushNode(child); 1939 if (jj_2_7(1)) { 1940 expression(); 1941 label_13: while (true) { 1942 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 1943 case COMMA: 1944 ; 1945 break; 1946 default: 1947 jj_la1[23] = jj_gen; 1948 break label_13; 1949 } 1950 jj_consume_token(COMMA); 1951 expression(); 1952 } 1953 } else { 1954 ; 1955 } 1956 jj_consume_token(CLOSEPAREN); 1957 } catch (Throwable jjte002) { 1958 if (jjtc002) { 1959 jjtree.clearNodeScope(jjtn002); 1960 jjtc002 = false; 1961 } else { 1962 jjtree.popNode(); 1963 } 1964 if (jjte002 instanceof RuntimeException) { 1965 { 1966 if (true) { 1967 throw (RuntimeException) jjte002; 1968 } 1969 } 1970 } 1971 if (jjte002 instanceof ParseException) { 1972 { 1973 if (true) { 1974 throw (ParseException) jjte002; 1975 } 1976 } 1977 } 1978 { 1979 if (true) { 1980 throw (Error) jjte002; 1981 } 1982 } 1983 } finally { 1984 if (jjtc002) { 1985 jjtree.closeNodeScope(jjtn002, true); 1986 } 1987 } 1988 child = (ASTPtRootNode) jjtree.popNode(); 1989 break; 1990 default: 1991 jj_la1[24] = jj_gen; 1992 jj_consume_token(-1); 1993 throw new ParseException(); 1994 } 1995 } 1996 jjtree.pushNode(child); 1997 } 1998 1999 final public void integer() throws ParseException { 2000 int len; 2001 boolean neg = false; 2002 String x; 2003 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2004 case MINUS: 2005 jj_consume_token(MINUS); 2006 neg = true; 2007 jj_consume_token(INTEGER); 2008 break; 2009 case INTEGER: 2010 jj_consume_token(INTEGER); 2011 break; 2012 default: 2013 jj_la1[25] = jj_gen; 2014 jj_consume_token(-1); 2015 throw new ParseException(); 2016 } 2017 ASTPtLeafNode jjtn001 = new ASTPtLeafNode(JJTPTLEAFNODE); 2018 boolean jjtc001 = true; 2019 jjtree.openNodeScope(jjtn001); 2020 try { 2021 jjtree.closeNodeScope(jjtn001, true); 2022 jjtc001 = false; 2023 try { 2024 x = token.image.toLowerCase(); 2025 if (neg) { 2026 x = "-" + x; 2027 } 2028 len = x.length(); 2029 2030 int radix; 2031 boolean mustBeLong = x.endsWith("l"); 2032 boolean mustBeShort = x.endsWith("s"); 2033 boolean mustBeUnsignedByte = x.endsWith("ub"); 2034 2035 int prefixLength; 2036 int suffixLength; 2037 2038 if (mustBeLong) { 2039 suffixLength = 1; 2040 } else if (mustBeShort) { 2041 suffixLength = 1; 2042 } else if (mustBeUnsignedByte) { 2043 suffixLength = 2; 2044 } else { 2045 suffixLength = 0; 2046 } 2047 2048 if (x.startsWith("0x")) { 2049 // Input is a hex number. 2050 radix = 16; 2051 prefixLength = 2; 2052 } else if (x.startsWith("0")) { 2053 // Input is an octal number. 2054 radix = 8; 2055 prefixLength = 0; 2056 } else { 2057 // Input is a decimal number. 2058 radix = 10; 2059 prefixLength = 0; 2060 } 2061 2062 // Strip off the radix prefix and the length suffix. 2063 x = x.substring(prefixLength, len - suffixLength); 2064 2065 if (mustBeLong) { 2066 // If the size was specified as long, then create a long. 2067 jjtn001._ptToken = new LongToken(Long.parseLong(x, radix)); 2068 } else if (mustBeShort) { 2069 // If the size was specified as short, then create a short. 2070 jjtn001._ptToken = new ShortToken( 2071 Short.parseShort(x, radix)); 2072 } else if (mustBeUnsignedByte) { 2073 // If the size was specified as unsignedbyte, 2074 // then create an unsigned byte, truncating if necessary. 2075 jjtn001._ptToken = new UnsignedByteToken( 2076 Integer.parseInt(x, radix)); 2077 } else { 2078 // Try to infer the size. Inferred sizes are at least 2079 // integer. 2080 try { 2081 jjtn001._ptToken = new IntToken( 2082 Integer.parseInt(x, radix)); 2083 } catch (NumberFormatException nfe) { 2084 jjtn001._ptToken = new LongToken( 2085 Long.parseLong(x, radix)); 2086 } 2087 } 2088 jjtn001._isConstant = true; 2089 } catch (NumberFormatException ee) { 2090 { 2091 if (true) { 2092 throw new ParseException("Unable to convert token " 2093 + token.image + " to an integer or long"); 2094 } 2095 } 2096 } 2097 } finally { 2098 if (jjtc001) { 2099 jjtree.closeNodeScope(jjtn001, true); 2100 } 2101 } 2102 } 2103 2104 final public void primaryElement() throws ParseException { 2105 int len; 2106 String x; 2107 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2108 case COMPLEX: 2109 ASTPtLeafNode jjtn001 = new ASTPtLeafNode(JJTPTLEAFNODE); 2110 boolean jjtc001 = true; 2111 jjtree.openNodeScope(jjtn001); 2112 try { 2113 jj_consume_token(COMPLEX); 2114 jjtree.closeNodeScope(jjtn001, true); 2115 jjtc001 = false; 2116 try { 2117 x = token.image.toLowerCase(); 2118 len = x.length(); 2119 Double imag = new Double(x.substring(0, len - 1)); 2120 Complex value = new Complex(0, imag.doubleValue()); 2121 jjtn001._ptToken = new ComplexToken(value); 2122 jjtn001._isConstant = true; 2123 } catch (NumberFormatException ee) { 2124 { 2125 if (true) { 2126 throw new ParseException("Unable to convert token " 2127 + token.image + " to a complex number."); 2128 } 2129 } 2130 } 2131 } finally { 2132 if (jjtc001) { 2133 jjtree.closeNodeScope(jjtn001, true); 2134 } 2135 } 2136 break; 2137 case DOUBLE: 2138 ASTPtLeafNode jjtn002 = new ASTPtLeafNode(JJTPTLEAFNODE); 2139 boolean jjtc002 = true; 2140 jjtree.openNodeScope(jjtn002); 2141 try { 2142 jj_consume_token(DOUBLE); 2143 jjtree.closeNodeScope(jjtn002, true); 2144 jjtc002 = false; 2145 try { 2146 x = token.image.toLowerCase(); 2147 len = x.length(); 2148 if (x.endsWith("f")) { 2149 Float value = new Float(x.substring(0, len - 1)); 2150 jjtn002._ptToken = new FloatToken(value.floatValue()); 2151 } else if (x.endsWith("d") || x.endsWith("p")) { 2152 // all floating point numbers are double 2153 Double value = new Double(x.substring(0, len - 1)); 2154 if (x.endsWith("p")) { 2155 jjtn002._ptToken = new PetiteToken( 2156 value.doubleValue()); 2157 } else { 2158 jjtn002._ptToken = new DoubleToken( 2159 value.doubleValue()); 2160 } 2161 } else { 2162 Double value = new Double(x); 2163 jjtn002._ptToken = new DoubleToken(value.doubleValue()); 2164 } 2165 jjtn002._isConstant = true; 2166 } catch (NumberFormatException ee) { 2167 { 2168 if (true) { 2169 throw new ParseException("Unable to convert token " 2170 + token.image + " to an float or double"); 2171 } 2172 } 2173 } 2174 } finally { 2175 if (jjtc002) { 2176 jjtree.closeNodeScope(jjtn002, true); 2177 } 2178 } 2179 break; 2180 case MINUS: 2181 case INTEGER: 2182 integer(); 2183 break; 2184 case STRING: 2185 ASTPtLeafNode jjtn003 = new ASTPtLeafNode(JJTPTLEAFNODE); 2186 boolean jjtc003 = true; 2187 jjtree.openNodeScope(jjtn003); 2188 try { 2189 jj_consume_token(STRING); 2190 jjtree.closeNodeScope(jjtn003, true); 2191 jjtc003 = false; 2192 jjtn003._ptToken = new StringToken(cleanupString(token.image)); 2193 jjtn003._isConstant = true; 2194 } finally { 2195 if (jjtc003) { 2196 jjtree.closeNodeScope(jjtn003, true); 2197 } 2198 } 2199 break; 2200 case BOOLEAN: 2201 ASTPtLeafNode jjtn004 = new ASTPtLeafNode(JJTPTLEAFNODE); 2202 boolean jjtc004 = true; 2203 jjtree.openNodeScope(jjtn004); 2204 try { 2205 jj_consume_token(BOOLEAN); 2206 jjtree.closeNodeScope(jjtn004, true); 2207 jjtc004 = false; 2208 if (token.image.equalsIgnoreCase("TRUE")) { 2209 jjtn004._ptToken = BooleanToken.TRUE; 2210 } else if (token.image.equalsIgnoreCase("FALSE")) { 2211 jjtn004._ptToken = BooleanToken.FALSE; 2212 } 2213 jjtn004._isConstant = true; 2214 } finally { 2215 if (jjtc004) { 2216 jjtree.closeNodeScope(jjtn004, true); 2217 } 2218 } 2219 break; 2220 default: 2221 jj_la1[26] = jj_gen; 2222 if (jj_2_8(2147483647)) { 2223 jj_consume_token(OPENPAREN); 2224 expression(); 2225 jj_consume_token(CLOSEPAREN); 2226 } else if (jj_2_9(2147483647)) { 2227 orderedRecordConstruct(); 2228 } else if (jj_2_10(2147483647)) { 2229 matrixConstruct(); 2230 } else if (jj_2_11(2147483647)) { 2231 recordConstruct(); 2232 } else if (jj_2_12(2147483647)) { 2233 unionConstruct(); 2234 } else if (jj_2_13(2147483647)) { 2235 nilArrayConstruct(); 2236 } else if (jj_2_14(2147483647)) { 2237 arrayConstruct(); 2238 } else if (jj_2_15(2147483647)) { 2239 function(); 2240 } else { 2241 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2242 case ID: 2243 case SMID: 2244 case SMIDBRACE: 2245 case SMIDPAREN: 2246 identifier(); 2247 break; 2248 default: 2249 jj_la1[27] = jj_gen; 2250 jj_consume_token(-1); 2251 throw new ParseException(); 2252 } 2253 } 2254 } 2255 } 2256 2257 final public void functionDefinition() throws ParseException { 2258 /*@bgen(jjtree) PtFunctionDefinitionNode */ 2259 ASTPtFunctionDefinitionNode jjtn000 = new ASTPtFunctionDefinitionNode( 2260 JJTPTFUNCTIONDEFINITIONNODE); 2261 boolean jjtc000 = true; 2262 jjtree.openNodeScope(jjtn000); 2263 try { 2264 jj_consume_token(FUNCTION); 2265 jj_consume_token(OPENPAREN); 2266 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2267 case ID: 2268 jj_consume_token(ID); 2269 jjtn000._argList.add(token.image); 2270 optTypeSpecifier(); 2271 label_14: while (true) { 2272 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2273 case COMMA: 2274 ; 2275 break; 2276 default: 2277 jj_la1[28] = jj_gen; 2278 break label_14; 2279 } 2280 jj_consume_token(COMMA); 2281 jj_consume_token(ID); 2282 jjtn000._argList.add(token.image); 2283 optTypeSpecifier(); 2284 } 2285 break; 2286 default: 2287 jj_la1[29] = jj_gen; 2288 ; 2289 } 2290 jj_consume_token(CLOSEPAREN); 2291 expression(); 2292 jjtree.closeNodeScope(jjtn000, true); 2293 jjtc000 = false; 2294 // A hack for type specification, since we don't have types in 2295 // the syntax. 2296 ParseTreeTypeInference inference = new ParseTreeTypeInference(); 2297 int argCount = jjtn000.getArgumentNameList().size(); 2298 jjtn000._argTypes = new ptolemy.data.type.Type[argCount]; 2299 for (int i = 0; i < argCount; i++) { 2300 ASTPtRootNode argChild = ((ASTPtRootNode) jjtn000 2301 .jjtGetChild(i)); 2302 ptolemy.data.type.Type type = inference.inferTypes(argChild); 2303 jjtn000._argTypes[i] = type; 2304 } 2305 } catch (Throwable jjte000) { 2306 if (jjtc000) { 2307 jjtree.clearNodeScope(jjtn000); 2308 jjtc000 = false; 2309 } else { 2310 jjtree.popNode(); 2311 } 2312 if (jjte000 instanceof RuntimeException) { 2313 { 2314 if (true) { 2315 throw (RuntimeException) jjte000; 2316 } 2317 } 2318 } 2319 if (jjte000 instanceof ParseException) { 2320 { 2321 if (true) { 2322 throw (ParseException) jjte000; 2323 } 2324 } 2325 } 2326 { 2327 if (true) { 2328 throw (Error) jjte000; 2329 } 2330 } 2331 } finally { 2332 if (jjtc000) { 2333 jjtree.closeNodeScope(jjtn000, true); 2334 } 2335 } 2336 } 2337 2338 final public void optTypeSpecifier() throws ParseException { 2339 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2340 case COLON: 2341 jj_consume_token(COLON); 2342 funcIf(); 2343 break; 2344 default: 2345 jj_la1[30] = jj_gen; 2346 ASTPtLeafNode node = new ASTPtLeafNode(JJTPTLEAFNODE); 2347 node._name = "general"; 2348 node._ptToken = new GeneralToken(); 2349 node._ptType = ptolemy.data.type.BaseType.GENERAL; 2350 node._isConstant = true; 2351 jjtree.pushNode(node); 2352 } 2353 } 2354 2355 final public void function() throws ParseException { 2356 /*@bgen(jjtree) PtFunctionApplicationNode */ 2357 ASTPtFunctionApplicationNode jjtn000 = new ASTPtFunctionApplicationNode( 2358 JJTPTFUNCTIONAPPLICATIONNODE); 2359 boolean jjtc000 = true; 2360 jjtree.openNodeScope(jjtn000); 2361 try { 2362 identifier(); 2363 jj_consume_token(OPENPAREN); 2364 if (jj_2_16(1)) { 2365 expression(); 2366 label_15: while (true) { 2367 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2368 case COMMA: 2369 ; 2370 break; 2371 default: 2372 jj_la1[31] = jj_gen; 2373 break label_15; 2374 } 2375 jj_consume_token(COMMA); 2376 expression(); 2377 } 2378 } else { 2379 ; 2380 } 2381 jj_consume_token(CLOSEPAREN); 2382 } catch (Throwable jjte000) { 2383 if (jjtc000) { 2384 jjtree.clearNodeScope(jjtn000); 2385 jjtc000 = false; 2386 } else { 2387 jjtree.popNode(); 2388 } 2389 if (jjte000 instanceof RuntimeException) { 2390 { 2391 if (true) { 2392 throw (RuntimeException) jjte000; 2393 } 2394 } 2395 } 2396 if (jjte000 instanceof ParseException) { 2397 { 2398 if (true) { 2399 throw (ParseException) jjte000; 2400 } 2401 } 2402 } 2403 { 2404 if (true) { 2405 throw (Error) jjte000; 2406 } 2407 } 2408 } finally { 2409 if (jjtc000) { 2410 jjtree.closeNodeScope(jjtn000, true); 2411 } 2412 } 2413 } 2414 2415 final public void assignmentIdentifier() throws ParseException { 2416 /*@bgen(jjtree) PtLeafNode */ 2417 ASTPtLeafNode jjtn000 = new ASTPtLeafNode(JJTPTLEAFNODE); 2418 boolean jjtc000 = true; 2419 jjtree.openNodeScope(jjtn000); 2420 StringBuffer name; 2421 try { 2422 jj_consume_token(ID); 2423 // Store the name of this identifier... This will be the 2424 // name of a variable, a constant, or an undefined identifier. 2425 // Note that this name is not actually resolved into a value 2426 // until the parse tree is evaluated. 2427 name = new StringBuffer(token.image); 2428 label_16: while (true) { 2429 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2430 case PERIOD: 2431 ; 2432 break; 2433 default: 2434 jj_la1[32] = jj_gen; 2435 break label_16; 2436 } 2437 jj_consume_token(PERIOD); 2438 jj_consume_token(ID); 2439 name.append("."); 2440 name.append(token.image); 2441 } 2442 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2443 case OPENPAREN: 2444 jj_consume_token(OPENPAREN); 2445 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2446 case INTEGER: 2447 jj_consume_token(INTEGER); 2448 name.append("("); 2449 name.append(token.image); 2450 name.append(")"); 2451 break; 2452 case ID: 2453 jj_consume_token(ID); 2454 name.append("("); 2455 name.append(token.image); 2456 name.append(")"); 2457 break; 2458 default: 2459 jj_la1[33] = jj_gen; 2460 jj_consume_token(-1); 2461 throw new ParseException(); 2462 } 2463 jj_consume_token(CLOSEPAREN); 2464 break; 2465 default: 2466 jj_la1[34] = jj_gen; 2467 ; 2468 } 2469 jjtree.closeNodeScope(jjtn000, true); 2470 jjtc000 = false; 2471 jjtn000._name = name.toString(); 2472 } finally { 2473 if (jjtc000) { 2474 jjtree.closeNodeScope(jjtn000, true); 2475 } 2476 } 2477 } 2478 2479 final public void identifier() throws ParseException { 2480 /*@bgen(jjtree) PtLeafNode */ 2481 ASTPtLeafNode jjtn000 = new ASTPtLeafNode(JJTPTLEAFNODE); 2482 boolean jjtc000 = true; 2483 jjtree.openNodeScope(jjtn000); 2484 try { 2485 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2486 case ID: 2487 jj_consume_token(ID); 2488 break; 2489 case SMID: 2490 jj_consume_token(SMID); 2491 break; 2492 case SMIDBRACE: 2493 jj_consume_token(SMIDBRACE); 2494 break; 2495 case SMIDPAREN: 2496 jj_consume_token(SMIDPAREN); 2497 break; 2498 default: 2499 jj_la1[35] = jj_gen; 2500 jj_consume_token(-1); 2501 throw new ParseException(); 2502 } 2503 jjtree.closeNodeScope(jjtn000, true); 2504 jjtc000 = false; 2505 // Store the name of this identifier... This will be the 2506 // name of a variable, a constant, or an undefined identifier. 2507 // Note that this name is not actually resolved into a value 2508 // until the parse tree is evaluated. 2509 2510 // NOTE: Parser constants *are not* evaluated here. Doing 2511 // this means that they can shadow other variables in scope, 2512 // which is bad. 2513 jjtn000._name = token.image; 2514 } finally { 2515 if (jjtc000) { 2516 jjtree.closeNodeScope(jjtn000, true); 2517 } 2518 } 2519 } 2520 2521 final public void matrixConstruct() throws ParseException { 2522 /*@bgen(jjtree) PtMatrixConstructNode */ 2523 ASTPtMatrixConstructNode jjtn000 = new ASTPtMatrixConstructNode( 2524 JJTPTMATRIXCONSTRUCTNODE); 2525 boolean jjtc000 = true; 2526 jjtree.openNodeScope(jjtn000); 2527 int i; 2528 int nRows = 0; 2529 try { 2530 jj_consume_token(OPENBRACKET); 2531 ++jjtn000._nColumns; 2532 ++nRows; 2533 funcIf(); 2534 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2535 case CLOSEBRACKET: 2536 case COMMA: 2537 case SEPARATOR: 2538 label_17: while (true) { 2539 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2540 case COMMA: 2541 ; 2542 break; 2543 default: 2544 jj_la1[36] = jj_gen; 2545 break label_17; 2546 } 2547 jj_consume_token(COMMA); 2548 ++jjtn000._nColumns; 2549 funcIf(); 2550 } 2551 label_18: while (true) { 2552 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2553 case SEPARATOR: 2554 ; 2555 break; 2556 default: 2557 jj_la1[37] = jj_gen; 2558 break label_18; 2559 } 2560 jj_consume_token(SEPARATOR); 2561 ++nRows; 2562 i = 0; 2563 funcIf(); 2564 ++i; 2565 label_19: while (true) { 2566 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2567 case COMMA: 2568 ; 2569 break; 2570 default: 2571 jj_la1[38] = jj_gen; 2572 break label_19; 2573 } 2574 jj_consume_token(COMMA); 2575 funcIf(); 2576 ++i; 2577 } 2578 /* Assert that the following rows have the same number of terms as the 2579 first row. */ 2580 if (i != jjtn000._nColumns) { 2581 { 2582 if (true) { 2583 throw new ParseException( 2584 "PtParser: error parsing matrix " 2585 + "construction, the row " 2586 + nRows 2587 + " does not have the same number of " 2588 + "terms as the first row."); 2589 } 2590 } 2591 } 2592 } 2593 jj_consume_token(CLOSEBRACKET); 2594 jjtree.closeNodeScope(jjtn000, true); 2595 jjtc000 = false; 2596 jjtn000._form = 1; 2597 jjtn000._nRows = nRows; 2598 break; 2599 case COLON: 2600 jj_consume_token(COLON); 2601 funcIf(); 2602 jj_consume_token(COLON); 2603 funcIf(); 2604 label_20: while (true) { 2605 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2606 case SEPARATOR: 2607 ; 2608 break; 2609 default: 2610 jj_la1[39] = jj_gen; 2611 break label_20; 2612 } 2613 jj_consume_token(SEPARATOR); 2614 ++nRows; 2615 funcIf(); 2616 jj_consume_token(COLON); 2617 funcIf(); 2618 jj_consume_token(COLON); 2619 funcIf(); 2620 } 2621 jj_consume_token(CLOSEBRACKET); 2622 jjtree.closeNodeScope(jjtn000, true); 2623 jjtc000 = false; 2624 jjtn000._form = 2; 2625 jjtn000._nRows = nRows; 2626 break; 2627 default: 2628 jj_la1[40] = jj_gen; 2629 jj_consume_token(-1); 2630 throw new ParseException(); 2631 } 2632 } catch (Throwable jjte000) { 2633 if (jjtc000) { 2634 jjtree.clearNodeScope(jjtn000); 2635 jjtc000 = false; 2636 } else { 2637 jjtree.popNode(); 2638 } 2639 if (jjte000 instanceof RuntimeException) { 2640 { 2641 if (true) { 2642 throw (RuntimeException) jjte000; 2643 } 2644 } 2645 } 2646 if (jjte000 instanceof ParseException) { 2647 { 2648 if (true) { 2649 throw (ParseException) jjte000; 2650 } 2651 } 2652 } 2653 { 2654 if (true) { 2655 throw (Error) jjte000; 2656 } 2657 } 2658 } finally { 2659 if (jjtc000) { 2660 jjtree.closeNodeScope(jjtn000, true); 2661 } 2662 } 2663 } 2664 2665 final public void recordConstruct() throws ParseException { 2666 /*@bgen(jjtree) PtRecordConstructNode */ 2667 ASTPtRecordConstructNode jjtn000 = new ASTPtRecordConstructNode( 2668 JJTPTRECORDCONSTRUCTNODE); 2669 boolean jjtc000 = true; 2670 jjtree.openNodeScope(jjtn000); 2671 Token x = null; 2672 try { 2673 jj_consume_token(OPENBRACE); 2674 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2675 case STRING: 2676 x = jj_consume_token(STRING); 2677 jjtn000._fieldNames.add(cleanupString(x.image)); 2678 jj_consume_token(SETEQUALS); 2679 funcIf(); 2680 break; 2681 case ID: 2682 x = jj_consume_token(ID); 2683 jjtn000._fieldNames.add(x.image); 2684 jj_consume_token(SETEQUALS); 2685 funcIf(); 2686 break; 2687 default: 2688 jj_la1[41] = jj_gen; 2689 jj_consume_token(-1); 2690 throw new ParseException(); 2691 } 2692 label_21: while (true) { 2693 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2694 case COMMA: 2695 ; 2696 break; 2697 default: 2698 jj_la1[42] = jj_gen; 2699 break label_21; 2700 } 2701 jj_consume_token(COMMA); 2702 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2703 case STRING: 2704 x = jj_consume_token(STRING); 2705 jjtn000._fieldNames.add(cleanupString(x.image)); 2706 jj_consume_token(SETEQUALS); 2707 funcIf(); 2708 break; 2709 case ID: 2710 x = jj_consume_token(ID); 2711 jjtn000._fieldNames.add(x.image); 2712 jj_consume_token(SETEQUALS); 2713 funcIf(); 2714 break; 2715 default: 2716 jj_la1[43] = jj_gen; 2717 jj_consume_token(-1); 2718 throw new ParseException(); 2719 } 2720 } 2721 jj_consume_token(CLOSEBRACE); 2722 } catch (Throwable jjte000) { 2723 if (jjtc000) { 2724 jjtree.clearNodeScope(jjtn000); 2725 jjtc000 = false; 2726 } else { 2727 jjtree.popNode(); 2728 } 2729 if (jjte000 instanceof RuntimeException) { 2730 { 2731 if (true) { 2732 throw (RuntimeException) jjte000; 2733 } 2734 } 2735 } 2736 if (jjte000 instanceof ParseException) { 2737 { 2738 if (true) { 2739 throw (ParseException) jjte000; 2740 } 2741 } 2742 } 2743 { 2744 if (true) { 2745 throw (Error) jjte000; 2746 } 2747 } 2748 } finally { 2749 if (jjtc000) { 2750 jjtree.closeNodeScope(jjtn000, true); 2751 } 2752 } 2753 } 2754 2755 final public void orderedRecordConstruct() throws ParseException { 2756 /*@bgen(jjtree) PtOrderedRecordConstructNode */ 2757 ASTPtOrderedRecordConstructNode jjtn000 = new ASTPtOrderedRecordConstructNode( 2758 JJTPTORDEREDRECORDCONSTRUCTNODE); 2759 boolean jjtc000 = true; 2760 jjtree.openNodeScope(jjtn000); 2761 Token x = null; 2762 try { 2763 jj_consume_token(OPENBRACKET); 2764 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2765 case STRING: 2766 x = jj_consume_token(STRING); 2767 jjtn000._fieldNames.add(cleanupString(x.image)); 2768 jj_consume_token(SETEQUALS); 2769 funcIf(); 2770 break; 2771 case ID: 2772 x = jj_consume_token(ID); 2773 jjtn000._fieldNames.add(x.image); 2774 jj_consume_token(SETEQUALS); 2775 funcIf(); 2776 break; 2777 default: 2778 jj_la1[44] = jj_gen; 2779 jj_consume_token(-1); 2780 throw new ParseException(); 2781 } 2782 label_22: while (true) { 2783 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2784 case COMMA: 2785 ; 2786 break; 2787 default: 2788 jj_la1[45] = jj_gen; 2789 break label_22; 2790 } 2791 jj_consume_token(COMMA); 2792 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2793 case STRING: 2794 x = jj_consume_token(STRING); 2795 jjtn000._fieldNames.add(cleanupString(x.image)); 2796 jj_consume_token(SETEQUALS); 2797 funcIf(); 2798 break; 2799 case ID: 2800 x = jj_consume_token(ID); 2801 jjtn000._fieldNames.add(x.image); 2802 jj_consume_token(SETEQUALS); 2803 funcIf(); 2804 break; 2805 default: 2806 jj_la1[46] = jj_gen; 2807 jj_consume_token(-1); 2808 throw new ParseException(); 2809 } 2810 } 2811 jj_consume_token(CLOSEBRACKET); 2812 } catch (Throwable jjte000) { 2813 if (jjtc000) { 2814 jjtree.clearNodeScope(jjtn000); 2815 jjtc000 = false; 2816 } else { 2817 jjtree.popNode(); 2818 } 2819 if (jjte000 instanceof RuntimeException) { 2820 { 2821 if (true) { 2822 throw (RuntimeException) jjte000; 2823 } 2824 } 2825 } 2826 if (jjte000 instanceof ParseException) { 2827 { 2828 if (true) { 2829 throw (ParseException) jjte000; 2830 } 2831 } 2832 } 2833 { 2834 if (true) { 2835 throw (Error) jjte000; 2836 } 2837 } 2838 } finally { 2839 if (jjtc000) { 2840 jjtree.closeNodeScope(jjtn000, true); 2841 } 2842 } 2843 } 2844 2845 final public void unionConstruct() throws ParseException { 2846 /*@bgen(jjtree) PtUnionConstructNode */ 2847 ASTPtUnionConstructNode jjtn000 = new ASTPtUnionConstructNode( 2848 JJTPTUNIONCONSTRUCTNODE); 2849 boolean jjtc000 = true; 2850 jjtree.openNodeScope(jjtn000); 2851 Token x = null; 2852 try { 2853 jj_consume_token(OPENUNION); 2854 x = jj_consume_token(ID); 2855 jjtn000._labelNames.add(x.image); 2856 jj_consume_token(SETEQUALS); 2857 funcIf(); 2858 label_23: while (true) { 2859 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2860 case COMMA: 2861 ; 2862 break; 2863 default: 2864 jj_la1[47] = jj_gen; 2865 break label_23; 2866 } 2867 jj_consume_token(COMMA); 2868 x = jj_consume_token(ID); 2869 jjtn000._labelNames.add(x.image); 2870 jj_consume_token(SETEQUALS); 2871 funcIf(); 2872 } 2873 jj_consume_token(CLOSEUNION); 2874 } catch (Throwable jjte000) { 2875 if (jjtc000) { 2876 jjtree.clearNodeScope(jjtn000); 2877 jjtc000 = false; 2878 } else { 2879 jjtree.popNode(); 2880 } 2881 if (jjte000 instanceof RuntimeException) { 2882 { 2883 if (true) { 2884 throw (RuntimeException) jjte000; 2885 } 2886 } 2887 } 2888 if (jjte000 instanceof ParseException) { 2889 { 2890 if (true) { 2891 throw (ParseException) jjte000; 2892 } 2893 } 2894 } 2895 { 2896 if (true) { 2897 throw (Error) jjte000; 2898 } 2899 } 2900 } finally { 2901 if (jjtc000) { 2902 jjtree.closeNodeScope(jjtn000, true); 2903 } 2904 } 2905 } 2906 2907 final public void arrayConstruct() throws ParseException { 2908 /*@bgen(jjtree) PtArrayConstructNode */ 2909 ASTPtArrayConstructNode jjtn000 = new ASTPtArrayConstructNode( 2910 JJTPTARRAYCONSTRUCTNODE); 2911 boolean jjtc000 = true; 2912 jjtree.openNodeScope(jjtn000); 2913 try { 2914 jj_consume_token(OPENBRACE); 2915 funcIf(); 2916 label_24: while (true) { 2917 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { 2918 case COMMA: 2919 ; 2920 break; 2921 default: 2922 jj_la1[48] = jj_gen; 2923 break label_24; 2924 } 2925 jj_consume_token(COMMA); 2926 funcIf(); 2927 } 2928 jj_consume_token(CLOSEBRACE); 2929 } catch (Throwable jjte000) { 2930 if (jjtc000) { 2931 jjtree.clearNodeScope(jjtn000); 2932 jjtc000 = false; 2933 } else { 2934 jjtree.popNode(); 2935 } 2936 if (jjte000 instanceof RuntimeException) { 2937 { 2938 if (true) { 2939 throw (RuntimeException) jjte000; 2940 } 2941 } 2942 } 2943 if (jjte000 instanceof ParseException) { 2944 { 2945 if (true) { 2946 throw (ParseException) jjte000; 2947 } 2948 } 2949 } 2950 { 2951 if (true) { 2952 throw (Error) jjte000; 2953 } 2954 } 2955 } finally { 2956 if (jjtc000) { 2957 jjtree.closeNodeScope(jjtn000, true); 2958 } 2959 } 2960 } 2961 2962 final public void nilArrayConstruct() throws ParseException { 2963 /*@bgen(jjtree) PtArrayConstructNode */ 2964 ASTPtArrayConstructNode jjtn000 = new ASTPtArrayConstructNode( 2965 JJTPTARRAYCONSTRUCTNODE); 2966 boolean jjtc000 = true; 2967 jjtree.openNodeScope(jjtn000); 2968 try { 2969 jj_consume_token(OPENBRACE); 2970 jj_consume_token(CLOSEBRACE); 2971 } finally { 2972 if (jjtc000) { 2973 jjtree.closeNodeScope(jjtn000, true); 2974 } 2975 } 2976 } 2977 2978 private boolean jj_2_1(int xla) { 2979 jj_la = xla; 2980 jj_lastpos = jj_scanpos = token; 2981 try { 2982 return !jj_3_1(); 2983 } catch (LookaheadSuccess ls) { 2984 return true; 2985 } finally { 2986 jj_save(0, xla); 2987 } 2988 } 2989 2990 private boolean jj_2_2(int xla) { 2991 jj_la = xla; 2992 jj_lastpos = jj_scanpos = token; 2993 try { 2994 return !jj_3_2(); 2995 } catch (LookaheadSuccess ls) { 2996 return true; 2997 } finally { 2998 jj_save(1, xla); 2999 } 3000 } 3001 3002 private boolean jj_2_3(int xla) { 3003 jj_la = xla; 3004 jj_lastpos = jj_scanpos = token; 3005 try { 3006 return !jj_3_3(); 3007 } catch (LookaheadSuccess ls) { 3008 return true; 3009 } finally { 3010 jj_save(2, xla); 3011 } 3012 } 3013 3014 private boolean jj_2_4(int xla) { 3015 jj_la = xla; 3016 jj_lastpos = jj_scanpos = token; 3017 try { 3018 return !jj_3_4(); 3019 } catch (LookaheadSuccess ls) { 3020 return true; 3021 } finally { 3022 jj_save(3, xla); 3023 } 3024 } 3025 3026 private boolean jj_2_5(int xla) { 3027 jj_la = xla; 3028 jj_lastpos = jj_scanpos = token; 3029 try { 3030 return !jj_3_5(); 3031 } catch (LookaheadSuccess ls) { 3032 return true; 3033 } finally { 3034 jj_save(4, xla); 3035 } 3036 } 3037 3038 private boolean jj_2_6(int xla) { 3039 jj_la = xla; 3040 jj_lastpos = jj_scanpos = token; 3041 try { 3042 return !jj_3_6(); 3043 } catch (LookaheadSuccess ls) { 3044 return true; 3045 } finally { 3046 jj_save(5, xla); 3047 } 3048 } 3049 3050 private boolean jj_2_7(int xla) { 3051 jj_la = xla; 3052 jj_lastpos = jj_scanpos = token; 3053 try { 3054 return !jj_3_7(); 3055 } catch (LookaheadSuccess ls) { 3056 return true; 3057 } finally { 3058 jj_save(6, xla); 3059 } 3060 } 3061 3062 private boolean jj_2_8(int xla) { 3063 jj_la = xla; 3064 jj_lastpos = jj_scanpos = token; 3065 try { 3066 return !jj_3_8(); 3067 } catch (LookaheadSuccess ls) { 3068 return true; 3069 } finally { 3070 jj_save(7, xla); 3071 } 3072 } 3073 3074 private boolean jj_2_9(int xla) { 3075 jj_la = xla; 3076 jj_lastpos = jj_scanpos = token; 3077 try { 3078 return !jj_3_9(); 3079 } catch (LookaheadSuccess ls) { 3080 return true; 3081 } finally { 3082 jj_save(8, xla); 3083 } 3084 } 3085 3086 private boolean jj_2_10(int xla) { 3087 jj_la = xla; 3088 jj_lastpos = jj_scanpos = token; 3089 try { 3090 return !jj_3_10(); 3091 } catch (LookaheadSuccess ls) { 3092 return true; 3093 } finally { 3094 jj_save(9, xla); 3095 } 3096 } 3097 3098 private boolean jj_2_11(int xla) { 3099 jj_la = xla; 3100 jj_lastpos = jj_scanpos = token; 3101 try { 3102 return !jj_3_11(); 3103 } catch (LookaheadSuccess ls) { 3104 return true; 3105 } finally { 3106 jj_save(10, xla); 3107 } 3108 } 3109 3110 private boolean jj_2_12(int xla) { 3111 jj_la = xla; 3112 jj_lastpos = jj_scanpos = token; 3113 try { 3114 return !jj_3_12(); 3115 } catch (LookaheadSuccess ls) { 3116 return true; 3117 } finally { 3118 jj_save(11, xla); 3119 } 3120 } 3121 3122 private boolean jj_2_13(int xla) { 3123 jj_la = xla; 3124 jj_lastpos = jj_scanpos = token; 3125 try { 3126 return !jj_3_13(); 3127 } catch (LookaheadSuccess ls) { 3128 return true; 3129 } finally { 3130 jj_save(12, xla); 3131 } 3132 } 3133 3134 private boolean jj_2_14(int xla) { 3135 jj_la = xla; 3136 jj_lastpos = jj_scanpos = token; 3137 try { 3138 return !jj_3_14(); 3139 } catch (LookaheadSuccess ls) { 3140 return true; 3141 } finally { 3142 jj_save(13, xla); 3143 } 3144 } 3145 3146 private boolean jj_2_15(int xla) { 3147 jj_la = xla; 3148 jj_lastpos = jj_scanpos = token; 3149 try { 3150 return !jj_3_15(); 3151 } catch (LookaheadSuccess ls) { 3152 return true; 3153 } finally { 3154 jj_save(14, xla); 3155 } 3156 } 3157 3158 private boolean jj_2_16(int xla) { 3159 jj_la = xla; 3160 jj_lastpos = jj_scanpos = token; 3161 try { 3162 return !jj_3_16(); 3163 } catch (LookaheadSuccess ls) { 3164 return true; 3165 } finally { 3166 jj_save(15, xla); 3167 } 3168 } 3169 3170 private boolean jj_3R_38() { 3171 if (jj_3R_39()) { 3172 return true; 3173 } 3174 return false; 3175 } 3176 3177 private boolean jj_3R_51() { 3178 if (jj_scan_token(BOOLEAN)) { 3179 return true; 3180 } 3181 return false; 3182 } 3183 3184 private boolean jj_3R_45() { 3185 if (jj_3R_46()) { 3186 return true; 3187 } 3188 return false; 3189 } 3190 3191 private boolean jj_3_16() { 3192 if (jj_3R_25()) { 3193 return true; 3194 } 3195 return false; 3196 } 3197 3198 private boolean jj_3R_31() { 3199 if (jj_3R_32()) { 3200 return true; 3201 } 3202 return false; 3203 } 3204 3205 private boolean jj_3R_50() { 3206 if (jj_scan_token(STRING)) { 3207 return true; 3208 } 3209 return false; 3210 } 3211 3212 private boolean jj_3R_62() { 3213 if (jj_scan_token(OPENBRACKET)) { 3214 return true; 3215 } 3216 return false; 3217 } 3218 3219 private boolean jj_3R_49() { 3220 if (jj_3R_61()) { 3221 return true; 3222 } 3223 return false; 3224 } 3225 3226 private boolean jj_3R_37() { 3227 if (jj_3R_38()) { 3228 return true; 3229 } 3230 return false; 3231 } 3232 3233 private boolean jj_3R_68() { 3234 if (jj_3R_69()) { 3235 return true; 3236 } 3237 return false; 3238 } 3239 3240 private boolean jj_3R_30() { 3241 if (jj_3R_31()) { 3242 return true; 3243 } 3244 return false; 3245 } 3246 3247 private boolean jj_3_1() { 3248 if (jj_scan_token(ID)) { 3249 return true; 3250 } 3251 if (jj_scan_token(SETEQUALS)) { 3252 return true; 3253 } 3254 return false; 3255 } 3256 3257 private boolean jj_3_2() { 3258 if (jj_3R_25()) { 3259 return true; 3260 } 3261 return false; 3262 } 3263 3264 private boolean jj_3R_36() { 3265 if (jj_3R_37()) { 3266 return true; 3267 } 3268 return false; 3269 } 3270 3271 private boolean jj_3R_64() { 3272 if (jj_scan_token(OPENBRACE)) { 3273 return true; 3274 } 3275 return false; 3276 } 3277 3278 private boolean jj_3R_28() { 3279 if (jj_3R_30()) { 3280 return true; 3281 } 3282 return false; 3283 } 3284 3285 private boolean jj_3_3() { 3286 if (jj_scan_token(FUNCTION)) { 3287 return true; 3288 } 3289 if (jj_scan_token(OPENPAREN)) { 3290 return true; 3291 } 3292 return false; 3293 } 3294 3295 private boolean jj_3R_35() { 3296 if (jj_3R_36()) { 3297 return true; 3298 } 3299 return false; 3300 } 3301 3302 private boolean jj_3R_26() { 3303 if (jj_3R_28()) { 3304 return true; 3305 } 3306 return false; 3307 } 3308 3309 private boolean jj_3_4() { 3310 if (jj_3R_26()) { 3311 return true; 3312 } 3313 return false; 3314 } 3315 3316 private boolean jj_3R_70() { 3317 if (jj_scan_token(MINUS)) { 3318 return true; 3319 } 3320 return false; 3321 } 3322 3323 private boolean jj_3R_48() { 3324 if (jj_scan_token(DOUBLE)) { 3325 return true; 3326 } 3327 return false; 3328 } 3329 3330 private boolean jj_3R_61() { 3331 Token xsp; 3332 xsp = jj_scanpos; 3333 if (jj_3R_70()) { 3334 jj_scanpos = xsp; 3335 if (jj_scan_token(44)) { 3336 return true; 3337 } 3338 } 3339 return false; 3340 } 3341 3342 private boolean jj_3R_39() { 3343 if (jj_3R_40()) { 3344 return true; 3345 } 3346 return false; 3347 } 3348 3349 private boolean jj_3R_27() { 3350 if (jj_3R_29()) { 3351 return true; 3352 } 3353 return false; 3354 } 3355 3356 private boolean jj_3_5() { 3357 if (jj_3R_25()) { 3358 return true; 3359 } 3360 return false; 3361 } 3362 3363 private boolean jj_3R_25() { 3364 Token xsp; 3365 xsp = jj_scanpos; 3366 if (jj_3R_27()) { 3367 jj_scanpos = xsp; 3368 if (jj_3_4()) { 3369 return true; 3370 } 3371 } 3372 return false; 3373 } 3374 3375 private boolean jj_3_15() { 3376 if (jj_scan_token(ID)) { 3377 return true; 3378 } 3379 if (jj_scan_token(OPENPAREN)) { 3380 return true; 3381 } 3382 return false; 3383 } 3384 3385 private boolean jj_3_7() { 3386 if (jj_3R_25()) { 3387 return true; 3388 } 3389 return false; 3390 } 3391 3392 private boolean jj_3_14() { 3393 if (jj_scan_token(OPENBRACE)) { 3394 return true; 3395 } 3396 return false; 3397 } 3398 3399 private boolean jj_3R_29() { 3400 if (jj_scan_token(FUNCTION)) { 3401 return true; 3402 } 3403 return false; 3404 } 3405 3406 private boolean jj_3_13() { 3407 if (jj_scan_token(OPENBRACE)) { 3408 return true; 3409 } 3410 if (jj_scan_token(CLOSEBRACE)) { 3411 return true; 3412 } 3413 return false; 3414 } 3415 3416 private boolean jj_3R_60() { 3417 if (jj_3R_69()) { 3418 return true; 3419 } 3420 return false; 3421 } 3422 3423 private boolean jj_3_6() { 3424 if (jj_scan_token(OPENPAREN)) { 3425 return true; 3426 } 3427 return false; 3428 } 3429 3430 private boolean jj_3R_44() { 3431 if (jj_3R_45()) { 3432 return true; 3433 } 3434 return false; 3435 } 3436 3437 private boolean jj_3_12() { 3438 if (jj_scan_token(OPENUNION)) { 3439 return true; 3440 } 3441 return false; 3442 } 3443 3444 private boolean jj_3R_63() { 3445 if (jj_scan_token(OPENBRACKET)) { 3446 return true; 3447 } 3448 return false; 3449 } 3450 3451 private boolean jj_3R_59() { 3452 if (jj_3R_68()) { 3453 return true; 3454 } 3455 return false; 3456 } 3457 3458 private boolean jj_3R_34() { 3459 if (jj_3R_35()) { 3460 return true; 3461 } 3462 return false; 3463 } 3464 3465 private boolean jj_3_11() { 3466 if (jj_scan_token(OPENBRACE)) { 3467 return true; 3468 } 3469 Token xsp; 3470 xsp = jj_scanpos; 3471 if (jj_scan_token(56)) { 3472 jj_scanpos = xsp; 3473 if (jj_scan_token(54)) { 3474 return true; 3475 } 3476 } 3477 if (jj_scan_token(SETEQUALS)) { 3478 return true; 3479 } 3480 return false; 3481 } 3482 3483 private boolean jj_3R_58() { 3484 if (jj_3R_67()) { 3485 return true; 3486 } 3487 return false; 3488 } 3489 3490 private boolean jj_3R_47() { 3491 if (jj_scan_token(COMPLEX)) { 3492 return true; 3493 } 3494 return false; 3495 } 3496 3497 private boolean jj_3R_46() { 3498 Token xsp; 3499 xsp = jj_scanpos; 3500 if (jj_3R_47()) { 3501 jj_scanpos = xsp; 3502 if (jj_3R_48()) { 3503 jj_scanpos = xsp; 3504 if (jj_3R_49()) { 3505 jj_scanpos = xsp; 3506 if (jj_3R_50()) { 3507 jj_scanpos = xsp; 3508 if (jj_3R_51()) { 3509 jj_scanpos = xsp; 3510 if (jj_3R_52()) { 3511 jj_scanpos = xsp; 3512 if (jj_3R_53()) { 3513 jj_scanpos = xsp; 3514 if (jj_3R_54()) { 3515 jj_scanpos = xsp; 3516 if (jj_3R_55()) { 3517 jj_scanpos = xsp; 3518 if (jj_3R_56()) { 3519 jj_scanpos = xsp; 3520 if (jj_3R_57()) { 3521 jj_scanpos = xsp; 3522 if (jj_3R_58()) { 3523 jj_scanpos = xsp; 3524 if (jj_3R_59()) { 3525 jj_scanpos = xsp; 3526 if (jj_3R_60()) { 3527 return true; 3528 } 3529 } 3530 } 3531 } 3532 } 3533 } 3534 } 3535 } 3536 } 3537 } 3538 } 3539 } 3540 } 3541 } 3542 return false; 3543 } 3544 3545 private boolean jj_3R_43() { 3546 if (jj_scan_token(BITWISE_NOT)) { 3547 return true; 3548 } 3549 return false; 3550 } 3551 3552 private boolean jj_3_10() { 3553 if (jj_scan_token(OPENBRACKET)) { 3554 return true; 3555 } 3556 return false; 3557 } 3558 3559 private boolean jj_3R_57() { 3560 if (jj_3R_66()) { 3561 return true; 3562 } 3563 return false; 3564 } 3565 3566 private boolean jj_3_9() { 3567 if (jj_scan_token(OPENBRACKET)) { 3568 return true; 3569 } 3570 Token xsp; 3571 xsp = jj_scanpos; 3572 if (jj_scan_token(56)) { 3573 jj_scanpos = xsp; 3574 if (jj_scan_token(54)) { 3575 return true; 3576 } 3577 } 3578 if (jj_scan_token(SETEQUALS)) { 3579 return true; 3580 } 3581 return false; 3582 } 3583 3584 private boolean jj_3R_66() { 3585 if (jj_scan_token(OPENBRACE)) { 3586 return true; 3587 } 3588 return false; 3589 } 3590 3591 private boolean jj_3R_56() { 3592 if (jj_3R_65()) { 3593 return true; 3594 } 3595 return false; 3596 } 3597 3598 private boolean jj_3R_42() { 3599 if (jj_scan_token(BOOL_NOT)) { 3600 return true; 3601 } 3602 return false; 3603 } 3604 3605 private boolean jj_3_8() { 3606 if (jj_scan_token(OPENPAREN)) { 3607 return true; 3608 } 3609 return false; 3610 } 3611 3612 private boolean jj_3R_55() { 3613 if (jj_3R_64()) { 3614 return true; 3615 } 3616 return false; 3617 } 3618 3619 private boolean jj_3R_33() { 3620 if (jj_3R_34()) { 3621 return true; 3622 } 3623 return false; 3624 } 3625 3626 private boolean jj_3R_54() { 3627 if (jj_3R_63()) { 3628 return true; 3629 } 3630 return false; 3631 } 3632 3633 private boolean jj_3R_69() { 3634 Token xsp; 3635 xsp = jj_scanpos; 3636 if (jj_scan_token(54)) { 3637 jj_scanpos = xsp; 3638 if (jj_scan_token(63)) { 3639 jj_scanpos = xsp; 3640 if (jj_scan_token(65)) { 3641 jj_scanpos = xsp; 3642 if (jj_scan_token(67)) { 3643 return true; 3644 } 3645 } 3646 } 3647 } 3648 return false; 3649 } 3650 3651 private boolean jj_3R_53() { 3652 if (jj_3R_62()) { 3653 return true; 3654 } 3655 return false; 3656 } 3657 3658 private boolean jj_3R_40() { 3659 Token xsp; 3660 xsp = jj_scanpos; 3661 jj_lookingAhead = true; 3662 jj_semLA = getToken(1).kind == MINUS && getToken(2).kind != INTEGER; 3663 jj_lookingAhead = false; 3664 if (!jj_semLA || jj_3R_41()) { 3665 jj_scanpos = xsp; 3666 if (jj_3R_42()) { 3667 jj_scanpos = xsp; 3668 if (jj_3R_43()) { 3669 jj_scanpos = xsp; 3670 if (jj_3R_44()) { 3671 return true; 3672 } 3673 } 3674 } 3675 } 3676 return false; 3677 } 3678 3679 private boolean jj_3R_41() { 3680 if (jj_scan_token(MINUS)) { 3681 return true; 3682 } 3683 return false; 3684 } 3685 3686 private boolean jj_3R_67() { 3687 if (jj_scan_token(OPENBRACE)) { 3688 return true; 3689 } 3690 return false; 3691 } 3692 3693 private boolean jj_3R_52() { 3694 if (jj_scan_token(OPENPAREN)) { 3695 return true; 3696 } 3697 return false; 3698 } 3699 3700 private boolean jj_3R_32() { 3701 if (jj_3R_33()) { 3702 return true; 3703 } 3704 return false; 3705 } 3706 3707 private boolean jj_3R_65() { 3708 if (jj_scan_token(OPENUNION)) { 3709 return true; 3710 } 3711 return false; 3712 } 3713 3714 /** Generated Token Manager. */ 3715 public PtParserTokenManager token_source; 3716 SimpleCharStream jj_input_stream; 3717 /** Current token. */ 3718 public Token token; 3719 /** Next token. */ 3720 public Token jj_nt; 3721 private int jj_ntk; 3722 private Token jj_scanpos, jj_lastpos; 3723 private int jj_la; 3724 /** Whether we are looking ahead. */ 3725 private boolean jj_lookingAhead = false; 3726 private boolean jj_semLA; 3727 private int jj_gen; 3728 final private int[] jj_la1 = new int[49]; 3729 static private int[] jj_la1_0; 3730 static private int[] jj_la1_1; 3731 static private int[] jj_la1_2; 3732 static { 3733 jj_la1_init_0(); 3734 jj_la1_init_1(); 3735 jj_la1_init_2(); 3736 } 3737 3738 private static void jj_la1_init_0() { 3739 jj_la1_0 = new int[] { 0x0, 0x0, 0x0, 0x2000000, 0x0, 0x0, 0x0, 0x0, 3740 0x0, 0x0, 0x0, 0x8000, 0xf0000000, 0xf0000000, 0x0, 0x0, 0xc00, 3741 0xc00, 0x7000, 0x7000, 0x4150800, 0x810000, 0x400000, 0x400000, 3742 0x810000, 0x800, 0x800, 0x0, 0x400000, 0x0, 0x1000000, 0x400000, 3743 0x800000, 0x0, 0x10000, 0x0, 0x400000, 0x0, 0x400000, 0x0, 3744 0x1600000, 0x0, 0x400000, 0x0, 0x0, 0x400000, 0x0, 0x400000, 3745 0x400000, }; 3746 } 3747 3748 private static void jj_la1_init_1() { 3749 jj_la1_1 = new int[] { 0x4000000, 0x78000000, 0x78000000, 0x0, 0x8, 0x4, 3750 0x80, 0x100, 0x40, 0x3, 0x3, 0x0, 0x0, 0x0, 0xe00, 0xe00, 0x0, 3751 0x0, 0x0, 0x0, 0x815c1030, 0x0, 0x0, 0x0, 0x0, 0x1000, 3752 0x11c1000, 0x80400000, 0x0, 0x400000, 0x0, 0x0, 0x0, 0x401000, 3753 0x0, 0x80400000, 0x0, 0x4000000, 0x0, 0x4000000, 0x4000000, 3754 0x1400000, 0x0, 0x1400000, 0x1400000, 0x0, 0x1400000, 0x0, 3755 0x0, }; 3756 } 3757 3758 private static void jj_la1_init_2() { 3759 jj_la1_2 = new int[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 3760 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 3761 0x0, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 3762 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 3763 0x0, }; 3764 } 3765 3766 final private JJCalls[] jj_2_rtns = new JJCalls[16]; 3767 private boolean jj_rescan = false; 3768 private int jj_gc = 0; 3769 3770 /** Constructor with InputStream. */ 3771 public PtParser(java.io.InputStream stream) { 3772 this(stream, null); 3773 } 3774 3775 /** Constructor with InputStream and supplied encoding */ 3776 public PtParser(java.io.InputStream stream, String encoding) { 3777 try { 3778 jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); 3779 } catch (java.io.UnsupportedEncodingException e) { 3780 throw new RuntimeException(e); 3781 } 3782 token_source = new PtParserTokenManager(jj_input_stream); 3783 token = new Token(); 3784 jj_ntk = -1; 3785 jj_gen = 0; 3786 for (int i = 0; i < 49; i++) { 3787 jj_la1[i] = -1; 3788 } 3789 for (int i = 0; i < jj_2_rtns.length; i++) { 3790 jj_2_rtns[i] = new JJCalls(); 3791 } 3792 } 3793 3794 /** Reinitialise. */ 3795 public void ReInit(java.io.InputStream stream) { 3796 ReInit(stream, null); 3797 } 3798 3799 /** Reinitialise. */ 3800 public void ReInit(java.io.InputStream stream, String encoding) { 3801 try { 3802 jj_input_stream.ReInit(stream, encoding, 1, 1); 3803 } catch (java.io.UnsupportedEncodingException e) { 3804 throw new RuntimeException(e); 3805 } 3806 token_source.ReInit(jj_input_stream); 3807 token = new Token(); 3808 jj_ntk = -1; 3809 jjtree.reset(); 3810 jj_gen = 0; 3811 for (int i = 0; i < 49; i++) { 3812 jj_la1[i] = -1; 3813 } 3814 for (int i = 0; i < jj_2_rtns.length; i++) { 3815 jj_2_rtns[i] = new JJCalls(); 3816 } 3817 } 3818 3819 /** Constructor. */ 3820 public PtParser(java.io.Reader stream) { 3821 jj_input_stream = new SimpleCharStream(stream, 1, 1); 3822 token_source = new PtParserTokenManager(jj_input_stream); 3823 token = new Token(); 3824 jj_ntk = -1; 3825 jj_gen = 0; 3826 for (int i = 0; i < 49; i++) { 3827 jj_la1[i] = -1; 3828 } 3829 for (int i = 0; i < jj_2_rtns.length; i++) { 3830 jj_2_rtns[i] = new JJCalls(); 3831 } 3832 } 3833 3834 /** Reinitialise. */ 3835 public void ReInit(java.io.Reader stream) { 3836 jj_input_stream.ReInit(stream, 1, 1); 3837 token_source.ReInit(jj_input_stream); 3838 token = new Token(); 3839 jj_ntk = -1; 3840 jjtree.reset(); 3841 jj_gen = 0; 3842 for (int i = 0; i < 49; i++) { 3843 jj_la1[i] = -1; 3844 } 3845 for (int i = 0; i < jj_2_rtns.length; i++) { 3846 jj_2_rtns[i] = new JJCalls(); 3847 } 3848 } 3849 3850 /** Constructor with generated Token Manager. */ 3851 public PtParser(PtParserTokenManager tm) { 3852 token_source = tm; 3853 token = new Token(); 3854 jj_ntk = -1; 3855 jj_gen = 0; 3856 for (int i = 0; i < 49; i++) { 3857 jj_la1[i] = -1; 3858 } 3859 for (int i = 0; i < jj_2_rtns.length; i++) { 3860 jj_2_rtns[i] = new JJCalls(); 3861 } 3862 } 3863 3864 /** Reinitialise. */ 3865 public void ReInit(PtParserTokenManager tm) { 3866 token_source = tm; 3867 token = new Token(); 3868 jj_ntk = -1; 3869 jjtree.reset(); 3870 jj_gen = 0; 3871 for (int i = 0; i < 49; i++) { 3872 jj_la1[i] = -1; 3873 } 3874 for (int i = 0; i < jj_2_rtns.length; i++) { 3875 jj_2_rtns[i] = new JJCalls(); 3876 } 3877 } 3878 3879 private Token jj_consume_token(int kind) throws ParseException { 3880 Token oldToken; 3881 if ((oldToken = token).next != null) { 3882 token = token.next; 3883 } else { 3884 token = token.next = token_source.getNextToken(); 3885 } 3886 jj_ntk = -1; 3887 if (token.kind == kind) { 3888 jj_gen++; 3889 if (++jj_gc > 100) { 3890 jj_gc = 0; 3891 for (int i = 0; i < jj_2_rtns.length; i++) { 3892 JJCalls c = jj_2_rtns[i]; 3893 while (c != null) { 3894 if (c.gen < jj_gen) { 3895 c.first = null; 3896 } 3897 c = c.next; 3898 } 3899 } 3900 } 3901 return token; 3902 } 3903 token = oldToken; 3904 jj_kind = kind; 3905 throw generateParseException(); 3906 } 3907 3908 @SuppressWarnings("serial") 3909 static private final class LookaheadSuccess extends java.lang.Error { 3910 } 3911 3912 final private LookaheadSuccess jj_ls = new LookaheadSuccess(); 3913 3914 private boolean jj_scan_token(int kind) { 3915 if (jj_scanpos == jj_lastpos) { 3916 jj_la--; 3917 if (jj_scanpos.next == null) { 3918 jj_lastpos = jj_scanpos = jj_scanpos.next = token_source 3919 .getNextToken(); 3920 } else { 3921 jj_lastpos = jj_scanpos = jj_scanpos.next; 3922 } 3923 } else { 3924 jj_scanpos = jj_scanpos.next; 3925 } 3926 if (jj_rescan) { 3927 int i = 0; 3928 Token tok = token; 3929 while (tok != null && tok != jj_scanpos) { 3930 i++; 3931 tok = tok.next; 3932 } 3933 if (tok != null) { 3934 jj_add_error_token(kind, i); 3935 } 3936 } 3937 if (jj_scanpos.kind != kind) { 3938 return true; 3939 } 3940 if (jj_la == 0 && jj_scanpos == jj_lastpos) { 3941 throw jj_ls; 3942 } 3943 return false; 3944 } 3945 3946 /** Get the next Token. */ 3947 final public Token getNextToken() { 3948 if (token.next != null) { 3949 token = token.next; 3950 } else { 3951 token = token.next = token_source.getNextToken(); 3952 } 3953 jj_ntk = -1; 3954 jj_gen++; 3955 return token; 3956 } 3957 3958 /** Get the specific Token. */ 3959 final public Token getToken(int index) { 3960 Token t = jj_lookingAhead ? jj_scanpos : token; 3961 for (int i = 0; i < index; i++) { 3962 if (t.next != null) { 3963 t = t.next; 3964 } else { 3965 t = t.next = token_source.getNextToken(); 3966 } 3967 } 3968 return t; 3969 } 3970 3971 private int jj_ntk() { 3972 if ((jj_nt = token.next) == null) { 3973 return (jj_ntk = (token.next = token_source.getNextToken()).kind); 3974 } else { 3975 return (jj_ntk = jj_nt.kind); 3976 } 3977 } 3978 3979 private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>(); 3980 private int[] jj_expentry; 3981 private int jj_kind = -1; 3982 private int[] jj_lasttokens = new int[100]; 3983 private int jj_endpos; 3984 3985 private void jj_add_error_token(int kind, int pos) { 3986 if (pos >= 100) { 3987 return; 3988 } 3989 if (pos == jj_endpos + 1) { 3990 jj_lasttokens[jj_endpos++] = kind; 3991 } else if (jj_endpos != 0) { 3992 jj_expentry = new int[jj_endpos]; 3993 for (int i = 0; i < jj_endpos; i++) { 3994 jj_expentry[i] = jj_lasttokens[i]; 3995 } 3996 jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries 3997 .iterator(); it.hasNext();) { 3998 int[] oldentry = (int[]) (it.next()); 3999 if (oldentry.length == jj_expentry.length) { 4000 for (int i = 0; i < jj_expentry.length; i++) { 4001 if (oldentry[i] != jj_expentry[i]) { 4002 continue jj_entries_loop; 4003 } 4004 } 4005 jj_expentries.add(jj_expentry); 4006 break jj_entries_loop; 4007 } 4008 } 4009 if (pos != 0) { 4010 jj_lasttokens[(jj_endpos = pos) - 1] = kind; 4011 } 4012 } 4013 } 4014 4015 /** Generate ParseException. */ 4016 public ParseException generateParseException() { 4017 jj_expentries.clear(); 4018 boolean[] la1tokens = new boolean[70]; 4019 if (jj_kind >= 0) { 4020 la1tokens[jj_kind] = true; 4021 jj_kind = -1; 4022 } 4023 for (int i = 0; i < 49; i++) { 4024 if (jj_la1[i] == jj_gen) { 4025 for (int j = 0; j < 32; j++) { 4026 if ((jj_la1_0[i] & (1 << j)) != 0) { 4027 la1tokens[j] = true; 4028 } 4029 if ((jj_la1_1[i] & (1 << j)) != 0) { 4030 la1tokens[32 + j] = true; 4031 } 4032 if ((jj_la1_2[i] & (1 << j)) != 0) { 4033 la1tokens[64 + j] = true; 4034 } 4035 } 4036 } 4037 } 4038 for (int i = 0; i < 70; i++) { 4039 if (la1tokens[i]) { 4040 jj_expentry = new int[1]; 4041 jj_expentry[0] = i; 4042 jj_expentries.add(jj_expentry); 4043 } 4044 } 4045 jj_endpos = 0; 4046 jj_rescan_token(); 4047 jj_add_error_token(0, 0); 4048 int[][] exptokseq = new int[jj_expentries.size()][]; 4049 for (int i = 0; i < jj_expentries.size(); i++) { 4050 exptokseq[i] = jj_expentries.get(i); 4051 } 4052 return new ParseException(token, exptokseq, tokenImage); 4053 } 4054 4055 /** Enable tracing. */ 4056 final public void enable_tracing() { 4057 } 4058 4059 /** Disable tracing. */ 4060 final public void disable_tracing() { 4061 } 4062 4063 private void jj_rescan_token() { 4064 jj_rescan = true; 4065 for (int i = 0; i < 16; i++) { 4066 try { 4067 JJCalls p = jj_2_rtns[i]; 4068 do { 4069 if (p.gen > jj_gen) { 4070 jj_la = p.arg; 4071 jj_lastpos = jj_scanpos = p.first; 4072 switch (i) { 4073 case 0: 4074 jj_3_1(); 4075 break; 4076 case 1: 4077 jj_3_2(); 4078 break; 4079 case 2: 4080 jj_3_3(); 4081 break; 4082 case 3: 4083 jj_3_4(); 4084 break; 4085 case 4: 4086 jj_3_5(); 4087 break; 4088 case 5: 4089 jj_3_6(); 4090 break; 4091 case 6: 4092 jj_3_7(); 4093 break; 4094 case 7: 4095 jj_3_8(); 4096 break; 4097 case 8: 4098 jj_3_9(); 4099 break; 4100 case 9: 4101 jj_3_10(); 4102 break; 4103 case 10: 4104 jj_3_11(); 4105 break; 4106 case 11: 4107 jj_3_12(); 4108 break; 4109 case 12: 4110 jj_3_13(); 4111 break; 4112 case 13: 4113 jj_3_14(); 4114 break; 4115 case 14: 4116 jj_3_15(); 4117 break; 4118 case 15: 4119 jj_3_16(); 4120 break; 4121 } 4122 } 4123 p = p.next; 4124 } while (p != null); 4125 } catch (LookaheadSuccess ls) { 4126 } 4127 } 4128 jj_rescan = false; 4129 } 4130 4131 private void jj_save(int index, int xla) { 4132 JJCalls p = jj_2_rtns[index]; 4133 while (p.gen > jj_gen) { 4134 if (p.next == null) { 4135 p = p.next = new JJCalls(); 4136 break; 4137 } 4138 p = p.next; 4139 } 4140 p.gen = jj_gen + xla - jj_la; 4141 p.first = token; 4142 p.arg = xla; 4143 } 4144 4145 static final class JJCalls { 4146 int gen; 4147 Token first; 4148 int arg; 4149 JJCalls next; 4150 } 4151 4152}