Package com.stuffwithstuff.magpie.parser

Source Code of com.stuffwithstuff.magpie.parser.BracketInfixParser

package com.stuffwithstuff.magpie.parser;

import com.stuffwithstuff.magpie.ast.Expr;

/**
* Parses an indexer call like "list[index]".
*/
public class BracketInfixParser implements InfixParser {
  @Override
  public Expr parse(MagpieParser parser, Expr left, Token token) {
    // Parse the argument, if any.
    Expr arg = parser.groupExpression(TokenType.RIGHT_BRACKET);
    return Expr.call(token.getPosition(), left, "[]", arg);
  }
 
  @Override
  public int getPrecedence() { return Precedence.MESSAGE; }
}
TOP

Related Classes of com.stuffwithstuff.magpie.parser.BracketInfixParser

TOP
Copyright © 2018 www.massapi.com. 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.