Skip to content

Commit 566dc2d

Browse files
committed
Updated LL(2) pretty printer and CLAUDE.md.
1 parent 89341fd commit 566dc2d

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

CLAUDE.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The LL(2) syntax differs from Scala-based syntax primarily in:
2222

2323
| Category | Scala-based Syntax | LL(2) Syntax | AST Node |
2424
|---|---|---|---|
25-
| **Program** | `// #Sireum` `package p` `import org.sireum._` ... | `package p` ... | `TopUnit.Program` |
25+
| **Program** | `// #Sireum \n package p import org.sireum._ ...` | `package p\n...` | `TopUnit.Program` |
2626
| **Import** | `import a.b.c` | `import a.b.c` | `Stmt.Import` |
2727
| **Import wildcard** | `import a.b._` | `import a.b._` | `Stmt.Import` + `WildcardSelector` |
2828
| **Import rename** | `import a.b.{x => y}` | `import a.b.{x => y}` | `Stmt.Import` + `MultiSelector` |
@@ -37,7 +37,7 @@ The LL(2) syntax differs from Scala-based syntax primarily in:
3737
| **Sig trait** | `@sig trait Foo` | `type @trait Foo` | `Stmt.Sig(isImmutable=T)` |
3838
| **Sealed sig** | `@sig sealed trait Foo` | `type @sealed @trait Foo` | `Stmt.Sig(isSealed=T)` |
3939
| **Msig trait** | `@msig trait Foo` | `type @trait @mut Foo` | `Stmt.Sig(isImmutable=F)` |
40-
| **Enum** | `@enum object Color { ... }` | `type @enum Color: { ... }` | `Stmt.Enum` |
40+
| **Enum** | `@enum object Color { "Red"\n "Green" }` | `type @enum Color: { Red\n Green }` | `Stmt.Enum` |
4141
| **Range type** | `@range(min = 0, max = 10) class Idx` | `type @range(min = 0, max = 10) Idx` | `Stmt.SubZ(isBitVector=F)` |
4242
| **Bits type** | `@bits(signed = F, width = 8) class U8` | `type @bits(signed = F, width = 8) U8` | `Stmt.SubZ(isBitVector=T)` |
4343
| **Type alias** | `type Foo = Bar[Z]` | `type @alias Foo = Bar[Z]` | `Stmt.TypeAlias` |
@@ -81,8 +81,8 @@ The LL(2) syntax differs from Scala-based syntax primarily in:
8181
| **Induct** | `(exp: @induct)` | `(@induct exp)` | `Stmt.Induct` |
8282
| **Deduce steps** | `Deduce(1. claim ...)` | `deduce { 1. claim ... }` | `Stmt.DeduceSteps` |
8383
| **Deduce sequent** | `Deduce(⊢ ...)` | `deduce : premises ⊢ conclusion` | `Stmt.DeduceSequent` |
84-
| **Assert** | `assert(exp)` | `assert exp` | `Stmt.Expr` (assert builtin) |
85-
| **Assume** | `assume(exp)` | `assume exp` | `Stmt.Expr` (assume builtin) |
84+
| **Assert** | `assert(exp)` | `assert exp [, exp]` | `Stmt.Expr` (assert builtin) |
85+
| **Assume** | `assume(exp)` | `assume exp [, exp]` | `Stmt.Expr` (assume builtin) |
8686

8787
### Expressions
8888

