42 lines
834 B
Smalltalk
42 lines
834 B
Smalltalk
Class {
|
|
#name : 'PPCLL1ChoiceVisitor',
|
|
#superclass : 'PPCRewritingVisitor',
|
|
#category : 'PetitCompiler-Visitors'
|
|
}
|
|
|
|
{ #category : 'as yet unclassified' }
|
|
PPCLL1ChoiceVisitor >> visitChoiceNode: node [
|
|
| bag |
|
|
super visitChoiceNode: node.
|
|
|
|
node firstFsa hasDistinctRetvals ifFalse: [
|
|
^ node
|
|
].
|
|
|
|
bag := IdentityBag new.
|
|
node children do: [ :child |
|
|
bag addAll: child firstSetWithTokens.
|
|
].
|
|
|
|
(bag size == bag asIdentitySet size) ifFalse: [
|
|
"some of the tokens are shared between choices"
|
|
^ node
|
|
].
|
|
|
|
^ PPCLL1ChoiceNode new
|
|
children: node children;
|
|
name: node name;
|
|
properties: node properties;
|
|
yourself.
|
|
]
|
|
|
|
{ #category : 'as yet unclassified' }
|
|
PPCLL1ChoiceVisitor >> visitTokenNode: node [
|
|
^ node
|
|
]
|
|
|
|
{ #category : 'as yet unclassified' }
|
|
PPCLL1ChoiceVisitor >> visitTrimmingTokenNode: node [
|
|
^ node
|
|
]
|