Package org.asdt.core.internal.antlr

Examples of org.asdt.core.internal.antlr.AS3Parser



public class ASTActionScriptParser implements ActionScriptParser {

  public ASCompilationUnit parse(Reader in) {
    AS3Parser parser = ASTUtils.parse(in);
    LinkedListTree cu;
    try {
      cu = AS3FragmentParser.tree(parser.compilationUnit());
    } catch (RecognitionException e) {
      throw ASTUtils.buildSyntaxException(null, parser, e);
    }
    return new AS3ASTCompilationUnit(cu);
  }
View Full Code Here


    // expression-statement will not unexpectedly find EOF. we add
    // a second ';' so that the trailing ';' can simply be ommitted
    // by the caller
    // TODO: assert that there really is no extra code trailing the
    //       parsed statement
    AS3Parser parser = ASTUtils.parse(statement+";;");
    LinkedListTree stmt;
    try {
      stmt = tree(parser.statement());
    } catch (RecognitionException e) {
      throw ASTUtils.buildSyntaxException(statement, parser, e);
    }
    return stmt;
  }
View Full Code Here

    return stmt;
  }


  public static LinkedListTree parseExprStatement(String expr) {
    AS3Parser parser = ASTUtils.parse(expr + ";");
    try {
      return tree(parser.expressionStatement());
    } catch (RecognitionException e) {
      throw ASTUtils.buildSyntaxException(expr, parser, e);
    }
  }
View Full Code Here

   *
   * @throws SyntaxException if the given text doesn't form a valid
   * expression.
   */
  public static LinkedListTree parseCondition(String expr) {
    AS3Parser parser = ASTUtils.parse("(" + expr + ")");
    try {
      return tree(parser.condition());
    } catch (RecognitionException e) {
      throw new SyntaxException("invalid condition "+ActionScriptFactory.str(expr), e);
    }
  }
View Full Code Here

   *
   * @throws SyntaxException if the given text doesn't form a valid
   * expression.
   */
  public static LinkedListTree parseExpr(String expr) {
    AS3Parser parser = ASTUtils.parse(expr + ")");
    try {
      LinkedListTree result = tree(parser.expression());
      ensureRemainingInputIs(parser.getTokenStream(), AS3Parser.RPAREN, expr);
      // zap the trailing ')'
      result.getStopToken().setNext(null);
      return result;
    } catch (RecognitionException e) {
      throw new SyntaxException("invalid expression "+ActionScriptFactory.str(expr), e);
View Full Code Here

   *
   * @throws SyntaxException if the given text doesn't form a valid
   * expression.
   */
  public static LinkedListTree parseExprList(String expr) {
    AS3Parser parser = ASTUtils.parse(expr + ")");
    try {
      return tree(parser.expressionList());
    } catch (RecognitionException e) {
      throw new SyntaxException("invalid expression-list "+ActionScriptFactory.str(expr), e);
    }
  }
View Full Code Here

   *
   * @throws SyntaxException if the given text doesn't form a valid
   * identifier.
   */
  public static LinkedListTree parseIdent(String value) {
    AS3Parser parser = ASTUtils.parse(value);
    try {
      LinkedListTree result = tree(parser.identifier());
      parser.endOfFile();
      return result;
    } catch (RecognitionException e) {
      throw new SyntaxException("invalid identifier "+ActionScriptFactory.str(value), e);
    }
  }
View Full Code Here

      throw new SyntaxException("invalid identifier "+ActionScriptFactory.str(value), e);
    }
  }

  public static LinkedListTree parseParameterDefault(String value) {
    AS3Parser parser = ASTUtils.parse("="+value);
    LinkedListTree def;
    try {
      def = tree(parser.parameterDefault());
    } catch (RecognitionException e) {
      throw new SyntaxException(e.getMessage());
    }
    return def;
  }
View Full Code Here

    }
    return def;
  }

  public static LinkedListTree parseForInit(String expr) {
    AS3Parser parser = ASTUtils.parse(expr + ";");
    try {
      LinkedListTree result = tree(parser.forInit());
      ensureRemainingInputIs(parser.getTokenStream(), AS3Parser.SEMI, expr);
      return result;
    } catch (RecognitionException e) {
      throw new SyntaxException(e);
    }
  }
View Full Code Here

      throw new SyntaxException(e);
    }
  }

  public static LinkedListTree parseForCond(String expr) {
    AS3Parser parser = ASTUtils.parse(expr + ";");
    try {
      LinkedListTree result = tree(parser.forCond());
      ensureRemainingInputIs(parser.getTokenStream(), AS3Parser.SEMI, expr);
      return result;
    } catch (RecognitionException e) {
      throw new SyntaxException(e);
    }
  }
View Full Code Here

TOP

Related Classes of org.asdt.core.internal.antlr.AS3Parser

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.