@@ -95,7 +95,7 @@ The LL(2) syntax differs from Scala-based syntax primarily in:
9595
| **Apply** | `x(i)` | `x(i)` | `Exp.Invoke(ident.id="apply")` |
9696
| **Binary** | `a + b` | `a + b` | `Exp.Binary` |
9797
| **Unary** | `-x`, `!x` | `-x`, `!x` | `Exp.Unary` |
98-
| **If exp** | `if (c) t else e` | `(c? t : e)` | `Exp.If` |
98+
| **If exp** | `if (c) t else e` | `if (c) t else e` | `Exp.If` |
9999
| **Tuple** | `(a, b)` | `(a, b)` | `Exp.Tuple` |
100100
| **This** | `this` | `this` | `Exp.This` |
101101
| **Super** | `super` | `super` | `Exp.Super` |
@@ -156,11 +156,11 @@ The LL(2) syntax differs from Scala-based syntax primarily in:
156156
|---|---|---|---|
157157
| **Proof block** | `Proof(...)` | `deduce { ... }` | `ProofAst` |
158158
| **Regular step** | `n (claim) by just` | `n. claim by just` | `ProofAst.Step.Regular` |
159-
| **Assume step** | `n Assume(claim)` | `n. assume(claim)` | `ProofAst.Step.Assume` |
160-
| **Assert step** | `n Assert(claim, SubProof(...))` | `n. assert(claim) { ... }` | `ProofAst.Step.Assert` |
159+
| **Assume step** | `n Assume(claim)` | `n. assume claim` | `ProofAst.Step.Assume` |
160+
| **Assert step** | `n Assert(claim, SubProof(...))` | `n. assert claim { ... }` | `ProofAst.Step.Assert` |
161161
| **SubProof** | `n SubProof(...)` | `n. { steps }` | `ProofAst.Step.SubProof` |
162162
| **Let step** | `n Let((x: T) => ...)` | `n. { x: T steps }` | `ProofAst.Step.Let` |
163-
| **Justification** | `by just` | `by just.` | `ProofAst.Step.Justification.*` |
163+
| **Justification** | `by just` | `by just` | `ProofAst.Step.Justification.*` |
164164
| **Sequent** | `⊢(premises, conclusion)` | `: premises ⊢ conclusion` | `Sequent` |
165165

166166
### LL(2)-Only Constructs

ast/shared/src/main/scala/org/sireum/lang/ast/SlangLl2PrettyPrinter.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ object SlangLl2PrettyPrinter {
148148
case o: AST.Exp.Eta => st"${printExp(o.ref.asExp)} _"
149149
case o: AST.Exp.ForYield => st"yield ${(for (g <- o.enumGens) yield printEnumGen(g), ", ")} => ${printExp(o.exp)}"
150150
case o: AST.Exp.Ident => st"${o.id.value}"
151-
case o: AST.Exp.If => st"(${printExp(o.cond)}? ${printExp(o.thenExp)} : ${printExp(o.elseExp)})"
151+
case o: AST.Exp.If => st"if (${printExp(o.cond)}) ${printExp(o.thenExp)} else ${printExp(o.elseExp)}"
152152
case o: AST.Exp.Input => st"In(${printExp(o.exp)})"
153153
case o: AST.Exp.Invoke => printInvoke(o)
154154
case o: AST.Exp.InvokeNamed => printInvokeNamed(o)
@@ -225,8 +225,8 @@ object SlangLl2PrettyPrinter {
225225
case o: AST.ProofAst.Step.Justification.Ref => st"by ${printJustExp(o.ref.asExp)}${printWitnesses(o)}"
226226
}
227227
@strictpure def printProofStep(o: AST.ProofAst.Step): ST = o match {
228-
case o: AST.ProofAst.Step.Assert => st"${o.id.prettyST}. assert(${printExp(o.claim)})"
229-
case o: AST.ProofAst.Step.Assume => st"${o.id.prettyST}. assume(${printExp(o.claim)})"
228+
case o: AST.ProofAst.Step.Assert => st"${o.id.prettyST}. assert ${printExp(o.claim)}"
229+
case o: AST.ProofAst.Step.Assume => st"${o.id.prettyST}. assume ${printExp(o.claim)}"
230230
case o: AST.ProofAst.Step.Let =>
231231
st"""${o.id.prettyST}. {
232232
| ${(for (param <- o.params) yield st"${param.id.value}${if (param.tipeOpt.isEmpty) st"" else st": ${printType(param.tipeOpt.get)}"}", " ")}

0 commit comments

Comments
 (0)