From c3c5d4eb72b8de83b5b6af5f420327cfa540eb07 Mon Sep 17 00:00:00 2001 From: John Brant Date: Thu, 26 Sep 2024 06:38:07 -0500 Subject: [PATCH] fix node creation signal bug created by previous optimization --- src/SmaCC_Development/SmaCCRHS.class.st | 2 +- src/SmaCC_Runtime/SmaCCParser.class.st | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/SmaCC_Development/SmaCCRHS.class.st b/src/SmaCC_Development/SmaCCRHS.class.st index 8eeec118..23732550 100644 --- a/src/SmaCC_Development/SmaCCRHS.class.st +++ b/src/SmaCC_Development/SmaCCRHS.class.st @@ -102,7 +102,7 @@ SmaCCRHS >> firstTerminals [ SmaCCRHS >> generateNamedVariableCollectionWarningFor: problemIndex [ SmaCCCompilationNotification new messageText: 'Node creation'; - tag: [ String + tagBlock: [ String streamContents: [ :stream | stream nextPutAll: 'Non terminal symbol that returns a variable collection is assigned to a variable. The non terminal should be changed to return an AST node:'; diff --git a/src/SmaCC_Runtime/SmaCCParser.class.st b/src/SmaCC_Runtime/SmaCCParser.class.st index f5618ea7..3ac71fab 100644 --- a/src/SmaCC_Runtime/SmaCCParser.class.st +++ b/src/SmaCC_Runtime/SmaCCParser.class.st @@ -785,6 +785,31 @@ SmaCCParser >> shiftAction [ ^ 2r01 ] +{ #category : #accessing } +SmaCCParser >> shortestPathsFrom: startingState [ + | paths todo currentState nextState | + paths := Dictionary new. + paths at: startingState put: OrderedCollection new. + todo := OrderedCollection with: startingState. + [ todo notEmpty ] + whileTrue: [ currentState := todo removeFirst. + 1 + to: self symbolNames size + do: [ :i | + (self actionsForState: currentState and: i) + do: [ :action | + (action bitAnd: 2r11) = self shiftAction + ifTrue: [ nextState := action bitShift: -2. + (paths includesKey: nextState) + ifFalse: [ todo add: nextState. + paths + at: nextState + put: ((paths at: currentState) copy + add: i; + yourself) ] ] ] ] ]. + ^ paths +] + { #category : #parsing } SmaCCParser >> spawnParser: aGLRParserClass [ ^ self