compiler/PPCNode.st
changeset 515 b5316ef15274
parent 502 1e45d3c96ec5
child 516 3b81c9e53352
child 524 f6f68d32de73
equal deleted inserted replaced
502:1e45d3c96ec5 515:b5316ef15274
    31 
    31 
    32 children
    32 children
    33     ^ #()
    33     ^ #()
    34 !
    34 !
    35 
    35 
       
    36 defaultName
       
    37     ^ 'node' 
       
    38 !
       
    39 
    36 firstFollowCache
    40 firstFollowCache
    37     ^ self propertyAt: #firstFollowCache ifAbsentPut: [ IdentityDictionary new ]
    41     ^ self propertyAt: #firstFollowCache ifAbsentPut: [ IdentityDictionary new ]
    38 !
    42 !
    39 
    43 
    40 firstFollowCache: value
    44 firstFollowCache: value
    58 name
    62 name
    59     ^ name
    63     ^ name
    60 !
    64 !
    61 
    65 
    62 name: anObject
    66 name: anObject
    63     
    67 "	(anObject asString beginsWith: 'symbolLiteral') ifTrue: [ self halt. ]."
    64     name := anObject
    68     name := anObject
       
    69 !
       
    70 
       
    71 nameOrEmptyString
       
    72     ^ self hasName ifTrue: [ self name ] ifFalse: [ '' ]
    65 !
    73 !
    66 
    74 
    67 parser
    75 parser
    68     ^ self propertyAt: #parser ifAbsent: [ nil ]
    76     ^ self propertyAt: #parser ifAbsent: [ nil ]
    69 !
    77 !
    71 parser: value
    79 parser: value
    72     self propertyAt: #parser put: value
    80     self propertyAt: #parser put: value
    73 !
    81 !
    74 
    82 
    75 prefix
    83 prefix
    76     ^ 'node' 
    84     ^ nil
    77 !
    85 !
    78 
    86 
    79 suffix
    87 suffix
    80     ^ self isMarkedForInline ifTrue: [ '_inlined' ] ifFalse: [ '' ]
    88     ^ self isMarkedForInline ifTrue: [ 'inlined' ] ifFalse: [ nil ]
    81 !
    89 !
    82 
    90 
    83 unmarkForGuard
    91 unmarkForGuard
    84     "Forbids compiling of guards, if guards would be available"
    92     "Forbids compiling of guards, if guards would be available"
    85     self propertyAt: #guard put: false
    93     self propertyAt: #guard put: false
   239 
   247 
   240     self hasFiniteLanguage ifTrue: [ 
   248     self hasFiniteLanguage ifTrue: [ 
   241         finite := self.
   249         finite := self.
   242         infinite := anotherNode.
   250         infinite := anotherNode.
   243     ] ifFalse: [ 
   251     ] ifFalse: [ 
   244  								finite := anotherNode.
   252  		finite := anotherNode.
   245         infinite := self.	
   253         infinite := self.	
   246     ].
   254     ].
   247         
   255         
   248     finite recognizedSentences do: [ :sentence |
   256     finite recognizedSentences do: [ :sentence |
   249             (infinite parser matches: sentence) ifTrue: [ ^ true ].
   257         (infinite parser matches: sentence) ifTrue: [ ^ true ].
   250     ].
   258     ].
   251     ^ false
   259     ^ false
   252     
   260     
   253 !
   261 !
   254 
   262 
   500 
   508 
   501 canHavePPCId
   509 canHavePPCId
   502     ^ true
   510     ^ true
   503 !
   511 !
   504 
   512 
       
   513 hasName
       
   514     ^ (name == nil) not
       
   515 !
       
   516 
   505 isMarkedForInline
   517 isMarkedForInline
   506     ^ self propertyAt: #inlined ifAbsent: [ false ].
   518     ^ self propertyAt: #inlined ifAbsent: [ false ].
   507 
   519 
   508     "Created: / 23-04-2015 / 15:40:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   520     "Created: / 23-04-2015 / 15:40:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   509 !
   521 !
   529 !
   541 !
   530 
   542 
   531 asFsa
   543 asFsa
   532     | visitor |
   544     | visitor |
   533     visitor := PEGFsaGenerator new.
   545     visitor := PEGFsaGenerator new.
   534     ^ visitor visit: self
   546     ^ (visitor visit: self)
       
   547         name: self name;
       
   548         yourself
       
   549     
   535 !
   550 !
   536 
   551 
   537 replace: node with: anotherNode
   552 replace: node with: anotherNode
   538 !
   553 !
   539 
   554