Package org.jruby.lexer.yacc

Examples of org.jruby.lexer.yacc.SyntaxException


    }
   
    public Node ret_args(Node node, ISourcePosition position) {
        if (node != null) {
            if (node instanceof BlockPassNode) {
                throw new SyntaxException(PID.DYNAMIC_CONSTANT_ASSIGNMENT, position,
                        lexer.getCurrentLine(), "Dynamic constant assignment.");
            } else if (node instanceof ArrayNode && ((ArrayNode)node).size() == 1) {
                node = ((ArrayNode)node).get(0);
            } else if (node instanceof SplatNode) {
                node = newSValueNode(position, node);
View Full Code Here


                        "void value expression");
                return false;
            case RETURNNODE: case BREAKNODE: case NEXTNODE: case REDONODE:
            case RETRYNODE:
                if (!conditional) {
                    throw new SyntaxException(PID.VOID_VALUE_EXPRESSION,
                            node.getPosition(), lexer.getCurrentLine(),
                            "void value expression");
                }
                return false;
            case BLOCKNODE:
View Full Code Here

  /**
     * assign_in_cond
   **/
    private boolean checkAssignmentInCondition(Node node) {
        if (node instanceof MultipleAsgnNode) {
            throw new SyntaxException(PID.MULTIPLE_ASSIGNMENT_IN_CONDITIONAL, node.getPosition(),
                    lexer.getCurrentLine(), "Multiple assignment in conditional.");
        } else if (node instanceof LocalAsgnNode || node instanceof DAsgnNode || node instanceof GlobalAsgnNode || node instanceof InstAsgnNode) {
            Node valueNode = ((AssignableNode) node).getValueNode();
            if (valueNode instanceof ILiteralNode || valueNode instanceof NilNode || valueNode instanceof TrueNode || valueNode instanceof FalseNode) {
                warnings.warn(ID.ASSIGNMENT_IN_CONDITIONAL, node.getPosition(), "Found '=' in conditional, should be '=='.");
View Full Code Here

    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;
    }
View Full Code Here

   
    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);
        }
View Full Code Here

        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);
    }
View Full Code Here

    public Node new_yield(ISourcePosition position, Node node) {
        boolean state = true;
       
        if (node != null) {
            if (node instanceof BlockPassNode) {
                throw new SyntaxException(PID.BLOCK_ARG_UNEXPECTED, node.getPosition(),
                        lexer.getCurrentLine(), "Block argument should not be given.");
            }

            if (node instanceof ArrayNode && configuration.getVersion() == CompatVersion.RUBY1_8 &&
                    ((ArrayNode)node).size() == 1) {
View Full Code Here

    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);
    }
View Full Code Here

    /**
     * generate parsing error
     */
    public void yyerror(String message) {
        throw new SyntaxException(PID.GRAMMAR_ERROR, lexer.getPosition(), lexer.getCurrentLine(), message);
    }
View Full Code Here

     * @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);
    }
View Full Code Here

TOP

Related Classes of org.jruby.lexer.yacc.SyntaxException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.