PropertyAST parseStaticProperty(CodePostion parentPostion)
        {
            PropertyAST ast = new PropertyAST();

            if (CurrentKind != TokenKind.Ident)
            {
                error("不是正确的名称");
            }
            else
            {
                ast.TypeToken = CurrentToken;
            }
            MoveNext();
            match(TokenKind.Colon);
            if (CurrentKind != TokenKind.Ident)
            {
                error("不是正确的变量名称");
            }
            else
            {
                ast.NameToken = CurrentToken;
            }
            MoveNext();
            if (CurrentKind == TokenKind.Assign)
            {
                MoveNext();
                Exp exp = parseExp();
                ast.ValueExp = exp;
            }
            matchSemiOrNewLine();//match(TokenKind.Semi);
            return(ast);
        }
        void parseStaticPropertyPart()
        {
            Token tempToken = CurrentToken;

            MoveNext(); //跳过"属性"
            MoveNext(); //跳过":"
            while (CurrentToken.Kind != TokenKind.EOF && CurrentToken.Col > tempToken.Col)
            {
                PropertyAST ast = parseStaticProperty(tempToken.Postion);
                prog.Add(ast);
            }
        }
Exemple #3
0
        private SectionProperties ParseProperties()
        {
            SectionProperties ast           = new SectionProperties();
            Token             headFistToken = tape.Current;
            string            headFirstText = headFistToken.GetText();

            if (headFirstText.Length > 2)
            {
                string baseTypeName = headFirstText.Substring(0, headFirstText.Length - 2);
                ast.TypeToken = new Token(baseTypeName, TokenKind.Ident, headFistToken.Line, headFistToken.Col);
                ast.KeyToken  = new Token("属性", TokenKind.Ident, headFistToken.Line, headFistToken.Col + headFirstText.Length - 2);
            }
            else
            {
                ast.KeyToken = headFistToken;
            }

            tape.MoveNext();
            tape.Match(TokenKind.Colon);

            while (tape.CurrentKind != TokenKind.EOF && tape.CurrentKind != TokenKind.NewLine)
            {
                if (tape.CurrentKind == TokenKind.Ident)
                {
                    PropertyAST property = ParseProperty();
                    if (property != null)
                    {
                        ast.AddProperty(property);
                    }
                }
                else if (tape.CurrentKind == TokenKind.Comma)
                {
                    tape.MoveNext();
                }
                else
                {
                    tape.error(string.Format("类型'{0}'不是正确的属性", tape.Current.GetText()));
                    tape.MoveNext();
                }
            }
            SkipNewLine();
            return(ast);
        }
Exemple #4
0
        private PropertyAST ParseProperty( )
        {
            PropertyAST property = new PropertyAST();

            //property.SetFileContext(this.filem.FileContext);//.FileContext = this.filem.FileContext;
            property.FileContext = this.fileMY.FileContext;

            property.NameToken = tape.Current;
            tape.MoveNext();
            if (tape.CurrentKind == TokenKind.Assign)
            {
                tape.MoveNext();
                Exp exp = ParseRawExpPropertyValue();
                if (exp != null)
                {
                    property.PropertyValue = exp;
                }
            }
            return(property);
        }