这个问题比较细,估计只有做源码分析的盆友会有点兴趣。我在平时会用srcML,javalang,Understand做tokenization,有时也会一起使用,但是发现这些工具有不一致的地方,所以简单以一个例子记录一下:
例如下面这段Java代码:
class Test{
public WndJournal(){
int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P;
int height = SPDSettings.landscape() ? HEIGHT_L : HEIGHT_P;
resize(width, height);
guideTab = new GuideTab();
add(guideTab);
guideTab.setRect(0, 0, width, height);
guideTab.updateList();
alchemyTab = new AlchemyTab();
add(alchemyTab);
alchemyTab.setRect(0, 0, width, height);
notesTab = new NotesTab();
add(notesTab);
notesTab.setRect(0, 0, width, height);
notesTab.updateList();
catalogTab = new CatalogTab();
add(catalogTab);
catalogTab.setRect(0, 0, width, height);
catalogTab.updateList();
Tab[] tabs = {
new IconTab( new ItemSprite(ItemSpriteSheet.GUIDE_PAGE, null) ) {
protected void select( boolean value ) {
super.select( value );
guideTab.active = guideTab.visible = value;
if (value) last_index = 0;
}
},
new IconTab( new ItemSprite(ItemSpriteSheet.ALCH_PAGE, null) ) {
protected void select( boolean value ) {
super.select( value );
alchemyTab.active = alchemyTab.visible = value;
if (value) last_index = 1;
}
},
new IconTab( Icons.get(Icons.DEPTH) ) {
protected void select( boolean value ) {
super.select( value );
notesTab.active = notesTab.visible = value;
if (value) last_index = 2;
}
},
new IconTab( new ItemSprite(ItemSpriteSheet.WEAPON_HOLDER, null) ) {
protected void select( boolean value ) {
super.select( value );
catalogTab.active = catalogTab.visible = value;
if (value) last_index = 3;
}
}
};
for (Tab tab : tabs) {
add( tab );
}
layoutTabs();
select(last_index);
}
}
如果用javalang对method内部的代码做tokenization是这个结果:
int
width
=
SPDSettings
(
)
?
WIDTH_L
:
WIDTH_P
;
int
height
=
SPDSettings
(
)
?
HEIGHT_L
:
HEIGHT_P
;
resize
(
width
,
height
)
;
guideTab
=
new
GuideTab
(
)
;
add
(
guideTab
)
;
guideTab
(
0
,
0
,
width
,
height
)
;
guideTab
(
)
;
alchemyTab
=
new
AlchemyTab
(
)
;
add
(
alchemyTab
)
;
alchemyTab
(
0
,
0
,
width
,
height
)
;
notesTab
=
new
NotesTab
(
)
;
add
(
notesTab
)
;
notesTab
(
0
,
0
,
width
,
height
)
;
notesTab
(
)
;
catalogTab
=
new
CatalogTab
(
)
;
add
(
catalogTab
)
;
catalogTab
(
0
,
0
,
width
,
height
)
;
catalogTab
(
)
;
Tab
[
]
tabs
=
{
new
IconTab
(
new
ItemSprite
(
ItemSpriteSheet
.
GUIDE_PAGE
,
null
)
)
{
protected
void
select
(
boolean
value
)
{
super
.
select
(
value
)
;
guideTab
.
active
=
guideTab
.
visible
=
value
;
if
(
value
)
last_index
=
0
;
}
}
,
new
IconTab
(
new
ItemSprite
这也是很好理解的,如果用Understand做tokenization,如果我们把每一个token当做一行输出,结果是类似于这个样子:
class|&|Keyword|&|1
Test|&|Identifier|&|1
{|&|Punctuation|&|1
public|&|Keyword|&|2
WndJournal|&|Identifier|&|2
(|&|Punctuation|&|2
)|&|Punctuation|&|2
{|&|Punctuation|&|2
int|&|Keyword|&|4
width|&|Identifier|&|4
=|&|Operator|&|4
SPDSettings|&|Identifier|&|4
.|&|Punctuation|&|4
landscape|&|Identifier|&|4
(|&|Punctuation|&|4
)|&|Punctuation|&|4
?|&|Operator|&|4
WIDTH_L|&|Identifier|&|4
:|&|Operator|&|4
WIDTH_P|&|Identifier|&|4
;|&|Punctuation|&|4
int|&|Keyword|&|5
height|&|Identifier|&|5
=|&|Operator|&|5
SPDSettings|&|Identifier|&|5
.|&|Punctuation|&|5
landscape|&|Identifier|&|5
(|&|Punctuation|&|5
)|&|Punctuation|&|5
?|&|Operator|&|5
HEIGHT_L|&|Identifier|&|5
:|&|Operator|&|5
HEIGHT_P|&|Identifier|&|5
;|&|Punctuation|&|5
resize|&|Identifier|&|7
(|&|Punctuation|&|7
width|&|Identifier|&|7
,|&|Punctuation|&|7
height|&|Identifier|&|7
)|&|Punctuation|&|7
;|&|Punctuation|&|7
guideTab|&|Identifier|&|9
=|&|Operator|&|9
new|&|Keyword|&|9
GuideTab|&|Identifier|&|9
(|&|Punctuation|&|9
)|&|Punctuation|&|9
;|&|Punctuation|&|9
add|&|Identifier|&|10
(|&|Punctuation|&|10
guideTab|&|Identifier|&|10
)|&|Punctuation|&|10
;|&|Punctuation|&|10
guideTab|&|Identifier|&|11
.|&|Punctuation|&|11
setRect|&|Identifier|&|11
(|&|Punctuation|&|11
0|&|Literal|&|11
,|&|Punctuation|&|11
0|&|Literal|&|11
,|&|Punctuation|&|11
width|&|Identifier|&|11
,|&|Punctuation|&|11
height|&|Identifier|&|11
)|&|Punctuation|&|11
;|&|Punctuation|&|11
guideTab|&|Identifier|&|12
.|&|Punctuation|&|12
updateList|&|Identifier|&|12
(|&|Punctuation|&|12
)|&|Punctuation|&|12
;|&|Punctuation|&|12
alchemyTab|&|Identifier|&|14
=|&|Operator|&|14
new|&|Keyword|&|14
AlchemyTab|&|Identifier|&|14
(|&|Punctuation|&|14
)|&|Punctuation|&|14
;|&|Punctuation|&|14
add|&|Identifier|&|15
(|&|Punctuation|&|15
alchemyTab|&|Identifier|&|15
)|&|Punctuation|&|15
;|&|Punctuation|&|15
alchemyTab|&|Identifier|&|16
.|&|Punctuation|&|16
setRect|&|Identifier|&|16
(|&|Punctuation|&|16
0|&|Literal|&|16
,|&|Punctuation|&|16
0|&|Literal|&|16
,|&|Punctuation|&|16
width|&|Identifier|&|16
,|&|Punctuation|&|16
height|&|Identifier|&|16
)|&|Punctuation|&|16
;|&|Punctuation|&|16
notesTab|&|Identifier|&|18
=|&|Operator|&|18
new|&|Keyword|&|18
NotesTab|&|Identifier|&|18
(|&|Punctuation|&|18
)|&|Punctuation|&|18
;|&|Punctuation|&|18
add|&|Identifier|&|19
(|&|Punctuation|&|19
notesTab|&|Identifier|&|19
)|&|Punctuation|&|19
;|&|Punctuation|&|19
notesTab|&|Identifier|&|20
.|&|Punctuation|&|20
setRect|&|Identifier|&|20
(|&|Punctuation|&|20
0|&|Literal|&|20
,|&|Punctuation|&|20
0|&|Literal|&|20
,|&|Punctuation|&|20
width|&|Identifier|&|20
,|&|Punctuation|&|20
height|&|Identifier|&|20
)|&|Punctuation|&|20
;|&|Punctuation|&|20
notesTab|&|Identifier|&|21
.|&|Punctuation|&|21
updateList|&|Identifier|&|21
(|&|Punctuation|&|21
)|&|Punctuation|&|21
;|&|Punctuation|&|21
catalogTab|&|Identifier|&|23
=|&|Operator|&|23
new|&|Keyword|&|23
CatalogTab|&|Identifier|&|23
(|&|Punctuation|&|23
)|&|Punctuation|&|23
;|&|Punctuation|&|23
add|&|Identifier|&|24
(|&|Punctuation|&|24
catalogTab|&|Identifier|&|24
)|&|Punctuation|&|24
;|&|Punctuation|&|24
catalogTab|&|Identifier|&|25
.|&|Punctuation|&|25
setRect|&|Identifier|&|25
(|&|Punctuation|&|25
0|&|Literal|&|25
,|&|Punctuation|&|25
0|&|Literal|&|25
,|&|Punctuation|&|25
width|&|Identifier|&|25
,|&|Punctuation|&|25
height|&|Identifier|&|25
)|&|Punctuation|&|25
;|&|Punctuation|&|25
catalogTab|&|Identifier|&|26
.|&|Punctuation|&|26
updateList|&|Identifier|&|26
(|&|Punctuation|&|26
)|&|Punctuation|&|26
;|&|Punctuation|&|26
Tab|&|Identifier|&|28
[|&|Punctuation|&|28
]|&|Punctuation|&|28
tabs|&|Identifier|&|28
=|&|Operator|&|28
{|&|Punctuation|&|28
new|&|Keyword|&|29
IconTab|&|Identifier|&|29
(|&|Punctuation|&|29
new|&|Keyword|&|29
ItemSprite|&|Identifier|&|29
(|&|Punctuation|&|29
ItemSpriteSheet|&|Identifier|&|29
.|&|Punctuation|&|29
GUIDE_PAGE|&|Identifier|&|29
,|&|Punctuation|&|29
null|&|Keyword|&|29
)|&|Punctuation|&|29
)|&|Punctuation|&|29
{|&|Punctuation|&|29
protected|&|Keyword|&|30
void|&|Keyword|&|30
select|&|Identifier|&|30
(|&|Punctuation|&|30
boolean|&|Keyword|&|30
value|&|Identifier|&|30
)|&|Punctuation|&|30
{|&|Punctuation|&|30
super|&|Keyword|&|31
.|&|Punctuation|&|31
select|&|Identifier|&|31
(|&|Punctuation|&|31
value|&|Identifier|&|31
)|&|Punctuation|&|31
;|&|Punctuation|&|31
guideTab|&|Identifier|&|32
.|&|Punctuation|&|32
active|&|Identifier|&|32
=|&|Operator|&|32
guideTab|&|Identifier|&|32
.|&|Punctuation|&|32
visible|&|Identifier|&|32
=|&|Operator|&|32
value|&|Identifier|&|32
;|&|Punctuation|&|32
if|&|Keyword|&|33
(|&|Punctuation|&|33
value|&|Identifier|&|33
)|&|Punctuation|&|33
last_index|&|Identifier|&|33
=|&|Operator|&|33
0|&|Literal|&|33
;|&|Punctuation|&|33
}|&|Punctuation|&|34
}|&|Punctuation|&|35
,|&|Punctuation|&|35
new|&|Keyword|&|36
IconTab|&|Identifier|&|36
(|&|Punctuation|&|36
new|&|Keyword|&|36
ItemSprite|&|Identifier|&|36
(|&|Punctuation|&|36
ItemSpriteSheet|&|Identifier|&|36
.|&|Punctuation|&|36
ALCH_PAGE|&|Identifier|&|36
,|&|Punctuation|&|36
null|&|Keyword|&|36
)|&|Punctuation|&|36
)|&|Punctuation|&|36
{|&|Punctuation|&|36
protected|&|Keyword|&|37
void|&|Keyword|&|37
select|&|Identifier|&|37
(|&|Punctuation|&|37
boolean|&|Keyword|&|37
value|&|Identifier|&|37
)|&|Punctuation|&|37
{|&|Punctuation|&|37
super|&|Keyword|&|38
.|&|Punctuation|&|38
select|&|Identifier|&|38
(|&|Punctuation|&|38
value|&|Identifier|&|38
)|&|Punctuation|&|38
;|&|Punctuation|&|38
alchemyTab|&|Identifier|&|39
.|&|Punctuation|&|39
active|&|Identifier|&|39
=|&|Operator|&|39
alchemyTab|&|Identifier|&|39
.|&|Punctuation|&|39
visible|&|Identifier|&|39
=|&|Operator|&|39
value|&|Identifier|&|39
;|&|Punctuation|&|39
if|&|Keyword|&|40
(|&|Punctuation|&|40
value|&|Identifier|&|40
)|&|Punctuation|&|40
last_index|&|Identifier|&|40
=|&|Operator|&|40
1|&|Literal|&|40
;|&|Punctuation|&|40
}|&|Punctuation|&|41
}|&|Punctuation|&|42
,|&|Punctuation|&|42
new|&|Keyword|&|43
IconTab|&|Identifier|&|43
(|&|Punctuation|&|43
Icons|&|Identifier|&|43
.|&|Punctuation|&|43
get|&|Identifier|&|43
(|&|Punctuation|&|43
Icons|&|Identifier|&|43
.|&|Punctuation|&|43
DEPTH|&|Identifier|&|43
)|&|Punctuation|&|43
)|&|Punctuation|&|43
{|&|Punctuation|&|43
protected|&|Keyword|&|44
void|&|Keyword|&|44
select|&|Identifier|&|44
(|&|Punctuation|&|44
boolean|&|Keyword|&|44
value|&|Identifier|&|44
)|&|Punctuation|&|44
{|&|Punctuation|&|44
super|&|Keyword|&|45
.|&|Punctuation|&|45
select|&|Identifier|&|45
(|&|Punctuation|&|45
value|&|Identifier|&|45
)|&|Punctuation|&|45
;|&|Punctuation|&|45
notesTab|&|Identifier|&|46
.|&|Punctuation|&|46
active|&|Identifier|&|46
=|&|Operator|&|46
notesTab|&|Identifier|&|46
.|&|Punctuation|&|46
visible|&|Identifier|&|46
=|&|Operator|&|46
value|&|Identifier|&|46
;|&|Punctuation|&|46
if|&|Keyword|&|47
(|&|Punctuation|&|47
value|&|Identifier|&|47
)|&|Punctuation|&|47
last_index|&|Identifier|&|47
=|&|Operator|&|47
2|&|Literal|&|47
;|&|Punctuation|&|47
}|&|Punctuation|&|48
}|&|Punctuation|&|49
,|&|Punctuation|&|49
new|&|Keyword|&|50
IconTab|&|Identifier|&|50
(|&|Punctuation|&|50
new|&|Keyword|&|50
ItemSprite|&|Identifier|&|50
(|&|Punctuation|&|50
ItemSpriteSheet|&|Identifier|&|50
.|&|Punctuation|&|50
WEAPON_HOLDER|&|Identifier|&|50
,|&|Punctuation|&|50
null|&|Keyword|&|50
)|&|Punctuation|&|50
)|&|Punctuation|&|50
{|&|Punctuation|&|50
protected|&|Keyword|&|51
void|&|Keyword|&|51
select|&|Identifier|&|51
(|&|Punctuation|&|51
boolean|&|Keyword|&|51
value|&|Identifier|&|51
)|&|Punctuation|&|51
{|&|Punctuation|&|51
super|&|Keyword|&|52
.|&|Punctuation|&|52
select|&|Identifier|&|52
(|&|Punctuation|&|52
value|&|Identifier|&|52
)|&|Punctuation|&|52
;|&|Punctuation|&|52
catalogTab|&|Identifier|&|53
.|&|Punctuation|&|53
active|&|Identifier|&|53
=|&|Operator|&|53
catalogTab|&|Identifier|&|53
.|&|Punctuation|&|53
visible|&|Identifier|&|53
=|&|Operator|&|53
value|&|Identifier|&|53
;|&|Punctuation|&|53
if|&|Keyword|&|54
(|&|Punctuation|&|54
value|&|Identifier|&|54
)|&|Punctuation|&|54
last_index|&|Identifier|&|54
=|&|Operator|&|54
3|&|Literal|&|54
;|&|Punctuation|&|54
}|&|Punctuation|&|55
}|&|Punctuation|&|56
}|&|Punctuation|&|57
;|&|Punctuation|&|57
for|&|Keyword|&|59
(|&|Punctuation|&|59
Tab|&|Identifier|&|59
tab|&|Identifier|&|59
:|&|Operator|&|59
tabs|&|Identifier|&|59
)|&|Punctuation|&|59
{|&|Punctuation|&|59
add|&|Identifier|&|60
(|&|Punctuation|&|60
tab|&|Identifier|&|60
)|&|Punctuation|&|60
;|&|Punctuation|&|60
}|&|Punctuation|&|61
layoutTabs|&|Identifier|&|63
(|&|Punctuation|&|63
)|&|Punctuation|&|63
;|&|Punctuation|&|63
select|&|Identifier|&|65
(|&|Punctuation|&|65
last_index|&|Identifier|&|65
)|&|Punctuation|&|65
;|&|Punctuation|&|65
}|&|Punctuation|&|66
}|&|Punctuation|&|67
|&|EOF|&|67
如果用srcML输出,则是这个样子:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<unit xmlns="http://www.srcML.org/srcML/src" revision="0.9.5" language="Java" filename="Test/1/186.java-Filter.java"><class>class <name>Test</name><block>{
<constructor><specifier>public</specifier> <name>WndJournal</name><parameter_list>()</parameter_list><block>{
<decl_stmt><decl><type><name>int</name></type> <name>width</name> <init>= <expr><ternary><condition><expr><call><name><name>SPDSettings</name><operator>.</operator><name>landscape</name></name><argument_list>()</argument_list></call></expr> ?</condition><then> <expr><name>WIDTH_L</name></expr> </then><else>: <expr><name>WIDTH_P</name></expr></else></ternary></expr></init></decl>;</decl_stmt>
<decl_stmt><decl><type><name>int</name></type> <name>height</name> <init>= <expr><ternary><condition><expr><call><name><name>SPDSettings</name><operator>.</operator><name>landscape</name></name><argument_list>()</argument_list></call></expr> ?</condition><then> <expr><name>HEIGHT_L</name></expr> </then><else>: <expr><name>HEIGHT_P</name></expr></else></ternary></expr></init></decl>;</decl_stmt>
<expr_stmt><expr><call><name>resize</name><argument_list>(<argument><expr><name>width</name></expr></argument>, <argument><expr><name>height</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><name>guideTab</name> <operator>=</operator> <operator>new</operator> <call><name>GuideTab</name><argument_list>()</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><call><name>add</name><argument_list>(<argument><expr><name>guideTab</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><call><name><name>guideTab</name><operator>.</operator><name>setRect</name></name><argument_list>(<argument><expr><literal type="number">0</literal></expr></argument>, <argument><expr><literal type="number">0</literal></expr></argument>, <argument><expr><name>width</name></expr></argument>, <argument><expr><name>height</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><call><name><name>guideTab</name><operator>.</operator><name>updateList</name></name><argument_list>()</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><name>alchemyTab</name> <operator>=</operator> <operator>new</operator> <call><name>AlchemyTab</name><argument_list>()</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><call><name>add</name><argument_list>(<argument><expr><name>alchemyTab</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><call><name><name>alchemyTab</name><operator>.</operator><name>setRect</name></name><argument_list>(<argument><expr><literal type="number">0</literal></expr></argument>, <argument><expr><literal type="number">0</literal></expr></argument>, <argument><expr><name>width</name></expr></argument>, <argument><expr><name>height</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><name>notesTab</name> <operator>=</operator> <operator>new</operator> <call><name>NotesTab</name><argument_list>()</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><call><name>add</name><argument_list>(<argument><expr><name>notesTab</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><call><name><name>notesTab</name><operator>.</operator><name>setRect</name></name><argument_list>(<argument><expr><literal type="number">0</literal></expr></argument>, <argument><expr><literal type="number">0</literal></expr></argument>, <argument><expr><name>width</name></expr></argument>, <argument><expr><name>height</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><call><name><name>notesTab</name><operator>.</operator><name>updateList</name></name><argument_list>()</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><name>catalogTab</name> <operator>=</operator> <operator>new</operator> <call><name>CatalogTab</name><argument_list>()</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><call><name>add</name><argument_list>(<argument><expr><name>catalogTab</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><call><name><name>catalogTab</name><operator>.</operator><name>setRect</name></name><argument_list>(<argument><expr><literal type="number">0</literal></expr></argument>, <argument><expr><literal type="number">0</literal></expr></argument>, <argument><expr><name>width</name></expr></argument>, <argument><expr><name>height</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><call><name><name>catalogTab</name><operator>.</operator><name>updateList</name></name><argument_list>()</argument_list></call></expr>;</expr_stmt>
<decl_stmt><decl><type><name><name>Tab</name><index>[]</index></name></type> <name>tabs</name> <init>= <expr><block>{
<expr><operator>new</operator> <class><super><name>IconTab</name></super><argument_list>( <argument><expr><operator>new</operator> <call><name>ItemSprite</name><argument_list>(<argument><expr><name><name>ItemSpriteSheet</name><operator>.</operator><name>GUIDE_PAGE</name></name></expr></argument>, <argument><expr><literal type="null">null</literal></expr></argument>)</argument_list></call></expr></argument> )</argument_list> <block>{
<function><specifier>protected</specifier> <type><name>void</name></type> <name>select</name><parameter_list>( <parameter><decl><type><name>boolean</name></type> <name>value</name></decl></parameter> )</parameter_list> <block>{
<expr_stmt><expr><call><name><name>super</name><operator>.</operator><name>select</name></name><argument_list>( <argument><expr><name>value</name></expr></argument> )</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><name><name>guideTab</name><operator>.</operator><name>active</name></name> <operator>=</operator> <name><name>guideTab</name><operator>.</operator><name>visible</name></name> <operator>=</operator> <name>value</name></expr>;</expr_stmt>
<if>if <condition>(<expr><name>value</name></expr>)</condition><then> <block type="pseudo"><expr_stmt><expr><name>last_index</name> <operator>=</operator> <literal type="number">0</literal></expr>;</expr_stmt></block></then></if>
<expr_stmt/>}</block>
}<operator>,</operator>
new IconTab<parameter_list>( <parameter><decl/></parameter></parameter_list>new ItemSprite<parameter_list>(<parameter><decl><type><name><name>ItemSpriteSheet</name><operator>.</operator><name>ALCH_PAGE</name></name></type></decl></parameter>, <parameter/></parameter_list>null</function>)</block></class></expr> ) <block>{
<expr><specifier>protected</specifier> <name>void</name> <call><name>select</name><argument_list>( <argument><expr><name>boolean</name> <name>value</name></expr></argument> )</argument_list></call> <block>{
<expr><call><name><name>super</name><operator>.</operator><name>select</name></name><argument_list>( <argument><expr><name>value</name></expr></argument> )</argument_list></call></expr>;
<expr><name><name>alchemyTab</name><operator>.</operator><name>active</name></name> <operator>=</operator> <name><name>alchemyTab</name><operator>.</operator><name>visible</name></name> <operator>=</operator> <name>value</name></expr>;
<if>if <condition>(<expr><name>value</name></expr>)</condition><then> <block type="pseudo"><expr_stmt><expr><name>last_index</name> <operator>=</operator> <literal type="number">1</literal></expr>;</expr_stmt></block></then></if>
}</block>
}</expr>,
<expr><operator>new</operator> <class><super><name>IconTab</name></super><argument_list>( <argument><expr><call><name><name>Icons</name><operator>.</operator><name>get</name></name><argument_list>(<argument><expr><name><name>Icons</name><operator>.</operator><name>DEPTH</name></name></expr></argument>)</argument_list></call></expr></argument> )</argument_list> <block>{
<function><specifier>protected</specifier> <type><name>void</name></type> <name>select</name><parameter_list>( <parameter><decl><type><name>boolean</name></type> <name>value</name></decl></parameter> )</parameter_list> <block>{
<expr_stmt><expr><call><name><name>super</name><operator>.</operator><name>select</name></name><argument_list>( <argument><expr><name>value</name></expr></argument> )</argument_list></call></expr>;</expr_stmt>
<expr_stmt><expr><name><name>notesTab</name><operator>.</operator><name>active</name></name> <operator>=</operator> <name><name>notesTab</name><operator>.</operator><name>visible</name></name> <operator>=</operator> <name>value</name></expr>;</expr_stmt>
<if>if <condition>(<expr><name>value</name></expr>)</condition><then> <block type="pseudo"><expr_stmt><expr><name>last_index</name> <operator>=</operator> <literal type="number">2</literal></expr>;</expr_stmt></block></then></if>
<expr_stmt/>}</block>
}<operator>,</operator>
new IconTab<parameter_list>( <parameter><decl/></parameter></parameter_list>new ItemSprite<parameter_list>(<parameter><decl><type><name><name>ItemSpriteSheet</name><operator>.</operator><name>WEAPON_HOLDER</name></name></type></decl></parameter>, <parameter/></parameter_list>null</function>)</block></class></expr> ) <block>{
<expr><specifier>protected</specifier> <name>void</name> <call><name>select</name><argument_list>( <argument><expr><name>boolean</name> <name>value</name></expr></argument> )</argument_list></call> <block>{
<expr><call><name><name>super</name><operator>.</operator><name>select</name></name><argument_list>( <argument><expr><name>value</name></expr></argument> )</argument_list></call></expr>;
<expr><name><name>catalogTab</name><operator>.</operator><name>active</name></name> <operator>=</operator> <name><name>catalogTab</name><operator>.</operator><name>visible</name></name> <operator>=</operator> <name>value</name></expr>;
<if>if <condition>(<expr><name>value</name></expr>)</condition><then> <block type="pseudo"><expr_stmt><expr><name>last_index</name> <operator>=</operator> <literal type="number">3</literal></expr>;</expr_stmt></block></then></if>
}</block>
}
}</expr>;
<for>for <control>(<init><decl><type><name>Tab</name></type> <name>tab</name> <range>: <expr><name>tabs</name></expr></range></decl></init>)</control> <block>{
<expr_stmt><expr><call><name>add</name><argument_list>( <argument><expr><name>tab</name></expr></argument> )</argument_list></call></expr>;</expr_stmt>
<expr_stmt/>}</block>
<expr_stmt><expr><call><name>layoutTabs</name><argument_list>()</argument_list></call></expr>;</expr_stmt></for>
<call><name>select</name><argument_list>(<argument><expr><name>last_index</name></expr></argument>)</argument_list></call></block></block></block></expr></init></decl>;</decl_stmt>
}</block></constructor>
}</block></class>
</unit>
区别在于:像new ItemSprite这种,srcML有些地方会当成一个token!