Extension { #name : 'PPParser' } { #category : '*petitcompiler' } PPParser >> allNodesDo: aBlock seen: aSet [ "Iterate over all the parse nodes of the receiver, do not visit and follow the ones contained in aSet." (aSet includes: self) ifTrue: [ ^ self ]. aSet add: self. aBlock value: self. self children do: [ :each | each allNodesDo: aBlock seen: aSet ] ] { #category : '*petitcompiler' } PPParser >> asCompilerNode [ ^ PPCUnknownNode new parser: self; name: self name; properties: self properties copy; yourself ] { #category : '*petitcompiler' } PPParser >> asCompilerTree [ ^ self transform: [ :p | p asCompilerNode ] ] { #category : '*petitcompiler' } PPParser >> bridge [ ^ self ] { #category : '*petitcompiler' } PPParser >> changesContext [ " by default true. When overriding be carefull to give the priority to the property value " ^ self propertyAt: #changesContext ifAbsentPut: [ true ] ] { #category : '*petitcompiler' } PPParser >> changesContext: value [ self propertyAt: #changesContext put: value. ^ self ] { #category : '*petitcompiler' } PPParser >> changesContextOpenSet: ctxEnv [ self changesContextSet ifTrue: [ ^ self changesContext ]. (ctxEnv changes includes: self) ifTrue: [ ^ self changesContext: false ]. ctxEnv changes add: self. ^ self changesContext ] { #category : '*petitcompiler' } PPParser >> changesContextSet [ ^ self hasProperty: #changesContext ] { #category : '*petitcompiler' } PPParser >> compile [ ^ self compileWithOptions: PPCCompilationOptions new "Modified: / 07-09-2015 / 10:54:54 / Jan Vrany " ] { #category : '*petitcompiler' } PPParser >> compileTokenizing [ | options | options := PPCCompilationOptions new tokenize: true; yourself. ^ self compileWithOptions: options ] { #category : '*petitcompiler' } PPParser >> compileWithOptions: options [ "Compile receiver with given options. Return an *instance* of the compiler parser which is ready to use (repeatedly). `options` may be either an instance of PPCCompilationOptions or an array specifying options like #( tokenizing: true debug: false ) " | compiler | compiler := PPCCompiler new. compiler options: options. ^compiler compile: self "Created: / 07-09-2015 / 10:52:27 / Jan Vrany " ] { #category : '*petitcompiler' } PPParser >> firstSetSuchThat: block into: aCollection openSet: aSet [ (aSet includes: self) ifTrue: [ ^ aCollection ]. aSet add: self. (block value: self) ifTrue: [aCollection add: self. ^ aCollection ]. self children do: [ :child | child firstSetSuchThat: block into: aCollection openSet: aSet ]. ^ aCollection ] { #category : '*petitcompiler' } PPParser >> id [ self name ifNotNil: [ ^ self name ]. ^ self hash asString ] { #category : '*petitcompiler' } PPParser >> indentPop: value [ self propertyAt: #indentPop put: value. ^ self ] { #category : '*petitcompiler' } PPParser >> indentPush: value [ self propertyAt: #indentPush put: value. ^ self ] { #category : '*petitcompiler' } PPParser >> isCompiled [ ^ false ] { #category : '*petitcompiler' } PPParser >> isContextFree [ ^ self propertyAt: #isContextFree ifAbsentPut: [ self allParsers allSatisfy: [ :p | p isContextFreePrim ] ]. ] { #category : '*petitcompiler' } PPParser >> isContextFreePrim [ ^ true ] { #category : '*petitcompiler' } PPParser >> isContextSensitive [ ^ self isContextFree not ] { #category : '*petitcompiler' } PPParser >> isToken [ ^ false ] { #category : '*petitcompiler' } PPParser >> isTokenParser [ ^ false ] { #category : '*petitcompiler' } PPParser >> javaToken [ | ws | ws := PPJavaWhitespaceParser new. ^ ((ws, ((PPTokenParser on: self) tokenClass: PPJavaToken; yourself), ws) ==> #second) propertyAt: #'trimmingToken' put: true; yourself . ] { #category : '*petitcompiler' } PPParser >> optimize [ ^ self copy ] { #category : '*petitcompiler' } PPParser >> optimized [ ^ self copy ] { #category : '*petitcompiler' } PPParser >> properties: whatever [ properties := whatever ] { #category : '*petitcompiler' } PPParser >> trimmingToken [ | ws | ws := #space asParser star. ^ ((ws, (PPTokenParser on: self), ws) ==> #second) propertyAt: #trimmingToken put: true; yourself ]