stred

Stred: Streaming Tree Editor. Like sed but for JSON
git clone http://shtanton.xyz/git/repo/stred
Log | Files | Refs | README

commit 48017049f23d3f213fc6e1313f34526d0bba4489
parent e5965749d17d5a70f92fdc981f863e85b7543838
Author: Charlie Stanton <charlie@shtanton.xyz>
Date:   Wed, 26 Apr 2023 11:04:36 +0100

Update subex , literal to no longer include terminals

Diffstat:
MREADME.md | 2+-
Msubex/subexast.go | 6+++---
Msubex/subexstate.go | 8++++----
3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md @@ -61,7 +61,7 @@ The simplest subexes are literals. These just copy directly from the input to th | Syntax | Description | | --- | --- | | `.` | Copy across any single atom unchanged | -| `,` | Copy across any single value unchanged (will copy a whole string) | +| `,` | Copy across any single JSON value (not `{`, `}`, `[` or `]` tokens) unchanged (will copy a whole string). Equivalent to `` `null`|?|%|# `` | | `?` | Copy across any single boolean atom | | `%` | Copy across any single number | | `_` | Copy across a single unicode codepoint inside a string | diff --git a/subex/subexast.go b/subex/subexast.go @@ -195,13 +195,13 @@ func (ast SubexASTCopyString) String() string { return "#" } -// Read in a value and copy it out unchanged -// , is equivalent to `null`|?|%|#|[`{}[]`] +// Read in a non-terminal value and copy it out unchanged +// , is equivalent to `null`|?|%|# type SubexASTCopyValue struct {} func (ast SubexASTCopyValue) compileWith(next SubexState, slotMap *SlotMap) SubexState { return &SubexGroupState { SubexASTCopyString{}.compileWith(next, slotMap), - &SubexCopyNonStringAtomState {next}, + &SubexCopyNonStringNonTerminalAtomState {next}, } } func (ast SubexASTCopyValue) String() string { diff --git a/subex/subexstate.go b/subex/subexstate.go @@ -203,11 +203,11 @@ func (state SubexCopyStringAtomState) accepting(store Store, outputStack OutputS } // Read in an atom and copy it out as long as it is not part of a string -type SubexCopyNonStringAtomState struct { +type SubexCopyNonStringNonTerminalAtomState struct { next SubexState } -func (state SubexCopyNonStringAtomState) eat(store Store, outputStack OutputStack, char walk.Atom) []SubexBranch { - if char.Typ == walk.AtomStringRune || char.Typ == walk.AtomStringTerminal { +func (state SubexCopyNonStringNonTerminalAtomState) eat(store Store, outputStack OutputStack, char walk.Atom) []SubexBranch { + if char.Typ == walk.AtomStringRune || char.Typ == walk.AtomStringTerminal || char.Typ == walk.AtomTerminal { return nil } return []SubexBranch{{ @@ -216,7 +216,7 @@ func (state SubexCopyNonStringAtomState) eat(store Store, outputStack OutputStac store: store, }} } -func (state SubexCopyNonStringAtomState) accepting(store Store, outputStack OutputStack) []OutputStack { +func (state SubexCopyNonStringNonTerminalAtomState) accepting(store Store, outputStack OutputStack) []OutputStack { return nil }