Package org.sablecc.objectmacro.intermediate.syntax3.parser

Examples of org.sablecc.objectmacro.intermediate.syntax3.parser.Parser


    public void testGenerateParseOneByteAtATime() throws Exception
    {
        GoAwayGenerator generator = new GoAwayGenerator(new HeaderGenerator());

        final List<GoAwayFrame> frames = new ArrayList<>();
        Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
        {
            @Override
            public boolean onGoAway(GoAwayFrame frame)
            {
                frames.add(frame);
                return false;
            }
        }, 4096, 8192);

        int lastStreamId = 13;
        int error = 17;
        byte[] payload = new byte[16];
        new Random().nextBytes(payload);

        ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
        generator.generateGoAway(lease, lastStreamId, error, payload);

        for (ByteBuffer buffer : lease.getByteBuffers())
        {
            while (buffer.hasRemaining())
            {
                parser.parse(ByteBuffer.wrap(new byte[]{buffer.get()}));
            }
        }

        Assert.assertEquals(1, frames.size());
        GoAwayFrame frame = frames.get(0);
View Full Code Here


        long idleTimeout = endPoint.getIdleTimeout();
        if (idleTimeout > 0)
            idleTimeout /= 2;
        session.setStreamIdleTimeout(idleTimeout);

        Parser parser = newServerParser(connector.getByteBufferPool(), session);
        HTTP2Connection connection = new HTTP2ServerConnection(connector.getByteBufferPool(), connector.getExecutor(),
                        endPoint, parser, session, getInputBufferSize(), isDispatchIO(), listener);

        return configure(connection, connector, endPoint);
    }
View Full Code Here

                        + textBuilder.toString() + "'")));
                textBuilder = null;
            }
        }

        return new AMacro(name, is_public, params, self_ref, ancestor_refs,
                param_refs, expands, expanded_macros, macro_parts);
    }
View Full Code Here

                        + textBuilder.toString() + "'")));
                textBuilder = null;
            }
        }

        return new AMacro(name, is_public, params, self_ref, ancestor_refs,
                param_refs, expands, expanded_macros, macro_parts);
    }
View Full Code Here

                .getReferencedAncestors()) {
            ancestor_refs.add(new TString("'" + ancestor.getCamelCaseName()
                    + "'"));
        }

        return new ATextInsert(name, args, ancestor_refs);
    }
View Full Code Here

                .getReferencedAncestors()) {
            ancestor_refs.add(new TString("'" + ancestor.getCamelCaseName()
                    + "'"));
        }

        return new ATextInsert(name, args, ancestor_refs);
    }
View Full Code Here

  private void runtest(String src) {
    runtest(src, true);
  }

  private void runtest(String src, boolean succeed) {
    Parser parser = new Parser();
    try {
      parser.parse(new Lexer(new StringReader(src)));
      if(!succeed) {
        fail("Test was supposed to fail, but succeeded");
      }
    } catch (beaver.Parser.Exception e) {
      if(succeed) {
View Full Code Here

  private void runtest(String... srcs) {
    runtest(true, srcs);
  }

  private void runtest(boolean succeed, String... srcs) {
    Parser parser = new Parser();
    try {
      List<Module> modules = new List<Module>();
      for(String src : srcs)
        modules.add((Module)parser.parse(new Lexer(new StringReader(src))));
      Program prog = new Program(modules);
      prog.namecheck();
      if(!prog.hasErrors()) prog.typecheck();
      if(succeed) {
        if(prog.hasErrors()) {
View Full Code Here

   */
  private void runtest(String[] modules_src, String main_module, String main_function, Class<?>[] parm_types, Object[] args, Object expected) {
    try {
      List<Module> modules = new List<Module>();
      for(String module_src : modules_src) {
        Parser parser = new Parser();
        Module module = (Module)parser.parse(new Lexer(new StringReader(module_src)));
        modules.add(module);
      }
      Program prog = new Program(modules);
     
      prog.namecheck();
View Full Code Here

  public void testSum() throws LexicalException, Exception {
    ValueMap values = new ValueMap();
    values.put("val1", new BigDecimal(5));
    values.put("val2", new BigDecimal(10));
   
    Parser p = new Parser("val1+val2");
    BigDecimal value = p.eval(p.lexicalVerifier(), values);
    assertEquals(value.compareTo(new BigDecimal("15")), 0);
  }
View Full Code Here

TOP

Related Classes of org.sablecc.objectmacro.intermediate.syntax3.parser.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.