Package uk.co.badgersinfoil.metaas

Examples of uk.co.badgersinfoil.metaas.SyntaxException


  public static LinkedListTree parseForInVar(String expr) {
    AS3Parser parser = ASTUtils.parse(expr + " in");
    try {
      return tree(parser.forInClauseDecl());
    } catch (RecognitionException e) {
      throw new SyntaxException(e);
    }
  }
View Full Code Here


  public static LinkedListTree parseForInIterated(String expr) {
    AS3Parser parser = ASTUtils.parse(expr + ")");
    try {
      return tree(parser.forInClauseTail());
    } catch (RecognitionException e) {
      throw new SyntaxException(e);
    }
  }
View Full Code Here

  public static LinkedListTree parseVariableDeclarator(String assignment) {
    AS3Parser parser = ASTUtils.parse(assignment + ";");
    try {
      return tree(parser.variableDeclarator());
    } catch (RecognitionException e) {
      throw new SyntaxException(e);
    }
  }
View Full Code Here

  }

  protected StatementContainer getStatementContainer() {
    LinkedListTree child = thenClause();
    if (AS3Parser.BLOCK != child.getType()) {
      throw new SyntaxException("statement is not a block");
    }
    return new ASTStatementList(child);
  }
View Full Code Here

      ASTUtils.increaseIndentAfterFirstLine(block, indent);
      return new ASTStatementList(block);
    }
    Statement stmt = StatementBuilder.build(elseClause.getFirstChild());
    if (!(stmt instanceof ASBlock)) {
      throw new SyntaxException("Expected a block, got "+ASTUtils.tokenName(elseClause.getFirstChild()));
    }
    return (ASBlock)stmt;
  }
View Full Code Here

  public static AS3Parser parse(Reader in) {
    ANTLRReaderStream cs;
    try {
      cs = new ANTLRReaderStream(in);
    } catch (IOException e) {
      throw new SyntaxException(e);
    }
    AS3Lexer lexer = new AS3Lexer(cs);
    LinkedListTokenSource linker = new LinkedListTokenSource(lexer);
    LinkedListTokenStream tokenStream = new LinkedListTokenStream(linker);
    AS3Parser parser = new AS3Parser(tokenStream);
View Full Code Here

      } else {
        msg = "Problem parsing "+ActionScriptFactory.str(statement);
      }
    }
    msg += " at line " + e.line;
    return new SyntaxException(msg, e);
  }
View Full Code Here

  public static String decodeStringLiteral(String str) {
    StringBuffer result = new StringBuffer();
    char[] s = str.toCharArray();
    int end = s.length - 1;
    if (s[0] != '"' && s[0] != '\'') {
      throw new SyntaxException("Invalid delimiter at position 0: "+s[0]);
    }
    char delimiter = s[0];
    for (int i=1; i<end; i++) {
      char c = s[i];
      switch (c) {
      case '\\':
        c = s[++i];
        switch (c) {
        case 'n':
          result.append('\n');
          break;
        case 't':
          result.append('\t');
          break;
        case '\\':
          result.append('\\');
          break;
        default:
          result.append(c);
        }
        break;
      default:
        result.append(c);
      }
    }
    if (s[end] != delimiter) {
      throw new SyntaxException("End delimiter doesn't match "+delimiter+" at position "+end);
    }
    return result.toString();
  }
View Full Code Here

        tok.delete();
      } else if (tok.getType() == AS3Parser.COMMA) {
        tok.delete();
        break;
      } else {
        throw new SyntaxException("Unexpected token: "+tok);
      }
    }
  }
View Full Code Here

        continue;
      } else if (tok.getType() == AS3Parser.COMMA) {
        tok.delete();
        break;
      } else {
        throw new SyntaxException("Unexpected token: "+tok);
      }
    }
  }
View Full Code Here

TOP

Related Classes of uk.co.badgersinfoil.metaas.SyntaxException

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.