Package org.mozilla.javascript

Examples of org.mozilla.javascript.Parser


   
    ce.setGenerateDebugInfo(true);   
    ce.initFromContext(ContextFactory.getGlobal().enterContext());
    ce.setErrorReporter(errorReporter);
   
    Parser p = new Parser(ce, errorReporter);
    ScriptOrFnNode ast = p.parse(this.scriptSource, "script", 0);
   
    searchAstForNodes(ast);
  }
View Full Code Here


   
    ce.setGenerateDebugInfo(true);   
    ce.initFromContext(ContextFactory.getGlobal().enterContext());
    ce.setErrorReporter(errorReporter);
   
    Parser p = new Parser(ce, errorReporter);
    ScriptOrFnNode ast = p.parse(scriptSource, "script", 0);
   
    return new ArrayLiteral(ast.getFirstChild().getFirstChild().getFirstChild());
  }
View Full Code Here

   
    ce.setGenerateDebugInfo(true);   
    ce.initFromContext(ContextFactory.getGlobal().enterContext());
    ce.setErrorReporter(errorReporter);
   
    Parser p = new Parser(ce, errorReporter);
    ScriptOrFnNode ast = p.parse(scriptSource, "script", 0);
   
    return new ObjectLiteral(ast.getFirstChild().getFirstChild().getFirstChild());
  }
View Full Code Here

   
    ce.setGenerateDebugInfo(true);   
    ce.initFromContext(ContextFactory.getGlobal().enterContext());
    ce.setErrorReporter(errorReporter);
   
    Parser p = new Parser(ce, errorReporter);
    ScriptOrFnNode ast = p.parse(this.scriptSource, "script", 0);
   
    recursiveParse(ast);
   
    this.scriptParsed = true;
  }
View Full Code Here

        environment.setErrorReporter(testErrorReporter);

        environment.setRecordingComments(true);
        environment.setRecordingLocalJsDocComments(jsdoc);

        Parser p = new Parser(environment, testErrorReporter);
        AstRoot script = p.parse(string, null, 0);

        assertTrue(testErrorReporter.hasEncounteredAllErrors());
        assertTrue(testErrorReporter.hasEncounteredAllWarnings());

        return script;
View Full Code Here

        environment.setErrorReporter(testErrorReporter);

        environment.setRecordingComments(true);
        environment.setRecordingLocalJsDocComments(true);

        Parser p = new Parser(environment, testErrorReporter);
        AstRoot script = p.parse(new StringReader(string), null, 0);

        assertTrue(testErrorReporter.hasEncounteredAllErrors());
        assertTrue(testErrorReporter.hasEncounteredAllWarnings());

        return script;
View Full Code Here

    public SourceProcessor(ConfigurationCommon config, String uri) {
        this.uri = uri;
        this.instrumenter = new ParseTreeInstrumenter(uri, config.isIncludeFunction());
        this.branchInstrumentor = new BranchInstrumentor(uri);
        parser = new Parser(config.getCompilerEnvirons());
        this.includeBranchCoverage = config.isIncludeBranch();
        this.includeFunctionCoverage = config.isIncludeFunction();
        this.localStorage = config.isLocalStorage();
    }
View Full Code Here

    ErrorReporter errorReporter = new LogErrorReporter(log);

    CompilerEnvirons env = new CompilerEnvirons();
    env.setErrorReporter(errorReporter);

    Parser parser = new Parser(env, errorReporter);
    Reader reader = new BufferedReader(new FileReader(source));
    try {
      AstRoot root = parser.parse(reader, source.getAbsolutePath(), 0);
      DependencyAccumulator visitor = new DependencyAccumulator(source);
      root.visit(visitor);

      // complain if no def was found in this source
      if (visitor.current == null) {
View Full Code Here

        CompilerEnvirons compilerEnv = new CompilerEnvirons();
        compilerEnv.setLanguageVersion(180);
        compilerEnv.setStrictMode(false);

        Bug788070 visitor = new Bug788070();
        addIncrement(new Parser(compilerEnv), visitor, "switch (x) {\n" +
                "case x:\n" +
                "  y = 0;\n" +
                "  break;\n" +
                "default:\n" +
                "  x = 0;\n" +
View Full Code Here

    public static void main(String args[]) throws Exception {
        String source = ioUtils.loadFromClassPath("/test.js");
//        String source = "let ({x: x0, y: y0} = point) {\n  print(x0);\n  print(y0);\n}";
        CompilerEnvirons compilerEnv = new CompilerEnvirons();
        compilerEnv.setLanguageVersion(180);
        Parser parser = new Parser(compilerEnv);
        AstRoot astRoot = parser.parse(new StringReader(source), null, 1);
        astRoot.visitAll(new InstrumentVisitor());
        System.out.println(astRoot.toSource());
//        System.out.println("****************************");
//
//        source = "label:{\nx++;\nwhile (x) {\n  if (x) {\n    continue label;\n  }\n}}";
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Parser

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.