egison-pattern-src

Manipulating Egison patterns: abstract syntax, parser, and pretty-printer

https://github.com/egison/egison-pattern-src#readme

Version on this page:0.2.1.2
LTS Haskell 23.0:0.2.1.2@rev:1
Stackage Nightly 2024-12-09:0.2.1.2@rev:1
Latest on Hackage:0.2.1.2@rev:1

See all snapshots egison-pattern-src appears in

BSD-3-Clause licensed by coord_e
Maintained by coord_e, Satoshi Egi
This version can be pinned in stack with:egison-pattern-src-0.2.1.2@sha256:ef33f17bd26b51c74ee7d133dbaf191234de57ac7fc501eddeaeae8dc5c21a30,4209

Egison Pattern Source

Actions Status Actions Status Hackage Hackage Deps

The egison-pattern-src provides a standalone syntax definition for patterns in the Egison programming language. This package enables you to embed Egison’s patterns in your parser (pretty-printer) by supplying expression and name parsers (printers) externally.

Syntax

The following is a simplified syntax of pattern expressions where v, c, op and e are meta-variables for variable names, constructor names, user-defined infix operators, and expressions in host language, respectively.

p ::= _                     (wildcard pattern)
    | $v                    (pattern variable)
    | #e                    (value pattern)
    | ?e                    (predicate pattern)
    | (p_1, p_2, ..., p_n)  (tuple pattern)
    | [p_1, p_2, ..., p_n]  (collection pattern)
    | p & p                 (and-pattern)
    | p | p                 (or-pattern)
    | !p                    (not-pattern)
    | p op p                (user-defined infix pattern)
    | c p_1 p_2 ... p_n     (constructor pattern)

License

egison-pattern-src is distributed as open source software under the terms of the 3 clause BSD License. See LICENSE for details.

Changes

0.2.1.2

  • Support megaparsec >= 9.0.0 #25

0.2.1.1

  • Relax version upper bound for prettyprinter and recursion-scheme.

0.2.1.0

  • Fix use of external parsers to delimit input with ,, ), or ]
  • Enable to parse value expression in the form of #[1, 2, 3] without parentheses

0.2.0.0

Breaking changes:

  • Add a tuple pattern #12
  • Add a collection pattern #17
  • UnexpectedEndOfFile error variant is added for greedy parsers (change in #19)
  • The name of parsing file is passed in ParseMode, not in the argument of parseExpr (change in #19)
  • Fix syntax of constructor patterns #18
    • We do not require constructor patterns to be parenthaized

Non-breacking changes:

  • Add non-greedy parsers #19
    • Variants of parsers are provided via Parsable class
  • not patterns are now parsed as atom patterns (change in #18)
  • Source type constraint is now just a type class providing few additional methods to Stream (change in #19)

0.1.1.0

Nothing changed (updated as other two adaptor packages)

0.1.0.0

  • Initial Release