예제 #1
0
파일: Parser.cs 프로젝트: Rohansi/LoonyC
        /// <summary>
        /// Check if the next token matches the given type. If they match, take the token.
        /// </summary>
        public bool MatchAndTake(LoonyTokenType type)
        {
            var isMatch = Match(type);
            if (isMatch)
                Take();

            return isMatch;
        }
예제 #2
0
파일: Parser.cs 프로젝트: Rohansi/LoonyC
        /// <summary>
        /// Take a token from the stream. Throws an exception if the given type does not match the token type.
        /// </summary>
        public LoonyToken Take(LoonyTokenType type)
        {
            var token = Take();

            if (token.Type != type)
                throw new CompilerException(token, CompilerError.ExpectedButFound, type, token);

            return token;
        }
예제 #3
0
        /// <summary>
        /// Take a token from the stream. Throws an exception if the given type does not match the token type.
        /// </summary>
        public LoonyToken Take(LoonyTokenType type)
        {
            var token = Take();

            if (token.Type != type)
            {
                throw new CompilerException(token, CompilerError.ExpectedButFound, type, token);
            }

            return(token);
        }
예제 #4
0
        /// <summary>
        /// Check if the next token matches the given type. If they match, take the token.
        /// </summary>
        public bool MatchAndTake(LoonyTokenType type)
        {
            var isMatch = Match(type);

            if (isMatch)
            {
                Take();
            }

            return(isMatch);
        }
예제 #5
0
 static void RegisterInfix(LoonyTokenType type, IInfixParselet parselet)
 {
     _infixParselets.Add(type, parselet);
 }
예제 #6
0
 static void RegisterPrefix(LoonyTokenType type, IPrefixParselet parselet)
 {
     _prefixParselets.Add(type, parselet);
 }
예제 #7
0
 static void RegisterStatement(LoonyTokenType type, IStatementParselet parselet)
 {
     _statementParselets.Add(type, parselet);
 }
예제 #8
0
 static void RegisterDeclaration(LoonyTokenType type, IDeclarationParselet parselet)
 {
     _declarationParselets.Add(type, parselet);
 }
예제 #9
0
 static void RegisterStatement(LoonyTokenType type, IStatementParselet parselet)
 {
     _statementParselets.Add(type, parselet);
 }
예제 #10
0
 static void RegisterPrefix(LoonyTokenType type, IPrefixParselet parselet)
 {
     _prefixParselets.Add(type, parselet);
 }
예제 #11
0
 static void RegisterInfix(LoonyTokenType type, IInfixParselet parselet)
 {
     _infixParselets.Add(type, parselet);
 }
예제 #12
0
 static void RegisterDeclaration(LoonyTokenType type, IDeclarationParselet parselet)
 {
     _declarationParselets.Add(type, parselet);
 }
예제 #13
0
 /// <summary>
 /// Check if the next token matches the given type.
 /// </summary>
 public bool Match(LoonyTokenType type, int distance = 0)
 {
     return(Peek(distance).Type == type);
 }
예제 #14
0
파일: Parser.cs 프로젝트: Rohansi/LoonyC
 /// <summary>
 /// Check if the next token matches the given type.
 /// </summary>
 public bool Match(LoonyTokenType type, int distance = 0)
 {
     return Peek(distance).Type == type;
 }