Add Lepiter snippets for Carp
This commit is contained in:
21
src/Carp-AST/CarpExpressionNode.class.st
Normal file
21
src/Carp-AST/CarpExpressionNode.class.st
Normal file
@@ -0,0 +1,21 @@
|
||||
Class {
|
||||
#name : #CarpExpressionNode,
|
||||
#superclass : #SmaCCParseNode,
|
||||
#category : #'Carp-AST'
|
||||
}
|
||||
|
||||
{ #category : #generated }
|
||||
CarpExpressionNode >> acceptVisitor: anExpressionVisitor [
|
||||
|
||||
^ anExpressionVisitor visitExpression: self
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
CarpExpressionNode >> isQuoted [
|
||||
^ parent ifNil: [ false ] ifNotNil: [ parent isQuoted ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
CarpExpressionNode >> listDepth [
|
||||
^ parent ifNil: [ 0 ] ifNotNil: [ parent listDepth + 1 ]
|
||||
]
|
@@ -13,6 +13,16 @@ CarpQuoteNode >> acceptVisitor: anExpressionVisitor [
|
||||
^ anExpressionVisitor visitQuote: self
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
CarpQuoteNode >> isQuoted [
|
||||
^ true
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
CarpQuoteNode >> newMethod [
|
||||
"This is a new method"
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpQuoteNode >> nodeVariables [
|
||||
|
1
src/Carp-AST/package.st
Normal file
1
src/Carp-AST/package.st
Normal file
@@ -0,0 +1 @@
|
||||
Package { #name : #'Carp-AST' }
|
1
src/Carp-LanguageLink/package.st
Normal file
1
src/Carp-LanguageLink/package.st
Normal file
@@ -0,0 +1 @@
|
||||
Package { #name : #'Carp-LanguageLink' }
|
@@ -2,9 +2,11 @@ Class {
|
||||
#name : #CarpArrayNode,
|
||||
#superclass : #CarpExpressionNode,
|
||||
#instVars : [
|
||||
'expressions'
|
||||
'leftBracket',
|
||||
'expressions',
|
||||
'rightBracket'
|
||||
],
|
||||
#category : #'Carp-AST'
|
||||
#category : #'Carp-Parser'
|
||||
}
|
||||
|
||||
{ #category : #generated }
|
||||
@@ -38,3 +40,33 @@ CarpArrayNode >> initialize [
|
||||
super initialize.
|
||||
expressions := OrderedCollection new: 2.
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpArrayNode >> leftBracket [
|
||||
|
||||
^ leftBracket
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpArrayNode >> leftBracket: aSmaCCToken [
|
||||
|
||||
leftBracket := aSmaCCToken
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpArrayNode >> rightBracket [
|
||||
|
||||
^ rightBracket
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpArrayNode >> rightBracket: aSmaCCToken [
|
||||
|
||||
rightBracket := aSmaCCToken
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpArrayNode >> tokenVariables [
|
||||
|
||||
^ #( #leftBracket #rightBracket )
|
||||
]
|
@@ -2,9 +2,10 @@ Class {
|
||||
#name : #CarpDerefNode,
|
||||
#superclass : #CarpExpressionNode,
|
||||
#instVars : [
|
||||
'derefGlyph',
|
||||
'value'
|
||||
],
|
||||
#category : #'Carp-AST'
|
||||
#category : #'Carp-Parser'
|
||||
}
|
||||
|
||||
{ #category : #generated }
|
||||
@@ -13,12 +14,30 @@ CarpDerefNode >> acceptVisitor: anExpressionVisitor [
|
||||
^ anExpressionVisitor visitDeref: self
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpDerefNode >> derefGlyph [
|
||||
|
||||
^ derefGlyph
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpDerefNode >> derefGlyph: aSmaCCToken [
|
||||
|
||||
derefGlyph := aSmaCCToken
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpDerefNode >> nodeVariables [
|
||||
|
||||
^ #( #value )
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpDerefNode >> tokenVariables [
|
||||
|
||||
^ #( #derefGlyph )
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpDerefNode >> value [
|
||||
|
@@ -2,9 +2,11 @@ Class {
|
||||
#name : #CarpListNode,
|
||||
#superclass : #CarpExpressionNode,
|
||||
#instVars : [
|
||||
'expressions'
|
||||
'leftParen',
|
||||
'expressions',
|
||||
'rightParen'
|
||||
],
|
||||
#category : #'Carp-AST'
|
||||
#category : #'Carp-Parser'
|
||||
}
|
||||
|
||||
{ #category : #generated }
|
||||
@@ -38,3 +40,33 @@ CarpListNode >> initialize [
|
||||
super initialize.
|
||||
expressions := OrderedCollection new: 2.
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpListNode >> leftParen [
|
||||
|
||||
^ leftParen
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpListNode >> leftParen: aSmaCCToken [
|
||||
|
||||
leftParen := aSmaCCToken
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpListNode >> rightParen [
|
||||
|
||||
^ rightParen
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpListNode >> rightParen: aSmaCCToken [
|
||||
|
||||
rightParen := aSmaCCToken
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpListNode >> tokenVariables [
|
||||
|
||||
^ #( #leftParen #rightParen )
|
||||
]
|
@@ -2,9 +2,11 @@ Class {
|
||||
#name : #CarpMapNode,
|
||||
#superclass : #CarpExpressionNode,
|
||||
#instVars : [
|
||||
'pairs'
|
||||
'leftBrace',
|
||||
'pairs',
|
||||
'rightBrace'
|
||||
],
|
||||
#category : #'Carp-AST'
|
||||
#category : #'Carp-Parser'
|
||||
}
|
||||
|
||||
{ #category : #generated }
|
||||
@@ -25,6 +27,18 @@ CarpMapNode >> initialize [
|
||||
pairs := OrderedCollection new: 2.
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpMapNode >> leftBrace [
|
||||
|
||||
^ leftBrace
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpMapNode >> leftBrace: aSmaCCToken [
|
||||
|
||||
leftBrace := aSmaCCToken
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpMapNode >> pairs [
|
||||
|
||||
@@ -38,3 +52,21 @@ CarpMapNode >> pairs: anOrderedCollection [
|
||||
pairs := anOrderedCollection.
|
||||
self setParents: self pairs to: self
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpMapNode >> rightBrace [
|
||||
|
||||
^ rightBrace
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpMapNode >> rightBrace: aSmaCCToken [
|
||||
|
||||
rightBrace := aSmaCCToken
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpMapNode >> tokenVariables [
|
||||
|
||||
^ #( #leftBrace #rightBrace )
|
||||
]
|
@@ -6,7 +6,7 @@ Class {
|
||||
|
||||
{ #category : #'generated-accessing' }
|
||||
CarpParser class >> cacheId [
|
||||
^'2022-03-20T20:34:27.408287+01:00'
|
||||
^'2022-04-16T18:21:43.028213+02:00'
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
@@ -95,22 +95,22 @@ Expression
|
||||
| Unquote
|
||||
;
|
||||
RefCall
|
||||
: ""~"" Expression 'value' {{}}
|
||||
: ""~"" 'refGlyph' Expression 'value' {{}}
|
||||
;
|
||||
Unquote
|
||||
: (""%"" | ""%@"") Expression 'value' {{}}
|
||||
: (""%"" 'unquoteGlyph' | ""%@""'unquoteGlyph') Expression 'value' {{}}
|
||||
;
|
||||
Ref
|
||||
: ""&"" Expression 'value' {{}}
|
||||
: ""&"" 'refGlyph' Expression 'value' {{}}
|
||||
;
|
||||
Deref
|
||||
: ""@"" Expression 'value' {{}}
|
||||
: ""@"" 'derefGlyph' Expression 'value' {{}}
|
||||
;
|
||||
Literal
|
||||
: String | List | Array | Symbol | Quote | Number | Character | Pattern | Map
|
||||
;
|
||||
Map
|
||||
: ""{"" MapPairs ""}"" {{}}
|
||||
: ""{"" 'leftBrace' MapPairs ""}"" 'rightBrace' {{}}
|
||||
;
|
||||
MapPairs
|
||||
:
|
||||
@@ -120,7 +120,7 @@ MapPair
|
||||
: Expression 'key' Expression 'value' {{Pair}}
|
||||
;
|
||||
Pattern
|
||||
: ""#"" <string_literal> 'value' {{}}
|
||||
: ""#"" 'patternGlyph' <string_literal> 'value' {{}}
|
||||
;
|
||||
Character
|
||||
: <character> 'value' {{}}
|
||||
@@ -129,7 +129,7 @@ Number
|
||||
: <numeric_literal> 'value' {{}}
|
||||
;
|
||||
Array
|
||||
: <open_bracket> Expressions <close_bracket> {{}}
|
||||
: <open_bracket> 'leftBracket' Expressions <close_bracket> 'rightBracket' {{}}
|
||||
;
|
||||
Quote
|
||||
: <quote> Expression 'value' {{}}
|
||||
@@ -145,7 +145,7 @@ ModuleOrType
|
||||
| <module> 'value' {{}}
|
||||
;
|
||||
List
|
||||
: <open_paren> Expressions <close_paren> {{}}
|
||||
: <open_paren> 'leftParen' Expressions <close_paren> 'rightParen' {{}}
|
||||
;
|
||||
String
|
||||
: <string_literal> 'value' {{}}
|
||||
@@ -157,42 +157,42 @@ CarpParser class >> reduceTable [
|
||||
^#(
|
||||
#(24 0 #reduceActionForExpressions1: 1289217 false)
|
||||
#(23 1 #reduceActionForStart1: 1258497 false)
|
||||
#(32 0 #reduceActionForExpressions1: 1712129 false)
|
||||
#(43 1 #reduceActionForString1: 2274305 false)
|
||||
#(40 1 #reduceActionForVariable1: 2097153 false)
|
||||
#(41 1 #reduceActionForModuleOrType2: 2137090 false)
|
||||
#(36 1 #reduceActionForNumber1: 1906689 false)
|
||||
#(35 1 #reduceActionForCharacter1: 1864705 false)
|
||||
#(32 0 #reduceActionForExpressions1: 1803265 false)
|
||||
#(43 1 #reduceActionForString1: 2436097 false)
|
||||
#(40 1 #reduceActionForVariable1: 2233345 false)
|
||||
#(41 1 #reduceActionForModuleOrType2: 2273282 false)
|
||||
#(36 1 #reduceActionForNumber1: 2013185 false)
|
||||
#(35 1 #reduceActionForCharacter1: 1971201 false)
|
||||
#(24 2 #reduceActionForExpressions2: 1289218 false)
|
||||
#(25 1 #liftFirstValue: 1347588 false)
|
||||
#(25 1 #liftFirstValue: 1347589 false)
|
||||
#(25 1 #liftFirstValue: 1347587 false)
|
||||
#(25 1 #liftFirstValue: 1347586 false)
|
||||
#(25 1 #liftFirstValue: 1347585 false)
|
||||
#(30 1 #liftFirstValue: 1587209 false)
|
||||
#(30 1 #liftFirstValue: 1587208 false)
|
||||
#(30 1 #liftFirstValue: 1587207 false)
|
||||
#(30 1 #liftFirstValue: 1587206 false)
|
||||
#(30 1 #liftFirstValue: 1587203 false)
|
||||
#(30 1 #liftFirstValue: 1587205 false)
|
||||
#(30 1 #liftFirstValue: 1587204 false)
|
||||
#(39 1 #liftFirstValue: 2059266 false)
|
||||
#(39 1 #liftFirstValue: 2059265 false)
|
||||
#(30 1 #liftFirstValue: 1587202 false)
|
||||
#(30 1 #liftFirstValue: 1587201 false)
|
||||
#(34 2 #reduceActionForPattern1: 1815553 false)
|
||||
#(27 2 #reduceActionForUnquote1: 1455105 false)
|
||||
#(27 2 #reduceActionForUnquote1: 1455106 false)
|
||||
#(28 2 #reduceActionForRef1: 1507329 false)
|
||||
#(29 2 #reduceActionForDeref1: 1546241 false)
|
||||
#(30 1 #liftFirstValue: 1652745 false)
|
||||
#(30 1 #liftFirstValue: 1652744 false)
|
||||
#(30 1 #liftFirstValue: 1652743 false)
|
||||
#(30 1 #liftFirstValue: 1652742 false)
|
||||
#(30 1 #liftFirstValue: 1652739 false)
|
||||
#(30 1 #liftFirstValue: 1652741 false)
|
||||
#(30 1 #liftFirstValue: 1652740 false)
|
||||
#(39 1 #liftFirstValue: 2195458 false)
|
||||
#(39 1 #liftFirstValue: 2195457 false)
|
||||
#(30 1 #liftFirstValue: 1652738 false)
|
||||
#(30 1 #liftFirstValue: 1652737 false)
|
||||
#(34 2 #reduceActionForPattern1: 1906689 false)
|
||||
#(27 2 #reduceActionForUnquote1: 1466369 false)
|
||||
#(27 2 #reduceActionForUnquote1: 1466370 false)
|
||||
#(28 2 #reduceActionForRef1: 1548289 false)
|
||||
#(29 2 #reduceActionForDeref1: 1598465 false)
|
||||
#(26 2 #reduceActionForRefCall1: 1412097 false)
|
||||
#(38 2 #reduceActionForQuote1: 2014209 false)
|
||||
#(31 3 #reduceActionForMap1: 1679361 false)
|
||||
#(32 2 #reduceActionForExpressions2: 1712130 false)
|
||||
#(42 3 #reduceActionForList1: 2217985 false)
|
||||
#(41 3 #reduceActionForModuleOrType1: 2137089 false)
|
||||
#(37 3 #reduceActionForArray1: 1952769 false)
|
||||
#(33 2 #reduceActionForMapPair1: 1755137 false)
|
||||
#(38 2 #reduceActionForQuote1: 2150401 false)
|
||||
#(31 3 #reduceActionForMap1: 1744897 false)
|
||||
#(32 2 #reduceActionForExpressions2: 1803266 false)
|
||||
#(42 3 #reduceActionForList1: 2354177 false)
|
||||
#(41 3 #reduceActionForModuleOrType1: 2273281 false)
|
||||
#(37 3 #reduceActionForArray1: 2059265 false)
|
||||
#(33 2 #reduceActionForMapPair1: 1846273 false)
|
||||
).
|
||||
]
|
||||
|
||||
@@ -300,7 +300,9 @@ CarpParser >> reduceActionForArray1: nodes [
|
||||
|
||||
| result |
|
||||
result := CarpArrayNode new.
|
||||
result leftBracket: (nodes at: 1).
|
||||
result addNodes: (nodes at: 2) to: result expressions.
|
||||
result rightBracket: (nodes at: 3).
|
||||
^ result
|
||||
]
|
||||
|
||||
@@ -318,6 +320,7 @@ CarpParser >> reduceActionForDeref1: nodes [
|
||||
|
||||
| result |
|
||||
result := CarpDerefNode new.
|
||||
result derefGlyph: (nodes at: 1).
|
||||
result value: (nodes at: 2).
|
||||
^ result
|
||||
]
|
||||
@@ -344,7 +347,9 @@ CarpParser >> reduceActionForList1: nodes [
|
||||
|
||||
| result |
|
||||
result := CarpListNode new.
|
||||
result leftParen: (nodes at: 1).
|
||||
result addNodes: (nodes at: 2) to: result expressions.
|
||||
result rightParen: (nodes at: 3).
|
||||
^ result
|
||||
]
|
||||
|
||||
@@ -353,7 +358,9 @@ CarpParser >> reduceActionForMap1: nodes [
|
||||
|
||||
| result |
|
||||
result := CarpMapNode new.
|
||||
result leftBrace: (nodes at: 1).
|
||||
result addNodes: (nodes at: 2) to: result pairs.
|
||||
result rightBrace: (nodes at: 3).
|
||||
^ result
|
||||
]
|
||||
|
||||
@@ -399,6 +406,7 @@ CarpParser >> reduceActionForPattern1: nodes [
|
||||
|
||||
| result |
|
||||
result := CarpPatternNode new.
|
||||
result patternGlyph: (nodes at: 1).
|
||||
result value: (nodes at: 2).
|
||||
^ result
|
||||
]
|
||||
@@ -417,6 +425,7 @@ CarpParser >> reduceActionForRef1: nodes [
|
||||
|
||||
| result |
|
||||
result := CarpRefNode new.
|
||||
result refGlyph: (nodes at: 1).
|
||||
result value: (nodes at: 2).
|
||||
^ result
|
||||
]
|
||||
@@ -426,6 +435,7 @@ CarpParser >> reduceActionForRefCall1: nodes [
|
||||
|
||||
| result |
|
||||
result := CarpRefCallNode new.
|
||||
result refGlyph: (nodes at: 1).
|
||||
result value: (nodes at: 2).
|
||||
^ result
|
||||
]
|
||||
@@ -453,6 +463,7 @@ CarpParser >> reduceActionForUnquote1: nodes [
|
||||
|
||||
| result |
|
||||
result := CarpUnquoteNode new.
|
||||
result unquoteGlyph: (nodes at: 1).
|
||||
result value: (nodes at: 2).
|
||||
^ result
|
||||
]
|
@@ -2,9 +2,10 @@ Class {
|
||||
#name : #CarpPatternNode,
|
||||
#superclass : #CarpExpressionNode,
|
||||
#instVars : [
|
||||
'patternGlyph',
|
||||
'value'
|
||||
],
|
||||
#category : #'Carp-AST'
|
||||
#category : #'Carp-Parser'
|
||||
}
|
||||
|
||||
{ #category : #generated }
|
||||
@@ -13,10 +14,22 @@ CarpPatternNode >> acceptVisitor: anExpressionVisitor [
|
||||
^ anExpressionVisitor visitPattern: self
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpPatternNode >> patternGlyph [
|
||||
|
||||
^ patternGlyph
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpPatternNode >> patternGlyph: aSmaCCToken [
|
||||
|
||||
patternGlyph := aSmaCCToken
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpPatternNode >> tokenVariables [
|
||||
|
||||
^ #( #value )
|
||||
^ #( #patternGlyph #value )
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
@@ -2,9 +2,10 @@ Class {
|
||||
#name : #CarpRefCallNode,
|
||||
#superclass : #CarpExpressionNode,
|
||||
#instVars : [
|
||||
'refGlyph',
|
||||
'value'
|
||||
],
|
||||
#category : #'Carp-AST'
|
||||
#category : #'Carp-Parser'
|
||||
}
|
||||
|
||||
{ #category : #generated }
|
||||
@@ -19,6 +20,24 @@ CarpRefCallNode >> nodeVariables [
|
||||
^ #( #value )
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpRefCallNode >> refGlyph [
|
||||
|
||||
^ refGlyph
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpRefCallNode >> refGlyph: aSmaCCToken [
|
||||
|
||||
refGlyph := aSmaCCToken
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpRefCallNode >> tokenVariables [
|
||||
|
||||
^ #( #refGlyph )
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpRefCallNode >> value [
|
||||
|
@@ -2,9 +2,10 @@ Class {
|
||||
#name : #CarpRefNode,
|
||||
#superclass : #CarpExpressionNode,
|
||||
#instVars : [
|
||||
'refGlyph',
|
||||
'value'
|
||||
],
|
||||
#category : #'Carp-AST'
|
||||
#category : #'Carp-Parser'
|
||||
}
|
||||
|
||||
{ #category : #generated }
|
||||
@@ -19,6 +20,24 @@ CarpRefNode >> nodeVariables [
|
||||
^ #( #value )
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpRefNode >> refGlyph [
|
||||
|
||||
^ refGlyph
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpRefNode >> refGlyph: aSmaCCToken [
|
||||
|
||||
refGlyph := aSmaCCToken
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpRefNode >> tokenVariables [
|
||||
|
||||
^ #( #refGlyph )
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpRefNode >> value [
|
||||
|
@@ -2,9 +2,10 @@ Class {
|
||||
#name : #CarpUnquoteNode,
|
||||
#superclass : #CarpExpressionNode,
|
||||
#instVars : [
|
||||
'unquoteGlyph',
|
||||
'value'
|
||||
],
|
||||
#category : #'Carp-AST'
|
||||
#category : #'Carp-Parser'
|
||||
}
|
||||
|
||||
{ #category : #generated }
|
||||
@@ -13,12 +14,35 @@ CarpUnquoteNode >> acceptVisitor: anExpressionVisitor [
|
||||
^ anExpressionVisitor visitUnquote: self
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
CarpUnquoteNode >> isQuoted [
|
||||
^ false
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpUnquoteNode >> nodeVariables [
|
||||
|
||||
^ #( #value )
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpUnquoteNode >> tokenVariables [
|
||||
|
||||
^ #( #unquoteGlyph )
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpUnquoteNode >> unquoteGlyph [
|
||||
|
||||
^ unquoteGlyph
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpUnquoteNode >> unquoteGlyph: aSmaCCToken [
|
||||
|
||||
unquoteGlyph := aSmaCCToken
|
||||
]
|
||||
|
||||
{ #category : #generated }
|
||||
CarpUnquoteNode >> value [
|
||||
|
1
src/Carp-Parser/package.st
Normal file
1
src/Carp-Parser/package.st
Normal file
@@ -0,0 +1 @@
|
||||
Package { #name : #'Carp-Parser' }
|
@@ -1,11 +0,0 @@
|
||||
Class {
|
||||
#name : #CarpExpressionNode,
|
||||
#superclass : #SmaCCParseNode,
|
||||
#category : #'Carp-AST'
|
||||
}
|
||||
|
||||
{ #category : #generated }
|
||||
CarpExpressionNode >> acceptVisitor: anExpressionVisitor [
|
||||
|
||||
^ anExpressionVisitor visitExpression: self
|
||||
]
|
129
src/Carp/GtCarpCoderModel.class.st
Normal file
129
src/Carp/GtCarpCoderModel.class.st
Normal file
@@ -0,0 +1,129 @@
|
||||
Class {
|
||||
#name : #GtCarpCoderModel,
|
||||
#superclass : #GtSourceCoder,
|
||||
#instVars : [
|
||||
'pharoBindings',
|
||||
'carpLinkApplicationStrategy'
|
||||
],
|
||||
#category : #'Carp-Coder'
|
||||
}
|
||||
|
||||
{ #category : #converting }
|
||||
GtCarpCoderModel >> asCoderViewModel [
|
||||
|
||||
^ GtSourceCoderViewModel new coder: self
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GtCarpCoderModel >> bindAndExecute: sourceString [
|
||||
"Answer the source code with all declared variables returned in an immediate dictionary"
|
||||
<gtIgnoreConstraint: #GtRBAcceptVisitorCalledFromNonVisitingMethods>
|
||||
| carpSource trimmedSource ast varNames lastStatement application commandFactory |
|
||||
|
||||
trimmedSource := SmaCCString on: sourceString trimRight.
|
||||
ast := JSParser parse: trimmedSource.
|
||||
"The variables to be returned are names that are in pharoBindings"
|
||||
varNames := pharoBindings bindingNames asSet.
|
||||
|
||||
"Assign the final statement to snippetResult"
|
||||
lastStatement := ast items last.
|
||||
trimmedSource
|
||||
insert: '(defdynamic snippetResult '
|
||||
at: lastStatement startPosition.
|
||||
varNames add: 'snippetResult'.
|
||||
|
||||
"Get the final source to execute"
|
||||
carpSource := self sourceFrom: trimmedSource asString returnedVarNames: varNames.
|
||||
|
||||
application := carpLinkApplicationStrategy applicationServer.
|
||||
application isRunning ifFalse: [ application start ].
|
||||
commandFactory := application newCommandFactory.
|
||||
|
||||
^ commandFactory
|
||||
<< carpSource;
|
||||
sendAndWait.
|
||||
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GtCarpCoderModel >> carpLinkApplicationStrategy: anApplicationStrategy [
|
||||
carpLinkApplicationStrategy := anApplicationStrategy
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GtCarpCoderModel >> computeAst: theSourceString [
|
||||
^ CarpParser
|
||||
parseWithErrors: theSourceString
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GtCarpCoderModel >> initializeAddOns: addOns [
|
||||
super initializeAddOns: addOns.
|
||||
|
||||
addOns addStyler: (GtCoderAstSmaCCParserStyler new smaccStyler: CarpParser gtStyler).
|
||||
|
||||
addOns
|
||||
addMainAction: 'Evaluate' translated
|
||||
icon: BrGlamorousVectorIcons play
|
||||
action: [ :aCoderUIModel :anElement |
|
||||
GtCoderCodeExecutor doIt
|
||||
coderViewModel: aCoderUIModel;
|
||||
element: anElement;
|
||||
execute ]
|
||||
id: GtSourceCoderDoItActionId.
|
||||
addOns
|
||||
addMainAction: 'Inspect' translated
|
||||
icon: BrGlamorousVectorIcons playinspect
|
||||
action: [ :aCoderUIModel :anElement |
|
||||
GtCoderCodeExecutor doItAndGo
|
||||
coderViewModel: aCoderUIModel;
|
||||
element: anElement;
|
||||
execute ]
|
||||
id: GtSourceCoderDoItAndGoActionId.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GtCarpCoderModel >> initializeShortcuts: addOns [
|
||||
super initializeShortcuts: addOns.
|
||||
|
||||
addOns
|
||||
addShortcut: GtSourceCoderDoItShortcut new;
|
||||
addShortcut: GtSourceCoderDoItAndInspectShortcut new
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GtCarpCoderModel >> newCompletionStrategy [
|
||||
^ GtCompletionStrategy new
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GtCarpCoderModel >> pharoBindings: anObject [
|
||||
pharoBindings := anObject
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GtCarpCoderModel >> sourceFrom: trimmedSourceString returnedVarNames: varNames [
|
||||
"Answer the modified source to return the declared variables"
|
||||
|
||||
^ String streamContents: [ :stream |
|
||||
stream << trimmedSourceString.
|
||||
stream
|
||||
cr
|
||||
<< '{ '.
|
||||
varNames do: [ :varName |
|
||||
stream
|
||||
<< '(quote ';
|
||||
<< varName;
|
||||
<< ') ';
|
||||
<< varName;
|
||||
<< ' ' ].
|
||||
"Answer the variable dictionary as an immediate object"
|
||||
stream
|
||||
<< '(quote carpLinkImmediate) true }' ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GtCarpCoderModel >> variableBindings: aGtSnippetBindings [
|
||||
|
||||
^ self pharoBindings: aGtSnippetBindings
|
||||
]
|
57
src/Carp/LeCarpApplicationStrategy.class.st
Normal file
57
src/Carp/LeCarpApplicationStrategy.class.st
Normal file
@@ -0,0 +1,57 @@
|
||||
Class {
|
||||
#name : #LeCarpApplicationStrategy,
|
||||
#superclass : #LeExternalServerStrategy,
|
||||
#category : #'Carp-Lepiter'
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
LeCarpApplicationStrategy class >> strategyName [
|
||||
|
||||
^ #global
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
LeCarpApplicationStrategy >> applicationServer [
|
||||
|
||||
content database isDatabase ifFalse: [ ^ nil ].
|
||||
JSLinkApplication uniqueInstance ifNil:
|
||||
[ JSLinkApplication uniqueInstance: (self newJavaScriptApplicationFor: content database) ].
|
||||
^ JSLinkApplication uniqueInstance
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
LeCarpApplicationStrategy >> applicationSettings [
|
||||
"Answer the settings that will be used by the server.
|
||||
This musn't actually start the server as that should be deferred until a snippet is evaluated for the first time."
|
||||
|
||||
^ JSLinkApplication isRunning ifTrue:
|
||||
[ JSLinkApplication uniqueInstance settings ]
|
||||
ifFalse:
|
||||
[ self updatedSettings: JSLinkApplication defaultSettings ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
LeCarpApplicationStrategy >> newJavaScriptApplicationFor: aLeDatabase [
|
||||
|
||||
^ JSLinkApplication new initializeWith:
|
||||
(self updatedSettings: LanguageLinkSettings carpDefaultSettings).
|
||||
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
LeCarpApplicationStrategy >> updatedSettings: applicationCarpSettings [
|
||||
"Update the supplied settings with the lepiter configuration"
|
||||
| lepiterCarpSettings lepiterDatabase carpDir |
|
||||
|
||||
lepiterDatabase := content database.
|
||||
lepiterCarpSettings := lepiterDatabase properties carpLinkSettings.
|
||||
lepiterCarpSettings directory ifNotNil:
|
||||
[ :relativeDir |
|
||||
carpDir := lepiterDatabase localStoreRootDirectory resolve: relativeDir.
|
||||
applicationCarpSettings workingDirectory: carpDir ].
|
||||
"lepiterCarpSettings carpPath ifNotNil:
|
||||
[ :carpPath | applicationCarpSettings serverExecutable: carpPath ]."
|
||||
applicationCarpSettings serverDebugMode: lepiterCarpSettings serverDebugMode.
|
||||
|
||||
^ applicationCarpSettings
|
||||
]
|
42
src/Carp/LeCarpSnippet.class.st
Normal file
42
src/Carp/LeCarpSnippet.class.st
Normal file
@@ -0,0 +1,42 @@
|
||||
Class {
|
||||
#name : #LeCarpSnippet,
|
||||
#superclass : #LeCodeSnippet,
|
||||
#category : #'Carp-Lepiter'
|
||||
}
|
||||
|
||||
{ #category : #'api - accessing menu' }
|
||||
LeCarpSnippet class >> contextMenuItemSpecification [
|
||||
<leSnippetSpecification>
|
||||
^ LeContextMenuItemSpecification new
|
||||
snippetClass: self;
|
||||
title: 'Carp'
|
||||
]
|
||||
|
||||
{ #category : #'lepiter-store' }
|
||||
LeCarpSnippet class >> leJsonV3Name [
|
||||
|
||||
^ 'carpSnippet'
|
||||
]
|
||||
|
||||
{ #category : #'lepiter-store' }
|
||||
LeCarpSnippet class >> leJsonV4Name [
|
||||
|
||||
^ 'carpSnippet'
|
||||
]
|
||||
|
||||
{ #category : #visiting }
|
||||
LeCarpSnippet >> acceptVisitor: aVisitor [
|
||||
|
||||
^ aVisitor visitCarpSnippet: self
|
||||
]
|
||||
|
||||
{ #category : #converting }
|
||||
LeCarpSnippet >> asSnippetViewModel [
|
||||
<return: #LeSnippetViewModel>
|
||||
^ LeCarpSnippetViewModel new snippetModel: self
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
LeCarpSnippet >> newCoder [
|
||||
^ GtCarpCoderModel new
|
||||
]
|
36
src/Carp/LeCarpSnippetElement.class.st
Normal file
36
src/Carp/LeCarpSnippetElement.class.st
Normal file
@@ -0,0 +1,36 @@
|
||||
Class {
|
||||
#name : #LeCarpSnippetElement,
|
||||
#superclass : #LeExternalEvaluatedSnippetElement,
|
||||
#category : #'Carp-Lepiter'
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
LeCarpSnippetElement >> onSnippetViewModelChanged [
|
||||
super onSnippetViewModelChanged.
|
||||
|
||||
self updateLanguageLabel.
|
||||
self coder
|
||||
carpLinkApplicationStrategy: self serverStrategy;
|
||||
pharoBindings: self snippetViewModel snippetBindings
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
LeCarpSnippetElement >> serverStrategy [
|
||||
|
||||
^ serverStrategy ifNil:
|
||||
[ serverStrategy := LeCarpApplicationStrategy new content: self ].
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
LeCarpSnippetElement >> updateLanguageLabel [
|
||||
| serverAddress label |
|
||||
|
||||
serverAddress := self serverStrategy applicationSettings serverSocketAddress.
|
||||
label := String streamContents: [ :stream |
|
||||
stream
|
||||
<< 'Carp @ ';
|
||||
<< serverAddress ipOrName;
|
||||
<< ':';
|
||||
print: serverAddress port ].
|
||||
languageElement text: (label asRopedText glamorousRegularFont foreground: BrGlamorousColors textMarkupColor).
|
||||
]
|
29
src/Carp/LeCarpSnippetViewModel.class.st
Normal file
29
src/Carp/LeCarpSnippetViewModel.class.st
Normal file
@@ -0,0 +1,29 @@
|
||||
Class {
|
||||
#name : #LeCarpSnippetViewModel,
|
||||
#superclass : #LeCodeSnippetViewModel,
|
||||
#category : #'Carp-Lepiter'
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
LeCarpSnippetViewModel >> initializeCoderAddOns: aCoderViewModel [
|
||||
"Initialise the keyboard shortcuts in the code editor"
|
||||
|
||||
aCoderViewModel
|
||||
"Create New snippet (after the current snippet)"
|
||||
addShortcut: (LeSnippetSplitSnippetShortcut new combination: (self keyboardShortcut: #SplitSnippet));
|
||||
"Delete previous character, or merge with previous snippet"
|
||||
addShortcut: (LeSnippetDeletePreviousShortcut new combination: (self keyboardShortcut: #DeletePrevious));
|
||||
"Indent LeSnippet"
|
||||
addShortcut: (LeSnippetIndentSnippetShortcut new combination: (self keyboardShortcut: #IndentSnippet));
|
||||
"Unindent LeSnippet"
|
||||
addShortcut: (LeSnippetUnindentSnippetShortcut new combination: (self keyboardShortcut: #UnindentSnippet));
|
||||
"Move Snippet up"
|
||||
addShortcut: (LeSnippetMoveSnippetUpShortcut new combination: (self keyboardShortcut: #MoveSnippetUp));
|
||||
"Move Snippet down"
|
||||
addShortcut: (LeSnippetMoveSnippetDownShortcut new combination: (self keyboardShortcut: #MoveSnippetDown))
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
LeCarpSnippetViewModel >> snippetElementClass [
|
||||
^ LeCarpSnippetElement
|
||||
]
|
13
src/Carp/LeRoamJSONExportVisitor.extension.st
Normal file
13
src/Carp/LeRoamJSONExportVisitor.extension.st
Normal file
@@ -0,0 +1,13 @@
|
||||
Extension { #name : #LeRoamJSONExportVisitor }
|
||||
|
||||
{ #category : #'*Carp' }
|
||||
LeRoamJSONExportVisitor >> visitCarpSnippet: aSnippet [
|
||||
|
||||
^ String streamContents: [ :aStream |
|
||||
aStream
|
||||
<< '```javascript';
|
||||
cr;
|
||||
<< aSnippet code;
|
||||
cr;
|
||||
<< '```' ]
|
||||
]
|
6
src/Carp/TLeModelVisitor.extension.st
Normal file
6
src/Carp/TLeModelVisitor.extension.st
Normal file
@@ -0,0 +1,6 @@
|
||||
Extension { #name : #TLeModelVisitor }
|
||||
|
||||
{ #category : #'*Carp' }
|
||||
TLeModelVisitor >> visitCarpSnippet: aSnippet [
|
||||
^ self visitTextualSnippet: aSnippet
|
||||
]
|
Reference in New Issue
Block a user