From 93d6018f23df78d95a8e15422a04aae0395bb0e5 Mon Sep 17 00:00:00 2001 From: Amir Hesamian Date: Mon, 10 Aug 2026 12:10:59 -0500 Subject: [PATCH 1/3] simple-snc improvements --- examples/simple-snc.aps | 47 +++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/examples/simple-snc.aps b/examples/simple-snc.aps index 3c6f9937..8936980a 100644 --- a/examples/simple-snc.aps +++ b/examples/simple-snc.aps @@ -1,30 +1,34 @@ with "simple"; -- Simple example of SNC module SIMPLE_SNC[T :: var SIMPLE[]] extends T begin - attribute Expr.i1 : Integer; - attribute Expr.i2 : Integer; - attribute Expr.s1 : Integer; - attribute Expr.s2 : Integer; + attribute Expr.expr_i1 : Integer; + attribute Expr.expr_i2 : Integer; + attribute Expr.expr_s1 : Integer; + attribute Expr.expr_s2 : Integer; - attribute Stmt.total : Integer; + attribute Block.block_total : Integer; + attribute Stmt.stmt_total : Integer; + attribute Stmts.stmts_total : Integer; + attribute Program.program_total : Integer; - pragma inherited(i1,i2); - pragma synthesized(s1,s2,total); + pragma inherited(expr_i1, expr_i2); + pragma synthesized(expr_s1, expr_s2, block_total, stmt_total, stmts_total, program_total); match ?s:Stmt=assign_stmt(?e1:Expr,?e2:Expr) begin - e1.i1 := 0; - e1.i2 := e1.s1; - e2.i2 := 0; - e2.i1 := e2.s2; - s.total := e1.s2 + e2.s1; + e1.expr_i1 := 0; + e1.expr_i2 := e1.expr_s1; + e2.expr_i2 := 0; + e2.expr_i1 := e2.expr_s2; + s.stmt_total := e1.expr_s2 + e2.expr_s1; end; match ?e:Expr=intconstant(?i:Integer) begin - e.s1 := e.i1; - e.s2 := e.i2; + e.expr_s1 := e.expr_i1; + e.expr_s2 := e.expr_i2; end; match ?b:Block=block(?ds:Decls,?ss:Stmts) begin + b.block_total := ss.stmts_total; end; match ?ds:Decls=no_decls() begin @@ -37,6 +41,7 @@ module SIMPLE_SNC[T :: var SIMPLE[]] extends T begin end; match ?p:Program=program(?b:Block) begin + p.program_total := b.block_total; end; match ?t:Type=integer_type() begin @@ -45,23 +50,25 @@ module SIMPLE_SNC[T :: var SIMPLE[]] extends T begin match ?t:Type=string_type() begin end; - match ?:Stmts=no_stmts() begin + match ?ss:Stmts=no_stmts() begin + ss.stmts_total := 0; end; match ?ss0:Stmts=xcons_stmts(?ss1:Stmts,?s:Stmt) begin + ss0.stmts_total := ss1.stmts_total + s.stmt_total; end; match ?s:Stmt=block_stmt(?b:Block) begin - s.total := 0; + s.stmt_total := 0; end; match ?e:Expr=strconstant(?:String) begin - e.s1 := 0; - e.s2 := 0; + e.expr_s1 := 0; + e.expr_s2 := 0; end; match ?e:Expr=variable(?id:String) begin - e.s1 := 0; - e.s2 := 0; + e.expr_s1 := 0; + e.expr_s2 := 0; end; end; From 8cdd224d4e4cca49f9cb41dd08098ba84dd8c869 Mon Sep 17 00:00:00 2001 From: Amir Hesamian Date: Mon, 10 Aug 2026 19:59:56 +0000 Subject: [PATCH 2/3] simple-snc driver --- examples/scala/Makefile | 12 +++++- examples/scala/README | 1 + examples/scala/compare-evaluators.sh | 54 +++++++++++++++----------- examples/scala/simple-snc-driver.scala | 36 +++++++++++++++++ examples/scala/simple.program | 19 +++++++++ 5 files changed, 98 insertions(+), 24 deletions(-) create mode 100644 examples/scala/simple-snc-driver.scala create mode 100644 examples/scala/simple.program diff --git a/examples/scala/Makefile b/examples/scala/Makefile index f98b9625..eb013236 100644 --- a/examples/scala/Makefile +++ b/examples/scala/Makefile @@ -30,7 +30,7 @@ AST_TREE_SCALAGEN = simple.scala tiny.scala grammar.scala \ EVALUATOR_EXAMPLES = classic-binding first follow nullable test-coll \ test-use-coll test-cycle test-fields use-global broad-fiber-cycle \ below-fiber-cycle below-single-fiber-cycle local-fiber-cycle nested-cycles \ - farrow-lv farrow-ubd farrow-ubd-fiber nested-ubd nested-ubd-fiber + farrow-lv farrow-ubd farrow-ubd-fiber nested-ubd nested-ubd-fiber simple-snc SCALAGEN = ${AST_TREE_SCALAGEN} \ $(foreach example,${EVALUATOR_EXAMPLES},$(example).scala $(example).static.scala) @@ -64,6 +64,7 @@ all : ${OUT}/below_fiber_cycle_implicit.class ${OUT}/BelowFiberCycleDriver.class all : ${OUT}/below_single_fiber_cycle_implicit.class ${OUT}/BelowSingleFiberCycleDriver.class all : ${OUT}/local_fiber_cycle_implicit.class ${OUT}/LocalFiberCycleDriver.class all : ${OUT}/test_fields_implicit.class ${OUT}/TestFieldsDriver.class +all : ${OUT}/simple_snc_implicit.class ${OUT}/SimpleSncDriver.class .PHONY: run @@ -350,6 +351,15 @@ ${OUT}/LocalFiberCycleDriver.class : ${OUT}/local_fiber_cycle_implicit.class ${O ${OUT}/LocalFiberCycleDriver.class : local-fiber-cycle-driver.scala ${SCALAC} ${SCALACFLAGS} $< +${OUT}/simple-snc.class: simple-snc${IMPL_SUFFIX} ${OUT}/simple_implicit.class + ${SCALAC} ${SCALACFLAGS} $< + +.PHONY: ${OUT}/simple_snc_implicit.class +${OUT}/simple_snc_implicit.class : ${OUT}/simple-snc.class ${OUT}/simple_implicit.class ; + +${OUT}/SimpleSncDriver.class: ${OUT}/simple_snc_implicit.class ${OUT}/SimpleParser.class + ${SCALAC} ${SCALACFLAGS} simple-snc-driver.scala + .PHONY: %.run %.run : ${OUT}/%.class diff --git a/examples/scala/README b/examples/scala/README index fa66cd23..34b9869c 100644 --- a/examples/scala/README +++ b/examples/scala/README @@ -16,3 +16,4 @@ make EVALUATOR=STATIC NestedCyclesDriver.run make EVALUATOR=STATIC ARGS="nested-ubd.program" NestedUbdDriver.run make EVALUATOR=STATIC ARGS="nested-ubd.program" NestedUbdFiberDriver.run make EVALUATOR=STATIC ARGS="tiny.program" TestFieldsDriver.run +make EVALUATOR=DYNAMIC ARGS="simple.program" SimpleSncDriver.run diff --git a/examples/scala/compare-evaluators.sh b/examples/scala/compare-evaluators.sh index de1940b0..8fca754a 100755 --- a/examples/scala/compare-evaluators.sh +++ b/examples/scala/compare-evaluators.sh @@ -3,7 +3,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" cd "$SCRIPT_DIR" -EVALUATORS=(DYNAMIC STATIC) +DEFAULT_EVALUATORS="DYNAMIC,STATIC" extract_results() { sed -n '/^Results:$/,$p' @@ -27,8 +27,9 @@ run_with_evaluator() { run_driver() { local driver="$1" - shift - local args="$*" + local args="$2" + local -a evals + IFS=',' read -ra evals <<< "$3" local pass=true local build_failed=false local tmpdir @@ -37,7 +38,7 @@ run_driver() { echo "--- $driver ${args:+(${args})} ---" local built_evaluators=() - for eval in "${EVALUATORS[@]}"; do + for eval in "${evals[@]}"; do echo " running $eval ..." if ! run_with_evaluator "$eval" "$driver" "$args" "$tmpdir/$eval"; then echo " FAIL: $eval build failed" @@ -59,9 +60,13 @@ run_driver() { local n=${#built_evaluators[@]} if [ $n -lt 2 ]; then - echo " FAIL: fewer than 2 evaluators built successfully" + if [ $n -eq 1 ]; then + echo " OK: ${built_evaluators[0]} ran successfully" + else + echo " FAIL: no evaluators ran successfully" + fi rm -rf "$tmpdir" - return 1 + return $(( n == 0 )) fi for ((i=0; i Date: Mon, 10 Aug 2026 20:06:00 +0000 Subject: [PATCH 3/3] more interesting simple-snc --- examples/simple-snc.aps | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/simple-snc.aps b/examples/simple-snc.aps index 8936980a..76a6afd1 100644 --- a/examples/simple-snc.aps +++ b/examples/simple-snc.aps @@ -15,16 +15,16 @@ module SIMPLE_SNC[T :: var SIMPLE[]] extends T begin pragma synthesized(expr_s1, expr_s2, block_total, stmt_total, stmts_total, program_total); match ?s:Stmt=assign_stmt(?e1:Expr,?e2:Expr) begin - e1.expr_i1 := 0; + e1.expr_i1 := 1; e1.expr_i2 := e1.expr_s1; - e2.expr_i2 := 0; + e2.expr_i2 := 2; e2.expr_i1 := e2.expr_s2; s.stmt_total := e1.expr_s2 + e2.expr_s1; end; match ?e:Expr=intconstant(?i:Integer) begin - e.expr_s1 := e.expr_i1; - e.expr_s2 := e.expr_i2; + e.expr_s1 := e.expr_i1 + i + 1; + e.expr_s2 := e.expr_i2 + i + 2; end; match ?b:Block=block(?ds:Decls,?ss:Stmts) begin @@ -59,7 +59,7 @@ module SIMPLE_SNC[T :: var SIMPLE[]] extends T begin end; match ?s:Stmt=block_stmt(?b:Block) begin - s.stmt_total := 0; + s.stmt_total := b.block_total; end; match ?e:Expr=strconstant(?:String) begin