@Test void parseDoubleCast() { Term term = SUT.parse(IOUtils.toInputStream("CAST(CAST(parameter,S7ParameterUserData).items(hurz)[0],S7ParameterUserDataItemCPUFunctions).cpuFunctionType", Charset.defaultCharset())); assertVariableLiteral( term, "CAST", outerCast -> { assertThat(outerCast, hasSize(2)); assertVariableLiteral( outerCast.get(0), "CAST", innerCast -> { assertThat(innerCast, hasSize(2)); assertVariableLiteral( innerCast.get(0), "parameter" ); assertVariableLiteral( innerCast.get(1), "S7ParameterUserData" ); }, items -> { assertVariableLiteral( items, "items", hurzes -> { assertThat(hurzes, hasSize(1)); assertVariableLiteral( hurzes.get(0), "hurz" ); }, null, 0 ); }); assertVariableLiteral( outerCast.get(1), "S7ParameterUserDataItemCPUFunctions" ); }, variableLiteral -> { assertVariableLiteral( variableLiteral, "cpuFunctionType" ); } ); }
public Term parse(InputStream source) { ExpressionLexer lexer; try { lexer = new ExpressionLexer(CharStreams.fromStream(source)); } catch (IOException e) { throw new RuntimeException(e); } ExpressionStringListener listener = new ExpressionStringListener(); new ParseTreeWalker().walk(listener, new ExpressionParser(new CommonTokenStream(lexer)).expressionString()); return listener.getRoot(); }
ExpressionStringParser { public Term parse(InputStream source) { ExpressionLexer lexer; try { lexer = new ExpressionLexer(CharStreams.fromStream(source)); } catch (IOException e) { throw new RuntimeException(e); } ExpressionStringListener listener = new ExpressionStringListener(); new ParseTreeWalker().walk(listener, new ExpressionParser(new CommonTokenStream(lexer)).expressionString()); return listener.getRoot(); } }
ExpressionStringParser { public Term parse(InputStream source) { ExpressionLexer lexer; try { lexer = new ExpressionLexer(CharStreams.fromStream(source)); } catch (IOException e) { throw new RuntimeException(e); } ExpressionStringListener listener = new ExpressionStringListener(); new ParseTreeWalker().walk(listener, new ExpressionParser(new CommonTokenStream(lexer)).expressionString()); return listener.getRoot(); }  }
ExpressionStringParser { public Term parse(InputStream source) { ExpressionLexer lexer; try { lexer = new ExpressionLexer(CharStreams.fromStream(source)); } catch (IOException e) { throw new RuntimeException(e); } ExpressionStringListener listener = new ExpressionStringListener(); new ParseTreeWalker().walk(listener, new ExpressionParser(new CommonTokenStream(lexer)).expressionString()); return listener.getRoot(); }  Term parse(InputStream source); }
ExpressionStringParser { public Term parse(InputStream source) { ExpressionLexer lexer; try { lexer = new ExpressionLexer(CharStreams.fromStream(source)); } catch (IOException e) { throw new RuntimeException(e); } ExpressionStringListener listener = new ExpressionStringListener(); new ParseTreeWalker().walk(listener, new ExpressionParser(new CommonTokenStream(lexer)).expressionString()); return listener.getRoot(); }  Term parse(InputStream source);  }