105 lines
2.2 KiB
Smalltalk
105 lines
2.2 KiB
Smalltalk
|
"
|
||
|
Creates a specialized recognizer nodes, that are faster.
|
||
|
|
||
|
The parsers returns objects, e.g. AST as a result.
|
||
|
Recognizer returns only True/False
|
||
|
|
||
|
If I could, I would be a private class of PPCRecognizerComponentDetector.
|
||
|
"
|
||
|
Class {
|
||
|
#name : 'PPCRecognizerComponentVisitor',
|
||
|
#superclass : 'PPCRewritingVisitor',
|
||
|
#category : 'PetitCompiler-Visitors'
|
||
|
}
|
||
|
|
||
|
{ #category : 'initialization' }
|
||
|
PPCRecognizerComponentVisitor >> initialize [
|
||
|
super initialize.
|
||
|
]
|
||
|
|
||
|
{ #category : 'visiting' }
|
||
|
PPCRecognizerComponentVisitor >> visitActionNode: node [
|
||
|
super visitActionNode: node.
|
||
|
^ node child
|
||
|
|
||
|
]
|
||
|
|
||
|
{ #category : 'visiting' }
|
||
|
PPCRecognizerComponentVisitor >> visitPlusMessagePredicateNode: node [
|
||
|
self visitChildren: node.
|
||
|
|
||
|
^ PPCTokenPlusMessagePredicateNode new
|
||
|
name: node name;
|
||
|
message: node message;
|
||
|
child: node child;
|
||
|
yourself
|
||
|
]
|
||
|
|
||
|
{ #category : 'visiting' }
|
||
|
PPCRecognizerComponentVisitor >> visitPlusNode: node [
|
||
|
self visitChildren: node.
|
||
|
|
||
|
^ PPCTokenPlusNode new
|
||
|
name: node name;
|
||
|
child: node child;
|
||
|
yourself
|
||
|
]
|
||
|
|
||
|
{ #category : 'visiting' }
|
||
|
PPCRecognizerComponentVisitor >> visitSequenceNode: node [
|
||
|
| newNode |
|
||
|
newNode := PPCRecognizingSequenceNode new
|
||
|
children: node children;
|
||
|
name: node name;
|
||
|
properties: node properties;
|
||
|
yourself.
|
||
|
|
||
|
self cache: node value: newNode.
|
||
|
|
||
|
^ super visitSequenceNode: newNode.
|
||
|
]
|
||
|
|
||
|
{ #category : 'visiting' }
|
||
|
PPCRecognizerComponentVisitor >> visitStarCharSetPredicateNode: node [
|
||
|
self visitChildren: node.
|
||
|
|
||
|
^ PPCTokenStarCharSetPredicateNode new
|
||
|
name: node name;
|
||
|
predicate: node predicate;
|
||
|
child: node child;
|
||
|
yourself
|
||
|
|
||
|
]
|
||
|
|
||
|
{ #category : 'visiting' }
|
||
|
PPCRecognizerComponentVisitor >> visitStarMessagePredicateNode: node [
|
||
|
self visitChildren: node.
|
||
|
|
||
|
(node message = #isSeparator) ifTrue: [
|
||
|
^ PPCTokenStarSeparatorNode new
|
||
|
name: node name;
|
||
|
child: node child;
|
||
|
message: node message;
|
||
|
yourself.
|
||
|
].
|
||
|
|
||
|
^ PPCTokenStarMessagePredicateNode new
|
||
|
name: node name;
|
||
|
message: node message;
|
||
|
child: node child;
|
||
|
yourself
|
||
|
|
||
|
]
|
||
|
|
||
|
{ #category : 'visiting' }
|
||
|
PPCRecognizerComponentVisitor >> visitSymbolActionNode: node [
|
||
|
self visitChildren: node.
|
||
|
^ node child
|
||
|
]
|
||
|
|
||
|
{ #category : 'visiting' }
|
||
|
PPCRecognizerComponentVisitor >> visitTokenNode: node [
|
||
|
self visitChildren: node.
|
||
|
^ node child
|
||
|
]
|