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

📄 syntacticclassification.jrag

📁 JDK1.4编译器前端
💻 JRAG
字号:
/* * The JastAdd Extensible Java Compiler (http://jastadd.org) is covered * by the modified BSD License. You should have received a copy of the * modified BSD license with this compiler. *  * Copyright (c) 2005-2008, Torbjorn Ekman * All rights reserved. */aspect SyntacticClassification {  // 6.5.1 Syntactic Classification of Name According to Context  // Replace the parsed name with a name reclassified according to context  // This is done upon first access to a name node  rewrite ParseName {    to Access nameType().reclassify(name(), start, end);  }  // The syntactic classification context  inh NameType Expr.nameType();  inh NameType BodyDecl.nameType();    // NameType is basically an Enum for the different kinds of names  // The factory method reclassify builds name nodes of a particular kind  class NameType {    private NameType() {      super();    }    public static final NameType NO_NAME = new NameType();    public static final NameType PACKAGE_NAME = new NameType() {      public Access reclassify(String name, int start, int end) { return new PackageAccess(name, start, end); }    };    public static final NameType TYPE_NAME = new NameType() {      public Access reclassify(String name, int start, int end) { return new TypeAccess(name, start, end); }    };    public static final NameType PACKAGE_OR_TYPE_NAME = new NameType() {      public Access reclassify(String name, int start, int end) { return new PackageOrTypeAccess(name, start, end); }    };    public static final NameType AMBIGUOUS_NAME = new NameType() {      public Access reclassify(String name, int start, int end) { return new AmbiguousAccess(name, start, end); }    };    public static final NameType METHOD_NAME = new NameType();    public static final NameType ARRAY_TYPE_NAME = new NameType();    public static final NameType ARRAY_READ_NAME = new NameType();    public static final NameType EXPRESSION_NAME = new NameType() {      public Access reclassify(String name, int start, int end) { return new VarAccess(name, start, end); }    };    public Access reclassify(String name, int start, int end) {      throw new Error("Can not reclassify ParseName node " + name);    }  }  // predNameType() defines the expected kind of name   // for the left hand side in a qualified name  syn NameType Access.predNameType() = NameType.NO_NAME;    // propagate predNameType() to the left hand side of a qualified name  eq AbstractDot.getLeft().nameType() = getRight().predNameType();  eq AbstractDot.predNameType() = getLeft() instanceof Access ? ((Access)getLeft()).predNameType() : NameType.NO_NAME;  // Equations for the syntactic classification context    eq Program.getChild().nameType() = NameType.NO_NAME;  // Package name    eq PackageAccess.predNameType() = NameType.PACKAGE_NAME;  eq CompilationUnit.getImportDecl().nameType() = NameType.PACKAGE_NAME;    // Type Name  eq SingleTypeImportDecl.getAccess().nameType() = NameType.TYPE_NAME;  eq ClassDecl.getSuperClassAccess().nameType() = NameType.TYPE_NAME;  eq ClassDecl.getImplements().nameType() = NameType.TYPE_NAME;  eq InterfaceDecl.getSuperInterfaceId().nameType() = NameType.TYPE_NAME;  eq FieldDecl.getTypeAccess().nameType() = NameType.TYPE_NAME;  eq FieldDeclaration.getTypeAccess().nameType() = NameType.TYPE_NAME;  eq MethodDecl.getTypeAccess().nameType() = NameType.TYPE_NAME;  eq MethodDecl.getParameter().nameType() = NameType.TYPE_NAME;  eq ConstructorDecl.getParameter().nameType() = NameType.TYPE_NAME;  eq MethodDecl.getException().nameType() = NameType.TYPE_NAME;  eq ConstructorDecl.getException().nameType() = NameType.TYPE_NAME;  eq VarDeclStmt.getTypeAccess().nameType() = NameType.TYPE_NAME;  eq VariableDeclaration.getTypeAccess().nameType() = NameType.TYPE_NAME;  eq CatchClause.getParameter().nameType() = NameType.TYPE_NAME;  eq ArrayCreationExpr.getTypeAccess().nameType() = NameType.TYPE_NAME;  eq CastExpr.getTypeAccess().nameType() = NameType.TYPE_NAME;  eq InstanceOfExpr.getTypeAccess().nameType() = NameType.TYPE_NAME;  eq ClassAccess.predNameType() = NameType.TYPE_NAME;  eq ThisAccess.predNameType() = NameType.TYPE_NAME;  eq SuperAccess.predNameType() = NameType.TYPE_NAME;    // Expression Name  eq SuperConstructorAccess.predNameType() = NameType.EXPRESSION_NAME;  eq ClassInstanceExpr.predNameType() = NameType.EXPRESSION_NAME;  eq PostfixExpr.getOperand().nameType() = NameType.EXPRESSION_NAME;  eq AssignExpr.getDest().nameType() = NameType.EXPRESSION_NAME;  eq ArrayAccess.predNameType() = NameType.EXPRESSION_NAME;  // Method Name  // The parser builds the correct node since it has a different structure  // Package Or Type Name  eq TypeAccess.predNameType() = NameType.PACKAGE_OR_TYPE_NAME;  eq TypeImportOnDemandDecl.getAccess().nameType() = NameType.PACKAGE_OR_TYPE_NAME;  eq PackageOrTypeAccess.predNameType() = NameType.PACKAGE_OR_TYPE_NAME;  // Ambiguous Name  eq VarAccess.predNameType() = NameType.AMBIGUOUS_NAME;  eq AmbiguousAccess.predNameType() = NameType.AMBIGUOUS_NAME;  eq MethodAccess.predNameType() = NameType.AMBIGUOUS_NAME;  // Extras  eq Block.getStmt().nameType() = NameType.EXPRESSION_NAME;  eq ConstructorDecl.getConstructorInvocation().nameType() = NameType.EXPRESSION_NAME;  eq TypeDecl.getBodyDecl().nameType() = NameType.EXPRESSION_NAME;  eq MethodAccess.getArg().nameType() = NameType.EXPRESSION_NAME;  eq ConstructorAccess.getArg().nameType() = NameType.EXPRESSION_NAME;  eq ArrayAccess.getExpr().nameType() = NameType.EXPRESSION_NAME;  eq ArrayTypeWithSizeAccess.getExpr().nameType() = NameType.EXPRESSION_NAME;  eq ClassInstanceExpr.getAccess().nameType() = NameType.TYPE_NAME;  eq ClassInstanceExpr.getTypeDecl().nameType() = NameType.TYPE_NAME;  eq ClassInstanceExpr.getArg().nameType() = NameType.EXPRESSION_NAME;  eq ConstructorAccess.predNameType() = NameType.AMBIGUOUS_NAME;  eq ArrayTypeAccess.predNameType() = NameType.AMBIGUOUS_NAME;}

⌨️ 快捷键说明

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