Changeset 37

Show
Ignore:
Timestamp:
06/05/08 18:57:43 (7 months ago)
Author:
mb0
Message:
  1. added simple namespace support
  2. added missing modifiers final enumerable explicit intrinsic
  3. condensed constructor and method header into methoddeclaration
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/contentProposer/AS3ContentProposer.java

    r31 r37  
    3232                if (decl instanceof VariableDeclarator) 
    3333                        return ((VariableDeclarator) decl).getName().toString(); 
    34                 else if (decl instanceof MethodHeader
    35                         return ((MethodHeader) decl).getName().toString(); 
     34                else if (decl instanceof MethodDeclaration
     35                        return ((MethodDeclaration) decl).getName().toString(); 
    3636                return ""; 
    3737        } 
     
    4343                        string = ((VariableDeclarator) decl).getName().toString() + "  (" 
    4444                                        + ((VariableDeclarator) decl).getType().toString() + ")"; 
    45                 } else if (decl instanceof MethodHeader) { 
    46                         MethodHeader fdecl = (MethodHeader) decl; 
     45                } else if (decl instanceof MethodDeclaration) { 
     46                        MethodDeclaration fdecl = (MethodDeclaration) decl; 
    4747                        FormalParameterList parameters = fdecl.getParameterBlock().getParameters(); 
    4848                        string = fdecl.getReturnType().toString() + " " 
     
    6464                } else if (decl instanceof MethodDeclaration) { 
    6565                        MethodDeclaration fdecl = (MethodDeclaration) decl; 
    66                         FormalParameterList parameters = fdecl.getMethodHeader().getParameterBlock().getParameters(); 
     66                        FormalParameterList parameters = fdecl.getParameterBlock().getParameters(); 
    6767                        String newText; 
    6868 
    69                         newText = fdecl.getMethodHeader().getName().toString() 
     69                        newText = fdecl.getName().toString() 
    7070                                        + "("; 
    7171                        for (int i = 0; i < parameters.size(); i++) 
     
    7373                                                + (i < parameters.size() - 1 ? ", " : ""); 
    7474                        newText += ")"; 
    75                         String proposal = fdecl.getMethodHeader().getReturnType().toString() 
     75                        String proposal = fdecl.getReturnType().toString() 
    7676                                        + " " + newText; 
    7777                        return new SourceProposal(proposal, newText, prefix, offset); 
  • axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/parser/AS3KWLexer.gi

    r31 r37  
    2323    package import class interface 
    2424    public private protected internal static dynamic override 
     25    final enumerable explicit intrinsic 
    2526    extends implements function var const 
    2627    if else for each in while do 
     
    108109          $EndAction 
    109110        ./ 
    110  
     111    Keyword ::= f i n a l 
     112        /.$BeginAction 
     113            $setResult($_final); 
     114          $EndAction 
     115        ./ 
     116    Keyword ::= e n u m e r a b l e 
     117        /.$BeginAction 
     118            $setResult($_enumerable); 
     119          $EndAction 
     120        ./ 
     121    Keyword ::= e x p l i c i t 
     122        /.$BeginAction 
     123            $setResult($_explicit); 
     124          $EndAction 
     125        ./ 
     126    Keyword ::= i n t r i n s i c 
     127        /.$BeginAction 
     128            $setResult($_intrinsic); 
     129          $EndAction 
     130        ./ 
    111131    Keyword ::= e x t e n d s 
    112132        /.$BeginAction 
  • axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Parser.g

    r36 r37  
    3535    package import class interface 
    3636    public private protected internal static dynamic override 
     37    final enumerable explicit intrinsic 
    3738    extends implements function var const 
    3839    if else for each in while do 
     
    134135    ObjectLiteralField$ObjectLiteralField ::= %empty 
    135136     
    136     ObjectLiteralFieldName ::= IDENTIFIER$Token | INTEGER_LITERAL$Token 
     137    ObjectLiteralFieldName$ObjectLiteralFieldName ::= IDENTIFIER$Token | INTEGER_LITERAL$Token 
    137138     
    138139    -- types 
    139140    Type ::= Name 
    140141    TypeList$$Type ::= Type | TypeList COMMA Type 
     142    OptType ::= Type | STAR 
    141143     
    142144    -- names 
     
    149151        public IAst getDeclaration() { return decl; } 
    150152    ./ 
     153    QIdent$QIdent ::= NamespaceMod DBL_COLON$ Ident 
    151154     
    152155    -- cunit 
     
    161164    TypeSpaceEntry ::= ClassDeclaration 
    162165    TypeSpaceEntry ::= InterfaceDeclaration 
     166    TypeSpaceEntry ::= NamespaceDeclaration 
    163167    TypeSpaceEntry ::= FieldDeclaration 
    164168    TypeSpaceEntry ::= MethodDeclaration 
     
    182186     
    183187    SemiOpt ::= SEMI 
     188     
     189     
    184190    -- mods 
    185191    Modifiers$$Modifier ::= %empty | Modifiers Modifier 
    186      
    187     Modifier$Modifier ::= public | private | protected | static | internal | dynamic | override 
     192    Modifier ::= NamespaceMod | OtherMod 
     193    OtherMod$OtherMod ::= static$Token | final$Token | enumerable$Token | explicit$Token  
     194               | intrinsic$Token | dynamic$Token | override$Token 
     195     
     196    NamespaceMod ::= CustomNamespace | ReservedNamespace 
     197    ReservedNamespace$ReservedNamespace ::= public$Token | private$Token | protected$Token | internal$Token 
     198    CustomNamespace ::= IDENTIFIER$Name 
     199     
    188200    -- anno 
    189201    Annotations$$Annotations ::= %empty | Annotations Annotation 
     
    210222     
    211223    ClassMemberDeclaration ::= FieldDeclaration 
    212     ClassMemberDeclaration ::= ConstantDeclaration 
    213     ClassMemberDeclaration ::= ConstructorDeclaration 
    214224    ClassMemberDeclaration ::= MethodDeclaration 
     225    ClassMemberDeclaration ::= NamespaceDeclaration 
    215226     
    216227    ClassMemberDeclaration$EmptyDeclaration ::= SEMI$ 
    217228     
    218     -- class members 
    219     FieldDeclaration$FieldDeclaration ::= Annotations Modifiers var VariableDeclarators SEMI 
    220     ConstantDeclaration$ConstantDeclaration ::= Annotations Modifiers const VariableDeclarators SEMI 
     229    -- class members  
     230    NamespaceDeclaration$NamespaceDeclaration ::= Modifiers namespace IDENTIFIER$Name 
     231    NamespaceDeclaration$NamespaceDeclaration ::= Modifiers namespace IDENTIFIER$Name ASSIGN$ Expression$Initializer 
     232     
     233    FieldDeclaration$FieldDeclaration ::= Annotations Modifiers FieldType VariableDeclarators SemiOpt 
     234     
     235    FieldType$FieldType ::= var$Token | const$Token  
    221236     
    222237    VariableDeclarators$$VariableDeclarator ::= VariableDeclarator | VariableDeclarators COMMA VariableDeclarator 
    223      
    224     VariableDeclarator$VariableDeclarator ::= IDENTIFIER$Name COLON$ Type 
    225     VariableDeclarator$VariableDeclarator ::= IDENTIFIER$Name COLON$ STAR$Dyn  
    226     VariableDeclarator$VariableDeclarator ::= IDENTIFIER$Name COLON$ Type ASSIGN$ Expression$Initializer 
    227     VariableDeclarator$VariableDeclarator ::= IDENTIFIER$Name COLON$ STAR$Dyn ASSIGN$ Expression$Initializer 
    228                           
    229     MethodDeclaration$MethodDeclaration ::= MethodHeader MethodBody 
    230     /. 
     238    VariableDeclarator$VariableDeclarator ::= IDENTIFIER$Name COLON$ OptType$Type 
     239    VariableDeclarator$VariableDeclarator ::= IDENTIFIER$Name COLON$ OptType$Type ASSIGN$ Expression$Initializer 
     240                           
     241    MethodDeclaration$MethodDeclaration ::= Annotations Modifiers function$ AccessorRole IDENTIFIER$Name ParameterBlock ReturnType MethodBody 
     242    /. 
     243        public boolean isConstructor = false; 
    231244        $action_type.SymbolTable symbolTable; 
    232245        public void setSymbolTable($action_type.SymbolTable symbolTable) { this.symbolTable = symbolTable; } 
    233246        public $action_type.SymbolTable getSymbolTable() { return symbolTable; } 
    234247    ./ 
    235      
    236     ConstructorDeclaration$ConstructorDeclaration ::= ConstructorHeader MethodBody 
    237     /. 
    238         $action_type.SymbolTable symbolTable; 
    239         public void setSymbolTable($action_type.SymbolTable symbolTable) { this.symbolTable = symbolTable; } 
    240         public $action_type.SymbolTable getSymbolTable() { return symbolTable; } 
    241     ./ 
    242      
    243     MethodHeader ::= Annotations Modifiers function$ SetOrGet IDENTIFIER$Name ParameterBlock COLON ReturnType 
    244      
    245     SetOrGet ::= %empty | set$Token | get$Token 
    246      
    247     ReturnType$ReturnType ::= Type | void$ | STAR$Dyn 
    248      
    249     ConstructorHeader ::= Modifiers function$ IDENTIFIER$Name ParameterBlock 
     248    AccessorRole$AccessorRole ::= %empty | set$Token | get$Token 
     249    ReturnType$ReturnType ::= %empty | COLON$ OptType | COLON$ void$  
     250     
    250251     
    251252    ParameterBlock$ParameterBlock ::= LPAREN$ RPAREN$ 
     
    276277     
    277278    InterfaceMemberDeclarations$$InterfaceMemberDeclaration ::= InterfaceMemberDeclaration | InterfaceMemberDeclarations InterfaceMemberDeclaration 
    278      
    279     InterfaceMemberDeclaration$MethodDeclaration ::= MethodHeader SEMI$ 
    280      
     279    InterfaceMemberDeclaration$MethodDeclaration ::= Annotations Modifiers function$ IDENTIFIER$Name ParameterBlock ReturnType SemiOpt$ 
    281280    InterfaceMemberDeclaration$EmptyDeclaration ::= SEMI$ 
     281    InterfaceMemberDeclaration ::= NamespaceDeclaration 
    282282 
    283283    -- block 
     
    389389    ThrowStatement$ThrowStatement ::= throw$ Expression SemiOpt$ 
    390390     
    391  
    392391    -- expressions 
    393     Primary ::= Literal 
     392    Primary$Primary ::= Literal 
    394393              | MethodInvocation 
    395394              | ArrayAccess 
     
    402401              | ObjectLiteral 
    403402              | FunctionExpression 
     403              | QIdent 
    404404     
    405405    FunctionExpression$FunctionExpression ::= function$ ParameterBlock COLON$ ReturnType Block 
     
    419419    ElementList$$Expression ::= Expression 
    420420                               | ElementList COMMA Expression 
    421      
     421 
     422    FieldAccess$FieldAccess ::= QIdent | Ident 
    422423    FieldAccess$FieldAccess ::= Primary$Base DOT$ Ident 
    423424     
    424425    MethodInvocation ::= MethodReference Arguments 
    425426                        
    426     MethodReference$MethodReference ::= Ident 
    427     MethodReference$MethodReference ::= Name$Base DOT$ Ident 
     427    MethodReference$MethodReference ::= QIdent | Ident 
    428428    MethodReference$MethodReference ::= Primary$Base DOT$ Ident 
    429429     
     
    539539                if (n instanceof MethodDeclaration) 
    540540                    return ((MethodDeclaration) n).getSymbolTable(); 
    541                 if (n instanceof ConstructorDeclaration) 
    542                     return ((ConstructorDeclaration) n).getSymbolTable(); 
    543541                if (n instanceof ClassBody) 
    544542                    return ((ClassBody) n).getSymbolTable(); 
  • axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/parser/SymbolTableVisitor.java

    r31 r37  
    11package org.axdt.as3.imp.parser; 
    22 
     3import lpg.runtime.IAst; 
    34import lpg.runtime.ILexStream; 
    45import lpg.runtime.IPrsStream; 
     
    1213import org.axdt.as3.imp.parser.Ast.Block; 
    1314import org.axdt.as3.imp.parser.Ast.ClassBody; 
    14 import org.axdt.as3.imp.parser.Ast.ConstructorDeclaration; 
    15 import org.axdt.as3.imp.parser.Ast.ConstructorHeader; 
     15import org.axdt.as3.imp.parser.Ast.CustomNamespace; 
    1616import org.axdt.as3.imp.parser.Ast.ExpressionStatement; 
     17import org.axdt.as3.imp.parser.Ast.FieldDeclaration; 
    1718import org.axdt.as3.imp.parser.Ast.FormalParameter; 
    18 import org.axdt.as3.imp.parser.Ast.FormalParameterList; 
    1919import org.axdt.as3.imp.parser.Ast.FunctionExpression; 
    2020import org.axdt.as3.imp.parser.Ast.InterfaceBody; 
    2121import org.axdt.as3.imp.parser.Ast.MethodDeclaration; 
    22 import org.axdt.as3.imp.parser.Ast.MethodHeader; 
    2322import org.axdt.as3.imp.parser.Ast.PackageBody; 
    2423import org.axdt.as3.imp.parser.Ast.VariableDeclarator; 
     
    110109 
    111110        public boolean visit(MethodDeclaration n) { 
    112                 MethodHeader hr = n.getMethodHeader(); 
    113                 IToken id = hr.getName().getIToken(); 
     111                IToken id = n.getName().getIToken(); 
    114112                SymbolTable symbol_table = peekTable(); 
    115113                String name = id.toString(); 
    116                 if (hr.getSetOrGet()!= null) { 
    117                         name = hr.getSetOrGet().toString() +" "+ name; 
     114                if (n.getAccessorRole()!= null) { 
     115                        name = n.getAccessorRole().toString() +" "+ name; 
    118116                } 
    119                 if (!symbol_table.create(name, hr)) 
     117                for (Object o:n.getModifiers().getArrayList()) { 
     118                        if (o instanceof CustomNamespace) { 
     119                                name =  o.toString() + "::" + name; 
     120                                break; 
     121                        } 
     122                } 
     123                if (!symbol_table.create(name, n)) 
    120124                        emitError(id, "Illegal redeclaration of " + name); 
    121125                // Add a symbol table for the parameters 
     
    129133        } 
    130134 
    131         public boolean visit(ConstructorDeclaration n) { 
    132                 ConstructorHeader hr = n.getConstructorHeader(); 
    133                 IToken id = hr.getName().getIToken(); 
    134                 SymbolTable symbol_table = peekTable(); 
    135                 String name = id.toString(); 
    136                  
    137                 if (!symbol_table.create(name, hr)) 
    138                         emitError(id, "Illegal redeclaration of " + name); 
    139                 // 
    140                 // Add a symbol table for the parameters 
    141                 symbol_table = parser.new SymbolTable(symbol_table); 
    142                 symbol_table = pushNewTable(); 
    143                 n.setSymbolTable(symbol_table); 
    144                 return true; 
    145         } 
    146  
    147         public void endVisit(ConstructorDeclaration n) { 
    148                 parser.symbolTableStack.pop(); 
    149         } 
    150          
    151135        public boolean visit(FunctionExpression n) { 
    152136                n.setSymbolTable(pushNewTable()); 
     
    176160        @Override 
    177161        public boolean visit(VariableDeclarator n) { 
     162                IAst parent = n.getParent().getParent(); 
    178163                String name = n.getName().toString(); 
     164                if (parent instanceof FieldDeclaration) { 
     165                        FieldDeclaration f = (FieldDeclaration) parent; 
     166                        for (Object o:f.getModifiers().getArrayList()) { 
     167                                if (o instanceof CustomNamespace) { 
     168                                        name =  o.toString() + "::" + name; 
     169                                        break; 
     170                                } 
     171                        } 
     172                } 
    179173                if (!peekTable().create(name, n)) 
    180174                        emitError(n, "Illegal redeclaration of " + name); 
  • axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/treeModelBuilder/AS3LabelProvider.java

    r31 r37  
    105105                if (n instanceof InterfaceDeclaration) 
    106106                        return OUTLINE_INTERFACE_IMAGE; 
    107                 if (n instanceof ConstructorDeclaration) { 
    108                         ModifierList modifiers = ((ConstructorDeclaration)n).getConstructorHeader().getModifiers(); 
    109                         if (modifiers!=null) { 
    110                                 for (Object m:modifiers.getArrayList()) { 
    111                                         if (m instanceof Modifier) { 
    112                                                 Modifier mod = (Modifier) m; 
    113                                                 if ("private".equals(mod.toString()))   
    114                                                         return OUTLINE_PRIVATE_CONSTRUCTOR_IMAGE; 
    115                                         } 
    116                                 } 
    117                         } 
    118                         return OUTLINE_PUBLIC_CONSTRUCTOR_IMAGE; 
    119                 } 
    120107                if (n instanceof VariableDeclarator) { 
    121108                        IAst parent = ((VariableDeclarator)n).getParent().getParent(); 
     
    124111                                if (modifiers!=null) { 
    125112                                        for (Object m:modifiers.getArrayList()) { 
    126                                                 if (m instanceof Modifier) { 
    127                                                         Modifier mod = (Modifier) m; 
    128                                                         if ("private".equals(mod.toString()))   
     113                                                if (m instanceof IReservedNamespace) { 
     114                                                        if ("private".equals(m.toString()))   
    129115                                                                return OUTLINE_PRIVATE_FIELD_IMAGE; 
    130116                                                } 
     
    135121                } 
    136122                if (n instanceof MethodDeclaration) { 
    137                         ModifierList modifiers = ((MethodDeclaration)n).getMethodHeader().getModifiers(); 
     123                        MethodDeclaration method = (MethodDeclaration)n; 
     124                        ModifierList modifiers = method.getModifiers(); 
    138125                        if (modifiers!=null) { 
    139126                                for (Object m:modifiers.getArrayList()) { 
    140                                         if (m instanceof Modifier) { 
    141                                                 Modifier mod = (Modifier) m; 
    142                                                 if ("private".equals(mod.toString()))   
     127                                        if (m instanceof IReservedNamespace) { 
     128                                                if ("private".equals(m.toString())) { 
     129                                                        if (method.isConstructor) 
     130                                                                return OUTLINE_PRIVATE_CONSTRUCTOR_IMAGE; 
    143131                                                        return OUTLINE_PRIVATE_METHOD_IMAGE; 
     132                                                } 
    144133                                        } 
    145134                                } 
    146135                        } 
     136                        if (method.isConstructor) 
     137                                return OUTLINE_PUBLIC_CONSTRUCTOR_IMAGE; 
    147138                        return OUTLINE_PUBLIC_METHOD_IMAGE; 
    148139                } 
     
    170161                        return ((VariableDeclarator)n).getName().toString(); 
    171162                if (n instanceof MethodDeclaration){ 
    172                         MethodHeader header = ((MethodDeclaration)n).getMethodHeader()
    173                         if (header.getSetOrGet()!=null) 
    174                                 return header.getSetOrGet().toString() +" "+ header.getName().toString(); 
    175                         return header.getName().toString(); 
     163                        MethodDeclaration method = (MethodDeclaration)n
     164                        if (method.getAccessorRole()!=null) 
     165                                return method.getAccessorRole().toString() +" "+ method.getName().toString(); 
     166                        return method.getName().toString(); 
    176167                } 
    177                 if (n instanceof ConstructorDeclaration) 
    178                         return ((ConstructorDeclaration)n).getConstructorHeader().getName().toString(); 
    179168                if (n instanceof ClassDeclaration) 
    180169                        return ((ClassDeclaration)n).getName().toString(); 
  • axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/treeModelBuilder/AS3TreeModelBuilder.java

    r31 r37  
    3232 
    3333                public boolean visit(MethodDeclaration n) { 
    34                         createSubItem(n); 
    35                         return true; 
    36                 } 
    37                  
    38                 public boolean visit(ConstructorDeclaration n) { 
    3934                        createSubItem(n); 
    4035                        return true;