Skip to content

Commit

Permalink
add support replace-lilac; alpha release
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenYong committed Jun 29, 2020
1 parent 2e52062 commit 1baa316
Show file tree
Hide file tree
Showing 5 changed files with 607 additions and 168 deletions.
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ Try with `(def a (add 1 2))` or `{"json": [1, 2]}`.
[![Clojars Project](https://img.shields.io/clojars/v/mvc-works/lilac-parser.svg)](https://clojars.org/mvc-works/lilac-parser)

```edn
[mvc-works/lilac-parser "0.0.2-a3"]
[mvc-works/lilac-parser "0.0.3-a1"]
```

```clojure
(require '[lilac-parser.core :refer
[parse-lilac defparser is+ many+ one-of+ other-than+
some+ combine+ interleave+ label+]])

(parse-lilac "aaaa" (many+ (is+ "a")))
(parse-lilac (string/split "aaaa" "") (many+ (is+ "a")))
```

Demo of a stupid S-expression parser:
Expand Down Expand Up @@ -151,6 +151,27 @@ Parser rules can be expected by injecting functions. It could be quite tricky an
)
```

### Replacer

A function is also provided for replacing text pieces matching a given rule:

```clojure
(replace-lilac (string/split content "") rule (fn [x] (str "<<<" x ">>>>")))
```

which returns `:result` as well as parsing details in `:attempts`:

```edn
{
:result "<<<MATCHED>>>>"
:attempts [
; parsing summaries in vector
]
}
```

This is an experimental API serving jobs as a custom regular expression replacer.

### Workflow

Workflow https://github.com/mvc-works/calcit-workflow
Expand Down
Loading

0 comments on commit 1baa316

Please sign in to comment.