Skip to content

Commit d3b2dd7

Browse files
committed
Vala: tag methods defined as parts of an enum
Signed-off-by: Masatake YAMATO <[email protected]>
1 parent d74f495 commit d3b2dd7

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

Units/parser-vala.r/enum.vala.d/expected.tags

+5
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ RELEASE_MASK input.vala /^ RELEASE_MASK = 1 << 30$/;" v enum:Skk.Modifier
2222
ModifierType2 input.vala /^ public enum ModifierType2 {$/;" e namespace:Skk
2323
ULTRA_MASK input.vala /^ ULTRA_MASK = 1 << 20,$/;" v enum:Skk.ModifierType2
2424
MIRACLE_MASK input.vala /^ MIRACLE_MASK = 1 << 21, \/\/ valac accept this.$/;" v enum:Skk.ModifierType2
25+
ModifierType3 input.vala /^ public enum ModifierType3 {$/;" e namespace:Skk
26+
A_MASK input.vala /^ A_MASK = 1 << 29,$/;" v enum:Skk.ModifierType3
27+
B_MASK input.vala /^ B_MASK = 1 << 31;$/;" v enum:Skk.ModifierType3
28+
to_string0 input.vala /^ string to_string0() {$/;" m enum:Skk.ModifierType3
29+
to_string1 input.vala /^ string to_string1() {$/;" m enum:Skk.ModifierType3
2530
KeyEvent input.vala /^ public class KeyEvent : Object {$/;" c namespace:Skk

Units/parser-vala.r/enum.vala.d/input.vala

+11
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ namespace Skk {
5858
MIRACLE_MASK = 1 << 21, // valac accept this.
5959
}
6060

61+
public enum ModifierType3 {
62+
A_MASK = 1 << 29,
63+
B_MASK = 1 << 31;
64+
string to_string0() {
65+
return "";
66+
}
67+
string to_string1() {
68+
return "";
69+
}
70+
}
71+
6172
/**
6273
* Object representing a key event.
6374
*/

parsers/vala.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ static void parseInterface (tokenInfo *const token, int corkIndex);
282282
static void parseClass (tokenInfo *const token, int kindIndex, int corkIndex);
283283
static void parseStatement (tokenInfo *const token, int corkIndex);
284284
static void parseEnum (tokenInfo *const token, int kindIndex, int elementKindIndex, int corkIndex);
285+
static void recurseValaTags (tokenInfo *token, int parentIndex);
285286

286287

287288
/*
@@ -575,7 +576,7 @@ static void parseEnumBody (tokenInfo *const token, int kindIndex, int corkIndex)
575576
if (tokenIsType (token, IDENTIFIER))
576577
{
577578
makeSimpleTagFromToken (token, kindIndex, corkIndex);
578-
tokenType endMakers [] = {',', '}'};
579+
tokenType endMakers [] = {',', ';', '}'};
579580
if (tokenSkipToTypesOverPairs (token, endMakers, ARRAY_SIZE(endMakers)))
580581
{
581582
if (tokenIsTypeVal (token, ','))
@@ -590,6 +591,19 @@ static void parseEnumBody (tokenInfo *const token, int kindIndex, int corkIndex)
590591

591592
if (tokenIsTypeVal (token, '}'))
592593
break;
594+
else if (tokenIsTypeVal (token, ';'))
595+
{
596+
bool t = trianglePairState;
597+
do
598+
{
599+
tokenRead (token);
600+
if (tokenIsTypeVal (token, '}'))
601+
break;
602+
recurseValaTags (token, corkIndex);
603+
} while (!tokenIsEOF (token));
604+
trianglePairState = t;
605+
break;
606+
}
593607
}
594608
else
595609
break;

0 commit comments

Comments
 (0)