Skip to content

Commit 536256c

Browse files
committed
Fix bug with parsing statement after a 'var' decl
1 parent 56a202d commit 536256c

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

hintegration_results.md

+19
Original file line numberDiff line numberDiff line change
@@ -800,4 +800,23 @@ Expected output:
800800
No issues
801801
```
802802

803+
---
804+
### test/DinersVar.hny
805+
806+
Average duration: 0.3950159549713135
807+
808+
Expected output:
809+
```
810+
#states 9095
811+
1700 components, 1 bad states
812+
Non-terminating state
813+
T0: __init__() [0-5,369-371,1047-1051,769-773,762-767,774,775,1052-1056,1102-1113,1104-1113,1104-1113,1104-1113,1104-1113,1104-1106,1114,1115] { bag: (), forks: [ False, False, False, False, False ], list: (), synch: () }
814+
T1: diner(0) [1057-1072(choose True),1073-1078,785-788,727-738,789-791,1079-1084,785-788,727-730] { bag: (), forks: [ True, False, False, False, False ], list: (), synch: () }
815+
T2: diner(1) [1057-1072(choose True),1073-1078,785-788,727-738,789-791,1079-1084,785-788,727-730] { bag: (), forks: [ True, True, False, False, False ], list: (), synch: () }
816+
T3: diner(2) [1057-1072(choose True),1073-1078,785-788,727-738,789-791,1079-1084,785-788,727-730] { bag: (), forks: [ True, True, True, False, False ], list: (), synch: () }
817+
T4: diner(3) [1057-1072(choose True),1073-1078,785-788,727-738,789-791,1079-1084,785-788,727-730] { bag: (), forks: [ True, True, True, True, False ], list: (), synch: () }
818+
T5: diner(4) [1057-1072(choose True),1073-1078,785-788,727-738,789-791,1079-1084,785-788,727-730] { bag: (), forks: [ True, True, True, True, True ], list: (), synch: () }
819+
820+
```
821+
803822
---

hintegration_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def __init__(
9393
TestCase('-msynch=synchS code/trap6.hny'),
9494
TestCase('code/hw.hny'),
9595
TestCase('code/abptest.hny'),
96+
TestCase('test/DinersVar.hny'),
9697
]
9798

9899

src/harmony/harmony.m4

+4-2
Original file line numberDiff line numberDiff line change
@@ -4544,14 +4544,16 @@ class StatementRule(Rule):
45444544
(bv, t) = BoundVarRule().parse(t[1:])
45454545
(lexeme, file, line, nextColumn) = t[0]
45464546
self.expect("var statement", lexeme == "=", t[0], "expected '='")
4547+
t = t[1:]
45474548
45484549
same_line = []
4549-
for tok in t[1:]:
4550+
for tok in t:
45504551
if tok[2] != line:
45514552
break
45524553
same_line.append(tok)
45534554
4554-
(ast, t) = TupleRule(set()).parse(same_line)
4555+
t = t[len(same_line):]
4556+
(ast, _) = TupleRule(set()).parse(same_line)
45554557
vars.append((bv, ast))
45564558
return (VarAST(token, vars), t)
45574559

test/DinersVar.hny

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from synch import Lock, acquire, release
2+
3+
const N = 5
4+
5+
forks = [Lock(),] * N
6+
7+
def diner(which):
8+
# let left, right = (which, (which + 1) % N):
9+
var left, right = (which, (which + 1) % N)
10+
while choose({ False, True }):
11+
acquire(?forks[left])
12+
acquire(?forks[right])
13+
# dine
14+
release(?forks[left])
15+
release(?forks[right])
16+
# think
17+
18+
for i in {0..N-1}:
19+
spawn diner(i)
20+

0 commit comments

Comments
 (0)