summaryrefslogtreecommitdiff
path: root/external/lasso-builtins-generator-9.lasso
blob: fc6d130acf3b40e683d2246b58da0387dfa7ff1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/lasso9

/*
	Builtins Generator for Lasso 9

	This is the shell script that was used to extract Lasso 9's built-in keywords
	and generate most of the _lassobuiltins.py file. When run, it creates a file
	named "lassobuiltins-9.py" containing the types, traits, and methods of the
	currently-installed version of Lasso 9.

	A partial list of keywords in Lasso 8 can be generated with this code:

	<?LassoScript
		local('l8tags' = list);
		iterate(tags_list, local('i'));
			#l8tags->insert(string_removeleading(#i, -pattern='_global_'));
		/iterate;
		#l8tags->sort;
		iterate(#l8tags, local('i'));
			string_lowercase(#i)+"<br>";
		/iterate;

*/

output("This output statement is required for a complete list of methods.")
local(f) = file("lassobuiltins-9.py")
#f->doWithClose => {

#f->openWrite
#f->writeString('# -*- coding: utf-8 -*-
"""
    pygments.lexers._lassobuiltins
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Built-in Lasso types, traits, and methods.
"""

')

lcapi_loadModules

// Load all of the libraries from builtins and lassoserver
// This forces all possible available types and methods to be registered
local(srcs =
	tie(
		dir(sys_masterHomePath + 'LassoLibraries/builtins/')->eachFilePath,
		dir(sys_masterHomePath + 'LassoLibraries/lassoserver/')->eachFilePath
	)
)

with topLevelDir in #srcs
where not #topLevelDir->lastComponent->beginsWith('.')
do protect => {
	handle_error => {
		stdoutnl('Unable to load: ' + #topLevelDir + ' ' + error_msg)
	}
	library_thread_loader->loadLibrary(#topLevelDir)
	stdoutnl('Loaded: ' + #topLevelDir)
}

local(
	typesList = list(),
	traitsList = list(),
	methodsList = list()
)

// unbound methods
with method in sys_listUnboundMethods
let m_name = #method->methodName->asString
where not #m_name->endsWith('=')		// skip setter methods
where #m_name->isAlpha(1)		// skip unpublished methods
where #methodsList !>> #m_name
do #methodsList->insert(#m_name)

// traits
with trait in sys_listTraits
let name = #trait->asString
where not #name->beginsWith('$')		// skip combined traits
where #traitsList !>> #name
do {
	#traitsList->insert(#name)
	with method in tie(#trait->getType->provides, #trait->getType->requires)
	let m_name = #method->methodName->asString
	where not #m_name->endsWith('=')		// skip setter methods
	where #m_name->isAlpha(1)		// skip unpublished methods
	where #methodsList !>> #m_name
	do #methodsList->insert(#m_name)
}

// types
with type in sys_listTypes
let name = #type->asString
where not #name->endsWith('$')		// skip threads
where #typesList !>> #name
do {
	#typesList->insert(#name)
	with method in #type->getType->listMethods
	let m_name = #method->methodName->asString
	where not #m_name->endsWith('=')		// skip setter methods
	where #m_name->isAlpha(1)		// skip unpublished methods
	where #methodsList !>> #m_name
	do #methodsList->insert(#m_name)
}

#f->writeString("BUILTINS = {
    'Types': [
")
with t in #typesList
do #f->writeString("        '"+string_lowercase(#t)+"',\n")

#f->writeString("    ],
    'Traits': [
")
with t in #traitsList
do #f->writeString("        '"+string_lowercase(#t)+"',\n")

#f->writeString("    ],
    'Methods': [
")
with t in #methodsList
do #f->writeString("        '"+string_lowercase(#t)+"',\n")

#f->writeString("    ],
}
")

}