linksplatform / linksplatform/Data.Doublets
Pattern syntax for Links
- Dominant language
- C#
- Stars
- 14
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Universal patterns syntax for links should be defined as structure in Links Notation.
It should be possible to match any link.
It should be possible to match variables that can be used in the pattern's substitution.
It should be possible to create user defined patterns/sub-patterns.
Each built-in sub-patterns should be defined in the same syntax where it is possible.
```
`*` - any
`set` - any set
`sequence` - any sequence
`tree` - any tree
`point` - any point
`partial-point` - any partial point
`$x`, `$y` - variables
-- expanded variable (varible with preset pattern of contents)
-- $x is equivalent to ($ x *)
(($ x tree) *)
(* ($ y point))
-- (1 1):
-- (* *):
(1: 1 1)
-- Concrete set
-- (set (1 2))
-- should match both:
(1 2)
(2 1)
-- Point
(pattern
(name "point")
($x: $x $x)
)
-- Partial point
(pattern
(name "partial-point")
(or
($x: $x *)
($x: * $x)
)
)
-- Tree
-- #element is argument, where any template can be placed
-- tree here is self reference to pattern
(pattern
(name "tree")
(or
#element
(or
(#element #element)
(or
(tree #element)
(#element tree)
)
)
)
)
-- is equivalent to
(pattern
(name "tree")
(or
#element
(#element #element)
(tree #element)
(#element tree)
)
)
-- it is possible to use alternative syntax for "or"
(pattern
(name "tree")
(|
#element
(#element #element)
(tree #element)
(#element tree)
)
)
-- or syntax
(or $x $y)
(| $x $y)
-- and syntax
(and $x $y)
(& $x $y)
-- not syntax
(not $x)
(! $x)
-- "link address is greater than" syntax
(gt 5)
(> 5)
-- "link address is greater or equal to" syntax
(gte 5)
(>= 5)
-- "link address is less than" syntax
(lt 5)
(< 5)
-- "link address is greater or equal to" syntax
(lte 5)
(<= 5)
-- incoming links syntax
(in $x)
-- outgoing links syntax
(out $x)
-- Concrete Tree
-- tree with element argument set to point template
-- (tree (element point))
-- How to define Set?
-- How to define Sequence?
-- Trigger/Substitution
-- pattern in the transformation can receive sequence/set of templates
-- and each of them can be assigned to variable
-- here the set/sequence consists of single doublet
-- this transformation corresponds to update transformation
(transform-once
(pattern ($x $y))
(pattern ($y $x))
)
-- creation transformation
(transform-once
(pattern ())
(pattern (1 2))
)
-- deletion transformation
(transform-once
(pattern ($x: * *))
(pattern ())
)
-- always transform (handlers)
(transform-always
(pattern
(and
($x: * *)
(not (* logged))
)
)
(pattern ($x logged))
)
```
`(* *)` and `($x $y)` would match the same number of links.
Related to https://github.com/linksplatform/Data.Doublets/issues/346.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the related issue #346 and comparing it with this proposal. The issue names no files or tests; completion would require an agreed syntax covering link matching, variables, user-defined and built-in patterns, and transformations, along with a defined validation approach.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100