Skip to content

Commit

Permalink
add code highlighting in README
Browse files Browse the repository at this point in the history
add `lang="kotlin"` and replace `<br/>` with HTML escape char for newlines.
  • Loading branch information
aSemy authored Jan 7, 2024
1 parent 6879310 commit f77b36f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ You can pick and choose the style for each parser and sub-parser, as there are n

| Description | Grammars |
| ----------- | -------- |
| Parsing a token and getting its text<br/><br/>Parses: `ab`, `aB` | Procedural:<br/><pre>val ab by regexToken("a[bB]")<br/>override val root by parser {<br/> val abMatch = ab()<br/> abMatch.text<br/>}</pre>Combinator:<br/><pre>val ab by regexToken("a[bB]")<br/>override val root by ab map { it.text }</pre> |
| Parsing two tokens sequentially<br/><br/>Parses: `ab`, `aB` | Procedural:<br/><pre>val a by literalToken("a")<br/>val b by regexToken("[bB]")<br/>override val root by parser {<br/> val aMatch = a()<br/> val bMatch = b()<br/> aMatch.text to bMatch.text<br/>}</pre>Combinator:<br/><pre>val a by literalToken("a")<br/>val b by regexToken("[bB]")<br/>override val root by a and b map<br/> { (aM, bM) -> aM.text to bM.text }</pre> |
| Parsing one of two tokens<br/><br/>Parses: `a`, `b`, `B` | Procedural:<br/><pre>val a by literalToken("a")<br/>val b by regexToken("[bB]")<br/>override val root by parser {<br/> val abMatch = choose(a, b)<br/> abMatch.text<br/>}</pre>Combinator:<br/><pre>val a by literalToken("a")<br/>val b by regexToken("[bB]")<br/>override val root by a or b map { it.text }</pre> |
| Parsing an optional token<br/><br/>Parses: `ab`, `aB`, `b`, `B` | Procedural:<br/><pre>val a by literalToken("a")<br/>val b by regexToken("[bB]")<br/>override val root by parser {<br/> val aMatch = poll(a)<br/> val bMatch = b()<br/> aMatch?.text to bMatch.text<br/>}</pre>Combinator:<br/><pre>val a by literalToken("a")<br/>val b by regexToken("[bB]")<br/>override val root by maybe(a) and b map<br/> { (aM, bM) -> aM?.text to bM.text }</pre> |
| Parsing a token and ignoring its value<br/><br/>Parses: `ab`, `aB` | Procedural:<br/><pre>val a by literalToken("a")<br/>val b by regexToken("[bB]")<br/>override val root by parser {<br/> skip(a) // or just a() without using the value<br/> val bMatch = b()<br/> bMatch.text<br/>}</pre>Combinator:<br/><pre>val a by literalToken("a")<br/>val b by regexToken("[bB]")<br/>override val root by -a * b map { it.text }</pre> |
| Parsing a token and getting its text&#13;&#13;Parses: `ab`, `aB` | Procedural:&#13;<pre lang="kotlin">val ab by regexToken("a[bB]")&#13;override val root by parser {&#13; val abMatch = ab()&#13; abMatch.text&#13;}</pre>Combinator:&#13;<pre lang="kotlin">val ab by regexToken("a[bB]")&#13;override val root by ab map { it.text }</pre> |
| Parsing two tokens sequentially&#13;&#13;Parses: `ab`, `aB` | Procedural:&#13;<pre lang="kotlin">val a by literalToken("a")&#13;val b by regexToken("[bB]")&#13;override val root by parser {&#13; val aMatch = a()&#13; val bMatch = b()&#13; aMatch.text to bMatch.text&#13;}</pre>Combinator:&#13;<pre lang="kotlin">val a by literalToken("a")&#13;val b by regexToken("[bB]")&#13;override val root by a and b map&#13; { (aM, bM) -> aM.text to bM.text }</pre> |
| Parsing one of two tokens&#13;&#13;Parses: `a`, `b`, `B` | Procedural:&#13;<pre lang="kotlin">val a by literalToken("a")&#13;val b by regexToken("[bB]")&#13;override val root by parser {&#13; val abMatch = choose(a, b)&#13; abMatch.text&#13;}</pre>Combinator:&#13;<pre lang="kotlin">val a by literalToken("a")&#13;val b by regexToken("[bB]")&#13;override val root by a or b map { it.text }</pre> |
| Parsing an optional token&#13;&#13;Parses: `ab`, `aB`, `b`, `B` | Procedural:&#13;<pre lang="kotlin">val a by literalToken("a")&#13;val b by regexToken("[bB]")&#13;override val root by parser {&#13; val aMatch = poll(a)&#13; val bMatch = b()&#13; aMatch?.text to bMatch.text&#13;}</pre>Combinator:&#13;<pre lang="kotlin">val a by literalToken("a")&#13;val b by regexToken("[bB]")&#13;override val root by maybe(a) and b map&#13; { (aM, bM) -> aM?.text to bM.text }</pre> |
| Parsing a token and ignoring its value&#13;&#13;Parses: `ab`, `aB` | Procedural:&#13;<pre lang="kotlin">val a by literalToken("a")&#13;val b by regexToken("[bB]")&#13;override val root by parser {&#13; skip(a) // or just a() without using the value&#13; val bMatch = b()&#13; bMatch.text&#13;}</pre>Combinator:&#13;<pre lang="kotlin">val a by literalToken("a")&#13;val b by regexToken("[bB]")&#13;override val root by -a * b map { it.text }</pre> |

## Introduction

Expand Down

0 comments on commit f77b36f

Please sign in to comment.