Example #1
0
 public AssignmentStatementRule(TerminalNode identifier, TerminalNode assignmentOperator,
                                ExpressionRule expression, TerminalNode semicolon)
 {
     Identifier         = Guard.OneOf(() => identifier, Token.Identifier);
     AssignmentOperator = Guard.OneOf(() => assignmentOperator, Token.Assignment);
     Expression         = expression;
     Semicolon          = Guard.OneOf(() => semicolon, Token.Semicolon);
 }
 //public methods
 public Expression Apply(Expression exp, ExpressionRule rule)
 {
     if (_matcher.Match(exp, rule.From, out _dict))
     {
         if (rule.Predicate == null || rule.Predicate(_dict))
         {
             return(Visit(rule.To.Body));
         }
     }
     return(exp);
 }
Example #3
0
 public IdOrAssignmentRule(TerminalNode identifier, TerminalNode assignmentOperator, ExpressionRule expression)
 {
     Identifier         = Guard.OneOf(() => identifier, Token.Identifier);
     AssignmentOperator = Guard.OneOf(() => assignmentOperator, Token.Assignment);
     Expression         = Guard.NonNull(() => expression);
 }
Example #4
0
 public MainFunctionBuilder WithReturnExpression(ExpressionRule expressionRule)
 {
     _mainFunctionRule.FunctionBody.ReturnStatement.Expression = expressionRule;
     return(this);
 }
Example #5
0
 public WriteStatementRule(TerminalNode write, ExpressionRule expression, TerminalNode semicolon)
 {
     Write      = Guard.OneOf(() => write, Token.Write);
     Expression = Guard.NonNull(() => expression);
     Semicolon  = Guard.OneOf(() => semicolon, Token.Semicolon);
 }
 public void Add(ExpressionRule rule)
 {
     rules.Add(rule);
 }
 public void Remove(ExpressionRule rule)
 {
     rules.Remove(rule);
 }
Example #8
0
 public ReturnStatementRule(TerminalNode @return, ExpressionRule expression, TerminalNode semicolon)
 {
     Return     = Guard.OneOf(() => @return, Token.Return);
     Expression = Guard.NonNull(() => expression);
     Semicolon  = Guard.OneOf(() => semicolon, Token.Semicolon);
 }