Skip to content

Commit 8794f50

Browse files
committed
fix inline test
1 parent bfa3454 commit 8794f50

File tree

4 files changed

+206
-57
lines changed

4 files changed

+206
-57
lines changed

src/tests/simple_inline_test/inline.mbt

Lines changed: 118 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,17 @@ fn yy_action_1(_last_pos : Position, _args : ArrayView[(YYObj, Position, Positio
7878
}
7979

8080
// file:///./inline.mbty
81-
// 14| a=a b=b x b { a + b + $3 + $4 }
81+
// 14| a=a b=b x x b { a + b + $3 + $4 + $5 }
8282
fn yy_action_2(_last_pos : Position, _args : ArrayView[(YYObj, Position, Position)]) -> YYObj {
8383
let _sub_action_0_result = yy_action_0(_last_pos, _args[0:1])
84+
let _sub_action_3_result = yy_action_1(_args[2].2, _args[3:4])
8485
let _sub_action_2_result = yy_action_3(_args[1].2, _args[2:3])
8586
guard _sub_action_0_result is YYObj_String(a)
8687
guard _args[1].0 is YYObj_String(b)
8788
guard _sub_action_2_result is YYObj_String(_dollar3)
88-
guard _args[3].0 is YYObj_String(_dollar4)
89-
YYObj_String({(); a + b + _dollar3 + _dollar4 })
89+
guard _sub_action_3_result is YYObj_String(_dollar4)
90+
guard _args[4].0 is YYObj_String(_dollar5)
91+
YYObj_String({(); a + b + _dollar3 + _dollar4 + _dollar5 })
9092
}
9193

9294
// file:///./inline.mbty
@@ -95,22 +97,52 @@ fn yy_action_4(_last_pos : Position, _args : ArrayView[(YYObj, Position, Positio
9597
YYObj_String({(); "b" })
9698
}
9799

100+
// file:///./inline.mbty
101+
// 14| a=a b=b x x b { a + b + $3 + $4 + $5 }
102+
fn yy_action_5(_last_pos : Position, _args : ArrayView[(YYObj, Position, Position)]) -> YYObj {
103+
let _sub_action_0_result = yy_action_0(_last_pos, _args[0:1])
104+
let _sub_action_3_result = yy_action_3(_args[2].2, _args[3:4])
105+
let _sub_action_2_result = yy_action_1(_args[1].2, _args[2:3])
106+
guard _sub_action_0_result is YYObj_String(a)
107+
guard _args[1].0 is YYObj_String(b)
108+
guard _sub_action_2_result is YYObj_String(_dollar3)
109+
guard _sub_action_3_result is YYObj_String(_dollar4)
110+
guard _args[4].0 is YYObj_String(_dollar5)
111+
YYObj_String({(); a + b + _dollar3 + _dollar4 + _dollar5 })
112+
}
113+
98114
// file:///./inline.mbty
99115
// 27| B { "b" }
100116
fn yy_action_3(_last_pos : Position, _args : ArrayView[(YYObj, Position, Position)]) -> YYObj {
101117
YYObj_String({(); "b" })
102118
}
103119

104120
// file:///./inline.mbty
105-
// 14| a=a b=b x b { a + b + $3 + $4 }
106-
fn yy_action_5(_last_pos : Position, _args : ArrayView[(YYObj, Position, Position)]) -> YYObj {
121+
// 14| a=a b=b x x b { a + b + $3 + $4 + $5 }
122+
fn yy_action_6(_last_pos : Position, _args : ArrayView[(YYObj, Position, Position)]) -> YYObj {
123+
let _sub_action_0_result = yy_action_0(_last_pos, _args[0:1])
124+
let _sub_action_3_result = yy_action_3(_args[2].2, _args[3:4])
125+
let _sub_action_2_result = yy_action_3(_args[1].2, _args[2:3])
126+
guard _sub_action_0_result is YYObj_String(a)
127+
guard _args[1].0 is YYObj_String(b)
128+
guard _sub_action_2_result is YYObj_String(_dollar3)
129+
guard _sub_action_3_result is YYObj_String(_dollar4)
130+
guard _args[4].0 is YYObj_String(_dollar5)
131+
YYObj_String({(); a + b + _dollar3 + _dollar4 + _dollar5 })
132+
}
133+
134+
// file:///./inline.mbty
135+
// 14| a=a b=b x x b { a + b + $3 + $4 + $5 }
136+
fn yy_action_7(_last_pos : Position, _args : ArrayView[(YYObj, Position, Position)]) -> YYObj {
107137
let _sub_action_0_result = yy_action_0(_last_pos, _args[0:1])
138+
let _sub_action_3_result = yy_action_1(_args[2].2, _args[3:4])
108139
let _sub_action_2_result = yy_action_1(_args[1].2, _args[2:3])
109140
guard _sub_action_0_result is YYObj_String(a)
110141
guard _args[1].0 is YYObj_String(b)
111142
guard _sub_action_2_result is YYObj_String(_dollar3)
112-
guard _args[3].0 is YYObj_String(_dollar4)
113-
YYObj_String({(); a + b + _dollar3 + _dollar4 })
143+
guard _sub_action_3_result is YYObj_String(_dollar4)
144+
guard _args[4].0 is YYObj_String(_dollar5)
145+
YYObj_String({(); a + b + _dollar3 + _dollar4 + _dollar5 })
114146
}
115147

116148
fn yy_input(token : Token, _start_pos : Position, _end_pos : Position) -> (YYSymbol, YYObj) {
@@ -120,9 +152,11 @@ fn yy_input(token : Token, _start_pos : Position, _end_pos : Position) -> (YYSym
120152
}
121153
}
122154

123-
// [0, start → • A b A b, $]
124-
// [1, start → • A b B b, $]
125-
// [3, start_prime → • start, $]
155+
// [0, start → • A b A A b, $]
156+
// [1, start → • A b A B b, $]
157+
// [2, start → • A b B A b, $]
158+
// [3, start → • A b B B b, $]
159+
// [5, start_prime → • start, $]
126160
fn yy_state_0(_lookahead : YYSymbol) -> YYDecision {
127161
match _lookahead {
128162
NT_start => Shift(yy_state_1)
@@ -131,14 +165,16 @@ fn yy_state_0(_lookahead : YYSymbol) -> YYDecision {
131165
}
132166
}
133167

134-
// [3, start_prime → start •, $]
168+
// [5, start_prime → start •, $]
135169
fn yy_state_1(_lookahead : YYSymbol) -> YYDecision {
136170
Accept
137171
}
138172

139-
// [0, start → A • b A b, $]
140-
// [1, start → A • b B b, $]
141-
// [2, b → • B, A / B]
173+
// [0, start → A • b A A b, $]
174+
// [1, start → A • b A B b, $]
175+
// [2, start → A • b B A b, $]
176+
// [3, start → A • b B B b, $]
177+
// [4, b → • B, A / B]
142178
fn yy_state_2(_lookahead : YYSymbol) -> YYDecision {
143179
match _lookahead {
144180
T_B => Shift(yy_state_3)
@@ -147,49 +183,101 @@ fn yy_state_2(_lookahead : YYSymbol) -> YYDecision {
147183
}
148184
}
149185

150-
// [2, b → B •, $ / A / B]
186+
// [4, b → B •, $ / A / B]
151187
fn yy_state_3(_lookahead : YYSymbol) -> YYDecision {
152188
ReduceNoLookahead(1, NT_b, yy_action_4)
153189
}
154190

155-
// [0, start → A b • A b, $]
156-
// [1, start → A b • B b, $]
191+
// [0, start → A b • A A b, $]
192+
// [1, start → A b • A B b, $]
193+
// [2, start → A b • B A b, $]
194+
// [3, start → A b • B B b, $]
157195
fn yy_state_4(_lookahead : YYSymbol) -> YYDecision {
158196
match _lookahead {
159197
T_B => Shift(yy_state_5)
160-
T_A => Shift(yy_state_7)
198+
T_A => Shift(yy_state_10)
161199
_ => Error
162200
}
163201
}
164202

165-
// [1, start → A b B • b, $]
166-
// [2, b → • B, $]
203+
// [2, start → A b B • A b, $]
204+
// [3, startA b B • B b, $]
167205
fn yy_state_5(_lookahead : YYSymbol) -> YYDecision {
168206
match _lookahead {
169-
T_B => Shift(yy_state_3)
170-
NT_b => Shift(yy_state_6)
207+
T_B => Shift(yy_state_6)
208+
T_A => Shift(yy_state_8)
171209
_ => Error
172210
}
173211
}
174212

175-
// [1, start → A b B b •, $]
213+
// [3, start → A b B B • b, $]
214+
// [4, b → • B, $]
176215
fn yy_state_6(_lookahead : YYSymbol) -> YYDecision {
177-
ReduceNoLookahead(4, NT_start, yy_action_2)
216+
match _lookahead {
217+
T_B => Shift(yy_state_3)
218+
NT_b => Shift(yy_state_7)
219+
_ => Error
220+
}
178221
}
179222

180-
// [0, start → A b A • b, $]
181-
// [2, b → • B, $]
223+
// [3, start → A b B B b •, $]
182224
fn yy_state_7(_lookahead : YYSymbol) -> YYDecision {
225+
ReduceNoLookahead(5, NT_start, yy_action_6)
226+
}
227+
228+
// [2, start → A b B A • b, $]
229+
// [4, b → • B, $]
230+
fn yy_state_8(_lookahead : YYSymbol) -> YYDecision {
183231
match _lookahead {
184232
T_B => Shift(yy_state_3)
185-
NT_b => Shift(yy_state_8)
233+
NT_b => Shift(yy_state_9)
186234
_ => Error
187235
}
188236
}
189237

190-
// [0, start → A b A b •, $]
191-
fn yy_state_8(_lookahead : YYSymbol) -> YYDecision {
192-
ReduceNoLookahead(4, NT_start, yy_action_5)
238+
// [2, start → A b B A b •, $]
239+
fn yy_state_9(_lookahead : YYSymbol) -> YYDecision {
240+
ReduceNoLookahead(5, NT_start, yy_action_2)
241+
}
242+
243+
// [0, start → A b A • A b, $]
244+
// [1, start → A b A • B b, $]
245+
fn yy_state_10(_lookahead : YYSymbol) -> YYDecision {
246+
match _lookahead {
247+
T_B => Shift(yy_state_11)
248+
T_A => Shift(yy_state_13)
249+
_ => Error
250+
}
251+
}
252+
253+
// [1, start → A b A B • b, $]
254+
// [4, b → • B, $]
255+
fn yy_state_11(_lookahead : YYSymbol) -> YYDecision {
256+
match _lookahead {
257+
T_B => Shift(yy_state_3)
258+
NT_b => Shift(yy_state_12)
259+
_ => Error
260+
}
261+
}
262+
263+
// [1, start → A b A B b •, $]
264+
fn yy_state_12(_lookahead : YYSymbol) -> YYDecision {
265+
ReduceNoLookahead(5, NT_start, yy_action_5)
266+
}
267+
268+
// [0, start → A b A A • b, $]
269+
// [4, b → • B, $]
270+
fn yy_state_13(_lookahead : YYSymbol) -> YYDecision {
271+
match _lookahead {
272+
T_B => Shift(yy_state_3)
273+
NT_b => Shift(yy_state_14)
274+
_ => Error
275+
}
276+
}
277+
278+
// [0, start → A b A A b •, $]
279+
fn yy_state_14(_lookahead : YYSymbol) -> YYDecision {
280+
ReduceNoLookahead(5, NT_start, yy_action_7)
193281
}
194282

195283
fn yy_parse[T](

src/tests/simple_inline_test/inline.mbt.map.json

Lines changed: 78 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,122 @@
22
"mappings": [
33
{
44
"source": "inline.mbty",
5-
"original_offset": 170,
5+
"original_offset": 177,
66
"generated_offset": 1172,
77
"length": 5
88
},
99
{
1010
"source": "inline.mbty",
11-
"original_offset": 220,
11+
"original_offset": 227,
1212
"generated_offset": 1344,
1313
"length": 5
1414
},
1515
{
1616
"source": "inline.mbty",
17-
"original_offset": 129,
18-
"generated_offset": 1853,
17+
"original_offset": 131,
18+
"generated_offset": 1980,
1919
"length": 9
2020
},
2121
{
2222
"source": "inline.mbty",
23-
"original_offset": 140,
24-
"generated_offset": 1870,
23+
"original_offset": 142,
24+
"generated_offset": 1997,
2525
"length": 3
2626
},
2727
{
2828
"source": "inline.mbty",
29-
"original_offset": 145,
30-
"generated_offset": 1881,
29+
"original_offset": 147,
30+
"generated_offset": 2008,
31+
"length": 3
32+
},
33+
{
34+
"source": "inline.mbty",
35+
"original_offset": 152,
36+
"generated_offset": 2019,
3137
"length": 1
3238
},
3339
{
3440
"source": "inline.mbty",
35-
"original_offset": 191,
36-
"generated_offset": 2049,
41+
"original_offset": 198,
42+
"generated_offset": 2187,
3743
"length": 5
3844
},
3945
{
4046
"source": "inline.mbty",
41-
"original_offset": 234,
42-
"generated_offset": 2221,
47+
"original_offset": 131,
48+
"generated_offset": 2823,
49+
"length": 9
50+
},
51+
{
52+
"source": "inline.mbty",
53+
"original_offset": 142,
54+
"generated_offset": 2840,
55+
"length": 3
56+
},
57+
{
58+
"source": "inline.mbty",
59+
"original_offset": 147,
60+
"generated_offset": 2851,
61+
"length": 3
62+
},
63+
{
64+
"source": "inline.mbty",
65+
"original_offset": 152,
66+
"generated_offset": 2862,
67+
"length": 1
68+
},
69+
{
70+
"source": "inline.mbty",
71+
"original_offset": 241,
72+
"generated_offset": 3030,
4373
"length": 5
4474
},
4575
{
4676
"source": "inline.mbty",
47-
"original_offset": 129,
48-
"generated_offset": 2730,
77+
"original_offset": 131,
78+
"generated_offset": 3666,
4979
"length": 9
5080
},
5181
{
5282
"source": "inline.mbty",
53-
"original_offset": 140,
54-
"generated_offset": 2747,
83+
"original_offset": 142,
84+
"generated_offset": 3683,
85+
"length": 3
86+
},
87+
{
88+
"source": "inline.mbty",
89+
"original_offset": 147,
90+
"generated_offset": 3694,
91+
"length": 3
92+
},
93+
{
94+
"source": "inline.mbty",
95+
"original_offset": 152,
96+
"generated_offset": 3705,
97+
"length": 1
98+
},
99+
{
100+
"source": "inline.mbty",
101+
"original_offset": 131,
102+
"generated_offset": 4337,
103+
"length": 9
104+
},
105+
{
106+
"source": "inline.mbty",
107+
"original_offset": 142,
108+
"generated_offset": 4354,
109+
"length": 3
110+
},
111+
{
112+
"source": "inline.mbty",
113+
"original_offset": 147,
114+
"generated_offset": 4365,
55115
"length": 3
56116
},
57117
{
58118
"source": "inline.mbty",
59-
"original_offset": 145,
60-
"generated_offset": 2758,
119+
"original_offset": 152,
120+
"generated_offset": 4376,
61121
"length": 1
62122
}
63123
]

src/tests/simple_inline_test/inline.mbty

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
%%
1212

1313
start
14-
: a=a b=b x b { a + b + $3 + $4 }
14+
: a=a b=b x x b { a + b + $3 + $4 + $5 }
1515
;
1616

1717
%inline a

0 commit comments

Comments
 (0)