1 /**********************************************************************
2 Copyright (c) 2002 Klaus Hartlage - www.eclipseproject.de
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
9 Klaus Hartlage - www.eclipseproject.de
10 **********************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.parser;
13 import java.util.ArrayList;
15 import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
16 import net.sourceforge.phpdt.core.compiler.InvalidInputException;
17 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
18 import net.sourceforge.phpeclipse.phpeditor.PHPString;
20 import org.eclipse.core.resources.IFile;
21 import org.eclipse.core.runtime.CoreException;
22 import org.eclipse.jface.preference.IPreferenceStore;
24 import test.PHPParserSuperclass;
26 public class Parser extends PHPParserSuperclass implements ITerminalSymbols {
29 public Scanner scanner;
31 private ArrayList phpList;
33 private int currentPHPString;
34 private boolean phpEnd;
36 // private static HashMap keywordMap = null;
44 // row counter for syntax errors:
46 // column counter for syntax errors:
51 // // current identifier
57 private String stringValue;
59 /** Contains the current expression. */
60 // private StringBuffer expression;
62 private boolean phpMode;
64 // final static int TokenNameEOF = 0;
65 // final static int TokenNameERROR = 1;
66 // final static int TokenNameHTML = 2;
68 // final static int TokenNameREMAINDER = 30;
69 // final static int TokenNameNOT = 31;
70 // final static int TokenNameDOT = 32;
71 // final static int TokenNameXOR = 33;
72 // final static int TokenNameDIVIDE = 34;
73 // final static int TokenNameMULTIPLY = 35;
74 // final static int TokenNameMINUS = 36;
75 // final static int TokenNamePLUS = 37;
76 // final static int TokenNameEQUAL_EQUAL = 38;
77 // final static int TokenNameNOT_EQUAL = 39;
78 // final static int TokenNameGREATER = 40;
79 // final static int TokenNameGREATER_EQUAL = 41;
80 // final static int TokenNameLESS = 42;
81 // final static int TokenNameLESS_EQUAL = 43;
82 // final static int TokenNameAND_AND = 44;
83 // final static int TokenNameOR_OR = 45;
84 // // final static int TokenNameHASH = 46;
85 // final static int TokenNameCOLON = 47;
86 // final static int TokenNameDOT_EQUAL = 48;
88 // final static int TokenNameEQUAL = 49;
89 // final static int TokenNameMINUS_GREATER = 50; // ->
90 // final static int TokenNameFOREACH = 51;
91 // final static int TokenNameAND = 52;
92 // //final static int TokenNameDOLLARLISTOPEN = 53;
93 // final static int TokenNameTWIDDLE = 54;
94 // final static int TokenNameTWIDDLE_EQUAL = 55;
95 // final static int TokenNameREMAINDER_EQUAL = 56;
96 // final static int TokenNameXOR_EQUAL = 57;
97 // final static int TokenNameRIGHT_SHIFT_EQUAL = 58;
98 // final static int TokenNameLEFT_SHIFT_EQUAL = 59;
99 // final static int TokenNameAND_EQUAL = 60;
100 // final static int TokenNameOR_EQUAL = 61;
101 // final static int TokenNameQUESTION = 62;
102 // final static int TokenNameCOLON_COLON = 63;
103 // final static int TokenNameAT = 63;
104 // // final static int TokenNameHEREDOC = 64;
106 // final static int TokenNameDOLLAROPEN = 127;
107 // final static int TokenNameLPAREN = 128;
108 // final static int TokenNameRPAREN = 129;
109 // final static int TokenNameLBRACE = 130;
110 // final static int TokenNameRBRACE = 131;
111 // final static int TokenNameLBRACKET = 132;
112 // final static int TokenNameRBRACKET = 133;
113 // final static int TokenNameCOMMA = 134;
115 // final static int TokenNameStringLiteral = 136;
116 // final static int TokenNameIdentifier = 138;
117 // // final static int TokenNameDIGIT = 139;
118 // final static int TokenNameSEMICOLON = 140;
119 // // final static int TokenNameSLOT = 141;
120 // // final static int TokenNameSLOTSEQUENCE = 142;
121 // final static int TokenNameMINUS_MINUS = 144;
122 // final static int TokenNamePLUS_PLUS = 145;
123 // final static int TokenNamePLUS_EQUAL = 146;
124 // final static int TokenNameDIVIDE_EQUAL = 147;
125 // final static int TokenNameMINUS_EQUAL = 148;
126 // final static int TokenNameMULTIPLY_EQUAL = 149;
127 // final static int TokenNameVariable = 150;
128 // final static int TokenNameIntegerLiteral = 151;
129 // final static int TokenNameDoubleLiteral = 152;
130 // final static int TokenNameStringInterpolated = 153;
131 // final static int TokenNameStringConstant = 154;
133 // final static int TokenNameLEFT_SHIFT = 155;
134 // final static int TokenNameRIGHT_SHIFT = 156;
135 // final static int TokenNameEQUAL_EQUAL_EQUAL = 157;
136 // final static int TokenNameNOT_EQUAL_EQUAL = 158;
137 // final static int TokenNameOR = 159;
138 // final static int TokenNameAT = 153; // @
143 public void setFileToParse(IFile fileToParse) {
144 this.currentPHPString = 0;
145 this.fileToParse = fileToParse;
148 this.token = TokenNameEOF;
150 this.initializeScanner();
153 * ClassDeclaration Constructor.
156 *@param sess Description of Parameter
159 public Parser(IFile fileToParse) {
160 // if (keywordMap == null) {
161 // keywordMap = new HashMap();
162 // for (int i = 0; i < PHP_KEYWORS.length; i++) {
163 // keywordMap.put(PHP_KEYWORS[i], new Integer(PHP_KEYWORD_TOKEN[i]));
166 this.currentPHPString = 0;
167 this.fileToParse = fileToParse;
170 this.token = TokenNameEOF;
172 // this.rowCount = 1;
173 // this.columnCount = 0;
177 this.initializeScanner();
180 public void initializeScanner() {
181 this.scanner = new Scanner(false, false, false, false);
184 * Create marker for the parse error
186 private void setMarker(String message, int charStart, int charEnd, int errorLevel) throws CoreException {
187 setMarker(fileToParse, message, charStart, charEnd, errorLevel);
191 * This method will throw the SyntaxError.
192 * It will add the good lines and columns to the Error
193 * @param error the error message
194 * @throws SyntaxError the error raised
196 private void throwSyntaxError(String error) {
198 // if (str.length() < chIndx) {
201 // // read until end-of-line
203 // while (str.length() > eol) {
204 // ch = str.charAt(eol++);
210 // throw new SyntaxError(
212 // chIndx - columnCount + 1,
213 // str.substring(columnCount, eol),
215 throw new SyntaxError(1, 1, "", error);
219 * This method will throw the SyntaxError.
220 * It will add the good lines and columns to the Error
221 * @param error the error message
222 * @throws SyntaxError the error raised
224 private void throwSyntaxError(String error, int startRow) {
225 throw new SyntaxError(startRow, 0, " ", error);
229 * Method Declaration.
233 // private void getChar() {
234 // if (str.length() > chIndx) {
235 // ch = str.charAt(chIndx++);
240 // chIndx = str.length() + 1;
242 // // token = TokenNameEOF;
247 * gets the next token from input
249 private void getNextToken() throws CoreException {
251 token = scanner.getNextToken();
253 int currentEndPosition = scanner.getCurrentTokenEndPosition();
254 int currentStartPosition = scanner.getCurrentTokenStartPosition();
256 System.out.print(currentStartPosition + "," + currentEndPosition + ": ");
257 System.out.println(scanner.toStringAction(token));
259 } catch (InvalidInputException e) {
260 token = TokenNameERROR;
268 * if it's a <code>double</code> the number will be stored in <code>doubleNumber</code> and the token will have the
269 * value {@link Parser#TokenNameDOUBLE_NUMBER}<br />
270 * if it's a <code>double</code> the number will be stored in <code>longNumber</code> and the token will have the
271 * value {@link Parser#TokenNameINT_NUMBER}
273 // private void getNumber() {
274 // StringBuffer inum = new StringBuffer();
276 // int numFormat = 10;
278 // // save first digit
279 // char firstCh = ch;
283 // // determine number conversions:
284 // if (firstCh == '0') {
313 // if (numFormat == 16) {
314 // while ((ch >= '0' && ch <= '9')
315 // || (ch >= 'a' && ch <= 'f')
316 // || (ch >= 'A' && ch <= 'F')) {
321 // while ((ch >= '0' && ch <= '9')
325 // if ((ch == '.') || (ch == 'E') || (ch == 'e')) {
326 // if (ch == '.' && dFlag != ' ') {
329 // if ((dFlag == 'E') || (dFlag == 'e')) {
335 // if ((ch == '-') || (ch == '+')) {
348 // if (dFlag != ' ') {
349 // doubleNumber = new Double(inum.toString());
350 // token = TokenNameDoubleLiteral;
353 // longNumber = Long.valueOf(inum.toString(), numFormat);
354 // token = TokenNameIntegerLiteral;
358 // } catch (Throwable e) {
359 // throwSyntaxError("Number format error: " + inum.toString());
365 // * @param openChar the opening char ('\'', '"', '`')
366 // * @param typeString the type of string {@link #TokenNameSTRING_CONSTANT},{@link #TokenNameINTERPOLATED_STRING}
367 // * @param errorMsg the error message in case of parse error in the string
369 // private void getString(
370 // final char openChar,
371 // final int typeString,
372 // final String errorMsg) {
373 // StringBuffer sBuffer = new StringBuffer();
374 // boolean openString = true;
375 // int startRow = rowCount;
376 // while (str.length() > chIndx) {
377 // ch = str.charAt(chIndx++);
379 // sBuffer.append(ch);
380 // if (str.length() > chIndx) {
381 // ch = str.charAt(chIndx++);
382 // sBuffer.append(ch);
384 // } else if (ch == openChar) {
385 // openString = false;
387 // } else if (ch == '\n') {
389 // columnCount = chIndx;
391 // sBuffer.append(ch);
395 // if (typeString == TokenNameStringConstant) {
396 // throwSyntaxError(errorMsg, startRow);
398 // throwSyntaxError(errorMsg);
401 // token = typeString;
402 // stringValue = sBuffer.toString();
405 // public void htmlParserTester(String input) {
406 // int lineNumber = 1;
407 // int startLineNumber = 1;
408 // int startIndex = 0;
411 // boolean phpMode = false;
412 // boolean phpFound = false;
414 // phpList = new ArrayList();
415 // currentPHPString = 0;
419 // while (i < input.length()) {
420 // ch = input.charAt(i++);
424 // if ((!phpMode) && ch == '<') {
425 // ch2 = input.charAt(i++);
427 // ch2 = input.charAt(i++);
428 // if (Character.isWhitespace(ch2)) {
433 // startLineNumber = lineNumber;
435 // } else if (ch2 == 'p') {
436 // ch2 = input.charAt(i++);
438 // ch2 = input.charAt(i++);
443 // startLineNumber = lineNumber;
449 // } else if (ch2 == 'P') {
450 // ch2 = input.charAt(i++);
452 // ch2 = input.charAt(i++);
457 // startLineNumber = lineNumber;
470 // if (ch == '/' && i < input.length()) {
471 // ch2 = input.charAt(i++);
473 // while (i < input.length()) {
474 // ch = input.charAt(i++);
475 // if (ch == '?' && i < input.length()) {
476 // ch2 = input.charAt(i++);
485 // startLineNumber));
489 // } else if (ch == '\n') {
495 // } else if (ch2 == '*') {
496 // // multi-line comment
497 // while (i < input.length()) {
498 // ch = input.charAt(i++);
501 // } else if (ch == '*' && i < input.length()) {
502 // ch2 = input.charAt(i++);
513 // } else if (ch == '#') {
514 // while (i < input.length()) {
515 // ch = input.charAt(i++);
516 // if (ch == '?' && i < input.length()) {
517 // ch2 = input.charAt(i++);
523 // input.substring(startIndex, i - 2),
524 // startLineNumber));
528 // } else if (ch == '\n') {
534 // } else if (ch == '"') {
536 // while (i < input.length()) {
537 // ch = input.charAt(i++);
541 // ch == '\\' && i < input.length()) { // escape
543 // } else if (ch == '"') {
548 // } else if (ch == '\'') {
550 // while (i < input.length()) {
551 // ch = input.charAt(i++);
555 // ch == '\\' && i < input.length()) { // escape
557 // } else if (ch == '\'') {
564 // if (ch == '?' && i < input.length()) {
565 // ch2 = input.charAt(i++);
571 // input.substring(startIndex, i - 2),
572 // startLineNumber));
582 // "No PHP source code found.",
588 // "Open PHP tag at end of file.",
593 // input.substring(startIndex, i - 2),
594 // startLineNumber));
596 // // for (int j=0;j<phpList.size();j++) {
597 // // String temp = ((PHPString)phpList.get(j)).getPHPString();
598 // // int startIndx = temp.length()-10;
599 // // if (startIndx<0) {
602 // // System.out.println(temp.substring(startIndx)+"?>");
604 // phpParserTester(null, 1);
605 // // PHPString temp;
606 // // for(int j=0;j<phpList.size();j++) {
607 // // temp = (PHPString) phpList.get(j);
608 // // parser.start(temp.getPHPString(), temp.getLineNumber());
611 // } catch (CoreException e) {
615 public void phpParserTester(String s, int rowCount) throws CoreException {
618 if (phpList.size() != 0) {
619 this.str = ((PHPString) phpList.get(currentPHPString++)).getPHPString();
622 this.token = TokenNameEOF;
624 // this.rowCount = rowCount;
625 // this.columnCount = 0;
628 scanner.setSource(s.toCharArray());
629 scanner.setPHPMode(true);
633 if (token != TokenNameEOF && token != TokenNameERROR) {
636 if (token != TokenNameEOF) {
637 if (token == TokenNameERROR) {
638 throwSyntaxError("Scanner error (Found unknown token: " + scanner.toStringAction(token) + ")");
640 if (token == TokenNameRPAREN) {
641 throwSyntaxError("Too many closing ')'; end-of-file not reached.");
643 if (token == TokenNameRBRACE) {
644 throwSyntaxError("Too many closing '}'; end-of-file not reached.");
646 if (token == TokenNameRBRACKET) {
647 throwSyntaxError("Too many closing ']'; end-of-file not reached.");
650 if (token == TokenNameLPAREN) {
651 throwSyntaxError("Read character '('; end-of-file not reached.");
653 if (token == TokenNameLBRACE) {
654 throwSyntaxError("Read character '{'; end-of-file not reached.");
656 if (token == TokenNameLBRACKET) {
657 throwSyntaxError("Read character '['; end-of-file not reached.");
660 throwSyntaxError("End-of-file not reached.");
663 } catch (SyntaxError err) {
667 // setMarker(err.getMessage(), err.getLine(), ERROR);
668 setMarker(err.getMessage(), scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(), ERROR);
670 // if an error occured,
671 // try to find keywords 'class' or 'function'
672 // to parse the rest of the string
673 while (token != TokenNameEOF && token != TokenNameERROR) {
674 if (token == TokenNameclass || token == TokenNamefunction) {
679 if (token == TokenNameEOF || token == TokenNameERROR) {
688 * Parses a string with php tags
689 * i.e. '<body> <?php phpinfo() ?> </body>'
691 public void parse(String s) throws CoreException {
693 this.token = TokenNameEOF;
695 // this.rowCount = 1;
696 // this.columnCount = 0;
698 this.phpMode = false;
699 /* scanner initialization */
700 scanner.setSource(s.toCharArray());
701 scanner.setPHPMode(false);
705 if (token != TokenNameEOF && token != TokenNameERROR) {
708 if (token != TokenNameEOF) {
709 if (token == TokenNameERROR) {
710 throwSyntaxError("Scanner error (Found unknown token: " + scanner.toStringAction(token) + ")");
712 if (token == TokenNameRPAREN) {
713 throwSyntaxError("Too many closing ')'; end-of-file not reached.");
715 if (token == TokenNameRBRACE) {
716 throwSyntaxError("Too many closing '}'; end-of-file not reached.");
718 if (token == TokenNameRBRACKET) {
719 throwSyntaxError("Too many closing ']'; end-of-file not reached.");
722 if (token == TokenNameLPAREN) {
723 throwSyntaxError("Read character '('; end-of-file not reached.");
725 if (token == TokenNameLBRACE) {
726 throwSyntaxError("Read character '{'; end-of-file not reached.");
728 if (token == TokenNameLBRACKET) {
729 throwSyntaxError("Read character '['; end-of-file not reached.");
732 throwSyntaxError("End-of-file not reached.");
735 } catch (SyntaxError sytaxErr1) {
736 // setMarker(sytaxErr1.getMessage(), sytaxErr1.getLine(), ERROR);
737 setMarker(sytaxErr1.getMessage(), scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(), ERROR);
739 // if an error occured,
740 // try to find keywords 'class' or 'function'
741 // to parse the rest of the string
742 while (token != TokenNameEOF && token != TokenNameERROR) {
743 if (token == TokenNameclass || token == TokenNamefunction) {
748 if (token == TokenNameEOF || token == TokenNameERROR) {
751 } catch (SyntaxError sytaxErr2) {
752 // setMarker(sytaxErr2.getMessage(), sytaxErr2.getLine(), ERROR);
753 setMarker(sytaxErr2.getMessage(), scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(), ERROR);
761 public PHPOutlineInfo parseInfo(Object parent, String s) {
762 PHPOutlineInfo outlineInfo = new PHPOutlineInfo(parent);
763 // Stack stack = new Stack();
764 // stack.push(outlineInfo.getDeclarations());
767 this.token = TokenNameEOF;
769 // this.rowCount = 1;
770 // this.columnCount = 0;
772 this.phpMode = false;
773 scanner.setSource(s.toCharArray());
774 scanner.setPHPMode(false);
778 parseDeclarations(outlineInfo, outlineInfo.getDeclarations(), false);
779 } catch (CoreException e) {
784 private boolean isVariable() {
785 return token == TokenNameVariable || token == TokenNamethis;
788 private void parseDeclarations(PHPOutlineInfo outlineInfo, OutlineableWithChildren current, boolean goBack) {
790 // PHPClassDeclaration current = (PHPClassDeclaration) stack.peek();
791 PHPSegmentWithChildren temp;
794 IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
796 while (token != TokenNameEOF && token != TokenNameERROR) {
797 if (token == TokenNameVariable) {
798 ident = scanner.getCurrentIdentifierSource();
799 outlineInfo.addVariable(new String(ident));
801 } else if (token == TokenNamevar) {
803 if (token == TokenNameVariable && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_VAR)) {
804 ident = scanner.getCurrentIdentifierSource();
805 //substring(1) added because PHPVarDeclaration doesn't need the $ anymore
806 String variableName = new String(ident).substring(1);
807 outlineInfo.addVariable(variableName);
809 if (token != TokenNameSEMICOLON) {
812 ident = scanner.getCurrentTokenSource();
813 if (token > TokenNameKEYWORD) {
814 current.add(new PHPVarDeclaration(current, variableName,
815 // chIndx - ident.length,
816 scanner.getCurrentTokenStartPosition(), new String(ident)));
819 case TokenNameVariable :
821 current.add(new PHPVarDeclaration(current, variableName,
822 // chIndx - ident.length,
823 scanner.getCurrentTokenStartPosition(), new String(ident)));
825 case TokenNameIdentifier :
826 current.add(new PHPVarDeclaration(current, variableName,
827 // chIndx - ident.length,
828 scanner.getCurrentTokenStartPosition(), new String(ident)));
830 case TokenNameDoubleLiteral :
831 current.add(new PHPVarDeclaration(current, variableName + doubleNumber,
832 // chIndx - ident.length,
833 scanner.getCurrentTokenStartPosition(), new String(ident)));
835 case TokenNameIntegerLiteral :
836 current.add(new PHPVarDeclaration(current, variableName,
837 // chIndx - ident.length,
838 scanner.getCurrentTokenStartPosition(), new String(ident)));
840 case TokenNameStringInterpolated :
841 case TokenNameStringLiteral :
842 current.add(new PHPVarDeclaration(current, variableName,
843 // chIndx - ident.length,
844 scanner.getCurrentTokenStartPosition(), new String(ident)));
846 case TokenNameStringConstant :
847 current.add(new PHPVarDeclaration(current, variableName,
848 // chIndx - ident.length,
849 scanner.getCurrentTokenStartPosition(), new String(ident)));
852 current.add(new PHPVarDeclaration(current, variableName,
853 // chIndx - ident.length
854 scanner.getCurrentTokenStartPosition()));
860 ident = scanner.getCurrentIdentifierSource();
862 current.add(new PHPVarDeclaration(current, variableName,
863 // chIndx - ident.length
864 scanner.getCurrentTokenStartPosition()));
867 } else if (token == TokenNamefunction) {
869 if (token == TokenNameAND) {
872 if (token == TokenNameIdentifier && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_FUNC)) {
873 ident = scanner.getCurrentIdentifierSource();
874 outlineInfo.addVariable(new String(ident));
875 temp = new PHPFunctionDeclaration(current, new String(ident),
876 // chIndx - ident.length
877 scanner.getCurrentTokenStartPosition());
880 parseDeclarations(outlineInfo, temp, true);
882 } else if (token == TokenNameclass) {
884 if (token == TokenNameIdentifier && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_CLASS)) {
885 ident = scanner.getCurrentIdentifierSource();
886 outlineInfo.addVariable(new String(ident));
887 temp = new PHPClassDeclaration(current, new String(ident),
888 // chIndx - ident.len
889 scanner.getCurrentTokenStartPosition());
894 //skip tokens for classname, extends and others until we have the opening '{'
895 while (token != TokenNameLBRACE && token != TokenNameEOF && token != TokenNameERROR) {
898 parseDeclarations(outlineInfo, temp, true);
901 } else if ((token == TokenNameLBRACE) || (token == TokenNameDOLLAR_LBRACE)) {
904 } else if (token == TokenNameRBRACE) {
907 if (counter == 0 && goBack) {
911 token == TokenNamerequire
912 || token == TokenNamerequire_once
913 || token == TokenNameinclude
914 || token == TokenNameinclude_once) {
915 ident = scanner.getCurrentTokenSource();
918 int startPosition = scanner.getCurrentTokenStartPosition();
920 char[] expr = scanner.getCurrentTokenSource(startPosition);
921 outlineInfo.addVariable(new String(ident));
922 current.add(new PHPReqIncDeclaration(current, new String(ident),
923 // chIndx - ident.length,
924 startPosition, new String(expr)));
930 } catch (CoreException e) {
931 } catch (SyntaxError sytaxErr) {
933 // setMarker(sytaxErr.getMessage(), sytaxErr.getLine(), ERROR);
934 setMarker(sytaxErr.getMessage(), scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(), ERROR);
935 } catch (CoreException e) {
940 private void statementList() throws CoreException {
942 statement(TokenNameEOF);
943 if ((token == TokenNameRBRACE)
944 || (token == TokenNamecase)
945 || (token == TokenNamedefault)
946 || (token == TokenNameelse)
947 || (token == TokenNameelseif)
948 || (token == TokenNameendif)
949 || (token == TokenNameendfor)
950 || (token == TokenNameendforeach)
951 || (token == TokenNameendwhile)
952 || (token == TokenNameendswitch)
953 || (token == TokenNameEOF)
954 || (token == TokenNameERROR)) {
960 private void compoundStatement() throws CoreException {
961 // '{' [statement-list] '}'
962 if (token == TokenNameLBRACE) {
965 throwSyntaxError("'{' expected in compound-statement.");
967 if (token != TokenNameRBRACE) {
970 if (token == TokenNameRBRACE) {
973 throwSyntaxError("'}' expected in compound-statement.");
977 private void statement(int previousToken) throws CoreException {
978 // if (token > TokenNameKEYWORD && token != TokenNamelist && token != TokenNamenew) {
979 // char[] ident = scanner.getCurrentIdentifierSource();
980 // String keyword = new String(ident);
981 if (token == TokenNameinclude || token == TokenNameinclude_once) {
983 if (token == TokenNameLPAREN) {
985 if (token == TokenNameSEMICOLON) {
988 if (previousToken != TokenNameAT && token != TokenNameStopPHP) {
989 throwSyntaxError("';' expected after 'include' or 'include_once'.");
994 concatenationExpression();
998 } else if (token == TokenNamerequire || token == TokenNamerequire_once) {
1001 if (token == TokenNameLPAREN) {
1003 if (token == TokenNameSEMICOLON) {
1006 if (previousToken != TokenNameAT && token != TokenNameStopPHP) {
1007 throwSyntaxError("';' expected after 'require' or 'require_once'.");
1012 concatenationExpression();
1015 } else if (token == TokenNameif) {
1017 if (token == TokenNameLPAREN) {
1020 throwSyntaxError("'(' expected after 'if' keyword.");
1023 if (token == TokenNameRPAREN) {
1026 throwSyntaxError("')' expected after 'if' condition.");
1031 } else if (token == TokenNameswitch) {
1033 if (token == TokenNameLPAREN) {
1036 throwSyntaxError("'(' expected after 'switch' keyword.");
1039 if (token == TokenNameRPAREN) {
1042 throwSyntaxError("')' expected after 'switch' condition.");
1046 } else if (token == TokenNamefor) {
1048 if (token == TokenNameLPAREN) {
1051 throwSyntaxError("'(' expected after 'for' keyword.");
1053 if (token == TokenNameSEMICOLON) {
1057 if (token == TokenNameSEMICOLON) {
1060 throwSyntaxError("';' expected after 'for'.");
1063 if (token == TokenNameSEMICOLON) {
1067 if (token == TokenNameSEMICOLON) {
1070 throwSyntaxError("';' expected after 'for'.");
1073 if (token == TokenNameRPAREN) {
1077 if (token == TokenNameRPAREN) {
1080 throwSyntaxError("')' expected after 'for'.");
1085 } else if (token == TokenNamewhile) {
1087 if (token == TokenNameLPAREN) {
1090 throwSyntaxError("'(' expected after 'while' keyword.");
1093 if (token == TokenNameRPAREN) {
1096 throwSyntaxError("')' expected after 'while' condition.");
1100 } else if (token == TokenNamedo) {
1102 if (token == TokenNameLBRACE) {
1105 throwSyntaxError("'{' expected after 'do' keyword.");
1107 if (token != TokenNameRBRACE) {
1110 if (token == TokenNameRBRACE) {
1113 throwSyntaxError("'}' expected after 'do' keyword.");
1115 if (token == TokenNamewhile) {
1117 if (token == TokenNameLPAREN) {
1120 throwSyntaxError("'(' expected after 'while' keyword.");
1123 if (token == TokenNameRPAREN) {
1126 throwSyntaxError("')' expected after 'while' condition.");
1129 throwSyntaxError("'while' expected after 'do' keyword.");
1131 if (token == TokenNameSEMICOLON) {
1134 if (token != TokenNameStopPHP) {
1135 throwSyntaxError("';' expected after do-while statement.");
1140 } else if (token == TokenNameforeach) {
1142 if (token == TokenNameLPAREN) {
1145 throwSyntaxError("'(' expected after 'foreach' keyword.");
1148 if (token == TokenNameas) {
1151 throwSyntaxError("'as' expected after 'foreach' exxpression.");
1154 if (token == TokenNameEQUAL_GREATER) {
1158 if (token == TokenNameRPAREN) {
1161 throwSyntaxError("')' expected after 'foreach' expression.");
1166 } else if (token == TokenNamecontinue || token == TokenNamebreak || token == TokenNamereturn) {
1168 if (token != TokenNameSEMICOLON) {
1171 if (token == TokenNameSEMICOLON) {
1174 if (token != TokenNameStopPHP) {
1175 throwSyntaxError("';' expected after 'continue', 'break' or 'return'.");
1181 } else if (token == TokenNameecho) {
1184 if (token == TokenNameSEMICOLON) {
1187 if (token != TokenNameStopPHP) {
1188 throwSyntaxError("';' expected after 'echo' statement.");
1193 // } else if (token == TokenNameprint) {
1196 // if (token == TokenNameSEMICOLON) {
1199 // if (token != TokenNameStopPHP) {
1200 // throwSyntaxError("';' expected after 'print' statement.");
1206 } else if (token == TokenNameglobal || token == TokenNamestatic) {
1209 if (token == TokenNameSEMICOLON) {
1212 if (token != TokenNameStopPHP) {
1213 throwSyntaxError("';' expected after 'global' or 'static' statement.");
1219 // } else if (token == TokenNameunset) {
1221 // if (token == TokenNameARGOPEN) {
1224 // throwSyntaxError("'(' expected after 'unset' keyword.");
1227 // if (token == TokenNameARGCLOSE) {
1230 // throwSyntaxError("')' expected after 'unset' statement.");
1232 // if (token == TokenNameSEMICOLON) {
1235 // if (token != TokenNameStopPHP) {
1236 // throwSyntaxError("';' expected after 'unset' statement.");
1242 // } else if (token == TokenNameexit || token == TokenNamedie) {
1244 // if (token != TokenNameSEMICOLON) {
1247 // if (token == TokenNameSEMICOLON) {
1250 // if (token != TokenNameStopPHP) {
1251 // throwSyntaxError("';' expected after 'exit' or 'die' statement.");
1257 } else if (token == TokenNamedefine) {
1259 if (token == TokenNameLPAREN) {
1262 throwSyntaxError("'(' expected after 'define' keyword.");
1265 if (token == TokenNameCOMMA) {
1268 throwSyntaxError("',' expected after first 'define' constant.");
1271 if (token == TokenNameCOMMA) {
1275 if (token == TokenNameRPAREN) {
1278 throwSyntaxError("')' expected after 'define' statement.");
1280 if (token == TokenNameSEMICOLON) {
1283 if (token != TokenNameStopPHP) {
1284 throwSyntaxError("';' expected after 'define' statement.");
1289 } else if (token == TokenNamefunction) {
1291 functionDefinition();
1293 } else if (token == TokenNameclass) {
1299 // throwSyntaxError("Unexpected keyword '" + keyword + "'");
1300 } else if (token == TokenNameLBRACE) {
1301 // compoundStatement
1303 if (token != TokenNameRBRACE) {
1306 if (token == TokenNameRBRACE) {
1310 throwSyntaxError("'}' expected.");
1313 if (token != TokenNameSEMICOLON) {
1316 if (token == TokenNameSEMICOLON) {
1320 if (token != TokenNameStopPHP && token != TokenNameEOF) {
1321 throwSyntaxError("';' expected after expression (Found token: " + scanner.toStringAction(token) + ")");
1328 private void classDeclarator() throws CoreException {
1330 //identifier 'extends' identifier
1331 if (token == TokenNameIdentifier) {
1333 if (token == TokenNameextends) {
1335 if (token == TokenNameIdentifier) {
1338 throwSyntaxError("ClassDeclaration name expected after keyword 'extends'.");
1342 if (token > TokenNameKEYWORD) {
1343 throwSyntaxError("Don't use keyword for class declaration [" + token + "].");
1345 throwSyntaxError("ClassDeclaration name expected after keyword 'class'.");
1349 private void classBody() throws CoreException {
1350 //'{' [class-element-list] '}'
1351 if (token == TokenNameLBRACE) {
1353 if (token != TokenNameRBRACE) {
1356 if (token == TokenNameRBRACE) {
1359 throwSyntaxError("'}' expected at end of class body.");
1362 throwSyntaxError("'{' expected at start of class body.");
1366 private void classElementList() throws CoreException {
1369 } while (token == TokenNamefunction || token == TokenNamevar);
1372 private void classElement() throws CoreException {
1374 //function-definition
1375 if (token == TokenNamefunction) {
1377 functionDefinition();
1378 } else if (token == TokenNamevar) {
1382 throwSyntaxError("'function' or 'var' expected.");
1386 private void classProperty() throws CoreException {
1387 //'var' variable ';'
1388 //'var' variable '=' constant ';'
1390 if (token == TokenNameVariable) {
1392 if (token == TokenNameEQUAL) {
1397 if (token == TokenNamethis) {
1398 throwSyntaxError("Reserved word '$this' not allowed after keyword 'var'.");
1400 throwSyntaxError("Variable expected after keyword 'var'.");
1402 if (token != TokenNameCOMMA) {
1407 if (token == TokenNameSEMICOLON) {
1410 throwSyntaxError("';' expected after variable declaration.");
1414 private void functionDefinition() throws CoreException {
1415 functionDeclarator();
1416 compoundStatement();
1419 private void functionDeclarator() throws CoreException {
1420 //identifier '(' [parameter-list] ')'
1421 if (token == TokenNameAND) {
1424 if (token == TokenNameIdentifier) {
1426 if (token == TokenNameLPAREN) {
1429 throwSyntaxError("'(' expected in function declaration.");
1431 if (token != TokenNameRPAREN) {
1434 if (token != TokenNameRPAREN) {
1435 throwSyntaxError("')' expected in function declaration.");
1440 if (token > TokenNameKEYWORD) {
1441 throwSyntaxError("Don't use keyword for function declaration [" + token + "].");
1443 throwSyntaxError("Function name expected after keyword 'function'.");
1447 private void parameterList() throws CoreException {
1448 //parameter-declaration
1449 //parameter-list ',' parameter-declaration
1451 parameterDeclaration();
1452 if (token != TokenNameCOMMA) {
1459 private void parameterDeclaration() throws CoreException {
1461 //variable-reference
1462 if (token == TokenNameAND) {
1467 throwSyntaxError("Variable expected after reference operator '&'.");
1470 //variable '=' constant
1471 if (token == TokenNameVariable) {
1473 if (token == TokenNameEQUAL) {
1479 if (token == TokenNamethis) {
1480 throwSyntaxError("Reserved word '$this' not allowed in parameter declaration.");
1484 private void labeledStatementList() throws CoreException {
1485 if (token != TokenNamecase && token != TokenNamedefault) {
1486 throwSyntaxError("'case' or 'default' expected.");
1489 if (token == TokenNamecase) {
1491 expression(); //constant();
1492 if (token == TokenNameCOLON) {
1494 if (token == TokenNamecase || token == TokenNamedefault) { // empty case statement ?
1498 } else if (token == TokenNameSEMICOLON) {
1500 // "':' expected after 'case' keyword (Found token: "
1501 // + scanner.toStringAction(token)
1506 "':' expected after 'case' keyword (Found token: " + scanner.toStringAction(token) + ")",
1507 scanner.getCurrentTokenStartPosition(),
1508 scanner.getCurrentTokenEndPosition(),
1511 if (token == TokenNamecase) { // empty case statement ?
1516 throwSyntaxError("':' character after 'case' constant expected (Found token: " + scanner.toStringAction(token) + ")");
1518 } else { // TokenNamedefault
1520 if (token == TokenNameCOLON) {
1524 throwSyntaxError("':' character after 'default' expected.");
1527 } while (token == TokenNamecase || token == TokenNamedefault);
1530 // public void labeledStatement() {
1531 // if (token == TokenNamecase) {
1534 // if (token == TokenNameDDOT) {
1538 // throwSyntaxError("':' character after 'case' constant expected.");
1541 // } else if (token == TokenNamedefault) {
1543 // if (token == TokenNameDDOT) {
1547 // throwSyntaxError("':' character after 'default' expected.");
1553 // public void expressionStatement() {
1556 // private void inclusionStatement() {
1559 // public void compoundStatement() {
1562 // public void selectionStatement() {
1565 // public void iterationStatement() {
1568 // public void jumpStatement() {
1571 // public void outputStatement() {
1574 // public void scopeStatement() {
1577 // public void flowStatement() {
1580 // public void definitionStatement() {
1583 private void ifStatement() throws CoreException {
1584 // ':' statement-list [elseif-list] [else-colon-statement] 'endif' ';'
1585 if (token == TokenNameCOLON) {
1587 if (token != TokenNameendif) {
1590 case TokenNameelse :
1592 if (token == TokenNameCOLON) {
1594 if (token != TokenNameendif) {
1598 if (token == TokenNameif) { //'else if'
1600 elseifStatementList();
1602 throwSyntaxError("':' expected after 'else'.");
1606 case TokenNameelseif :
1608 elseifStatementList();
1613 if (token != TokenNameendif) {
1614 throwSyntaxError("'endif' expected.");
1617 if (token != TokenNameSEMICOLON) {
1618 throwSyntaxError("';' expected after if-statement.");
1622 // statement [else-statement]
1623 statement(TokenNameEOF);
1624 if (token == TokenNameelseif) {
1626 if (token == TokenNameLPAREN) {
1629 throwSyntaxError("'(' expected after 'elseif' keyword.");
1632 if (token == TokenNameRPAREN) {
1635 throwSyntaxError("')' expected after 'elseif' condition.");
1638 } else if (token == TokenNameelse) {
1640 statement(TokenNameEOF);
1645 private void elseifStatementList() throws CoreException {
1649 case TokenNameelse :
1651 if (token == TokenNameCOLON) {
1653 if (token != TokenNameendif) {
1658 if (token == TokenNameif) { //'else if'
1661 throwSyntaxError("':' expected after 'else'.");
1665 case TokenNameelseif :
1674 private void elseifStatement() throws CoreException {
1675 if (token == TokenNameLPAREN) {
1678 if (token != TokenNameRPAREN) {
1679 throwSyntaxError("')' expected in else-if-statement.");
1682 if (token != TokenNameCOLON) {
1683 throwSyntaxError("':' expected in else-if-statement.");
1686 if (token != TokenNameendif) {
1692 private void switchStatement() throws CoreException {
1693 if (token == TokenNameCOLON) {
1694 // ':' [labeled-statement-list] 'endswitch' ';'
1696 labeledStatementList();
1697 if (token != TokenNameendswitch) {
1698 throwSyntaxError("'endswitch' expected.");
1701 if (token != TokenNameSEMICOLON) {
1702 throwSyntaxError("';' expected after switch-statement.");
1706 // '{' [labeled-statement-list] '}'
1707 if (token != TokenNameLBRACE) {
1708 throwSyntaxError("'{' expected in switch statement.");
1711 if (token != TokenNameRBRACE) {
1712 labeledStatementList();
1714 if (token != TokenNameRBRACE) {
1715 throwSyntaxError("'}' expected in switch statement.");
1722 private void forStatement() throws CoreException {
1723 if (token == TokenNameCOLON) {
1726 if (token != TokenNameendfor) {
1727 throwSyntaxError("'endfor' expected.");
1730 if (token != TokenNameSEMICOLON) {
1731 throwSyntaxError("';' expected after for-statement.");
1735 statement(TokenNameEOF);
1739 private void whileStatement() throws CoreException {
1740 // ':' statement-list 'endwhile' ';'
1741 if (token == TokenNameCOLON) {
1744 if (token != TokenNameendwhile) {
1745 throwSyntaxError("'endwhile' expected.");
1748 if (token != TokenNameSEMICOLON) {
1749 throwSyntaxError("';' expected after while-statement.");
1753 statement(TokenNameEOF);
1757 private void foreachStatement() throws CoreException {
1758 if (token == TokenNameCOLON) {
1761 if (token != TokenNameendforeach) {
1762 throwSyntaxError("'endforeach' expected.");
1765 if (token != TokenNameSEMICOLON) {
1766 throwSyntaxError("';' expected after foreach-statement.");
1770 statement(TokenNameEOF);
1774 private void exitStatus() throws CoreException {
1775 if (token == TokenNameLPAREN) {
1778 throwSyntaxError("'(' expected in 'exit-status'.");
1780 if (token != TokenNameRPAREN) {
1783 if (token == TokenNameRPAREN) {
1786 throwSyntaxError("')' expected after 'exit-status'.");
1790 private void expressionList() throws CoreException {
1793 if (token == TokenNameCOMMA) {
1801 private void expression() throws CoreException {
1802 //todo: find a better way to get the expression
1803 // expression = new StringBuffer();
1804 // for (int i = chIndx; i < str.length(); i++) {
1805 // if (str.charAt(i) == ';') {
1808 // expression.append(str.charAt(i));
1811 // if (token == TokenNameSTRING_CONSTANT || token == TokenNameINTERPOLATED_STRING) {
1814 logicalinclusiveorExpression();
1815 // while (token != TokenNameSEMICOLON) {
1821 private void postfixExpression() throws CoreException {
1824 boolean castFlag = false;
1825 boolean arrayFlag = false;
1831 case TokenNamenull :
1834 case TokenNamefalse :
1837 case TokenNametrue :
1840 case TokenNameStringConstant :
1843 case TokenNameHEREDOC :
1844 case TokenNameStringInterpolated :
1845 case TokenNameStringLiteral :
1848 case TokenNameLPAREN :
1851 if (token == TokenNameIdentifier) {
1852 // check if identifier is a type:
1853 // ident = identifier;
1854 ident = scanner.getCurrentIdentifierSource();
1855 String str = new String(ident).toLowerCase();
1856 for (int i = 0; i < PHP_TYPES.length; i++) {
1857 if (PHP_TYPES[i].equals(str)) {
1859 if (PHP_TYPES[i].equals("array")) {
1869 if (arrayFlag && token == TokenNameLPAREN) {
1871 if (token == TokenNameRPAREN) {
1875 if (token != TokenNameRPAREN) {
1876 throwSyntaxError(") expected after 'array('.");
1880 if (token != TokenNameRPAREN) {
1881 throwSyntaxError(") expected after cast-type '" + str + "'.");
1889 if (token != TokenNameRPAREN) {
1890 throwSyntaxError(") expected in postfix-expression.");
1894 case TokenNameDoubleLiteral :
1897 case TokenNameIntegerLiteral :
1900 case TokenNameDOLLAR_LBRACE :
1903 if (token != TokenNameRBRACE) {
1904 throwSyntaxError("'}' expected after indirect variable token '${'.");
1908 case TokenNameVariable :
1909 case TokenNamethis :
1910 ident = scanner.getCurrentIdentifierSource();
1912 if (token == TokenNameLBRACE) {
1915 if (token != TokenNameRBRACE) {
1916 throwSyntaxError("'}' expected after variable '" + new String(ident) + "' in variable-expression.");
1919 } else if (token == TokenNameLPAREN) {
1921 if (token != TokenNameRPAREN) {
1923 if (token != TokenNameRPAREN) {
1924 throwSyntaxError("')' expected after variable '" + new String(ident) + "' in postfix-expression.");
1930 case TokenNameIdentifier :
1931 ident = scanner.getCurrentIdentifierSource();
1933 if (token == TokenNameLPAREN) {
1935 if (token != TokenNameRPAREN) {
1937 if (token != TokenNameRPAREN) {
1939 "')' expected after identifier '"
1941 + "' in postfix-expression."
1943 + scanner.toStringAction(token)
1950 case TokenNameprint :
1953 // if (token == TokenNameSEMICOLON) {
1956 // if (token != TokenNameStopPHP) {
1957 // throwSyntaxError("';' expected after 'print' statement.");
1962 case TokenNamelist :
1964 if (token == TokenNameLPAREN) {
1966 if (token == TokenNameCOMMA) {
1970 if (token != TokenNameRPAREN) {
1971 throwSyntaxError("')' expected after 'list' keyword.");
1974 // if (token == TokenNameSET) {
1976 // logicalinclusiveorExpression();
1979 throwSyntaxError("'(' expected after 'list' keyword.");
1982 // case TokenNameexit :
1984 // if (token != TokenNameSEMICOLON) {
1987 // if (token == TokenNameSEMICOLON) {
1990 // if (token != TokenNameStopPHP) {
1991 // throwSyntaxError("';' expected after 'exit' expression.");
1996 // case TokenNamedie :
1998 // if (token != TokenNameSEMICOLON) {
2001 // if (token == TokenNameSEMICOLON) {
2004 // if (token != TokenNameStopPHP) {
2005 // throwSyntaxError("';' expected after 'die' expression.");
2010 // case TokenNamearray :
2012 // if (token == TokenNameARGOPEN) {
2014 // if (token == TokenNameCOMMA) {
2017 // expressionList();
2018 // if (token != TokenNameARGCLOSE) {
2019 // throwSyntaxError("')' expected after 'list' keyword.");
2022 // if (token == TokenNameSET) {
2024 // logicalinclusiveorExpression();
2027 // throwSyntaxError("'(' expected after 'list' keyword.");
2031 boolean while_flag = true;
2034 case TokenNameLBRACKET :
2037 if (token != TokenNameRBRACKET) {
2038 throwSyntaxError("] expected in postfix-expression.");
2042 case TokenNameCOLON_COLON : // ::
2043 case TokenNameMINUS_GREATER : // ->
2045 if (token > TokenNameKEYWORD) {
2046 ident = scanner.getCurrentIdentifierSource();
2048 // "Avoid using keyword '"
2049 // + new String(ident)
2050 // + "' as variable name.",
2054 "Avoid using keyword '" + new String(ident) + "' as variable name.",
2055 scanner.getCurrentTokenStartPosition(),
2056 scanner.getCurrentTokenEndPosition(),
2060 case TokenNameVariable :
2061 ident = scanner.getCurrentIdentifierSource();
2063 // if (token == TokenNameARGOPEN) {
2065 // expressionList();
2066 // if (token != TokenNameARGCLOSE) {
2067 // throwSyntaxError(") expected after variable '" + ident + "'.");
2072 case TokenNameIdentifier :
2073 //ident = scanner.getCurrentIdentifierSource();
2076 case TokenNameLBRACE :
2079 if (token != TokenNameRBRACE) {
2080 throwSyntaxError("} expected in postfix-expression.");
2085 throwSyntaxError("Syntax error after '->' token.");
2086 } while (token == TokenNameLBRACKET || token == TokenNameLPAREN || token == TokenNameLBRACE) {
2087 if (token == TokenNameLBRACKET) {
2090 if (token != TokenNameRBRACKET) {
2091 throwSyntaxError("] expected after '->'.");
2094 } else if (token == TokenNameLPAREN) {
2097 if (token != TokenNameRPAREN) {
2098 throwSyntaxError(") expected after '->'.");
2101 } else if (token == TokenNameLBRACE) {
2104 if (token != TokenNameRBRACE) {
2105 throwSyntaxError("} expected after '->'.");
2111 case TokenNamePLUS_PLUS :
2114 case TokenNameMINUS_MINUS :
2125 private void unaryExpression() throws CoreException {
2127 case TokenNamePLUS_PLUS :
2131 case TokenNameMINUS_MINUS :
2135 // '@' '&' '*' '+' '-' '~' '!'
2138 if (token == TokenNameinclude
2139 || token == TokenNameinclude_once
2140 || token == TokenNamerequire
2141 || token == TokenNamerequire_once) {
2142 statement(TokenNameAT);
2144 postfixExpression(); // castExpression();
2151 case TokenNameMULTIPLY :
2155 case TokenNamePLUS :
2159 case TokenNameMINUS :
2163 case TokenNameTWIDDLE :
2172 postfixExpression();
2176 private void castExpression() throws CoreException {
2177 // if (token == TokenNameARGOPEN) {
2180 // if (token != TokenNameARGCLOSE) {
2181 // throwSyntaxError(") expected after cast-expression.");
2188 private void assignExpression() throws CoreException {
2190 if (token == TokenNameEQUAL) { // =
2192 logicalinclusiveorExpression();
2193 } else if (token == TokenNameDOT_EQUAL) { // .=
2195 logicalinclusiveorExpression();
2196 } else if (token == TokenNameEQUAL_GREATER) { // =>
2198 logicalinclusiveorExpression();
2199 } else if (token == TokenNamePLUS_EQUAL) { // +=
2201 logicalinclusiveorExpression();
2202 } else if (token == TokenNameMINUS_EQUAL) { // -=
2204 logicalinclusiveorExpression();
2205 } else if (token == TokenNameMULTIPLY_EQUAL) { // *=
2207 logicalinclusiveorExpression();
2208 } else if (token == TokenNameDIVIDE_EQUAL) { // *=
2210 logicalinclusiveorExpression();
2211 } else if (token == TokenNameREMAINDER_EQUAL) { // %=
2213 logicalinclusiveorExpression();
2214 } else if (token == TokenNameAND_EQUAL) { // &=
2216 logicalinclusiveorExpression();
2217 } else if (token == TokenNameOR_EQUAL) { // |=
2219 logicalinclusiveorExpression();
2220 } else if (token == TokenNameXOR_EQUAL) { // ^=
2222 logicalinclusiveorExpression();
2223 } else if (token == TokenNameLEFT_SHIFT_EQUAL) { // <<=
2225 logicalinclusiveorExpression();
2226 } else if (token == TokenNameRIGHT_SHIFT_EQUAL) { // >>=
2228 logicalinclusiveorExpression();
2229 } else if (token == TokenNameTWIDDLE_EQUAL) { // ~=
2231 logicalinclusiveorExpression();
2235 private void multiplicativeExpression() throws CoreException {
2238 if (token != TokenNameMULTIPLY && token != TokenNameDIVIDE && token != TokenNameREMAINDER) {
2245 private void concatenationExpression() throws CoreException {
2247 multiplicativeExpression();
2248 if (token != TokenNameDOT) {
2255 private void additiveExpression() throws CoreException {
2257 concatenationExpression();
2258 if (token != TokenNamePLUS && token != TokenNameMINUS) {
2265 private void shiftExpression() throws CoreException {
2267 additiveExpression();
2268 if (token != TokenNameLEFT_SHIFT && token != TokenNameRIGHT_SHIFT) {
2275 private void relationalExpression() throws CoreException {
2278 if (token != TokenNameLESS && token != TokenNameGREATER && token != TokenNameLESS_EQUAL && token != TokenNameGREATER_EQUAL) {
2285 private void identicalExpression() throws CoreException {
2287 relationalExpression();
2288 if (token != TokenNameEQUAL_EQUAL_EQUAL && token != TokenNameNOT_EQUAL_EQUAL) {
2295 private void equalityExpression() throws CoreException {
2297 identicalExpression();
2298 if (token != TokenNameEQUAL_EQUAL && token != TokenNameNOT_EQUAL) {
2305 private void ternaryExpression() throws CoreException {
2306 equalityExpression();
2307 if (token == TokenNameQUESTION) {
2310 if (token == TokenNameCOLON) {
2314 throwSyntaxError("':' expected in ternary operator '? :'.");
2319 private void andExpression() throws CoreException {
2321 ternaryExpression();
2322 if (token != TokenNameAND) {
2329 private void exclusiveorExpression() throws CoreException {
2332 if (token != TokenNameXOR) {
2339 private void inclusiveorExpression() throws CoreException {
2341 exclusiveorExpression();
2342 if (token != TokenNameOR) {
2349 private void booleanandExpression() throws CoreException {
2351 inclusiveorExpression();
2352 if (token != TokenNameAND_AND) {
2359 private void booleanorExpression() throws CoreException {
2361 booleanandExpression();
2362 if (token != TokenNameOR_OR) {
2369 private void logicalandExpression() throws CoreException {
2371 booleanorExpression();
2372 if (token != TokenNameAND) {
2379 private void logicalexclusiveorExpression() throws CoreException {
2381 logicalandExpression();
2382 if (token != TokenNameXOR) {
2389 private void logicalinclusiveorExpression() throws CoreException {
2391 logicalexclusiveorExpression();
2392 if (token != TokenNameOR) {
2399 // public void assignmentExpression() {
2400 // if (token == TokenNameVARIABLE) {
2402 // if (token == TokenNameSET) {
2404 // logicalinclusiveorExpression();
2407 // logicalinclusiveorExpression();
2411 private void variableList() throws CoreException {
2414 if (token == TokenNameCOMMA) {
2422 private void variable() throws CoreException {
2423 if (token == TokenNameDOLLAR_LBRACE) {
2427 if (token != TokenNameRBRACE) {
2428 throwSyntaxError("'}' expected after indirect variable token '${'.");
2432 if (token == TokenNameVariable) {
2434 if (token == TokenNameLBRACKET) {
2437 if (token != TokenNameRBRACKET) {
2438 throwSyntaxError("']' expected in variable-list.");
2441 } else if (token == TokenNameEQUAL) {
2446 throwSyntaxError("$-variable expected in variable-list.");
2452 * It will look for a value (after a '=' for example)
2453 * @throws CoreException
2455 private void constant() throws CoreException {
2458 case TokenNamePLUS :
2461 case TokenNameDoubleLiteral :
2464 case TokenNameIntegerLiteral :
2468 throwSyntaxError("Constant expected after '+' presign.");
2471 case TokenNameMINUS :
2474 case TokenNameDoubleLiteral :
2477 case TokenNameIntegerLiteral :
2481 throwSyntaxError("Constant expected after '-' presign.");
2484 case TokenNamenull :
2487 case TokenNamefalse :
2490 case TokenNametrue :
2493 case TokenNameIdentifier :
2494 // ident = identifier;
2495 char[] ident = scanner.getCurrentIdentifierSource();
2497 if (token == TokenNameLPAREN) {
2499 if (token != TokenNameRPAREN) {
2501 if (token != TokenNameRPAREN) {
2502 throwSyntaxError("')' expected after identifier '" + new String(ident) + "' in postfix-expression.");
2508 case TokenNameStringLiteral :
2511 case TokenNameStringConstant :
2514 case TokenNameStringInterpolated :
2517 case TokenNameDoubleLiteral :
2520 case TokenNameIntegerLiteral :
2524 throwSyntaxError("Constant expected.");