Skip to content

Section

xtay2 edited this page Mar 15, 2023 · 5 revisions

Introduction

The Section is a terminal that matches any section enclosed in two symbols. This can get used for comments or strings.

Constructors

  1. Section(char open, char close):
    • Matches a section without an escape-symbol.
    • tokenize() Produces a TerminalToken when matched
  2. Section(char open, char close, char escape):
    • Matches a section with an escape-symbol.
    • tokenize() Produces a TerminalToken when matched
  3. Section(Function<String, TerminalToken> tokenFactory, char open, char close):
    • Matches a section without an escape-symbol.
    • tokenize() calls the tokenFactory when matched
  4. Section(Function<String, TerminalToken> tokenFactory, char open, char close, char escape):
    • Matches a section with an escape-symbol.
    • tokenize() calls the tokenFactory when matched

Examples

new Section('[', ']', '/');

Matches

"[]"
"[some content]"
"[other /]content]"

Fails

"[]]"
"]["
"/[]"
Clone this wiki locally