summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2011-07-10 21:43:30 +0000
committerAdrian Thurston <thurston@complang.org>2011-07-10 21:43:30 +0000
commitcc31dc1d130af2324b7e83ca12431477edcdb3dd (patch)
treef4bb8a60d96bd6fdb02b41ea3058f250335f506c
parent1aa15a519c1e588a34702767875d2ec3825b67e1 (diff)
downloadcolm-cc31dc1d130af2324b7e83ca12431477edcdb3dd.tar.gz
Removed the old production-style generics. Now only using the type-args style.
refs #295.
-rw-r--r--colm/lmparse.kl48
-rw-r--r--test/btscan2.lm4
-rw-r--r--test/cxx/cxx.lm51
-rw-r--r--test/dns.lm3
-rw-r--r--test/python/python.lm3
-rw-r--r--test/undofrag1.lm3
-rw-r--r--test/undofrag2.lm3
-rw-r--r--test/undofrag3.lm3
8 files changed, 27 insertions, 91 deletions
diff --git a/colm/lmparse.kl b/colm/lmparse.kl
index b5cfd77a..5ebbdbbc 100644
--- a/colm/lmparse.kl
+++ b/colm/lmparse.kl
@@ -75,7 +75,6 @@ root_item: region_def commit final { $$->stmt = 0; };
root_item: context_def commit final { $$->stmt = 0; };
root_item: namespace_def commit final { $$->stmt = 0; };
root_item: function_def commit final { $$->stmt = 0; };
-root_item: generic_def commit final { $$->stmt = 0; };
root_item: iter_def commit final { $$->stmt = 0; };
root_item: global_def commit final { $$->stmt = $1->stmt; };
root_item: statement commit final { $$->stmt = $1->stmt; };
@@ -190,49 +189,6 @@ reference_type_ref: KW_Ref type_ref
$$->typeRef->isRef = true;
};
-generic_def: KW_Map TK_Word '[' type_ref type_ref ']'
- final {
- Namespace *nspace = namespaceStack.top();
-
- GenericType *generic = new GenericType( $2->data, GEN_MAP,
- pd->nextGenericId++, 0/*langEl*/, $5->typeRef );
- generic->keyTypeArg = $4->typeRef;
-
- nspace->genericList.append( generic );
- };
-
-generic_def: KW_List TK_Word '[' type_ref ']'
- final {
- /* Get the language element. */
- Namespace *nspace = namespaceStack.top();
-
- GenericType *generic = new GenericType( $2->data, GEN_LIST,
- pd->nextGenericId++, 0/*langEl*/, $4->typeRef );
-
- nspace->genericList.append( generic );
- };
-
-generic_def: KW_Vector TK_Word '[' type_ref ']'
- final {
- GenericType *generic = new GenericType( $2->data, GEN_VECTOR,
- pd->nextGenericId++, 0, $4->typeRef );
-
- Namespace *nspace = namespaceStack.top();
- nspace->genericList.append( generic );
- };
-
-
-generic_def: KW_Accum TK_Word '[' type_ref ']'
- final {
- /* Get the language element. */
- Namespace *nspace = namespaceStack.top();
-
- GenericType *generic = new GenericType( $2->data, GEN_PARSER,
- pd->nextGenericId++, 0/*langEl*/, $4->typeRef );
-
- nspace->genericList.append( generic );
- };
-
nonterm global_def uses statement;
global_def: KW_Global var_def opt_def_init
@@ -543,7 +499,6 @@ context_item: cfl_def commit;
context_item: region_def commit;
context_item: context_def commit;
context_item: function_def commit;
-context_item: generic_def commit;
context_item: iter_def commit;
context_item: pre_eof commit;
context_item: precedence commit;
@@ -2417,9 +2372,6 @@ void Parser::init()
void Parser::addArgvList()
{
- /* Get the language element. */
- Namespace *nspace = namespaceStack.top();
-
NamespaceQual *nspaceQual1 = new NamespaceQual(
namespaceStack.top(), regionStack.top() );
TypeRef *typeRef = new TypeRef( InputLoc(), nspaceQual1, "str" );
diff --git a/test/btscan2.lm b/test/btscan2.lm
index 14413c6f..8cc43a4a 100644
--- a/test/btscan2.lm
+++ b/test/btscan2.lm
@@ -28,9 +28,7 @@ def item
def btscan
[item*]
-parser btscan_parser [btscan]
-
-Parser: btscan_parser = cons btscan_parser []
+Parser: parser<btscan> = cons parser<btscan> []
Parser << "!ab"
Parser << "b "
diff --git a/test/cxx/cxx.lm b/test/cxx/cxx.lm
index a8dfd37c..811bd7af 100644
--- a/test/cxx/cxx.lm
+++ b/test/cxx/cxx.lm
@@ -10,8 +10,8 @@ def lang_object
# If the object is a typedef, this points to the real object.
typedefOf: ptr lang_object
- objectMap: map<str object_list>
- inherited: object_list
+ objectMap: map<str list<ptr lang_object>>
+ inherited: list<ptr lang_object>
lookupParent: ptr lang_object
specializationOf: ptr lang_object
[]
@@ -33,9 +33,6 @@ def declarator_data
lookupObj: ptr lang_object
[]
-list declaration_data_list [declaration_data]
-list declarator_data_list [declarator_data]
-
# Constants for language object types.
global NamespaceType: int = typeid namespace_id
global ClassType: int = typeid class_id
@@ -45,29 +42,23 @@ global IdType: int = typeid identifier
global TypedefType: int = typeid typedef_id
global TemplateIdType: int = typeid template_id
-# Object stack definition. Uses references to objects.
-list object_list [ptr lang_object]
-
-# Stack of integers.
-list int_stack [int]
-
#
# Global data declarations
#
# Object stacks.
-global curNamespace: object_list = construct object_list []
-global declNs: object_list = construct object_list []
-global lookupNs: object_list = construct object_list []
-global qualNs: object_list = construct object_list []
-global templateParamNs: object_list = construct object_list []
+global curNamespace: list<ptr lang_object> = construct list<ptr lang_object> []
+global declNs: list<ptr lang_object> = construct list<ptr lang_object> []
+global lookupNs: list<ptr lang_object> = construct list<ptr lang_object> []
+global qualNs: list<ptr lang_object> = construct list<ptr lang_object> []
+global templateParamNs: list<ptr lang_object> = construct list<ptr lang_object> []
# Declaration, declarator data.
-global declarationData: declaration_data_list = construct declaration_data_list []
-global declaratorData: declarator_data_list = construct declarator_data_list []
+global declarationData: list<declaration_data> = construct list<declaration_data> []
+global declaratorData: list<declarator_data> = construct list<declarator_data> []
# Template declarations
-global templDecl: int_stack = construct int_stack []
+global templDecl: list<int> = construct list<int> []
# Root namespace object
global rootNamespace: ptr lang_object = createLangObject( NamespaceType
@@ -94,7 +85,7 @@ ptr lang_object lookupInObject( obj: ptr lang_object name: str )
{
# LOG print( ' looking in ', obj->name, '\n' )
- ol: object_list = obj->objectMap.find( name )
+ ol: list<ptr lang_object> = obj->objectMap.find( name )
if ol {
# LOG print( ' * found an object: ', ol.head, '\n' )
return ol.head
@@ -111,7 +102,7 @@ ptr lang_object lookupWithInheritance( obj: ptr lang_object name: str )
if found
return found
- localObjInherited: object_list = obj->inherited
+ localObjInherited: list<ptr lang_object> = obj->inherited
for II: ptr lang_object in localObjInherited {
inh: ptr lang_object = II
@@ -135,7 +126,7 @@ ptr lang_object unqualifiedLookup( name: str )
found: ptr lang_object
# Start with the objects in the templateParamNs.
- localTemplateParamNs: object_list = templateParamNs
+ localTemplateParamNs: list<ptr lang_object> = templateParamNs
for TemplParaObjIter: ptr lang_object in rev_child(localTemplateParamNs) {
found = lookupWithInheritance( TemplParaObjIter name )
if found
@@ -267,8 +258,8 @@ ptr lang_object createLangObject( typeId: int name: str lookupParent: ptr lang_o
obj: ptr lang_object = new construct lang_object(
typeId: typeId
name: name
- objectMap: construct map<str object_list> []
- inherited: construct object_list []
+ objectMap: construct map<str list<ptr lang_object>> []
+ inherited: construct list<ptr lang_object> []
lookupParent: lookupParent ) []
return obj
}
@@ -276,10 +267,10 @@ ptr lang_object createLangObject( typeId: int name: str lookupParent: ptr lang_o
# Building the language object tree.
int insertObject( definedIn: ptr lang_object name: str obj: ptr lang_object )
{
- ol: object_list = definedIn->objectMap.find( name )
+ ol: list<ptr lang_object> = definedIn->objectMap.find( name )
if !ol {
# Element not in the map already
- ol = construct object_list []
+ ol = construct list<ptr lang_object> []
}
ol.append( obj )
definedIn->objectMap.store( name ol )
@@ -287,7 +278,7 @@ int insertObject( definedIn: ptr lang_object name: str obj: ptr lang_object )
ptr lang_object findClass( inObj: ptr lang_object name: str )
{
- ol: object_list = inObj->objectMap.find( name )
+ ol: list<ptr lang_object> = inObj->objectMap.find( name )
if ol {
for ObjIter: ptr lang_object in ol {
obj: ptr lang_object = ObjIter
@@ -301,7 +292,7 @@ ptr lang_object findClass( inObj: ptr lang_object name: str )
ptr lang_object findTemplateClass( inObj: ptr lang_object name: str )
{
- ol: object_list = inObj->objectMap.find( name )
+ ol: list<ptr lang_object> = inObj->objectMap.find( name )
if ol {
for ObjIter: ptr lang_object in ol {
obj: ptr lang_object = ObjIter
@@ -2138,8 +2129,8 @@ int printObject( indent: str obj: ptr lang_object )
if obj->objectMap.length > 0
print( ' {\n' )
- ChildNames: map<str object_list> = obj->objectMap
- for MapEl: object_list in child( ChildNames ) {
+ ChildNames: map<str list<ptr lang_object>> = obj->objectMap
+ for MapEl: list<ptr lang_object> in child( ChildNames ) {
for Obj: ptr lang_object in MapEl
printObject( indent + ' ' Obj )
}
diff --git a/test/dns.lm b/test/dns.lm
index 98205d13..1ca701f1 100644
--- a/test/dns.lm
+++ b/test/dns.lm
@@ -114,8 +114,7 @@ def count
# end
#
-list count_stack [int]
-global CL: count_stack = construct count_stack []
+global CL: list<int> = construct list<int> []
int start_list( count: int )
{
diff --git a/test/python/python.lm b/test/python/python.lm
index c3284092..b7230b34 100644
--- a/test/python/python.lm
+++ b/test/python/python.lm
@@ -2,8 +2,7 @@
rl ident_char /[a-zA-Z_]/
# List used as a stack of indentations.
-list indent_stack [int]
-global IndentStack: indent_stack = construct indent_stack []
+global IndentStack: list<int> = construct list<int> []
IndentStack.push( 0 )
# Has a newline been sent for this '\n' .. whitespace match.
diff --git a/test/undofrag1.lm b/test/undofrag1.lm
index 1382199c..1316f336 100644
--- a/test/undofrag1.lm
+++ b/test/undofrag1.lm
@@ -12,8 +12,7 @@ def item2
def start2
[item2*]
-parser start2_parser [start2]
-global SP: start2_parser = cons start2_parser []
+global SP: parser<start2> = cons parser<start2> []
context ctx
{
diff --git a/test/undofrag2.lm b/test/undofrag2.lm
index 21943962..06430d7b 100644
--- a/test/undofrag2.lm
+++ b/test/undofrag2.lm
@@ -5,8 +5,7 @@ lex start
token id /[a-zA-Z_]+/
}
-parser out_parser [out]
-global Out: out_parser = construct out_parser []
+global Out: parser<out> = construct parser<out> []
def out_item
[id]
diff --git a/test/undofrag3.lm b/test/undofrag3.lm
index 0996e432..6f9b703c 100644
--- a/test/undofrag3.lm
+++ b/test/undofrag3.lm
@@ -5,8 +5,7 @@ lex start
token id /[a-zA-Z_]+/
}
-parser out_parser [out]
-global Out: out_parser = construct out_parser []
+global Out: parser<out> = construct parser<out> []
def out_item
[id]