Charj : added AST nodes to support pointers and references
authorMinas Charalambides <charala1@illinois.edu>
Wed, 26 May 2010 05:36:36 +0000 (00:36 -0500)
committerMinas Charalambides <charala1@illinois.edu>
Wed, 26 May 2010 05:36:36 +0000 (00:36 -0500)
src/langs/charj/src/charj/translator/Charj.g
src/langs/charj/src/charj/translator/Charj.stg
src/langs/charj/src/charj/translator/CharjASTModifier.g
src/langs/charj/src/charj/translator/CharjEmitter.g
src/langs/charj/src/charj/translator/CharjSemantics.g

index 6d28af2177c985075cc2795a15e9a70c7f074878..742243984cec660f0cc4b375015392bd85f2005a 100644 (file)
@@ -172,6 +172,10 @@ tokens {
     SUPER_CONSTRUCTOR_CALL;
     THIS_CONSTRUCTOR_CALL;
     TYPE;
+    SIMPLE_TYPE;
+    OBJECT_TYPE;
+    REFERENCE_TYPE;
+    POINTER_TYPE;
     PRIMITIVE_VAR_DECLARATION;
     OBJECT_VAR_DECLARATION;
     VAR_DECLARATOR;
@@ -402,12 +406,12 @@ type
 
 simpleType
     :   primitiveType arrayDeclaratorList?
-        ->  ^(TYPE primitiveType arrayDeclaratorList?)  
+        ->  ^(SIMPLE_TYPE primitiveType arrayDeclaratorList?)  
     ;
 
 objectType
     :   qualifiedTypeIdent arrayDeclaratorList?
-        ->  ^(TYPE qualifiedTypeIdent arrayDeclaratorList?)
+        ->  ^(OBJECT_TYPE qualifiedTypeIdent arrayDeclaratorList?)
     ;
 
 qualifiedTypeIdent
index 88e04103b3824653cb7e481cfd7ffa2bafb64037..e30c561e9b0848b17ee1f0ab19887acf54964ef3 100644 (file)
@@ -267,7 +267,7 @@ local_var_decl(modList, type, declList) ::=
 >>
 
 
-type(typeID, arrDeclList) ::=
+simple_type(typeID, arrDeclList) ::=
 <<
 <typeID><arrDeclList>
 >>
@@ -275,9 +275,19 @@ type(typeID, arrDeclList) ::=
 
 obj_type(typeID, arrDeclList) ::=
 <<
+<typeID><arrDeclList>
+>>
+
+pointer_type(typeID, arrDeclList) ::=
+<<
 <typeID>*<arrDeclList>
 >>
 
+reference_type(typeID, arrDeclList) ::=
+<<
+<typeID>&<arrDeclList>
+>>
+
 
 typeIdent(typeID, generics) ::=
 <<
index 1c582a8d6ba0a1af4c2b2642afe5e94738227995..91b7272f0e669393a18a586f6a18d3686d4a3248 100644 (file)
@@ -171,11 +171,13 @@ type
     ;
 
 simpleType
-    :   ^(TYPE primitiveType arrayDeclaratorList?)
+    :   ^(SIMPLE_TYPE primitiveType arrayDeclaratorList?)
     ;
     
 objectType
-    :   ^(TYPE qualifiedTypeIdent arrayDeclaratorList?)
+    :   ^(OBJECT_TYPE qualifiedTypeIdent arrayDeclaratorList?)
+    |   ^(REFERENCE_TYPE qualifiedTypeIdent arrayDeclaratorList?)
+    |   ^(POINTER_TYPE qualifiedTypeIdent arrayDeclaratorList?)
     ;
 
 qualifiedTypeIdent
index 892499d578ab6ad4e0e6f5735b8eb3742671e2f2..e41a48b3cebc864cd7f3731b81616d6976579204 100644 (file)
@@ -377,13 +377,17 @@ type
     ;
 
 simpleType
-    :   ^(TYPE primitiveType arrayDeclaratorList?)
-        -> type(typeID={$primitiveType.st}, arrDeclList={$arrayDeclaratorList.st})
+    :   ^(SIMPLE_TYPE primitiveType arrayDeclaratorList?)
+        -> simple_type(typeID={$primitiveType.st}, arrDeclList={$arrayDeclaratorList.st})
     ;
 
 objectType
-    :   ^(TYPE qualifiedTypeIdent arrayDeclaratorList?)
+    :   ^(OBJECT qualifiedTypeIdent arrayDeclaratorList?)
         -> obj_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$arrayDeclaratorList.st})
+    |   ^(OBJECT_POINTER qualifiedTypeIdent arrayDeclaratorList?)
+        -> pointer_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$arrayDeclaratorList.st})
+    |   ^(OBJECT_REFERENCE qualifiedTypeIdent arrayDeclaratorList?)
+        -> reference_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$arrayDeclaratorList.st})
     ;
 
 qualifiedTypeIdent
@@ -576,7 +580,7 @@ expr
         -> template(e1={$e1.st}, e2={$e2.st}) "<e1> || <e2>"
     |   ^('&&' e1=expr e2=expr)
         -> template(e1={$e1.st}, e2={$e2.st}) "<e1> && <e2>"
-    |   ^('|' e1=expr e2=expr)
+    |   ^(BITWISE_OR e1=expr e2=expr)
         -> template(e1={$e1.st}, e2={$e2.st}) "<e1> | <e2>"
     |   ^('^' e1=expr e2=expr)
         -> template(e1={$e1.st}, e2={$e2.st}) "<e1> ^ <e2>"
@@ -624,9 +628,9 @@ expr
         -> template(e1={$e1.st}) "<e1>++"
     |   ^(POST_DEC e1=expr)
         -> template(e1={$e1.st}) "<e1>--"
-    |   ^('~' e1=expr)
+    |   ^(TILDA e1=expr)
         -> template(e1={$e1.st}) "~<e1>"
-    |   ^('!' e1=expr)
+    |   ^(NOT e1=expr)
         -> template(e1={$e1.st}) "!<e1>"
     |   ^(CAST_EXPR ty=type e1=expr)
         -> template(ty={$ty.st}, e1={$e1.st}) "(<ty>)<e1>"
index 9bd9b2939a98f1ec090b7edad616ad2d146715a5..7cc3e65ed5ae14992ee5c87ee1a2983c24123981 100644 (file)
@@ -256,11 +256,13 @@ type
     ;
 
 simpleType
-    :   ^(TYPE primitiveType arrayDeclaratorList?)
+    :   ^(SIMPLE_TYPE primitiveType arrayDeclaratorList?)
     ;
     
 objectType
-    :   ^(TYPE qualifiedTypeIdent arrayDeclaratorList?)
+    :   ^(OBJECT_TYPE qualifiedTypeIdent arrayDeclaratorList?)
+    |   ^(REFERENCE_TYPE qualifiedTypeIdent arrayDeclaratorList?)
+    |   ^(POINTER_TYPE qualifiedTypeIdent arrayDeclaratorList?)
     ;
 
 qualifiedTypeIdent