Package edu.wisc.game.parser
Interface Expression
- All Known Subinterfaces:
Expression.ArithmeticExpression
- All Known Implementing Classes:
Expression.AdditiveExpression,Expression.BracketList,Expression.ColonExpression,Expression.ComparisonExpression,Expression.ExList,Expression.Id,Expression.MultiplicativeExpression,Expression.NegationExpression,Expression.Num,Expression.ParenList,Expression.QualifiedId,Expression.RangeExpression,Expression.SerialExpression,Expression.Star
public interface Expression
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic interfaceAn arithmetic expression is composed of variables, constants, and arithmetic operations; parentheses can be used for ordering operations.static classstatic classId:ArithmeticExpression; used in GS 3static classHas exactly two operands, and the operator is one of '==', '!=', 'invalid input: '<'=', '>', etcstatic classCan be overridden as neededstatic classA variable.static interfaceA Mapper is something that can take a variable (Expression.Id) and produce another Expression (e.g.static classA HashMap storing a set of values of a given type T for each keystatic classstatic class!E evaluates to [1] if E is an empty set, or to [] otherwisestatic classA numeric constantstatic classstatic classValues are String or Integerstatic classA.Bstatic class[Num..Num]static classAdditive or multiplicativestatic classA Star expression is simply "*".static classstatic classObjects in question may be Integer, String, or PropMap (ImageObject or equivalent) -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionmap(Expression.Mapper mapper) static Expression.BracketListmkBracketList(Vector<Token> tokens) static ExpressionmkCounterOrAtom(Vector<Token> tokens) Extracts one of the sections of a rule line: either the leading counter (int or star), or one of the atoms (paren lists that may include arithmetic expressions or stars)mkLongestArithmeticExpression(Vector<Token> tokens) Creates the longest ArithmeticExpression starting at the beginning of the tokens array.mkLongestE1(Vector<Token> tokens) E1 := (E) | Id.Id | Id | Num | -Num | [E,E,...]mkLongestE2(Vector<Token> tokens) E2 := E1 | !E2mkLongestE3(Vector<Token> tokens) E3 := E2 | E2*E2...mkLongestE4(Vector<Token> tokens) mkLongestE5(Vector<Token> tokens) static Expression.RangeExpressionmkRangeExpression(Vector<Token> tokens) If the given sequence of tokens starts with a range expression, extracts it; otherwise, returns nullTranslates all elements of the set to the [0..NBU-1] range, as appropriate for bucket numbersstatic IntegertoSrc()
-
Field Details
-
STAR
-
-
Method Details
-
toInteger
-
map
- Throws:
RuleParseException
-
toSrc
String toSrc() -
mkCounterOrAtom
Extracts one of the sections of a rule line: either the leading counter (int or star), or one of the atoms (paren lists that may include arithmetic expressions or stars)- Throws:
RuleParseException
-
mkRangeExpression
If the given sequence of tokens starts with a range expression, extracts it; otherwise, returns null- Throws:
RuleParseException
-
mkLongestArithmeticExpression
static Expression.ArithmeticExpression mkLongestArithmeticExpression(Vector<Token> tokens) throws RuleParseException Creates the longest ArithmeticExpression starting at the beginning of the tokens array.E := E5 E5 := E4 | E4==E4 E4 := E3 | E3+E3+... E3 := E2 | E2*E2... E2 := E1 | !E2 E1 := (E) | Id.Id | Id | Num | [E4,E4,...]- Throws:
RuleParseException
-
mkLongestE5
- Throws:
RuleParseException
-
mkLongestE4
- Throws:
RuleParseException
-
mkLongestE3
E3 := E2 | E2*E2...- Throws:
RuleParseException
-
mkLongestE2
E2 := E1 | !E2- Throws:
RuleParseException
-
mkLongestE1
E1 := (E) | Id.Id | Id | Num | -Num | [E,E,...]- Throws:
RuleParseException
-
mkBracketList
- Throws:
RuleParseException
-
moduloNB
Translates all elements of the set to the [0..NBU-1] range, as appropriate for bucket numbers -
moduloNB2
-