예제 #1
0
 public override IASTNode Parse(IASTNodeFactory nodeFactory, IAParser aParser, ATokens tokens)
 {
     tokens.GetNextToken();
     while (tokens.CurrentToken != null && !aParser.Acceptable(tokens, ASTEndParenthesesNode.KeyWord))
     {
         IASTNode newNode = aParser.NodeFactory.CreateNode(tokens.CurrentToken.Text, tokens.CurrentToken.AddSpace);
         newNode.Parse(aParser.NodeFactory, aParser, tokens);
         SubNodes.Add(newNode);
     }
     if (!aParser.Acceptable(tokens, ASTEndParenthesesNode.KeyWord))
     {
         throw new AParserException("Didn't find closing parentheses");
     }
     SubNodes.Add(aParser.Accept(tokens, ASTEndParenthesesNode.KeyWord));
     return(this);
 }
예제 #2
0
파일: AParser.cs 프로젝트: radtek/ACopy
        public IASTNode Accept(ATokens tokens, string text)
        {
            if (tokens.CurrentToken == null)
            {
                throw new AParserException(string.Format("Expected token '{0}' but current token is empty", text));
            }
            if (text != tokens.CurrentToken.Text.ToLower())
            {
                throw new AParserException(string.Format("Expected token '{0}' but found '{1}'", text, tokens.CurrentToken.Text.ToLower()));
            }
            IASTNode node = NodeFactory.CreateNode(tokens.CurrentToken.Text, tokens.CurrentToken.AddSpace);

            node.AddSpace = tokens.CurrentToken.AddSpace;
            tokens.GetNextToken();
            return(node);
        }