public void Parse(ExpressionParserHelper parseHelper)
        {
            Token token = parseHelper.Current;

            parseHelper.Reduce(typeof(T));
            Expression lhs = parseHelper.Pop();

            if (AdditionalToken != null)
            {
                parseHelper.Expect($"TupleExpressionParser<{typeof(T).Name}>", Tokens);
            }
            else
            {
                parseHelper.Expect(DistinctToken.Token);
            }
            TupleExpression subResult = Create(lhs);

            subResult.Token = token;
            parseHelper.Push(subResult);
            parseHelper.ParseExpression();
            if (subResult.Rhs == null)
            {
                subResult.FillInRhs(parseHelper.Pop());
            }
        }
Example #2
0
 public void Parse(ExpressionParserHelper parseHelper)
 {
     if (parseHelper.At(BRACKETS_OPEN))
     {
         var token = parseHelper.Current;
         parseHelper.Expect(BRACKETS_OPEN);
         var brackets = new Brackets(_functionArgument, _arguments, _paramsArgument)
         {
             Token = token
         };
         parseHelper.Push(brackets);
         parseHelper.ParseExpression();
     }
     else
     {
         Brackets brackets;
         if (!parseHelper.PreviousWas(BRACKETS_OPEN))
         {
             parseHelper.Reduce(TYPE);
             var nested = parseHelper.Pop();
             parseHelper.Expect(nameof(BracketsParser), SIGNS);
             brackets = ((Brackets)parseHelper.Top);
             brackets.FillNext(nested);
         }
         else
         {
             brackets = ((Brackets)parseHelper.Top);
         }
         if (parseHelper.At(BRACKETS_CLOSE) && brackets.PartOfFunction)
         {
             FunctionParser.FillArguments(parseHelper);
         }
     }
 }
Example #3
0
        public void Parse(ExpressionParserHelper parseHelper)
        {
            Token token = parseHelper.Current;

            if (token.Contents.Equals(AdditionalToken.Token))
            {
                if (!parseHelper.AnyOnStack(ParsedTypes))
                {
                    throw ParseException.ExpectedToken(DistinctToken.Token, token.Contents, $"TernaryExpressionParser<{typeof(T).Name}>").Decorate(token);
                }
                parseHelper.Expect(AdditionalToken.Token);
                parseHelper.Reduce(typeof(T));
                return;
            }
            if (ShouldReduce(parseHelper))
            {
                parseHelper.Reduce(typeof(T));
            }
            Expression first = parseHelper.Pop();

            parseHelper.Expect(DistinctToken.Token);
            TernaryExpression subResult = Create(first);

            subResult.Token      = token;
            subResult.FirstSign  = DistinctToken.Token;
            subResult.SecondSign = AdditionalToken.Token;
            parseHelper.Push(subResult);
            parseHelper.ParseExpression();
        }
Example #4
0
 public void Parse(ExpressionParserHelper parseHelper)
 {
     Token token = parseHelper.Current;
     parseHelper.Expect(CONSTANT_SIGN);
     String constantStr = parseHelper.ReadUntil(TokenType.Seperator, CONSTANT_SIGN);
     parseHelper.Expect(CONSTANT_SIGN);
     var constant = new Constant(constantStr);
     constant.Token = token;
     parseHelper.Push(constant);
 }
Example #5
0
        public void Parse(ExpressionParserHelper parseHelper)
        {
            Token token = parseHelper.Current;

            parseHelper.Expect(CONSTANT_SIGN);
            String constantStr = parseHelper.ReadUntil(TokenType.Seperator, CONSTANT_SIGN);

            parseHelper.Expect(CONSTANT_SIGN);
            var constant = new Constant(constantStr);

            constant.Token = token;
            parseHelper.Push(constant);
        }
Example #6
0
        public void Parse(ExpressionParserHelper parseHelper)
        {
            Token start = parseHelper.Current;

            parseHelper.Expect(FunctionSign);
            var helperExpressionLib = parseHelper.ExpressionLib;

            parseHelper.PushNewTokenConfiguration(new TokenizerConfiguration('\\', _lib.FunctionNamesSet, _lib.FunctionNameSetMaxLength, helperExpressionLib.WhiteSpaceOperandsSet, helperExpressionLib.WhiteSpaceOperandsSetMaxLength, null, true, true), ResetIndex.CurrentAndLookAhead);
            Token token    = parseHelper.Next();
            var   function = _lib.Obtain(token.Contents);

            parseHelper.PopTokenConfiguration(ResetIndex.MaintainPosition);
            parseHelper.Next();
            function.Token  = start;
            function.PreFix = start.Contents;
            parseHelper.Push(function);
            if (function.Arguments.Length == 0)
            {
                BracketsParser.MunchEmptyBrackets(parseHelper);
            }
            else if (function.IsParamsFunctions())
            {
                var bp = new BracketsParser(true, function.Arguments.Length, true);
                bp.Parse(parseHelper);
            }
            else
            {
                var bp = new BracketsParser(true, function.Arguments.Length);
                bp.Parse(parseHelper);
            }
        }
