Beispiel #1
0
        public void Consume(TokenType type)
        {
            var nextToken = _tokenStream.Next();

            if (nextToken.Type != type)
            {
                throw new ParseError($"Expected '{type}', but '{nextToken.Value}' found", nextToken.Line, nextToken.Column);
            }
        }
Beispiel #2
0
 private void RegisterBinaryOperatorR(TokenType type, Precedence precedence)
 {
     Register(type, new BinaryOperatorParse(precedence, true));
 }
Beispiel #3
0
 private void RegisterComparison(TokenType type, Precedence precedence)
 {
     Register(type, new ComparisonParse(precedence));
 }
Beispiel #4
0
 private void RegisterBitwiseOperator(TokenType type, Precedence precedence)
 {
     Register(type, new BitwiseOperatorParse(precedence));
 }
Beispiel #5
0
 private void RegisterPrefix(TokenType type, Precedence prec)
 {
     Register(type, new PrefixParse(prec));
 }
Beispiel #6
0
 private void Register(TokenType type, IPrefix prefix)
 {
     _prefixMap[type] = prefix;
 }
Beispiel #7
0
 private void Register(TokenType type, IInfix infix)
 {
     _infixMap[type] = infix;
 }