Page Menu
Home
Xreate
Search
Configure Global Search
Log In
Docs
Questions
Repository
Issues
Patches
Internal API
Files
F4821096
ASTLispNode.java
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Aug 24, 10:33 AM
Size
1 KB
Mime Type
text/x-c++
Expires
Wed, Aug 26, 10:33 AM (1 d, 13 h)
Engine
blob
Format
Raw Data
Handle
281966
Attached To
rXR Xreate
ASTLispNode.java
View Options
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
org.xreate.grammatic.lisp
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
java.util.ArrayList
;
import
java.util.Map
;
public
class
ASTLispNode
{
public
String
caption
;
public
ArrayList
<
ASTLispNode
>
parameters
=
Lists
.
newArrayList
();
protected
Map
<
String
,
ASTLispNode
>
index
;
public
ASTLispNode
(
String
c
){
caption
=
c
;
}
public
ASTLispNode
add
(
ASTLispNode
node
){
parameters
.
add
(
node
);
return
node
;
}
public
ASTLispNode
get
(
String
node
){
if
(
null
==
index
){
buildIndex
();
}
return
index
.
get
(
node
);
}
protected
void
buildIndex
(){
index
=
Maps
.
newHashMap
();
for
(
ASTLispNode
param
:
parameters
){
index
.
put
(
param
.
caption
,
param
);
}
}
}
class
ASTLispConstantNode
extends
ASTLispNode
{
public
int
value
;
public
ASTLispConstantNode
(
String
c
)
{
super
(
c
);
value
=
Integer
.
parseInt
(
c
);
}
}
class
NodeFunctionVarsList
{
ASTLispNode
node
;
NodeFunctionVarsList
(
ASTLispNode
node
){
this
.
node
=
node
;
}
String
[]
getVarNames
(){
int
size
=
node
.
parameters
.
size
();
String
[]
result
=
new
String
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++){
result
[
i
]
=
node
.
parameters
.
get
(
i
).
get
(
"name"
).
parameters
.
get
(
0
).
caption
;
}
return
result
;
}
}
Event Timeline
Log In to Comment