Permalink
Browse files

Merge pull request #7 from shamanas/patch-1

Added namespace types
  • Loading branch information...
2 parents 2fcb1c2 + bbb29d3 commit 2fce1363698be8eb00909bb9f98c2fb2a8be1a12 Amos Wenger committed May 12, 2012
Showing with 37 additions and 2 deletions.
  1. +32 −2 grammar/nagaqueen.leg
  2. +4 −0 source/nagaqueen/OocListener.ooc
  3. +1 −0 source/nagaqueen/callbacks.ooc
View
@@ -197,6 +197,7 @@ void nq_onTypeGenericArgument(void *this, void *type, void *genType);
void nq_onFuncTypeGenericArgument(void *this, void *type, char *name);
void *nq_onTypeList(void *this);
void *nq_onTypeListElement(void *this, void *list, void *elem);
+void *nq_onTypeNamespace(void *this, void *type, void *ident);
void *nq_onFuncTypeNew(void *this);
void nq_onFuncTypeArgument(void *this, void *funcType, void *argType);
@@ -959,7 +960,19 @@ TypeBase = FuncType |
# a GenericType is just like a Type but with non-optional generic type arguments
# it's used when we have to decide between a Type and a VariableAccess
GenericType
- = t:TypeBase
+ = (t:TypeBase
+ - '<' - t2:Type { nq_onTypeGenericArgument(core->this, t, t2); }
+ (- ',' - t2:Type { nq_onTypeGenericArgument(core->this, t, t2); })*
+ - '>'
+ - ('*' { t=$$=nq_onTypePointer (core->this, t); }
+ | '@' { t=$$=nq_onTypeReference(core->this, t); }
+ | "[" WS { inner=NULL; } - inner:Expr? "]" { t=$$=nq_onTypeBrackets(core->this, t, inner); }
+ )*
+ - { $$=t; }) |
+ ('('
+ temp: Old # When entering the TypeBase rule, i gets overwritten, so we just use a dummy rule to store it
+ - i:IDENT { temp=nq_StringClone(i); }
+ - t:TypeBase { t=$$=nq_onTypeNamespace(core->this, t, temp); }
- '<' - t2:Type { nq_onTypeGenericArgument(core->this, t, t2); }
(- ',' - t2:Type { nq_onTypeGenericArgument(core->this, t, t2); })*
- '>'
@@ -968,6 +981,8 @@ GenericType
| "[" WS { inner=NULL; } - inner:Expr? "]" { t=$$=nq_onTypeBrackets(core->this, t, inner); }
)*
- { $$=t; }
+ ')'
+ )
Type = list:TypeList { $$=list; } | (
t:TypeBase
@@ -978,7 +993,22 @@ Type = list:TypeList { $$=list; } | (
| '@' { t=$$=nq_onTypeReference(core->this, t); }
| "[" WS { inner=NULL; } - inner:Expr? "]" { t=$$=nq_onTypeBrackets(core->this, t, inner); }
)*
- - { $$=t; })
+ - { $$=t; }) |
+ ('('
+ temp: Old # When entering the TypeBase rule, i gets overwritten, so we just use a dummy rule to store it
+ - i:IDENT { temp=nq_StringClone(i); }
+ - t:TypeBase { t=$$=nq_onTypeNamespace(core->this, t, temp); }
+ (- '<' - genType:Type { nq_onTypeGenericArgument(core->this, t, genType); }
+ (- ',' - genType:Type { nq_onTypeGenericArgument(core->this, t, genType); })*
+ - '>')?
+ - (STAR { t=$$=nq_onTypePointer (core->this, t); }
+ | '@' { t=$$=nq_onTypeReference(core->this, t); }
+ | "[" WS { inner=NULL; } - inner:Expr? "]" { t=$$=nq_onTypeBrackets(core->this, t, inner); }
+ )*
+ - { $$=t; }
+ ')'
+ )
+
TypeListCore = { $$=nq_onTypeList(core->this); }
TypeList = '(' WS list:TypeListCore
@@ -295,6 +295,10 @@ OocListener: abstract class {
UnsupportedAstElement new(class, "type-list-element") throw(); null
}
+ onTypeNamespace: func (type, ident: Object) -> Object {
+ UnsupportedAstElement new(class, "type-namespace") throw(); null
+ }
+
// FuncType
@@ -124,6 +124,7 @@ nq_onTypeGenericArgument: unmangled func (l: OocListener, type: Object, genType:
nq_onTypeList: unmangled func (l: OocListener) -> Object { l onTypeList() }
nq_onTypeListElement: unmangled func (l: OocListener, list, elem: Object) -> Object { l onTypeListElement(list, elem) }
+nq_onTypeNamespace: unmangled func (l: OocListener, type, ident: Object) -> Object { l onTypeNamespace(type, ident) }
// FuncType

0 comments on commit 2fce136

Please sign in to comment.