forked from B-Lang-org/bsc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pretty-print
let
s with surrounding braces
The pretty-printer for `letseq` and `letrec` was not adding braces around the variables being bound, resulting in malformed pretty-printed output such as `letseq hw = "Hello, World!";; ...`. After adding braces, this now becomes `letseq { hw = "Hello, World!"; };`, which is valid Bluespec code. Fixes B-Lang-org#529.
- Loading branch information
1 parent
de3a575
commit 07e4507
Showing
5 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.bs-pretty-out.bs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package Bug529 where | ||
|
||
helloWorld :: Module Empty | ||
helloWorld = | ||
module | ||
rules | ||
"hello_world": when True ==> do | ||
-- let(rec) and letseq expressions | ||
let hello1 :: String | ||
hello1 = let hello = "Hello, " | ||
in hello | ||
|
||
world1 :: String | ||
world1 = letseq world = "World!" | ||
in world | ||
$display (hello1 +++ world1) | ||
|
||
-- let(rec) and letseq statements | ||
let hello2 = "Hello, " | ||
letseq world2 = "World!" | ||
$display (hello2 +++ world2) | ||
|
||
$finish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# for "make clean" to work everywhere | ||
|
||
CONFDIR = $(realpath ../..) | ||
|
||
include $(CONFDIR)/clean.mk | ||
|
||
DONTKEEPFILES = *.bs-pretty-out.bs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
# tests for Bluespec Haskell syntax | ||
# parse - prettyprint - parse loop | ||
|
||
proc bsc_compile_prettyprint_parse { source { options "" } } { | ||
if [bsc_compile $source "$options -dparsed=${source}-pretty-out.bs"] then { | ||
return [bsc_compile "$source-pretty-out.bs" $options] | ||
} else { | ||
return 0 | ||
} | ||
} | ||
|
||
proc compile_ppp_pass { source {options ""} } { | ||
incr_stat "compile_ppp_pass" | ||
if [bsc_compile_prettyprint_parse $source $options] { | ||
pass "`$source' compiles, pretty-prints, and compiles again" | ||
} else { | ||
fail "`$source' should compile, pretty-print, and compile again" | ||
} | ||
} | ||
|
||
proc compile_ppp_pass_bug { source {bug ""} {options ""}} { | ||
global target_triplet | ||
setup_xfail $target_triplet $bug | ||
compile_ppp_pass $source $options | ||
} | ||
|
||
# let bindings | ||
compile_ppp_pass Bug529.bs |