compiler/PPCNode.st
changeset 516 3b81c9e53352
parent 503 ff58cd9f1f3c
parent 515 b5316ef15274
child 525 751532c8f3db
equal deleted inserted replaced
514:46dd1237b20a 516:3b81c9e53352
    32 
    32 
    33 children
    33 children
    34     ^ #()
    34     ^ #()
    35 !
    35 !
    36 
    36 
       
    37 defaultName
       
    38     ^ 'node' 
       
    39 !
       
    40 
    37 firstFollowCache
    41 firstFollowCache
    38     ^ self propertyAt: #firstFollowCache ifAbsentPut: [ IdentityDictionary new ]
    42     ^ self propertyAt: #firstFollowCache ifAbsentPut: [ IdentityDictionary new ]
    39 !
    43 !
    40 
    44 
    41 firstFollowCache: value
    45 firstFollowCache: value
    59 name
    63 name
    60     ^ name
    64     ^ name
    61 !
    65 !
    62 
    66 
    63 name: anObject
    67 name: anObject
    64     
    68 "	(anObject asString beginsWith: 'symbolLiteral') ifTrue: [ self halt. ]."
    65     name := anObject
    69     name := anObject
       
    70 !
       
    71 
       
    72 nameOrEmptyString
       
    73     ^ self hasName ifTrue: [ self name ] ifFalse: [ '' ]
    66 !
    74 !
    67 
    75 
    68 parser
    76 parser
    69     ^ self propertyAt: #parser ifAbsent: [ nil ]
    77     ^ self propertyAt: #parser ifAbsent: [ nil ]
    70 !
    78 !
    72 parser: value
    80 parser: value
    73     self propertyAt: #parser put: value
    81     self propertyAt: #parser put: value
    74 !
    82 !
    75 
    83 
    76 prefix
    84 prefix
    77     ^ 'node' 
    85     ^ nil
    78 !
    86 !
    79 
    87 
    80 suffix
    88 suffix
    81     ^ self isMarkedForInline ifTrue: [ '_inlined' ] ifFalse: [ '' ]
    89     ^ self isMarkedForInline ifTrue: [ 'inlined' ] ifFalse: [ nil ]
    82 !
    90 !
    83 
    91 
    84 unmarkForGuard
    92 unmarkForGuard
    85     "Forbids compiling of guards, if guards would be available"
    93     "Forbids compiling of guards, if guards would be available"
    86     self propertyAt: #guard put: false
    94     self propertyAt: #guard put: false
   240 
   248 
   241     self hasFiniteLanguage ifTrue: [ 
   249     self hasFiniteLanguage ifTrue: [ 
   242         finite := self.
   250         finite := self.
   243         infinite := anotherNode.
   251         infinite := anotherNode.
   244     ] ifFalse: [ 
   252     ] ifFalse: [ 
   245  								finite := anotherNode.
   253  		finite := anotherNode.
   246         infinite := self.	
   254         infinite := self.	
   247     ].
   255     ].
   248         
   256         
   249     finite recognizedSentences do: [ :sentence |
   257     finite recognizedSentences do: [ :sentence |
   250             (infinite parser matches: sentence) ifTrue: [ ^ true ].
   258         (infinite parser matches: sentence) ifTrue: [ ^ true ].
   251     ].
   259     ].
   252     ^ false
   260     ^ false
   253     
   261     
   254 !
   262 !
   255 
   263 
   527 
   535 
   528 canHavePPCId
   536 canHavePPCId
   529     ^ true
   537     ^ true
   530 !
   538 !
   531 
   539 
       
   540 hasName
       
   541     ^ (name == nil) not
       
   542 !
       
   543 
   532 isMarkedForInline
   544 isMarkedForInline
   533     ^ self propertyAt: #inlined ifAbsent: [ false ].
   545     ^ self propertyAt: #inlined ifAbsent: [ false ].
   534 
   546 
   535     "Created: / 23-04-2015 / 15:40:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   547     "Created: / 23-04-2015 / 15:40:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   536 !
   548 !
   556 !
   568 !
   557 
   569 
   558 asFsa
   570 asFsa
   559     | visitor |
   571     | visitor |
   560     visitor := PEGFsaGenerator new.
   572     visitor := PEGFsaGenerator new.
   561     ^ visitor visit: self
   573     ^ (visitor visit: self)
       
   574         name: self name;
       
   575         yourself
       
   576     
   562 !
   577 !
   563 
   578 
   564 replace: node with: anotherNode
   579 replace: node with: anotherNode
   565 !
   580 !
   566 
   581