From d2b0e006273d55c170ed6cd56f9509bc1eaa90eb Mon Sep 17 00:00:00 2001 From: Andrei Aiordachioaie Date: Mon, 8 Jun 2009 17:49:13 +0200 Subject: Implemented Condense Expression and Constant Coverage Expression. WCPS Grammar modified --- src/wcps/server/cli/grammar.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/wcps/server/cli/grammar.java') diff --git a/src/wcps/server/cli/grammar.java b/src/wcps/server/cli/grammar.java index eabee72..29961a2 100644 --- a/src/wcps/server/cli/grammar.java +++ b/src/wcps/server/cli/grammar.java @@ -24,22 +24,30 @@ public class grammar { if (args.length != 1) { System.err.println("AbstractGrammarGen: no query as parameter !"); - query = "for r in (rgb) return encode( r * ((r.green > 130) and " + - "(r.red < 110)), \"jpeg\")"; + query = "for a in (rgb) return " + + "condense + over $x x(1:10), $y y(25:75) " + + "using $x * (a[x($x), y($y)]).red"; } else query = args[0]; System.out.println("Running with the following query: " + query); - String xmlString = runQuery(query); + String xmlString = convertAbstractQueryToXml(query); System.out.println("Output XML: \n****************\n" + xmlString); System.exit(0); } - public static String runQuery(String query) throws IOException, RecognitionException + /** Converts a WCPS abstract syntax query to an XML query + * + * @param query Abstract Syntax query + * @return String XML query + * @throws java.io.IOException + * @throws org.antlr.runtime.RecognitionException + */ + public static String convertAbstractQueryToXml(String query) throws IOException, RecognitionException { InputStream stream = new ByteArrayInputStream(query.getBytes()); // defaults to ISO-1 ANTLRInputStream inputStream = new ANTLRInputStream(stream); -- cgit