From 324e51f7464e329230bac87057fc4b37c4a23de6 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Wed, 16 Dec 2009 20:09:48 +0000 Subject: [PATCH] Code tidy (parser). git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@1656 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/parser/PrismParser.jj | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/prism/src/parser/PrismParser.jj b/prism/src/parser/PrismParser.jj index f9e2a382..6b30ba77 100644 --- a/prism/src/parser/PrismParser.jj +++ b/prism/src/parser/PrismParser.jj @@ -291,16 +291,6 @@ public class PrismParser return SimpleCharStream.getTabSize(0); } - /** - * Split a single argument ExpressionFunc object into two expressions. - */ - protected ExpressionPair splitExpressionFunc(ExpressionFunc func) - { - ExpressionPair expr = new ExpressionPair(); - - return expr; - } - /** * Generate a syntax error (PrismLangException) from a ParseException. */ @@ -370,6 +360,7 @@ TOKEN : | < ENDSYSTEM: "endsystem" > | < FALSE: "false" > | < FORMULA: "formula" > +| < FILTER: "filter" > | < FUNC: "func" > | < F: "F" > | < GLOBAL: "global" > @@ -1281,6 +1272,8 @@ Expression ExpressionBasic(boolean prop, boolean pathprop) : ret = ExpressionForAll(prop, pathprop) | ret = ExpressionLabel(prop, pathprop) + | + ret = ExpressionFilter(prop, pathprop) ) { return ret; } } @@ -1601,6 +1594,23 @@ Expression ExpressionLabel(boolean prop, boolean pathprop) : { ret = new ExpressionLabel(s); ret.setPosition(begin, getToken(0)); return ret; } } +// (Property) expression: filter (using "filter" keyword) + +Expression ExpressionFilter(boolean prop, boolean pathprop) : +{ + String s = null; + ExpressionFunc func = null; + Token begin = null; +} +{ + // This production is only allowed in expressions if the "prop" parameter is true + { if (!prop) throw generateParseException(); } + + ( begin = { s = "min"; } | begin = { s = "max"; } ) + { func = new ExpressionFunc(s); } ExpressionFuncArgs(prop, pathprop, func) + { func.setPosition(begin, getToken(0)); return func; } +} + //----------------------------------------------------------------------------------- // Miscellaneous stuff //-----------------------------------------------------------------------------------