Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/robin/gh-1810-nested-lah-s…
Browse files Browse the repository at this point in the history
…witch'

* origin/topic/robin/gh-1810-nested-lah-switch:
  Update CHANGES. [skip ci]
  Fix nested look-ahead switches.
  • Loading branch information
rsmmr committed Jul 30, 2024
2 parents 4c5c26b + e4ce31b commit fd2c889
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.11.0-dev.282 | 2024-07-30 17:02:31 +0200

* GH-1810: Fix nested look-ahead switches. (Robin Sommer, Corelight)

1.11.0-dev.279 | 2024-07-26 12:47:30 +0200

* GH-1808: Fix non-converging optimizer pass for used functions. (Benjamin Bannier, Corelight)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.0-dev.279
1.11.0-dev.282
1 change: 1 addition & 0 deletions spicy/toolchain/src/compiler/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,7 @@ unit_switch_case
| exprs ARROW unit_item { $$ = builder->typeUnitItemSwitchCase($1, {$3}, __loc__); }
| '*' ARROW unit_item { $$ = builder->typeUnitItemSwitchCase(type::unit::Items{$3}, __loc__); }
| ARROW unit_field { $$ = builder->typeUnitItemSwitchCase($2, __loc__); }
| ARROW unit_switch { $$ = builder->typeUnitItemSwitchCase($2, __loc__); }

/* --- End of Spicy units --- */

Expand Down
11 changes: 11 additions & 0 deletions tests/Baseline/spicy.types.unit.switch-nested-lahead/output
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
foo::X {
a: a
}
foo::X {
b: b
}
foo::X {
c: c
}
[fatal error] terminating with uncaught exception of type spicy::rt::ParseError: no expected look-ahead token found (<...>/switch-nested-lahead.spicy:18:10-18:20)
20 changes: 20 additions & 0 deletions tests/spicy/types/unit/switch-nested-lahead.spicy
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# @TEST-EXEC: spicyc %INPUT -j -o %INPUT.hlto
# @TEST-EXEC: ${SCRIPTS}/printf a | spicy-dump %INPUT.hlto >>output 2>&1
# @TEST-EXEC: ${SCRIPTS}/printf b | spicy-dump %INPUT.hlto >>output 2>&1
# @TEST-EXEC: ${SCRIPTS}/printf c | spicy-dump %INPUT.hlto >>output 2>&1
# @TEST-EXEC-FAIL: ${SCRIPTS}/printf d | spicy-dump %INPUT.hlto >>output 2>&1
# @TEST-EXEC: btest-diff output
#
# @TEST-DOC: Check nested switch constructs both using look-ahead.

module foo;

public type X = unit {
switch {
-> switch {
-> a: b"a";
-> b: b"b";
};
-> c: b"c";
};
};

0 comments on commit fd2c889

Please # to comment.