Package uk.co.badgersinfoil.metaas.impl.antlr

Examples of uk.co.badgersinfoil.metaas.impl.antlr.LinkedListToken


  private static LinkedListToken increaseIndentAt(LinkedListToken tok, String indentStr) {
    if (tok.getType() == AS3Parser.WS) {
      tok.setText(indentStr + tok.getText());
      return tok;
    }
    LinkedListToken indent = TokenBuilder.newWhiteSpace(indentStr);
    tok.beforeInsert(indent);
    return indent;
  }
View Full Code Here


   * startToken and returns the contents of the first whitespace token
   * following a newline token, or the empty string if no such pattern
   * is found.
   */
  public static String findIndent(LinkedListTree node) {
    LinkedListToken tok = node.getStartToken();
    if (tok == null) {
      return findIndent(node.getParent());
    }
    // the start-token of this AST node is actually whitespace, so
    // scan forward until we hit a non-WS token,
    while (tok.getType()==AS3Parser.NL || tok.getType()==AS3Parser.WS) {
      if (tok.getNext() == null) {
        break;
      }
      tok = tok.getNext();
    }
    // search backwards though the tokens, looking for the start of
    // the line,
    for (; tok.getPrev()!=null; tok=tok.getPrev()) {
      if (tok.getType() == AS3Parser.NL) {
        break;
      }
    }
    if (tok.getType() == AS3Parser.WS) {
      return tok.getText();
    }
    if (tok.getType()!=AS3Parser.NL) {
      return "";
    }
    LinkedListToken startOfLine = tok.getNext();
    if (startOfLine.getType() == AS3Parser.WS) {
      return startOfLine.getText();
    }
    return "";
  }
View Full Code Here

    }
    return result.toString();
  }

  public static LinkedListToken newStringLiteral(String constant) {
    return new LinkedListToken(AS3Parser.STRING_LITERAL, ActionScriptFactory.str(constant));
  }
View Full Code Here

  }

  public static void removePreceedingWhitespaceAndComma(LinkedListToken startToken) {
    for (LinkedListToken tok = startToken.getPrev(); tok!=null; tok=tok.getPrev()) {
      if (tok.getChannel() == AS3Parser.HIDDEN) {
        LinkedListToken del = tok;
        tok = tok.getNext();
        del.delete();
        continue;
      } else if (tok.getType() == AS3Parser.COMMA) {
        tok.delete();
        break;
      } else {
View Full Code Here

  private TokenBuilder() {
    // hide default ctor
  }

  public static LinkedListToken newToken(int type, String text) {
    return new LinkedListToken(type, text);
  }
View Full Code Here

  public static LinkedListToken newToken(int type, String text) {
    return new LinkedListToken(type, text);
  }

  public static LinkedListToken newNewline() {
    LinkedListToken nl = newToken(AS3Parser.NL, "\n");
    nl.setChannel(AS3Parser.HIDDEN);
    return nl;
  }
View Full Code Here

  public static LinkedListToken newSpace() {
    return newWhiteSpace(" ");
  }

  public static LinkedListToken newWhiteSpace(String indentStr) {
    LinkedListToken ws = newToken(AS3Parser.WS, indentStr);
    ws.setChannel(AS3Parser.HIDDEN);
    return ws;
  }
View Full Code Here

  private void addParam(String name, LinkedListTree val) {
    LinkedListTree assign = ASTUtils.newImaginaryAST(AS3Parser.ASSIGN);
    LinkedListTree ident = ASTUtils.newAST(AS3Parser.IDENT, name);
    assign.addChildWithTokens(ident);
    LinkedListToken assignToken = new LinkedListToken(AS3Parser.ASSIGN, "=");
    assign.appendToken(assignToken);
    assign.token = assignToken;
    assign.addChildWithTokens(val);

    addParam(assign);
View Full Code Here

TOP

Related Classes of uk.co.badgersinfoil.metaas.impl.antlr.LinkedListToken

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.