Exemplo n.º 1
0
 public ProcMethod(ClassAST classAST, SectionProcRaw raw)
 {
     ASTClass      = classAST;
     Raw           = raw;
     MethodContext = new ContextMethod(ASTClass.ClassContext);
     NamePart      = new MethodName(this, Raw.NamePart);
     Body          = new StmtBlock(this, Raw.Body);
 }
Exemplo n.º 2
0
        public SectionProcRaw Parse(IEnumerable <LexToken> tokens, ContextFile fileContext, SectionProcRaw procAST)
        {
            this.fileContext = fileContext;
            this.ast         = procAST;

            List <LexToken> tokens2 = new List <LexToken>(tokens);

            tape         = new TokenTape(tokens2.ToArray(), fileContext);
            ast.NamePart = ParseProcName();
            tape.Match(TokenKindSymbol.Colon);
            ast.RetToken = ParseRetProc();

            return(ast);
        }
Exemplo n.º 3
0
        private SectionRaw ParseSection()
        {
            string headText      = tape.Current.FirstToken.Text;
            bool   secondIsColon = tape.Current.SecondToken.IsKind(TokenKindSymbol.Colon);

            if (false)
            {
                //<<重新编写分析,同行换行都可以>>
            }
            else if (secondIsColon && headText == "导入包")
            {
                SectionImportRaw section = ParseImport();
                return(section);
            }
            else if (secondIsColon && headText == "导入类")
            {
                SectionUseRaw section = ParseUse();
                return(section);
            }
            //else if (secondIsColon && headText == "约定")
            //{
            //    SectionEnum section = ParseEnum();
            //    return section;
            //}
            else if (secondIsColon && headText == "名称")
            {
                SectionNameRaw section = ParseClassName();
                return(section);
            }
            else if (secondIsColon && headText == "属于")
            {
                SectionExtendsRaw section = ParseExtends();
                return(section);
            }
            //else if (secondIsColon && headText == "声明" )
            //{
            //    SectionDim section = ParseDim();
            //    return section;
            //}
            else if (secondIsColon && headText == "属性")
            {
                SectionPropertiesRaw section = ParseProperties();
                return(section);
            }
            else
            {
                SectionProcRaw section = ParseProc();
                return(section);
            }
        }
Exemplo n.º 4
0
        private SectionProcRaw ParseProc()
        {
            SectionProcRaw    ast            = new SectionProcRaw();
            ASTProcNameParser procnameparser = new ASTProcNameParser();

            ast = procnameparser.Parse(tape.Current.ToList(), this.fileContext, ast);
            if (ast.NamePart == null)
            {
                tape.MoveNext();
                return(null);
            }
            tape.MoveNext();
            ast.Body = ParseProcBody();
            return(ast);
        }
Exemplo n.º 5
0
 public ProcConstructor(ClassAST classAST, SectionProcRaw raw)
 {
     RetZType                 = ZLangBasicTypes.ZVOID;
     ASTClass                 = classAST;
     Raw                      = raw;
     NameBracketRaw           = Raw.NamePart.GetNameBracket();
     ConstructorContext       = new ContextConstructor(ASTClass.ClassContext);
     ConstructorParameterList = new List <ConstructorParameter>();
     foreach (var item in NameBracketRaw.Parameters)
     {
         ConstructorParameter cp = new ConstructorParameter(this, item);
         ConstructorParameterList.Add(cp);
     }
     Body = new StmtBlock(this, Raw.Body);
 }