⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ast_decl.cc

📁 编译原理课程设计之pp2语法分析程序
💻 CC
字号:
/* File: ast_decl.cc * ----------------- * Implementation of Decl node classes. */#include "ast_decl.h"#include "ast_type.h"#include "ast_stmt.h"                 Decl::Decl(Identifier *n) : Node(*n->GetLocation()) {    Assert(n != NULL);    (id=n)->SetParent(this); }VarDecl::VarDecl(Identifier *n, Type *t) : Decl(n) {    Assert(n != NULL && t != NULL);    (type=t)->SetParent(this);}  void VarDecl::PrintChildren(int indentLevel) {    type->Print(indentLevel+1);   id->Print(indentLevel+1);}ClassDecl::ClassDecl(Identifier *n, NamedType *ex, List<Decl*> *m) : Decl(n) {    // extends can be NULL, impl & mem may be empty lists but cannot be NULL    Assert(n != NULL && m != NULL);         extends = ex;    if (extends) extends->SetParent(this);    //(implements=imp)->SetParentAll(this);    (members=m)->SetParentAll(this);}void ClassDecl::PrintChildren(int indentLevel) {    id->Print(indentLevel+1);    if (extends) extends->Print(indentLevel+1, "(extends) ");    //implements->PrintAll(indentLevel+1, "(implements) ");    members->PrintAll(indentLevel+1);}/*InterfaceDecl::InterfaceDecl(Identifier *n, List<Decl*> *m) : Decl(n) {    Assert(n != NULL && m != NULL);    (members=m)->SetParentAll(this);}void InterfaceDecl::PrintChildren(int indentLevel) {    id->Print(indentLevel+1);    members->PrintAll(indentLevel+1);}*/	FnDecl::FnDecl(Identifier *n, Type *r, List<VarDecl*> *d) : Decl(n) {    Assert(n != NULL && r!= NULL && d != NULL);    (returnType=r)->SetParent(this);    (formals=d)->SetParentAll(this);    body = NULL;}void FnDecl::SetFunctionBody(Stmt *b) {     (body=b)->SetParent(this);}void FnDecl::PrintChildren(int indentLevel) {    returnType->Print(indentLevel+1, "(return type) ");    id->Print(indentLevel+1);    formals->PrintAll(indentLevel+1, "(formals) ");    if (body) body->Print(indentLevel+1, "(body) ");}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -