@Test public void shouldParseWriteLiteralTextWithMuchPunctuation() throws Exception { String scriptFragment = "write \"GET / HTTP/1.1\\r\\nHost: localhost:8000\\r\\n" + "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20100101 Firefox/8.0\\r\\n" + "Accept: text/html, application/xhtml+xml, application/xml;q=0.9,**;q=0.8\r\n\r\n").done(); assertEquals(expected, actual); }
public <T extends AstRegion> T parseWithStrategy(String input, ScriptParseStrategy<T> strategy) throws ScriptParseException { T result = null; int newStart = 0; int newEnd = input.length(); CharStream ais = CharStreams.fromString(input); RobotLexer lexer = new RobotLexer(ais); CommonTokenStream tokens = new CommonTokenStream(lexer); final RobotParser parser = new RobotParser(tokens); parser.setErrorHandler(new BailErrorStrategy()); try { result = strategy.parse(parser, factory, context); RegionInfo regionInfo = result.getRegionInfo(); List<RegionInfo> newChildren = regionInfo.children; switch (regionInfo.kind) { case SEQUENTIAL: result.setRegionInfo(newSequential(newChildren, newStart, newEnd)); break; case PARALLEL: result.setRegionInfo(newParallel(newChildren, newStart, newEnd)); break; } } catch (ParseCancellationException pce) { Throwable cause = pce.getCause(); if (cause instanceof RecognitionException) { RecognitionException re = (RecognitionException) cause; throw createScriptParseException(parser, re); } throw pce; } catch (RecognitionException re) { throw createScriptParseException(parser, re); } return result; }
ScriptParserImpl implements ScriptParser { public <T extends AstRegion> T parseWithStrategy(String input, ScriptParseStrategy<T> strategy) throws ScriptParseException { T result = null; int newStart = 0; int newEnd = input.length(); CharStream ais = CharStreams.fromString(input); RobotLexer lexer = new RobotLexer(ais); CommonTokenStream tokens = new CommonTokenStream(lexer); final RobotParser parser = new RobotParser(tokens); parser.setErrorHandler(new BailErrorStrategy()); try { result = strategy.parse(parser, factory, context); RegionInfo regionInfo = result.getRegionInfo(); List<RegionInfo> newChildren = regionInfo.children; switch (regionInfo.kind) { case SEQUENTIAL: result.setRegionInfo(newSequential(newChildren, newStart, newEnd)); break; case PARALLEL: result.setRegionInfo(newParallel(newChildren, newStart, newEnd)); break; } } catch (ParseCancellationException pce) { Throwable cause = pce.getCause(); if (cause instanceof RecognitionException) { RecognitionException re = (RecognitionException) cause; throw createScriptParseException(parser, re); } throw pce; } catch (RecognitionException re) { throw createScriptParseException(parser, re); } return result; } }
ScriptParserImpl implements ScriptParser { public <T extends AstRegion> T parseWithStrategy(String input, ScriptParseStrategy<T> strategy) throws ScriptParseException { T result = null; int newStart = 0; int newEnd = input.length(); CharStream ais = CharStreams.fromString(input); RobotLexer lexer = new RobotLexer(ais); CommonTokenStream tokens = new CommonTokenStream(lexer); final RobotParser parser = new RobotParser(tokens); parser.setErrorHandler(new BailErrorStrategy()); try { result = strategy.parse(parser, factory, context); RegionInfo regionInfo = result.getRegionInfo(); List<RegionInfo> newChildren = regionInfo.children; switch (regionInfo.kind) { case SEQUENTIAL: result.setRegionInfo(newSequential(newChildren, newStart, newEnd)); break; case PARALLEL: result.setRegionInfo(newParallel(newChildren, newStart, newEnd)); break; } } catch (ParseCancellationException pce) { Throwable cause = pce.getCause(); if (cause instanceof RecognitionException) { RecognitionException re = (RecognitionException) cause; throw createScriptParseException(parser, re); } throw pce; } catch (RecognitionException re) { throw createScriptParseException(parser, re); } return result; } ScriptParserImpl();  ScriptParserImpl(ExpressionFactory factory, ExpressionContext context); }
ScriptParserImpl implements ScriptParser { public <T extends AstRegion> T parseWithStrategy(String input, ScriptParseStrategy<T> strategy) throws ScriptParseException { T result = null; int newStart = 0; int newEnd = input.length(); CharStream ais = CharStreams.fromString(input); RobotLexer lexer = new RobotLexer(ais); CommonTokenStream tokens = new CommonTokenStream(lexer); final RobotParser parser = new RobotParser(tokens); parser.setErrorHandler(new BailErrorStrategy()); try { result = strategy.parse(parser, factory, context); RegionInfo regionInfo = result.getRegionInfo(); List<RegionInfo> newChildren = regionInfo.children; switch (regionInfo.kind) { case SEQUENTIAL: result.setRegionInfo(newSequential(newChildren, newStart, newEnd)); break; case PARALLEL: result.setRegionInfo(newParallel(newChildren, newStart, newEnd)); break; } } catch (ParseCancellationException pce) { Throwable cause = pce.getCause(); if (cause instanceof RecognitionException) { RecognitionException re = (RecognitionException) cause; throw createScriptParseException(parser, re); } throw pce; } catch (RecognitionException re) { throw createScriptParseException(parser, re); } return result; } ScriptParserImpl();  ScriptParserImpl(ExpressionFactory factory, ExpressionContext context); ExpressionFactory getExpressionFactory(); ExpressionContext getExpressionContext(); @Override AstScriptNode parse(String input); T parseWithStrategy(String input, ScriptParseStrategy<T> strategy); }
ScriptParserImpl implements ScriptParser { public <T extends AstRegion> T parseWithStrategy(String input, ScriptParseStrategy<T> strategy) throws ScriptParseException { T result = null; int newStart = 0; int newEnd = input.length(); CharStream ais = CharStreams.fromString(input); RobotLexer lexer = new RobotLexer(ais); CommonTokenStream tokens = new CommonTokenStream(lexer); final RobotParser parser = new RobotParser(tokens); parser.setErrorHandler(new BailErrorStrategy()); try { result = strategy.parse(parser, factory, context); RegionInfo regionInfo = result.getRegionInfo(); List<RegionInfo> newChildren = regionInfo.children; switch (regionInfo.kind) { case SEQUENTIAL: result.setRegionInfo(newSequential(newChildren, newStart, newEnd)); break; case PARALLEL: result.setRegionInfo(newParallel(newChildren, newStart, newEnd)); break; } } catch (ParseCancellationException pce) { Throwable cause = pce.getCause(); if (cause instanceof RecognitionException) { RecognitionException re = (RecognitionException) cause; throw createScriptParseException(parser, re); } throw pce; } catch (RecognitionException re) { throw createScriptParseException(parser, re); } return result; } ScriptParserImpl();  ScriptParserImpl(ExpressionFactory factory, ExpressionContext context); ExpressionFactory getExpressionFactory(); ExpressionContext getExpressionContext(); @Override AstScriptNode parse(String input); T parseWithStrategy(String input, ScriptParseStrategy<T> strategy);  }