@Test void parseCast() { Term term = SUT.parse(IOUtils.toInputStream("CAST(parameter,S7ParameterUserData).items(hurz)[0]", Charset.defaultCharset())); assertVariableLiteral( term, "CAST", terms -> { assertThat(terms, hasSize(2)); assertVariableLiteral( terms.get(0), "parameter" ); assertVariableLiteral( terms.get(1), "S7ParameterUserData" ); }, variableLiteral -> { assertVariableLiteral( variableLiteral, "items", terms -> { assertThat(terms, hasSize(1)); assertVariableLiteral( terms.get(0), "hurz" ); }, null, 0 ); } ); }
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);  }