コード例 #1
0
        //------------------------------------------------------------
        // コンストラクタ。
        public IdentPath(TokenArray aTokens, bool aFromRoot)
        {
            idents   = new List <Identifier>();
            fromRoot = aFromRoot;

            // 全てIdentifierかチェック
            foreach (Token token in aTokens)
            {
                idents.Add(new Identifier(token));
            }
        }
コード例 #2
0
ファイル: Parser.cs プロジェクト: hoboaki/oldcode
        IdentPath parseIdentPath(int aMinDepth)
        {
            TokenArray tokens   = new TokenArray();
            bool       fromRoot = false;

            if (currentToken().Value == Token.Kind.OpDot)
            {// rootから
                fromRoot = true;
                nextToken();
            }
            while (true)
            {
                // Identifier
                if (currentToken().Value != Token.Kind.Identifier)
                {
                    setErrorKind(ErrorKind.IDENT_PATH_IDENTIFIER_EXPECTED);
                    return(null);
                }
                tokens.Add(currentToken());
                nextToken();

                // dot
                if (currentToken().Value == Token.Kind.OpDot)
                {// 次のIdentifierも見に行く
                    nextToken();
                    continue;
                }

                if (tokens.Count < aMinDepth)
                {// 深さが足りない
                    setErrorKind(ErrorKind.IDENT_PATH_DOT_EXPECTED);
                    return(null);
                }
                break;
            }

            return(new IdentPath(tokens, fromRoot));
        }