Skip to content

Commit

Permalink
Merge pull request #17120 from jecisc/ast/rename-last-classes
Browse files Browse the repository at this point in the history
Rename AST tokens to start with AST prefix
  • Loading branch information
MarcusDenker authored Sep 18, 2024
2 parents 4b509e7 + 70e902f commit d512ef9
Show file tree
Hide file tree
Showing 26 changed files with 229 additions and 214 deletions.
2 changes: 1 addition & 1 deletion src/AST-Core-Tests/ASTCommentNodeTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ASTCommentNodeTest >> testFoo [
{ #category : 'tests' }
ASTCommentNodeTest >> testIntersectsInterval [
| node |
node:= ASTCommentNode with: (RBCommentToken value: 'Some sample text' start: 5 stop: 21).
node:= ASTCommentNode with: (ASTCommentToken value: 'Some sample text' start: 5 stop: 21).

self
assert: (node intersectsInterval: (4 to: 6)) description: 'either side of interval';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Class {
#name : 'RBEOFTokenTest',
#name : 'ASTEOFTokenTest',
#superclass : 'TestCase',
#instVars : [
'token'
Expand All @@ -10,31 +10,31 @@ Class {
}

{ #category : 'running' }
RBEOFTokenTest >> setUp [
ASTEOFTokenTest >> setUp [
super setUp.
token := RBEOFToken start: (1 to: 10)
token := ASTEOFToken start: (1 to: 10)
]

{ #category : 'tests' }
RBEOFTokenTest >> testLength [
ASTEOFTokenTest >> testLength [

self assert: token length equals: 0
]

{ #category : 'tests' }
RBEOFTokenTest >> testSource [
ASTEOFTokenTest >> testSource [

self assert: token source equals: String empty
]

{ #category : 'tests' }
RBEOFTokenTest >> testValue [
ASTEOFTokenTest >> testValue [

self assert: token value equals: String empty
]

{ #category : 'tests' }
RBEOFTokenTest >> testisEOF [
ASTEOFTokenTest >> testisEOF [

self assert: token isEOF
]
27 changes: 27 additions & 0 deletions src/AST-Core/ASTAssignmentToken.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"
ASTAssignmentToken is the first-class representation of the assignment token ':='
"
Class {
#name : 'ASTAssignmentToken',
#superclass : 'ASTToken',
#category : 'AST-Core-Tokens',
#package : 'AST-Core',
#tag : 'Tokens'
}

{ #category : 'testing' }
ASTAssignmentToken >> isAssignment [
^true
]

{ #category : 'accessing' }
ASTAssignmentToken >> length [

^ 2
]

{ #category : 'evaluating' }
ASTAssignmentToken >> value [
^':='
]
21 changes: 21 additions & 0 deletions src/AST-Core/ASTBinarySelectorToken.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"
ASTBinarySelectorToken is the first-class representation of a binary selector (e.g. +)
"
Class {
#name : 'ASTBinarySelectorToken',
#superclass : 'ASTValueToken',
#category : 'AST-Core-Tokens',
#package : 'AST-Core',
#tag : 'Tokens'
}

{ #category : 'testing' }
ASTBinarySelectorToken >> isBinary [
^true
]

{ #category : 'testing' }
ASTBinarySelectorToken >> isBinary: aString [
^ value = aString
]
2 changes: 1 addition & 1 deletion src/AST-Core/ASTCommentNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ASTCommentNode class >> with: aCommentToken [
{ #category : 'instance creation' }
ASTCommentNode class >> with: aString at: startPosition [

^ self with: (RBCommentToken
^ self with: (ASTCommentToken
value: aString
start: startPosition
stop: startPosition + aString size - 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
First class representation of a scanned comment
"
Class {
#name : 'RBCommentToken',
#superclass : 'RBValueToken',
#name : 'ASTCommentToken',
#superclass : 'ASTValueToken',
#instVars : [
'stopPosition'
],
Expand All @@ -13,35 +13,35 @@ Class {
}

{ #category : 'instance creation' }
RBCommentToken class >> value: aString start: aStartPosition stop: aStopPosition [
ASTCommentToken class >> value: aString start: aStartPosition stop: aStopPosition [
^self new value: aString;
start: aStartPosition;
stop: aStopPosition
]

{ #category : 'accessing' }
RBCommentToken >> first [
ASTCommentToken >> first [

^ self start
]

{ #category : 'testing' }
RBCommentToken >> isComment [
ASTCommentToken >> isComment [
^true
]

{ #category : 'accessing' }
RBCommentToken >> last [
ASTCommentToken >> last [

^ self stop
]

{ #category : 'accessing' }
RBCommentToken >> stop [
ASTCommentToken >> stop [
^ stopPosition
]

{ #category : 'accessing' }
RBCommentToken >> stop: aPosition [
ASTCommentToken >> stop: aPosition [
stopPosition := aPosition
]
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
Class {
#name : 'RBEOFToken',
#superclass : 'RBToken',
#name : 'ASTEOFToken',
#superclass : 'ASTToken',
#category : 'AST-Core-Tokens',
#package : 'AST-Core',
#tag : 'Tokens'
}

{ #category : 'testing' }
RBEOFToken >> isEOF [
ASTEOFToken >> isEOF [
^true
]

{ #category : 'accessing' }
RBEOFToken >> length [
ASTEOFToken >> length [
^ 0
]

{ #category : 'accessing' }
RBEOFToken >> source [
ASTEOFToken >> source [
^ self value
]

{ #category : 'accessing' }
RBEOFToken >> value [
ASTEOFToken >> value [

^ ''
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ I'm a scanned error.
I can have multiple causes.
"
Class {
#name : 'RBErrorToken',
#superclass : 'RBValueToken',
#name : 'ASTErrorToken',
#superclass : 'ASTValueToken',
#instVars : [
'cause',
'location'
Expand All @@ -15,7 +15,7 @@ Class {
}

{ #category : 'instance creation' }
RBErrorToken class >> value: value start: tokenStart cause: errorCause location: thePosition [
ASTErrorToken class >> value: value start: tokenStart cause: errorCause location: thePosition [
^ self new
value: value
start: tokenStart
Expand All @@ -25,27 +25,27 @@ RBErrorToken class >> value: value start: tokenStart cause: errorCause location:
]

{ #category : 'accessing' }
RBErrorToken >> cause [
ASTErrorToken >> cause [
^ cause
]

{ #category : 'testing' }
RBErrorToken >> isError [
ASTErrorToken >> isError [
^true
]

{ #category : 'accessing' }
RBErrorToken >> location [
ASTErrorToken >> location [
^ location
]

{ #category : 'accessing' }
RBErrorToken >> location: anInteger [
ASTErrorToken >> location: anInteger [
location := anInteger
]

{ #category : 'accessing' }
RBErrorToken >> value: theValue start: tokenStart cause: errorCause location: errorPosition [
ASTErrorToken >> value: theValue start: tokenStart cause: errorCause location: errorPosition [
self value: theValue start: tokenStart.
location := errorPosition.
cause := errorCause
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
"
RBIdentifierToken is the first-class representation of an identifier token (e.g. Class)
ASTIdentifierToken is the first-class representation of an identifier token (e.g. Class)
"
Class {
#name : 'RBIdentifierToken',
#superclass : 'RBValueToken',
#name : 'ASTIdentifierToken',
#superclass : 'ASTValueToken',
#category : 'AST-Core-Tokens',
#package : 'AST-Core',
#tag : 'Tokens'
}

{ #category : 'testing' }
RBIdentifierToken >> isIdentifier [
ASTIdentifierToken >> isIdentifier [
^true
]

{ #category : 'testing' }
RBIdentifierToken >> isKeywordPattern [
ASTIdentifierToken >> isKeywordPattern [
^ self isPatternVariable and: [ value second = RBScanner keywordPatternCharacter
and: [ value third ~= RBScanner cascadePatternCharacter ] ]
]

{ #category : 'testing' }
RBIdentifierToken >> isPatternVariable [
ASTIdentifierToken >> isPatternVariable [
^value first = RBScanner patternVariableCharacter
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
RBKeywordToken is the first-class representation of a keyword token (e.g. add:)
"
Class {
#name : 'RBKeywordToken',
#superclass : 'RBValueToken',
#name : 'ASTKeywordToken',
#superclass : 'ASTValueToken',
#category : 'AST-Core-Tokens',
#package : 'AST-Core',
#tag : 'Tokens'
}

{ #category : 'testing' }
RBKeywordToken >> isKeyword [
ASTKeywordToken >> isKeyword [
^true
]

{ #category : 'testing' }
RBKeywordToken >> isPatternVariable [
ASTKeywordToken >> isPatternVariable [
^value first = RBScanner patternVariableCharacter
]

{ #category : 'testing' }
RBKeywordToken >> isPrimitiveKeyword [
ASTKeywordToken >> isPrimitiveKeyword [
^ self value = #primitive:
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ I am the start of a literal array, normal literal arrays `#()` or byte arrays `#
"
Class {
#name : 'RBLiteralArrayToken',
#superclass : 'RBValueToken',
#name : 'ASTLiteralArrayToken',
#superclass : 'ASTValueToken',
#category : 'AST-Core-Tokens',
#package : 'AST-Core',
#tag : 'Tokens'
}

{ #category : 'testing' }
RBLiteralArrayToken >> isForByteArray [
ASTLiteralArrayToken >> isForByteArray [
^value last = $[
]

{ #category : 'testing' }
RBLiteralArrayToken >> isLiteralArrayToken [
ASTLiteralArrayToken >> isLiteralArrayToken [
^true
]
Loading

0 comments on commit d512ef9

Please sign in to comment.