PPPredicateObjectParser.st
changeset 4 90de244a7fa2
parent 0 739fe9b7253e
child 40 2cb8fad69877
equal deleted inserted replaced
3:e1b11f74e142 4:90de244a7fa2
     1 "{ Package: 'squeak:petitparser' }"
     1 "{ Package: 'stx:goodies/petitparser' }"
     2 
     2 
     3 PPPredicateParser subclass:#PPPredicateObjectParser
     3 PPPredicateParser subclass:#PPPredicateObjectParser
     4 	instanceVariableNames:''
     4 	instanceVariableNames:''
     5 	classVariableNames:''
     5 	classVariableNames:''
     6 	poolDictionaries:''
     6 	poolDictionaries:''
    46 digit
    46 digit
    47 	^ self on: (PPCharSetPredicate on: [ :char | char isDigit ]) message: 'digit expected'
    47 	^ self on: (PPCharSetPredicate on: [ :char | char isDigit ]) message: 'digit expected'
    48 !
    48 !
    49 
    49 
    50 hex
    50 hex
    51 	^ self 
    51 	^ self
    52 		on: (PPCharSetPredicate on: [ :char | 
    52 		on: (PPCharSetPredicate on: [ :char |
    53 			(char between: $0 and: $9) 
    53 			(char between: $0 and: $9)
    54 				or: [ (char between: $a and: $f) 
    54 				or: [ (char between: $a and: $f)
    55 				or: [ (char between: $A and: $F) ] ] ])
    55 				or: [ (char between: $A and: $F) ] ] ])
    56 		message: 'hex digit expected'
    56 		message: 'hex digit expected'
    57 !
    57 !
    58 
    58 
    59 letter
    59 letter
   121 expect: anObject
   121 expect: anObject
   122 	^ self expect: anObject message: anObject printString , ' expected'
   122 	^ self expect: anObject message: anObject printString , ' expected'
   123 !
   123 !
   124 
   124 
   125 expect: anObject message: aString
   125 expect: anObject message: aString
   126 	^ self 
   126 	^ self
   127 		on: [ :each | each = anObject ] message: aString
   127 		on: [ :each | each = anObject ] message: aString
   128 		negated: [ :each | each ~= anObject ] message: 'no ' , aString
   128 		negated: [ :each | each ~= anObject ] message: 'no ' , aString
   129 ! !
   129 ! !
   130 
   130 
   131 !PPPredicateObjectParser methodsFor:'initialization'!
   131 !PPPredicateObjectParser methodsFor:'initialization'!
   139 
   139 
   140 !PPPredicateObjectParser methodsFor:'operators'!
   140 !PPPredicateObjectParser methodsFor:'operators'!
   141 
   141 
   142 negate
   142 negate
   143 	"Answer a parser that is the negation of the receiving predicate parser."
   143 	"Answer a parser that is the negation of the receiving predicate parser."
   144 	
   144 
   145 	^ self class 
   145 	^ self class
   146 		on: negated message: negatedMessage 
   146 		on: negated message: negatedMessage
   147 		negated: predicate message: predicateMessage
   147 		negated: predicate message: predicateMessage
   148 ! !
   148 ! !
   149 
   149 
   150 !PPPredicateObjectParser methodsFor:'parsing'!
   150 !PPPredicateObjectParser methodsFor:'parsing'!
   151 
   151 
   156 ! !
   156 ! !
   157 
   157 
   158 !PPPredicateObjectParser class methodsFor:'documentation'!
   158 !PPPredicateObjectParser class methodsFor:'documentation'!
   159 
   159 
   160 version_SVN
   160 version_SVN
   161     ^ '$Id: PPPredicateObjectParser.st,v 1.1 2011-08-18 18:56:17 cg Exp $'
   161     ^ '$Id: PPPredicateObjectParser.st,v 1.2 2012-01-13 11:22:50 cg Exp $'
   162 ! !
   162 ! !