-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A new version of the method to reconstruct skipped spaces based on a …
…source map
- Loading branch information
1 parent
31c8c08
commit 9b85725
Showing
20 changed files
with
115 additions
and
20 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/Ohm-Core.package/OhmNode.class/instance/calculateSourceMap.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
private | ||
calculateSourceMap | ||
|
||
^ (self grammar semanticAction: OhmSourceMapping new) createSourceMapFor: self |
8 changes: 8 additions & 0 deletions
8
packages/Ohm-Core.package/OhmNode.class/instance/enclosingRule.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
treeNavigation | ||
enclosingRule | ||
|
||
| aParent | | ||
aParent := self parent. | ||
[aParent ruleName = OhmParsingExpression listRuleIdentifier] whileTrue: [ | ||
aParent := aParent parent]. | ||
^ aParent |
4 changes: 4 additions & 0 deletions
4
packages/Ohm-Core.package/OhmNode.class/instance/isRootNode.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
testing | ||
isRootNode | ||
|
||
^ self parent isNil |
4 changes: 0 additions & 4 deletions
4
packages/Ohm-Core.package/OhmNode.class/instance/nextParentWithChildFurtherLeft.st
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
packages/Ohm-Core.package/OhmNode.class/instance/nextParentWithChildFurtherLeftThan..st
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
treeNavigation | ||
rootNode | ||
|
||
^ self parent | ||
ifNil: [self] | ||
ifNotNil: [self parent rootNode] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/Ohm-Core.package/OhmNode.class/instance/sourceMap.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
accessing | ||
sourceMap | ||
"The sourceMap is only held by the root node" | ||
^ self isRootNode | ||
ifTrue: [sourceMap ifNil: [sourceMap := self calculateSourceMap]] | ||
ifFalse: [self rootNode sourceMap] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/Ohm-Core.package/OhmNodeTest.class/instance/testSkippedSpacesWithManyPExpr.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
running | ||
testSkippedSpacesWithManyPExpr | ||
|
||
| result | | ||
grammar := OhmGrammar new: 'OhmNodeTestGrammar { | ||
StartRule = (";" firstRule)+ | ||
firstRule = "a" | ||
space += comment | ||
comment = "\"" (~"\"" any)* "\"" | ||
}'. | ||
result := (grammar match: ';a ; "comment" a' startingFrom: #StartRule) cst. | ||
|
||
self assert: ' "comment" ' equals: result children last children last skippedSpacesString. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
8 changes: 8 additions & 0 deletions
8
packages/Ohm-Core.package/OhmSourceMapping.class/instance/createSourceMapFor..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
source map generating | ||
createSourceMapFor: aNode | ||
|
||
self sourceMap: ((1 to: aNode interval length) collect: [:i | OrderedCollection new]). | ||
|
||
[self value: aNode. | ||
^ self sourceMap] | ||
ensure: [self sourceMap: nil] |
7 changes: 7 additions & 0 deletions
7
packages/Ohm-Core.package/OhmSourceMapping.class/instance/defaultExpression..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
standard attributes | ||
defaultExpression: aNode | ||
|
||
(aNode interval start to: (aNode interval end min: self sourceMap size)) | ||
do: [:index | (self sourceMap at: index) add: aNode]. | ||
|
||
aNode children do: [:c | self value: c]. |
4 changes: 4 additions & 0 deletions
4
packages/Ohm-Core.package/OhmSourceMapping.class/instance/sourceMap..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
accessing | ||
sourceMap: anObject | ||
|
||
sourceMap := anObject. |
4 changes: 4 additions & 0 deletions
4
packages/Ohm-Core.package/OhmSourceMapping.class/instance/sourceMap.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
accessing | ||
sourceMap | ||
|
||
^ sourceMap |
5 changes: 5 additions & 0 deletions
5
packages/Ohm-Core.package/OhmSourceMapping.class/instance/terminalExpression..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
standard attributes | ||
terminalExpression: aNode | ||
|
||
aNode interval start to: aNode interval end do: [:i | | ||
(self sourceMap at: i) add: aNode] |
9 changes: 9 additions & 0 deletions
9
packages/Ohm-Core.package/OhmSourceMapping.class/methodProperties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"class" : { | ||
}, | ||
"instance" : { | ||
"createSourceMapFor:" : "pre 7/13/2020 10:39", | ||
"defaultExpression:" : "pre 7/13/2020 11:02", | ||
"sourceMap" : "pre 4/29/2020 10:20", | ||
"sourceMap:" : "pre 4/29/2020 10:20", | ||
"terminalExpression:" : "pre 7/13/2020 11:01" } } |
14 changes: 14 additions & 0 deletions
14
packages/Ohm-Core.package/OhmSourceMapping.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"category" : "Ohm-Core", | ||
"classinstvars" : [ | ||
], | ||
"classvars" : [ | ||
], | ||
"commentStamp" : "", | ||
"instvars" : [ | ||
"sourceMap" ], | ||
"name" : "OhmSourceMapping", | ||
"pools" : [ | ||
], | ||
"super" : "OhmSemanticAction", | ||
"type" : "normal" } |