Beispiel #1
0
 private bool Expect(TokenType pSymbol)
 {
     if (!_stream.EOF && Current.Type == pSymbol)
     {
         _stream.MoveNext();
         return(true);
     }
     else
     {
         Compiler.ReportError(CompilerErrorType.InvalidSyntax, PeekSpan(), pSymbol.ToString(), Current.Type.ToString());
         return(false);
     }
 }
Beispiel #2
0
        public Expression?Parse(ITokenStream tokens)
        {
            if (!tokens.MoveNext())
            {
                return(null);
            }

            if (tokens.Current is IEvaluatable valueToken)
            {
                tokens.MoveNext();
                return(valueToken.GetValue());
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        private bool MatchesOperation(ITokenStream tokens)
        {
            if (!tokens.MoveNext())
            {
                return(false);
            }

            if (tokens.Current is DelimiterToken delimiterToken)
            {
                if (delimiterToken.Content == OperatorDelimiter)
                {
                    return(true);
                }
            }

            return(false);
        }