/** * generate parsing error */ public void yyerror(String message) { throw new SyntaxException(PID.GRAMMAR_ERROR, lexer.getPosition(), lexer.getCurrentLine(), message); }
/** * generate parsing error */ public void yyerror(String message) { throw new SyntaxException(PID.GRAMMAR_ERROR, lexer.getPosition(), lexer.getCurrentLine(), message); }
/** * generate parsing error * @param message text to be displayed. * @param expected list of acceptable tokens, if available. */ public void yyerror(String message, String[] expected, String found) { String text = message + ", unexpected " + found + "\n"; throw new SyntaxException(PID.GRAMMAR_ERROR, lexer.getPosition(), lexer.getCurrentLine(), text, found); }
/** * generate parsing error * @param message text to be displayed. * @param expected list of acceptable tokens, if available. */ public void yyerror(String message, String[] expected, String found) { String text = message + ", unexpected " + found + "\n"; throw new SyntaxException(PID.GRAMMAR_ERROR, lexer.getPosition(), lexer.getCurrentLine(), text, found); }
protected void compileError(Encoding optionEncoding, Encoding encoding) { throw new SyntaxException(PID.REGEXP_ENCODING_MISMATCH, lexer.getPosition(), lexer.getCurrentLine(), "regexp encoding option '" + optionsEncodingChar(optionEncoding) + "' differs from source encoding '" + encoding + "'"); }
protected void compileError(Encoding optionEncoding, Encoding encoding) { throw new SyntaxException(PID.REGEXP_ENCODING_MISMATCH, lexer.getPosition(), lexer.getCurrentLine(), "regexp encoding option '" + optionsEncodingChar(optionEncoding) + "' differs from source encoding '" + encoding + "'"); }
public Node getReturnArgsNode(Node node) { if (node instanceof ArrayNode && ((ArrayNode) node).size() == 1) { return ((ListNode) node).get(0); } else if (node instanceof BlockPassNode) { throw new SyntaxException(PID.BLOCK_ARG_UNEXPECTED, node.getPosition(), lexer.getCurrentLine(), "Block argument should not be given."); } return node; }
private int getNumberToken(String number, boolean isFloat, int nondigit) { if (nondigit != '\0') { throw new SyntaxException(PID.TRAILING_UNDERSCORE_IN_NUMBER, getPosition(), getCurrentLine(), "Trailing '_' in number."); } else if (isFloat) { return getFloatToken(number); } yaccValue = getInteger(number, 10); return Tokens.tINTEGER; }
private int getNumberToken(String number, boolean isFloat, int nondigit) { if (nondigit != '\0') { throw new SyntaxException(PID.TRAILING_UNDERSCORE_IN_NUMBER, getPosition(), getCurrentLine(), "Trailing '_' in number."); } else if (isFloat) { return getFloatToken(number); } yaccValue = getInteger(number, 10); return Tokens.tINTEGER; }
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { if (((Node)yyVals[-1+yyTop]) != null && ((BlockAcceptingNode)yyVals[-1+yyTop]).getIterNode() instanceof BlockPassNode) { throw new SyntaxException(PID.BLOCK_ARG_AND_BLOCK_GIVEN, ((Node)yyVals[-1+yyTop]).getPosition(), lexer.getCurrentLine(), "Both block arg and actual block given."); } yyVal = ((BlockAcceptingNode)yyVals[-1+yyTop]).setIterNode(((IterNode)yyVals[0+yyTop])); ((Node)yyVal).setPosition(((Node)yyVals[-1+yyTop]).getPosition()); return yyVal; } };
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { if (((Node)yyVals[-1+yyTop]) != null && ((BlockAcceptingNode)yyVals[-1+yyTop]).getIterNode() instanceof BlockPassNode) { throw new SyntaxException(PID.BLOCK_ARG_AND_BLOCK_GIVEN, ((Node)yyVals[-1+yyTop]).getPosition(), lexer.getCurrentLine(), "Both block arg and actual block given."); } yyVal = ((BlockAcceptingNode)yyVals[-1+yyTop]).setIterNode(((IterNode)yyVals[0+yyTop])); ((Node)yyVal).setPosition(((Node)yyVals[-1+yyTop]).getPosition()); return yyVal; } };
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { if (((Node)yyVals[-1+yyTop]) != null && ((BlockAcceptingNode)yyVals[-1+yyTop]).getIterNode() instanceof BlockPassNode) { throw new SyntaxException(PID.BLOCK_ARG_AND_BLOCK_GIVEN, ((Node)yyVals[-1+yyTop]).getPosition(), lexer.getCurrentLine(), "Both block arg and actual block given."); } yyVal = ((BlockAcceptingNode)yyVals[-1+yyTop]).setIterNode(((IterNode)yyVals[0+yyTop])); ((Node)yyVal).setPosition(((Node)yyVals[-1+yyTop]).getPosition()); return yyVal; } };
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { if (((Node)yyVals[-1+yyTop]) != null && ((BlockAcceptingNode)yyVals[-1+yyTop]).getIterNode() instanceof BlockPassNode) { throw new SyntaxException(PID.BLOCK_ARG_AND_BLOCK_GIVEN, ((Node)yyVals[-1+yyTop]).getPosition(), lexer.getCurrentLine(), "Both block arg and actual block given."); } yyVal = ((BlockAcceptingNode)yyVals[-1+yyTop]).setIterNode(((IterNode)yyVals[0+yyTop])); ((Node)yyVal).setPosition(((Node)yyVals[-1+yyTop]).getPosition()); return yyVal; } };
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { if (((Node)yyVals[-1+yyTop]) != null && ((BlockAcceptingNode)yyVals[-1+yyTop]).getIterNode() instanceof BlockPassNode) { throw new SyntaxException(PID.BLOCK_ARG_AND_BLOCK_GIVEN, ((Node)yyVals[-1+yyTop]).getPosition(), lexer.getCurrentLine(), "Both block arg and actual block given."); } yyVal = ((BlockAcceptingNode)yyVals[-1+yyTop]).setIterNode(((IterNode)yyVals[0+yyTop])); ((Node)yyVal).setPosition(((Node)yyVals[-1+yyTop]).getPosition()); return yyVal; } };
public Node new_fcall(Token operation, Node args, Node iter) { if (args == null) return new_fcall_noargs(operation, (IterNode) iter); if (args instanceof ArrayNode) return new_fcall_simpleargs(operation, (ArrayNode) args, iter); if (args instanceof BlockPassNode) { if (iter == null) return new_fcall_blockpass(operation, (BlockPassNode) args); throw new SyntaxException(PID.BLOCK_ARG_AND_BLOCK_GIVEN, iter.getPosition(), lexer.getCurrentLine(), "Both block arg and actual block given."); } return new FCallSpecialArgNode(position(operation, args), (String) operation.getValue(), args); }
public Node new_fcall(Token operation, Node args, Node iter) { if (args == null) return new_fcall_noargs(operation, (IterNode) iter); if (args instanceof ArrayNode) return new_fcall_simpleargs(operation, (ArrayNode) args, iter); if (args instanceof BlockPassNode) { if (iter == null) return new_fcall_blockpass(operation, (BlockPassNode) args); throw new SyntaxException(PID.BLOCK_ARG_AND_BLOCK_GIVEN, iter.getPosition(), lexer.getCurrentLine(), "Both block arg and actual block given."); } return new FCallSpecialArgNode(position(operation, args), (String) operation.getValue(), args); }
private Node new_call_complexargs(Node receiver, Token name, Node args, Node iter) { if (args instanceof BlockPassNode) { // Block and block pass passed in at same time....uh oh if (iter != null) { throw new SyntaxException(PID.BLOCK_ARG_AND_BLOCK_GIVEN, iter.getPosition(), lexer.getCurrentLine(), "Both block arg and actual block given."); } return new_call_blockpass(receiver, name, (BlockPassNode) args); } if (iter != null) return new CallSpecialArgBlockNode(position(receiver, args), receiver,(String) name.getValue(), args, (IterNode) iter); return new CallSpecialArgNode(position(receiver, args), receiver, (String) name.getValue(), args); }
public BlockArgNode newBlockArg(ISourcePosition position, Token nameToken) { String identifier = (String) nameToken.getValue(); if (getCurrentScope().getLocalScope().isDefined(identifier) >= 0) { throw new SyntaxException(PID.BAD_IDENTIFIER, position, lexer.getCurrentLine(), "duplicate block argument name"); } return new BlockArgNode(position, getCurrentScope().getLocalScope().addVariable(identifier), identifier); }
public BlockArgNode newBlockArg(ISourcePosition position, Token nameToken) { String identifier = (String) nameToken.getValue(); if (getCurrentScope().getLocalScope().isDefined(identifier) >= 0) { throw new SyntaxException(PID.BAD_IDENTIFIER, position, lexer.getCurrentLine(), "duplicate block argument name"); } return new BlockArgNode(position, getCurrentScope().getLocalScope().addVariable(identifier), identifier); }
private Node new_call_complexargs(Node receiver, Token name, Node args, Node iter) { if (args instanceof BlockPassNode) { // Block and block pass passed in at same time....uh oh if (iter != null) { throw new SyntaxException(PID.BLOCK_ARG_AND_BLOCK_GIVEN, iter.getPosition(), lexer.getCurrentLine(), "Both block arg and actual block given."); } return new_call_blockpass(receiver, name, (BlockPassNode) args); } if (iter != null) return new CallSpecialArgBlockNode(position(receiver, args), receiver,(String) name.getValue(), args, (IterNode) iter); return new CallSpecialArgNode(position(receiver, args), receiver, (String) name.getValue(), args); }