Example #7
0
        public void Parse(ExpressionParserHelper parseHelper)
        {
            Token start = parseHelper.Current;
            var   helperExpressionLib = parseHelper.ExpressionLib;

            parseHelper.PushNewTokenConfiguration(new TokenizerConfiguration('\\', new HashSet <string> {
                _func.Name
            }, _func.Name.Length, helperExpressionLib.WhiteSpaceOperandsSet, helperExpressionLib.WhiteSpaceOperandsSetMaxLength, null, true, true), ResetIndex.CurrentAndLookAhead);
            parseHelper.Expect(_func.Name);
            parseHelper.PopTokenConfiguration(ResetIndex.LookAhead);
            var function = new Function(_func);

            function.Token = start;
            parseHelper.Push(function);
            parseHelper.Next();
            if (function.Arguments.Length == 0)
            {
                BracketsParser.MunchEmptyBrackets(parseHelper);
            }
            else
            {
                var bp = new BracketsParser(true, function.Arguments.Length);
                bp.Parse(parseHelper);
            }
        }
Example #8
0
 public void Parse(ExpressionParserHelper parseHelper)
 {
     Token token = parseHelper.Current;
     parseHelper.Expect(nameof(NotParser), NOT_SIGN, ADDITIONAL_SIGN);
     parseHelper.ParseExpression();
      var not = new Not(parseHelper.Pop());
     not.Token = token;
     parseHelper.Push(not);
 }
Example #9
0
        public void Parse(ExpressionParserHelper parseHelper)
        {
            Token token = parseHelper.Current;

            parseHelper.Expect(nameof(NotParser), SIGNS);
            parseHelper.ParseExpression();
            var not = new Not(parseHelper.Pop());

            not.Token = token;
            parseHelper.Push(not);
        }
Example #10
0
 public void Parse(ExpressionParserHelper parseHelper)
 {
     if (parseHelper.At(BRACKETS_OPEN))
     {
         GuardPartOfPropertyAccess(parseHelper);
         var token = parseHelper.Current;
         parseHelper.Expect(BRACKETS_OPEN);
         var brackets = new SquareBrackets {
             Token = token
         };
         parseHelper.Push(brackets);
         parseHelper.ParseExpression();
     }
     else
     {
         parseHelper.Reduce(TYPE);
         var nested = parseHelper.Pop();
         parseHelper.Expect(nameof(SquareBracketsParser), BRACKETS_CLOSE);
         var brackets = ((SquareBrackets)parseHelper.Top);
         brackets.Fill(nested);
         PropertyParser.FillArguments(parseHelper);
     }
 }
Example #11
0
 public void Parse(ExpressionParserHelper parseHelper)
 {
     Token start = parseHelper.Current;
     parseHelper.PushNewTokenConfiguration(true, true,'\\', new string[] {_func.Name}, parseHelper.ExpressionLib.WhiteSpaceOperands, null, ResetIndex.CurrentAndLookAhead);
     parseHelper.Expect(_func.Name);
     parseHelper.PopTokenConfiguration(ResetIndex.LookAhead);
     var function = new Function(_func);
     function.Token = start;
     parseHelper.Push(function);
     parseHelper.Next();
     if (function.Arguments.Length == 0)
     {
         BracketsParser.MunchEmptyBrackets(parseHelper);
     }
     else
     {
         var bp = new BracketsParser(true, function.Arguments.Length);
         bp.Parse(parseHelper);
     }
 }
Example #12
0
 public void Parse(ExpressionParserHelper parseHelper)
 {
     Token start = parseHelper.Current;
     parseHelper.Expect(FunctionSign);
     parseHelper.PushNewTokenConfiguration(true, true, '\\', _lib.Functions.Select(f=>f.Name).ToArray(), parseHelper.ExpressionLib.WhiteSpaceOperands, null, ResetIndex.CurrentAndLookAhead);
     Token token = parseHelper.Next();
     var function = _lib.Obtain(token.Contents);
     parseHelper.PopTokenConfiguration(ResetIndex.MaintainPosition);
     parseHelper.Next();
     function.Token = start;
     function.PreFix = start.Contents;
     parseHelper.Push(function);
     if (function.Arguments.Length == 0)
     {
            BracketsParser.MunchEmptyBrackets(parseHelper);
     }
     else
     {
         var bp = new BracketsParser(true, function.Arguments.Length);
         bp.Parse(parseHelper);
     }
 }
Example #13
0
 public static void MunchEmptyBrackets(ExpressionParserHelper parseHelper)
 {
     parseHelper.Expect(BRACKETS_OPEN);
     parseHelper.Read(BRACKETS_CLOSE);
 }
Example #14
0
 public void Parse(ExpressionParserHelper parseHelper)
 {
     if (parseHelper.At(BRACKETS_OPEN))
     {
         var token = parseHelper.Current;
         parseHelper.Expect(BRACKETS_OPEN);
         var brackets = new Brackets(_functionArgument, _arguments) {Token = token};
         parseHelper.Push(brackets);
         parseHelper.ParseExpression();
     }
     else
     {
         parseHelper.Reduce(TYPE);
         var nested = parseHelper.Pop();
         parseHelper.Expect(nameof(BracketsParser), BRACKETS_CLOSE, BRACKETS_COMMA);
         var brackets = ((Brackets) parseHelper.Top);
         brackets.FillNext(nested);
         if (parseHelper.At(BRACKETS_CLOSE) && brackets.PartOfFunction)
         {
             FunctionParser.FillArguments(parseHelper);
         }
     }
 }
Example #15
0
 public static void MunchEmptyBrackets(ExpressionParserHelper parseHelper)
 {
     parseHelper.Expect(BRACKETS_OPEN);
     parseHelper.Read(BRACKETS_CLOSE);
 }