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); } }
public Expression?Parse(ITokenStream tokens) { if (!tokens.MoveNext()) { return(null); } if (tokens.Current is IEvaluatable valueToken) { tokens.MoveNext(); return(valueToken.GetValue()); } else { return(null); } }
private bool MatchesOperation(ITokenStream tokens) { if (!tokens.MoveNext()) { return(false); } if (tokens.Current is DelimiterToken delimiterToken) { if (delimiterToken.Content == OperatorDelimiter) { return(true); } } return(false); }