Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern syntax for Links #347

Open
Konard opened this issue May 2, 2022 · 0 comments
Open

Pattern syntax for Links #347

Konard opened this issue May 2, 2022 · 0 comments

Comments

@Konard
Copy link
Member

Konard commented May 2, 2022

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 #346.

@Konard Konard transferred this issue from linksplatform/Data May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant