Giter VIP home page Giter VIP logo

ptl's People

Contributors

aranega avatar cafekrem avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

alesshosry

ptl's Issues

[Pattern-matching ] ContainMatcher

example

Class suchAs: {
  #slotNames -> ContainMatcher element: #toto
}

can use collection as argument of ContainerMatcher

Class suchAs: {
  #slotNames -> ContainMatcher element: { #toto . #patrick}
 }

[Pharo ] error on Pharo 8 but not in pharo 9

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'

[Pattern Matching] when match a symbol should be a symbol

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)

[Pattern-matching] navigation shorcut

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'
        }
}

[Pattern matching] add repetition

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

[PatternMatching-Test] upgrade the hierarchy.

when a dev implement a new matcher some property should be respected like:

((aMatcher named: #toto)  match: someThingThatMatchWithaMatcher)  at: toto "contentOf someThingThatMatchWithaMatcher" 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.