@Override public int _handleToken(ParseContext ctx) throws InvalidQueryException { Token[] tokens = ctx.getTokens(); int idx = ctx.getCurrentTokensIndex(); Token token = tokens[idx]; RelationalOperator relationalOp = RelationalOperatorFactory.createOperator(token.getValue()); ctx.addExpression(new RelationalExpression(relationalOp)); ctx.setCurrentTokensIndex(++idx); TokenHandler propertyHandler = new PropertyOperandTokenHandler(); propertyHandler.handleToken(ctx); // handle right operand if applicable to operator idx = ctx.getCurrentTokensIndex(); if (ctx.getCurrentTokensIndex() < tokens.length && tokens[idx].getType().equals(Token.TYPE.VALUE_OPERAND)) { TokenHandler valueHandler = new ValueOperandTokenHandler(); valueHandler.handleToken(ctx); } // skip closing bracket idx = ctx.getCurrentTokensIndex(); if (idx >= tokens.length || tokens[idx].getType() != Token.TYPE.BRACKET_CLOSE) { throw new InvalidQueryException("Missing closing bracket for in expression."); } return 1; }
public static void exitCriticalSection() { TokenHandler.setHolderWhileInCS(false); if (!TokenHandler.childQueueIsEmpty()) { TokenHandler.setHasToken(false); TCPSend.grantToken( TokenHandler.childQueue.get(0), TreeGeneration.getPort(TokenHandler.childQueue.get(0))); TokenHandler.setParent(TokenHandler.childQueue.get(0)); TokenHandler.childQueue.remove(0); } }
protected void parsedTag(int type, String name, int start, int length) { this.type = type; this.name = name; this.position = start; this.length = length; handler.tag(reusableToken); reusableToken.attributeCount = 0; }
private void parseTag(int type) throws IOException { // Start parsing a TAG int start = position(); skipWhiteSpace(); int token; if (pushbackToken == -1) { token = yylex(); } else { token = pushbackToken; pushbackToken = -1; } if (token == Parser.SLASH) { // Token "/" - it's a closing tag type = Tag.CLOSE; if (pushbackToken == -1) { token = yylex(); } else { token = pushbackToken; pushbackToken = -1; } } if (token == Parser.WORD) { // Token WORD - name of tag String name = text(); if (handler.shouldProcessTag(name)) { parseFullTag(type, name, start); } else { resetLexerState(); pushBack(yylex()); // take and replace the next token, so the position is correct parsedText(start, position() - start); } } else if (token == Parser.GT) { // Token ">" - an illegal <> or < > tag. Ignore } else if (token == 0) { parsedText(start, position() - start); // eof } else { reportError("Could not recognise tag", line(), column()); } }
public static void setHolderWhileInCS(boolean holderWhileInCS) { TokenHandler.setHolderWhileInCS(holderWhileInCS); }
public static boolean isHolderWhileInCS() { return TokenHandler.isHolderWhileInCS(); }
public static void setSentRequest(boolean sentRequest) { TokenHandler.setSentRequest(sentRequest); }
public static boolean SentRequest() { return TokenHandler.SentRequest(); }
public static boolean HasToken() { return TokenHandler.HasToken(); }
public static void setParent(int parent) { TokenHandler.setParent(parent); }
public static int getParent() { return TokenHandler.getParent(); }
public static void setHasToken(boolean value) { TokenHandler.setHasToken(value); }
public static void setInitiatorParent(int node) { TokenHandler.setParent(node); }
protected void reportError(String message, int line, int column) { handler.warning(message, line, column); }
protected void parsedText(int position, int length) { this.position = position; this.length = length; handler.text(reusableToken); }