cafekrem / ptl Goto Github PK
View Code? Open in Web Editor NEWPharo transformation Language is a transformation model language like ALT tefkat.
License: MIT License
Pharo transformation Language is a transformation model language like ALT tefkat.
License: MIT License
example
Class suchAs: {
#slotNames -> ContainMatcher element: #toto
}
can use collection as argument of ContainerMatcher
Class suchAs: {
#slotNames -> ContainMatcher element: { #toto . #patrick}
}
testJokerMatcher3
| pattern a |
pattern := RBMessageNode suchAs: {(#selector -> #'@selector')}.
self
assert:
((pattern match: ([ 1 -> 3 ] sourceNode statements at: 1))
at: #selector)
equals: '->'. "Me retourne uniquement '-' et pas '->'"
self
assert:
((pattern match: ([ a foo ] sourceNode statements at: 1))
at: #selector)
equals: 'foo'
testMatchSymbolShouldBeSymbol
| pattern a pattern0 |
pattern0 := #'@x' asMatcher.
pattern := RBMessageNode suchAs:
{ (#selector -> RBSelectorNode suchAs:
{ (#value -> #'@selector') }) }.
self assert: (((pattern0 match: #klm) at: #x) isKindOf: Symbol).
self deny: (((pattern0 match: 'klm') at: #x) isKindOf: Symbol).
self assert:
(((pattern match: ([ 1 -> 3 ] sourceNode statements at: 1)) at:
#selector) isKindOf: Symbol).
self assert:
(((pattern match: ([ a foo ] sourceNode statements at: 1)) at:
#selector) isKindOf: Symbol)
testStringMatcher4
| pattern |
pattern := String named: #x.
self assert: (pattern match: 'klm') isMatch.
self assert: ((pattern match: 'klm') at: #x) equals: 'klm'
actually test case are built on FAST-Pharo , maybe replace it by RBAST ?
a joker should match any object
result := #'@x' asMatcher match: { 1 . 2 . 3 }.
self assertCollection: (result at: #x) hasSameElement: { 1 . 2 . 3 }
when executing this it's should return an error
pattern := PTLTestClassA suchAs: { #klm -> 'klm' }.
pattern match: PTLTestClassA new "should raise an error"
RBVariableNode suchAs: {
#name -> #'@name'.
#methodNode -> RBMethodNode suchAs: {
#methodClass -> Class suchAs: {
#slotNames -> #( #'*' #'@name' #'*')
}
}
}
become
RBVariableNode suchAs: {
#name -> #'@name'.
#'methodNode methodClass' -> Class suchAs: {
#slotNames -> ContainMatcher element: #'@name'
}
}
or become this
RBVariableNode suchAs: {
#name -> #'@name'.
#'methodNode>methodClass' -> Class suchAs: {
#slotNames -> ContainMatcher element: #'@name'
}
}
example we want to express something like this:
p1 := (ReturnStatement suchAs: { StringLiteral} depth: #*).
p2 := (ReturnStatement suchAs: { StringLiteral} depth: #1)
p2 match: [^ 1 + 5] "true"
p1 match: [^ 1 + 5] "false"
pattern := { 1 } asMatcher
(pattern match: { 1 }) isMatch
should be true
(pattern match: { 1 . 2 }) isMatch
should be false
we should a way to express something like this :
pattern := {String repeat: 3 . 100 } asMatcher.
self assert: (pattern match: { '1' . '2' . '3' . 100}) isMatch.
self deny: (pattern match: { '1' . '2' . 100}) isMatch.
self assert: (pattern match: { '1' . '2' . '3' . 100 . 100}) isMatch.
self deny: (pattern match: { 100}) isMatch
maybe use Interval
pattern := {String repeat: #(1 3) . 100} asMatcher "repeat between 1 and 3 times"
self assert: (pattern match: { '1' . '2' . '3' . 100}) isMatch.
self assert: (pattern match: { '1' . '2' . 100}) isMatch.
self assert: (pattern match: { '1' . '2' . '3' . 100 . 100}) isMatch.
self deny: (pattern match: { 100}) isMatch.
self assert: (pattern match: {'1' . 100 }) isMatch
when a dev implement a new matcher some property should be respected like:
((aMatcher named: #toto) match: someThingThatMatchWithaMatcher) at: toto "contentOf someThingThatMatchWithaMatcher"
MooseObject>>#MTLequalsTo: , is responsible of asking if 2 mooseEntity are equals.
maybe rename in conformTo:
using spec , add a tree of pattern
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.