Package com.stuffwithstuff.magpie.ast

Examples of com.stuffwithstuff.magpie.ast.Field


      }
     
      Map<String, Field> fields = new HashMap<String, Field>();
      for (Obj entry : expr.getField("fields").asList()) {
        Obj fieldObj = entry.getField(1);
        Field field = new Field(
            getBool(fieldObj, "isMutable"),
            getExpr(fieldObj, "initializer"),
            getPattern(fieldObj, "pattern"));
        fields.put(entry.getField(0).asString(), field);
      }

      return Expr.class_(
          getPosition(expr),
          getString(expr, "doc"),
          getString(expr, "name"),
          parents,
          fields);
    } else if (exprClass == getClass("FunctionExpression")) {
      return Expr.fn(
          getPosition(expr),
          getString(expr, "doc"),
          getPattern(expr, "pattern"),
          getExpr(expr, "body"));
    } else if (exprClass == getClass("ImportExpression")) {
      List<ImportDeclaration> declarations = new ArrayList<ImportDeclaration>();
      for (Obj declaration : expr.getField("declarations").asList()) {
        declarations.add(new ImportDeclaration(
            getBool(declaration, "isExport"),
            getString(declaration, "name"),
            getString(declaration, "rename")));
      }

      return Expr.import_(
          getPosition(expr),
          getString(expr, "scheme"),
          getString(expr, "module"),
          getString(expr, "prefix"),
          getBool(expr, "isOnly"),
          declarations);
    } else if (exprClass == getClass("IntExpression")) {
      return Expr.int_(
          getPosition(expr),
          getInt(expr, "value"));
    } else if (exprClass == getClass("LoopExpression")) {
      return Expr.loop(
          getPosition(expr),
          getExpr(expr, "body"));
    } else if (exprClass == getClass("MatchExpression")) {
      return Expr.match(
          getPosition(expr),
          getExpr(expr, "value"),
          getMatchCaseList(expr, "cases"));
    } else if (exprClass == getClass("MethodExpression")) {
      return Expr.method(
          getPosition(expr),
          getString(expr, "doc"),
          getString(expr, "name"),
          getPattern(expr, "pattern"),
          getExpr(expr, "body"));
    } else if (exprClass == getClass("NameExpression")) {
      return Expr.name(
          getPosition(expr),
          getString(expr, "name"));
    } else if (exprClass == getClass("NothingExpression")) {
      return Expr.nothing(
          getPosition(expr));
    } else if (exprClass == getClass("QuoteExpression")) {
      return Expr.quote(
          getPosition(expr),
          getExpr(expr, "body"));
    } else if (exprClass == getClass("RecordExpression")) {
      List<Pair<String, Expr>> fields = new ArrayList<Pair<String, Expr>>();
      for (Obj field : getList(expr, "fields")) {
        String name = field.getField(0).asString();
        Expr value = convertExpr(field.getField(1));
        fields.add(new Pair<String, Expr>(name, value));
      }
      return Expr.record(
          getPosition(expr),
          fields);
View Full Code Here

TOP

Related Classes of com.stuffwithstuff.magpie.ast.Field

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.