"{ Package: 'stx:goodies/petitparser/compiler' }"
"{ NameSpace: Smalltalk }"
PPCNode subclass:#PPCUnknownNode
instanceVariableNames:'parser'
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Nodes'
!
!PPCUnknownNode class methodsFor:'as yet unclassified'!
new
^ self basicNew initialize
! !
!PPCUnknownNode methodsFor:'accessing'!
acceptsEpsilon
^ parser acceptsEpsilon
!
acceptsEpsilonOpenSet: aSet
^ parser acceptsEpsilonOpenSet: aSet
!
children
^ parser children
!
isContextFreePrim
^ parser isContextFreePrim
!
isNullable
^ parser isNullable
!
parser
^ parser
!
parser: anObject
parser := anObject
!
prefix
^ #parser
! !
!PPCUnknownNode methodsFor:'as yet unclassified'!
firstCharSet
^ parser firstCharSet
! !
!PPCUnknownNode methodsFor:'comparison'!
= anotherNode
super = anotherNode ifFalse: [ ^ false ].
^ parser = anotherNode parser.
!
hash
^ super hash bitXor: parser hash
! !
!PPCUnknownNode methodsFor:'compiling'!
compileWith: compiler effect: effect id: id
| compiledChild compiledParser |
compiler startMethod: id.
compiledParser := parser copy.
"Compile all the children and call compiled version of them instead of the original one"
compiledParser children do: [ :child |
compiledChild := child compileWith: compiler.
compiledParser replace: child with: compiledChild bridge.
].
compiler addConstant: compiledParser as: id.
compiler addVariable: 'retval'.
compiler add: 'self clearError.'.
compiler add: '(retval := ', id, ' parseOn: context) isPetitFailure'.
compiler indent.
compiler add: ' ifTrue: [self error: retval message at: retval position ].'.
compiler dedent.
compiler add: 'error := retval isPetitFailure.'.
compiler add: '^ retval'.
^ compiler stopMethod.
! !
!PPCUnknownNode methodsFor:'transformation'!
replace: node with: anotherNode
parser replace: node with: anotherNode
! !
!PPCUnknownNode class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
! !