@Override protected void getterIdentifierError(ISourcePosition position, String identifier) { throw new SyntaxException(PID.BAD_IDENTIFIER, position, "identifier " + identifier + " is not valid to get", identifier); }
@Override protected void getterIdentifierError(ISourcePosition position, String identifier) { throw new SyntaxException(PID.BAD_IDENTIFIER, position, "identifier " + identifier + " is not valid to get", identifier); }
public void backrefAssignError(Node node) { if (node instanceof NthRefNode) { String varName = "$" + ((NthRefNode) node).getMatchNumber(); throw new SyntaxException(PID.INVALID_ASSIGNMENT, node.getPosition(), "Can't set variable " + varName + '.', varName); } else if (node instanceof BackRefNode) { String varName = "$" + ((BackRefNode) node).getType(); throw new SyntaxException(PID.INVALID_ASSIGNMENT, node.getPosition(), "Can't set variable " + varName + '.', varName); } }
/** * generate parsing error */ public void yyerror(String message) { throw new SyntaxException(PID.GRAMMAR_ERROR, lexer.getPosition(), lexer.getCurrentLine(), message); }
private void syntaxError(LexerSource src) { throw new SyntaxException(PID.STRING_MARKER_MISSING, src.getPosition(), src.getCurrentLine(), "can't find string \"" + marker + "\" anywhere before EOF", marker); } }
public void backrefAssignError(Node node) { if (node instanceof NthRefNode) { String varName = "$" + ((NthRefNode) node).getMatchNumber(); throw new SyntaxException(PID.INVALID_ASSIGNMENT, node.getPosition(), "Can't set variable " + varName + '.', varName); } else if (node instanceof BackRefNode) { String varName = "$" + ((BackRefNode) node).getType(); throw new SyntaxException(PID.INVALID_ASSIGNMENT, node.getPosition(), "Can't set variable " + varName + '.', varName); } }
/** * generate parsing error */ public void yyerror(String message) { throw new SyntaxException(PID.GRAMMAR_ERROR, lexer.getPosition(), lexer.getCurrentLine(), message); }
private void syntaxError(LexerSource src) { throw new SyntaxException(PID.STRING_MARKER_MISSING, src.getPosition(), src.getCurrentLine(), "can't find string \"" + marker + "\" anywhere before EOF", marker); } }
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 void setEncoding(ByteList name) { Encoding newEncoding = parserSupport.getConfiguration().getEncodingService().loadEncoding(name); if (newEncoding == null) { throw new SyntaxException(PID.UNKNOWN_ENCODING, getPosition(), null, "unknown encoding name: " + name.toString()); } if (!newEncoding.isAsciiCompatible()) { throw new SyntaxException(PID.NOT_ASCII_COMPATIBLE, getPosition(), null, name.toString() + " is not ASCII compatible"); } setEncoding(newEncoding); }
@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 void compile_error(PID pid, String message) { String src = createAsEncodedString(lex_lastline.unsafeBytes(), lex_lastline.begin(), lex_lastline.length(), getEncoding()); throw new SyntaxException(pid, getFile(), ruby_sourceline, src, message); }
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); }