Skip to content

Commit

Permalink
Merge pull request #1361 from DanielXMoore/bullets
Browse files Browse the repository at this point in the history
Bulleted arrays with `.` or `•`
  • Loading branch information
edemaine authored Aug 15, 2024
2 parents 0c19054 + 4697e08 commit 022a39f
Show file tree
Hide file tree
Showing 5 changed files with 442 additions and 54 deletions.
26 changes: 26 additions & 0 deletions civet.dev/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ json's "long property"'s `${movie} name`

## Arrays

### Bracketed

Commas are optional at the ends of lines.

<Playground>
Expand All @@ -270,6 +272,30 @@ people := [
]
</Playground>

### Bulleted

Instead of brackets, array items can be specified via `.` or `` bullets:

<Playground>
rotate :=
. c, -s
. s, c
</Playground>

<Playground>
func.apply @,
• arg1
• arg2
</Playground>

<Playground>
people :=
. name: "Alice"
id: 7
. name: "Bob"
id: 9
</Playground>

### Rest

Rest properties/parameters/elements are no longer limited to the final position.
Expand Down
5 changes: 3 additions & 2 deletions source/main.civet
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ uncacheable := new Set [
"PushIndent"
"PopIndent"
"TrackIndented"
"BulletIndent"

// JSX
"PushJSXOpeningElement"
Expand Down Expand Up @@ -247,9 +248,9 @@ makeCache := ({hits, trace}: CacheOptions = {}): CacheEvents ->

// We cache `undefined` when a rule fails to match so we need to use `has` here.
if stateCache.has(key)
if trace
logs.push "".padStart(stack.length * 2, " ") + ruleName + ":" + state.pos + "💰"
result := stateCache.get(key)
if trace
logs.push "".padStart(stack.length * 2, " ") + ruleName + ":" + state.pos + "💰" + (if result then "✅" else "❌")
return {
cache: if result then { ...result }
}
Expand Down
Loading

0 comments on commit 022a39f

Please sign in to comment.