Package com.orange.wink.ast

Examples of com.orange.wink.ast.AstNode


  public GetProp(final AstNode n) throws WinkUnmanagedSyntaxException {
    super(n);

    final List<AstNode> childs = n.getChilds();
    if (childs.size() == 2) {
      final AstNode left = childs.get(0);
      final AstNode right = childs.get(1);
      final int lt = left.getType();
      final int rt = right.getType();

      if (lt == Token.NAME || lt == Token.GETVAR) {
        name = left.asString();
      } else if (lt == Token.THIS) {
        name = Ast.tokenName(Token.THIS);
      } else if (lt == Token.GETPROP || lt == Token.GETELEM) {
        child = new GetProp(left);
      } else {
        throw new WinkUnmanagedSyntaxException("Unknow GetProp Syntax, unexpected: " + Ast.tokenName(lt) + "-" + Ast.tokenName(rt) + " " + Ast.getPositionInfo(n));
      }
      if (rt == Token.STRING || rt == Token.NAME || rt == Token.GETVAR || rt == Token.NUMBER) {
        prop = right.asString();
      } else if (rt == Token.SUB || rt == Token.ADD) {
        final List<AstNode> rightChilds = right.getChilds();
        final String sign = (rt == Token.SUB) ? "-" : "+";
        try {
          prop = rightChilds.get(0).asString() + sign + rightChilds.get(1).asString();
        } catch (final Exception e) {
          prop = Ast.tokenName(rt);
View Full Code Here


  public Call(final AstNode n) throws WinkUnmanagedSyntaxException {
    super(n);

    parameters = Common.newArrayList(1);

    final AstNode callnode = n;

    final List<AstNode> childsCall = callnode.getChilds();
    final AstNode c0 = childsCall.get(0);
    int type = c0.getType();

    if (type == Token.NAME) {
      namespace = new Namespace();
      namespace.addName(c0.asString());
    } else if (type == Token.GETPROP) {
      final Namespace ns = new GetProp(c0).resolveNamespace();
      namespace = new Namespace();
      namespace.appendNamespace(ns);
    } else if (type == Token.FUNCTION) {
      function = new Function(c0);
      namespace = new Namespace();
      namespace.addName(function.getNode().getFunctionName());
    } else {
      throw new WinkUnmanagedSyntaxException("Unknow Call Syntax, unexpected(0): " + Ast.tokenName(type) + " " + Ast.getPositionInfo(n));
    }

    for (int i = 1; i < childsCall.size(); i++) {
      final AstNode ci = childsCall.get(i);
      type = ci.getType();

      if (type == Token.NAME || type == Token.STRING || type == Token.GETVAR || type == Token.NUMBER) {
        final Namespace ns = new Namespace();
        ns.addName(ci.asString());
        parameters.add(ns);
      } else if (type == Token.GETPROP) {
        final Namespace ns = new GetProp(ci).resolveNamespace();
        parameters.add(ns);
      } else {
View Full Code Here

    if (call.getType() == Token.CALL) {
      final List<AstNode> childsCall = call.getChilds();
      if (childsCall.size() < 1) {
        return false;
      }
      final AstNode c0 = childsCall.get(0);
      int type = c0.getType();
      if (type == Token.NAME || type == Token.FUNCTION) {
        return true;
      }

      boolean valid = true;
      for (int i = 0; i < childsCall.size(); i++) {
        final AstNode ci = childsCall.get(i);
        type = ci.getType();

        if (type == Token.GETPROP) {
          try {
            new GetProp(ci);
          } catch (final WinkUnmanagedSyntaxException e) {
View Full Code Here

   * @param n
   * @return
   * @throws WinkUnmanagedSyntaxException
   */
  public static Call getAppropriateCall(final AstNode n) throws WinkUnmanagedSyntaxException {
    final AstNode callnode = n;

    final List<AstNode> childsCall = callnode.getChilds();
    final AstNode c0 = childsCall.get(0);
    final int type = c0.getType();

    if (type == Token.NAME && Constants.DEFINE_CALL.equals(c0.asString())) {
      return new DefineCall(n);
    } else {
      return new Call(n);
    }
  }
View Full Code Here

   */
  public SetProp(final AstNode n) throws WinkUnmanagedSyntaxException {
    super(n);

    final List<AstNode> childs = n.getChilds();
    final AstNode left = childs.get(0);
    final AstNode mid = childs.get(1);
    final AstNode right = childs.get(2);

    namespace = new Namespace();
    final int leftType = left.getType();
    final int midType = mid.getType();

View Full Code Here

    final List<AstNode> childsSp = setprop.getChilds();

    if (childsSp.size() != 3) {
      return false; // "Unknow SetProp Syntax : expected 3 tokens"
    }
    final AstNode left = childsSp.get(0);
    final AstNode mid = childsSp.get(1);
    final int leftType = left.getType();
    final int midType = mid.getType();

    if (leftType != Token.NAME && leftType != Token.GETVAR && leftType != Token.GETPROP && leftType != Token.THIS && leftType != Token.GETELEM) {
      // System.err.println("Unknow SetProp Syntax : unexpected left node : "
      // + Ast.tokenName(leftType) + " " + Ast.getPositionInfo(left));
      return false;
View Full Code Here

  public DefineCall(final AstNode n) throws WinkUnmanagedSyntaxException {
    super(n);

    parameters = Common.newArrayList(0);

    final AstNode callnode = n;
    final List<AstNode> childsCall = callnode.getChilds();

    for (int i = 0; i < childsCall.size(); i++) {
      final AstNode ci = childsCall.get(i);
      final int type = ci.getType();

      if (type == Token.FUNCTION) {
        function = new Function(ci);
        namespace = new Namespace();
        namespace.addName(function.getNode().getFunctionName());
View Full Code Here

  public GetElem(final AstNode n) throws WinkUnmanagedSyntaxException {
    super(n);

    final List<AstNode> childs = n.getChilds();
    if (childs.size() == 2) {
      final AstNode left = childs.get(0);
      final AstNode right = childs.get(1);
      final int lt = left.getType();
      final int rt = right.getType();

      if (lt == Token.NAME && rt == Token.NAME) {
        name = left.asString();
        prop = right.asString();
      } else {
        final String syntax = "" + Ast.tokenName(Token.NAME) + "-" + Ast.tokenName(Token.NAME);
        throw new WinkUnmanagedSyntaxException("Unknow GetElem Syntax, expected: " + syntax + " -> " + Ast.tokenName(lt) + "-" + Ast.tokenName(rt) + " " + Ast.getPositionInfo(n));
      }
    } else {
View Full Code Here

    final List<AstNode> childs = node.getChilds();

    int index = 0;
    for (final String pName : objectIds) {
      final AstNode c = childs.get(index++);
      final ParseObject po = ParserUtils.resolveParseObject(c);
      final ScriptObject soc = ParserUtils.buildScriptObject(po, this);
      final Namespace nsc = Namespace.build(getNamespace(), pName);
      addComponent(pName, soc, this, nsc);
    }
View Full Code Here

    /**
     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
     */
    @Override
    public int compare(final ParseObject o1, final ParseObject o2) {
      final AstNode n1 = o1.getNode();
      final AstNode n2 = o2.getNode();
      return new Integer(n1.getLineStart()).compareTo(n2.getLineStart());
    }
View Full Code Here

TOP

Related Classes of com.orange.wink.ast.AstNode

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.