Package com.google.caja.lexer

Examples of com.google.caja.lexer.CharProducer


    System.out.println(
        " VarZ:" + getClass().getName() + ".msPerRun=" + microsPerRun);
  }

  private int benchmark(int nRuns) throws IOException, ParseException {
    CharProducer testInput = fromResource("amazon.com.html");
    InputSource is = testInput.getSourceBreaks(0).source();
    MessageQueue mq = DevNullMessageQueue.singleton();
    long t0 = System.nanoTime();
    for (int i = nRuns; --i >= 0;) {
      HtmlLexer lexer = new HtmlLexer(testInput.clone());
      lexer.setTreatedAsXml(false);
      TokenQueue<HtmlTokenType> tq = new TokenQueue<HtmlTokenType>(
          lexer, is, DomParser.SKIP_COMMENTS);
      DomParser p = new DomParser(tq, false, mq);
      p.setNeedsDebugData(false);
View Full Code Here


        continue;
      }
      StringLiteral sl = vprop.getPropertyNameNode();
      String rawExpr = sl.getValue();
      rawExpr = " " + rawExpr.substring(1, rawExpr.length() - 1) + " ";
      CharProducer valueCp = CharProducer.Factory.fromJsString(
          CharProducer.Factory.fromString(rawExpr, sl.getFilePosition()));
      try {
        Expression expr = jsExpr(valueCp, DevNullMessageQueue.singleton());
        optimizer.addFact(expr, Fact.is((Literal) value));
      } catch (ParseException ex) {
View Full Code Here

          String jsonfile = arg.substring(arg.indexOf('=') + 1);
          opt.setEnvJson((ObjectConstructor) jsExpr(fromFile(jsonfile), mq));
        } else {
          if ("--".equals(arg)) { ++i; }
          for (;i < n; ++i) {
            CharProducer cp = fromFile(args[i]);
            mc.addInputSource(cp.getCurrentPosition().source());
            opt.addInput(js(cp, mq));
          }
        }
      }
    } catch (ParseException ex) {
View Full Code Here

        extRef, deferred, el, t);
  }

  private EmbeddedContent fromElementBody(
      Element el, ContentType t, boolean deferred) {
    final CharProducer cp = textNodesToCharProducer(el, t == ContentType.JS);
    return new EmbeddedContent(
        this, cp.filePositionForOffsets(0, cp.getLimit()),
        new Function<UriFetcher, CharProducer>() {
          public CharProducer apply(UriFetcher fetcher) { return cp.clone(); }
        },
        null, deferred, el, t);
  }
View Full Code Here

        this, Nodes.getFilePositionForValue(a),
        new Function<UriFetcher, CharProducer>() {
          CharProducer cp;
          public CharProducer apply(UriFetcher fetcher) {
            if (this.cp == null) {
              CharProducer cp;
              String rawText = rawValue;
              if (rawText != null) {
                int n = rawText.length();
                if (n >= 2) {  // Strip quotes
                  char lastCh = rawText.charAt(n - 1);
View Full Code Here

      return false;
    }
  }

  private static void loadEnvJsonFile(File f, JsOptimizer op, MessageQueue mq) {
    CharProducer cp;
    try {
      cp = read(f);
    } catch (IOException ex) {
      mq.addMessage(
          MessageType.IO_ERROR, MessagePart.Factory.valueOf(ex.toString()));
View Full Code Here

    // Parse each input, and find annotations.
    for (File inp : inputs) {
      InputSource src = new InputSource(inp.toURI());
      mc.addInputSource(src);

      CharProducer cp = CharProducer.Factory.create(
          new InputStreamReader(new FileInputStream(inp), "UTF-8"), src);
      contents.put(src, new FileContent(cp));

      JsTokenQueue tq = new JsTokenQueue(new JsLexer(cp), src);
      try {
View Full Code Here

    MessageContext mc = new MessageContext();
    mc.addInputSource(input.a);

    final MessageQueue errs = new EchoingMessageQueue(
        err, mc, false);
    CharProducer cp = CharProducer.Factory.create(
        new InputStreamReader(new FileInputStream(input.b),
            Charsets.UTF_8.name()),
        input.a);

    JsLexer lexer = new JsLexer(cp);
View Full Code Here

                MessagePart.Factory.valueOf(ex.getMessage()));
          }
        })));

    for (Pair<InputSource, File> input : inputs) {
      CharProducer cp = CharProducer.Factory.create(
          new InputStreamReader(new FileInputStream(input.b),
              Charsets.UTF_8.name()),
          input.a);
      JsLexer lexer = new JsLexer(cp);
      JsTokenQueue tq = new JsTokenQueue(lexer, input.a);
View Full Code Here

    compiler.setJobCache(new AppEngineJobCache());
    compiler.setMessageContext(mc);

    URI uri = guessURI(base, url);
    InputSource is = new InputSource(uri);
    CharProducer cp = CharProducer.Factory.fromString(input, is);
    boolean okToContinue = true;
    Dom inputNode = null;
    try {
      DomParser p = new DomParser(new HtmlLexer(cp), false, is, mq);
      inputNode = new Dom(p.parseFragment());
View Full Code Here

TOP

Related Classes of com.google.caja.lexer.CharProducer

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.