From 81a483d540179c7f344590faaf1be7343fab8820 Mon Sep 17 00:00:00 2001 From: Veit Heller Date: Mon, 13 Jun 2022 15:10:12 +0200 Subject: [PATCH] Evaluation works! --- src/Carp-AST/CarpCharacterNode.class.st | 5 + src/Carp-AST/CarpExpressionNode.class.st | 5 + src/Carp-AST/CarpNumberNode.class.st | 5 + src/Carp-AST/CarpPairNode.class.st | 5 + src/Carp-AST/CarpQuoteNode.class.st | 5 + src/Carp-AST/CarpStartNode.class.st | 5 + src/Carp-AST/CarpStringNode.class.st | 5 + src/Carp-AST/CarpVariableNode.class.st | 5 + src/Carp-Parser/CarpArrayNode.class.st | 5 + src/Carp-Parser/CarpDerefNode.class.st | 5 + src/Carp-Parser/CarpListNode.class.st | 5 + src/Carp-Parser/CarpMapNode.class.st | 5 + src/Carp-Parser/CarpModuleOrTypeNode.class.st | 5 + src/Carp-Parser/CarpParser.class.st | 98 ++++++---- src/Carp-Parser/CarpPatternNode.class.st | 5 + src/Carp-Parser/CarpRefCallNode.class.st | 5 + src/Carp-Parser/CarpRefNode.class.st | 5 + src/Carp-Parser/CarpScanner.class.st | 172 ++++++++---------- src/Carp-Parser/CarpUnquoteNode.class.st | 5 + src/Carp/CarpApplication.class.st | 2 +- src/Carp/CarpCommand.class.st | 10 + src/Carp/CarpCommandFactory.class.st | 10 + src/Carp/CarpDeserializer.class.st | 14 +- src/Carp/CarpPostMortemDebugger.class.st | 11 +- src/Carp/CarpPostMortemStackFrame.class.st | 13 ++ src/Carp/GtCarpCoderModel.class.st | 77 ++++---- src/Carp/LanguageLinkSettings.extension.st | 2 +- src/Carp/LeCarpApplicationStrategy.class.st | 11 +- 28 files changed, 307 insertions(+), 198 deletions(-) create mode 100644 src/Carp/CarpCommand.class.st diff --git a/src/Carp-AST/CarpCharacterNode.class.st b/src/Carp-AST/CarpCharacterNode.class.st index 070f20b..a3ee3cf 100644 --- a/src/Carp-AST/CarpCharacterNode.class.st +++ b/src/Carp-AST/CarpCharacterNode.class.st @@ -13,6 +13,11 @@ CarpCharacterNode >> acceptVisitor: anExpressionVisitor [ ^ anExpressionVisitor visitCharacter: self ] +{ #category : #accessing } +CarpCharacterNode >> toPharo [ + ^ value source asCharacter +] + { #category : #generated } CarpCharacterNode >> tokenVariables [ diff --git a/src/Carp-AST/CarpExpressionNode.class.st b/src/Carp-AST/CarpExpressionNode.class.st index a9fbabc..402d974 100644 --- a/src/Carp-AST/CarpExpressionNode.class.st +++ b/src/Carp-AST/CarpExpressionNode.class.st @@ -25,3 +25,8 @@ CarpExpressionNode >> isQuoted [ CarpExpressionNode >> listDepth [ ^ parent ifNil: [ 0 ] ifNotNil: [ parent listDepth + 1 ] ] + +{ #category : #accessing } +CarpExpressionNode >> toPharo [ + ^ self subclassResponsibility +] diff --git a/src/Carp-AST/CarpNumberNode.class.st b/src/Carp-AST/CarpNumberNode.class.st index db30bce..d19feb6 100644 --- a/src/Carp-AST/CarpNumberNode.class.st +++ b/src/Carp-AST/CarpNumberNode.class.st @@ -13,6 +13,11 @@ CarpNumberNode >> acceptVisitor: anExpressionVisitor [ ^ anExpressionVisitor visitNumber: self ] +{ #category : #accessing } +CarpNumberNode >> toPharo [ + ^ value source asInteger +] + { #category : #generated } CarpNumberNode >> tokenVariables [ diff --git a/src/Carp-AST/CarpPairNode.class.st b/src/Carp-AST/CarpPairNode.class.st index 5e80154..609107c 100644 --- a/src/Carp-AST/CarpPairNode.class.st +++ b/src/Carp-AST/CarpPairNode.class.st @@ -34,6 +34,11 @@ CarpPairNode >> nodeVariables [ ^ #( #key #value ) ] +{ #category : #accessing } +CarpPairNode >> toPharo [ + ^ Association key: key toPharo value: value toPharo +] + { #category : #generated } CarpPairNode >> value [ diff --git a/src/Carp-AST/CarpQuoteNode.class.st b/src/Carp-AST/CarpQuoteNode.class.st index 4baf199..eccd997 100644 --- a/src/Carp-AST/CarpQuoteNode.class.st +++ b/src/Carp-AST/CarpQuoteNode.class.st @@ -29,6 +29,11 @@ CarpQuoteNode >> nodeVariables [ ^ #( #value ) ] +{ #category : #accessing } +CarpQuoteNode >> toPharo [ + ^ {#quote . value toPharo } +] + { #category : #generated } CarpQuoteNode >> value [ diff --git a/src/Carp-AST/CarpStartNode.class.st b/src/Carp-AST/CarpStartNode.class.st index bf90707..642c2e7 100644 --- a/src/Carp-AST/CarpStartNode.class.st +++ b/src/Carp-AST/CarpStartNode.class.st @@ -38,3 +38,8 @@ CarpStartNode >> initialize [ super initialize. expressions := OrderedCollection new: 2. ] + +{ #category : #accessing } +CarpStartNode >> toPharo [ + ^ expressions collect: #toPharo +] diff --git a/src/Carp-AST/CarpStringNode.class.st b/src/Carp-AST/CarpStringNode.class.st index a4aa7b8..10565d2 100644 --- a/src/Carp-AST/CarpStringNode.class.st +++ b/src/Carp-AST/CarpStringNode.class.st @@ -13,6 +13,11 @@ CarpStringNode >> acceptVisitor: anExpressionVisitor [ ^ anExpressionVisitor visitString: self ] +{ #category : #accessing } +CarpStringNode >> toPharo [ + ^ value source +] + { #category : #generated } CarpStringNode >> tokenVariables [ diff --git a/src/Carp-AST/CarpVariableNode.class.st b/src/Carp-AST/CarpVariableNode.class.st index d99a7eb..28d1447 100644 --- a/src/Carp-AST/CarpVariableNode.class.st +++ b/src/Carp-AST/CarpVariableNode.class.st @@ -13,6 +13,11 @@ CarpVariableNode >> acceptVisitor: anExpressionVisitor [ ^ anExpressionVisitor visitVariable: self ] +{ #category : #accessing } +CarpVariableNode >> toPharo [ + ^ value source asSymbol +] + { #category : #generated } CarpVariableNode >> tokenVariables [ diff --git a/src/Carp-Parser/CarpArrayNode.class.st b/src/Carp-Parser/CarpArrayNode.class.st index cbb45f0..3a0c70e 100644 --- a/src/Carp-Parser/CarpArrayNode.class.st +++ b/src/Carp-Parser/CarpArrayNode.class.st @@ -65,6 +65,11 @@ CarpArrayNode >> rightBracket: aSmaCCToken [ rightBracket := aSmaCCToken ] +{ #category : #accessing } +CarpArrayNode >> toPharo [ + ^ expressions collect: #toPharo +] + { #category : #generated } CarpArrayNode >> tokenVariables [ diff --git a/src/Carp-Parser/CarpDerefNode.class.st b/src/Carp-Parser/CarpDerefNode.class.st index 20c6813..8863b41 100644 --- a/src/Carp-Parser/CarpDerefNode.class.st +++ b/src/Carp-Parser/CarpDerefNode.class.st @@ -32,6 +32,11 @@ CarpDerefNode >> nodeVariables [ ^ #( #value ) ] +{ #category : #accessing } +CarpDerefNode >> toPharo [ + ^ {#deref . value toPharo} +] + { #category : #generated } CarpDerefNode >> tokenVariables [ diff --git a/src/Carp-Parser/CarpListNode.class.st b/src/Carp-Parser/CarpListNode.class.st index 3aa6afd..923271d 100644 --- a/src/Carp-Parser/CarpListNode.class.st +++ b/src/Carp-Parser/CarpListNode.class.st @@ -65,6 +65,11 @@ CarpListNode >> rightParen: aSmaCCToken [ rightParen := aSmaCCToken ] +{ #category : #accessing } +CarpListNode >> toPharo [ + ^ expressions collect: #toPharo +] + { #category : #generated } CarpListNode >> tokenVariables [ diff --git a/src/Carp-Parser/CarpMapNode.class.st b/src/Carp-Parser/CarpMapNode.class.st index 74a3cf6..abc2215 100644 --- a/src/Carp-Parser/CarpMapNode.class.st +++ b/src/Carp-Parser/CarpMapNode.class.st @@ -65,6 +65,11 @@ CarpMapNode >> rightBrace: aSmaCCToken [ rightBrace := aSmaCCToken ] +{ #category : #accessing } +CarpMapNode >> toPharo [ + ^ (pairs collect: #toPharo) asDictionary +] + { #category : #generated } CarpMapNode >> tokenVariables [ diff --git a/src/Carp-Parser/CarpModuleOrTypeNode.class.st b/src/Carp-Parser/CarpModuleOrTypeNode.class.st index 424425c..c94420d 100644 --- a/src/Carp-Parser/CarpModuleOrTypeNode.class.st +++ b/src/Carp-Parser/CarpModuleOrTypeNode.class.st @@ -32,6 +32,11 @@ CarpModuleOrTypeNode >> nodeVariables [ ^ #( #value ) ] +{ #category : #accessing } +CarpModuleOrTypeNode >> toPharo [ + ^ value source asSymbol +] + { #category : #generated } CarpModuleOrTypeNode >> tokenVariables [ diff --git a/src/Carp-Parser/CarpParser.class.st b/src/Carp-Parser/CarpParser.class.st index 28d24ac..b0d4086 100644 --- a/src/Carp-Parser/CarpParser.class.st +++ b/src/Carp-Parser/CarpParser.class.st @@ -6,7 +6,7 @@ Class { { #category : #'generated-accessing' } CarpParser class >> cacheId [ - ^'2022-04-17T17:01:25.369965+02:00' + ^'2022-06-13T14:48:36.40126+02:00' ] { #category : #generated } @@ -16,6 +16,26 @@ CarpParser class >> definitionComment [ %root Expression; %prefix Carp; %suffix Node; + +%hierarchy Expression ( + Array + Deref + List + Map + ModuleOrType + Pattern + RefCall + Ref + Unquote + Character + Number + Pair + Quote + Start + String + Variable +); + : \\ (. | u[0-9A-F]{4,4} | o[0-7]{3,3} | newline | return | space | tab | space | backspace | formfeed) # other character types ; @@ -155,44 +175,44 @@ String { #category : #generated } CarpParser class >> reduceTable [ ^#( - #(24 0 #reduceActionForExpressions1: 1289217 false) - #(23 1 #reduceActionForStart1: 1258497 false) - #(32 0 #reduceActionForExpressions1: 1803265 false) - #(43 1 #reduceActionForString1: 2446337 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: 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: 2150401 false) - #(31 3 #reduceActionForMap1: 1744897 false) - #(32 2 #reduceActionForExpressions2: 1803266 false) - #(42 3 #reduceActionForList1: 2364417 false) - #(41 3 #reduceActionForModuleOrType1: 2273281 false) - #(37 3 #reduceActionForArray1: 2059265 false) - #(33 2 #reduceActionForMapPair1: 1846273 false) + #(24 0 #reduceActionForExpressions1: 1449985 false) + #(23 1 #reduceActionForStart1: 1419265 false) + #(32 0 #reduceActionForExpressions1: 1964033 false) + #(43 1 #reduceActionForString1: 2607105 false) + #(40 1 #reduceActionForVariable1: 2394113 false) + #(41 1 #reduceActionForModuleOrType2: 2434050 false) + #(36 1 #reduceActionForNumber1: 2173953 false) + #(35 1 #reduceActionForCharacter1: 2131969 false) + #(24 2 #reduceActionForExpressions2: 1449986 false) + #(25 1 #liftFirstValue: 1508356 false) + #(25 1 #liftFirstValue: 1508357 false) + #(25 1 #liftFirstValue: 1508355 false) + #(25 1 #liftFirstValue: 1508354 false) + #(25 1 #liftFirstValue: 1508353 false) + #(30 1 #liftFirstValue: 1813513 false) + #(30 1 #liftFirstValue: 1813512 false) + #(30 1 #liftFirstValue: 1813511 false) + #(30 1 #liftFirstValue: 1813510 false) + #(30 1 #liftFirstValue: 1813507 false) + #(30 1 #liftFirstValue: 1813509 false) + #(30 1 #liftFirstValue: 1813508 false) + #(39 1 #liftFirstValue: 2356226 false) + #(39 1 #liftFirstValue: 2356225 false) + #(30 1 #liftFirstValue: 1813506 false) + #(30 1 #liftFirstValue: 1813505 false) + #(34 2 #reduceActionForPattern1: 2067457 false) + #(27 2 #reduceActionForUnquote1: 1627137 false) + #(27 2 #reduceActionForUnquote1: 1627138 false) + #(28 2 #reduceActionForRef1: 1709057 false) + #(29 2 #reduceActionForDeref1: 1759233 false) + #(26 2 #reduceActionForRefCall1: 1572865 false) + #(38 2 #reduceActionForQuote1: 2311169 false) + #(31 3 #reduceActionForMap1: 1905665 false) + #(32 2 #reduceActionForExpressions2: 1964034 false) + #(42 3 #reduceActionForList1: 2525185 false) + #(41 3 #reduceActionForModuleOrType1: 2434049 false) + #(37 3 #reduceActionForArray1: 2220033 false) + #(33 2 #reduceActionForMapPair1: 2007041 false) ). ] diff --git a/src/Carp-Parser/CarpPatternNode.class.st b/src/Carp-Parser/CarpPatternNode.class.st index 06a29bc..2929eff 100644 --- a/src/Carp-Parser/CarpPatternNode.class.st +++ b/src/Carp-Parser/CarpPatternNode.class.st @@ -26,6 +26,11 @@ CarpPatternNode >> patternGlyph: aSmaCCToken [ patternGlyph := aSmaCCToken ] +{ #category : #accessing } +CarpPatternNode >> toPharo [ + ^ value source +] + { #category : #generated } CarpPatternNode >> tokenVariables [ diff --git a/src/Carp-Parser/CarpRefCallNode.class.st b/src/Carp-Parser/CarpRefCallNode.class.st index f10e5f6..f51a624 100644 --- a/src/Carp-Parser/CarpRefCallNode.class.st +++ b/src/Carp-Parser/CarpRefCallNode.class.st @@ -32,6 +32,11 @@ CarpRefCallNode >> refGlyph: aSmaCCToken [ refGlyph := aSmaCCToken ] +{ #category : #accessing } +CarpRefCallNode >> toPharo [ + ^ {#'ref-call' . value toPharo} +] + { #category : #generated } CarpRefCallNode >> tokenVariables [ diff --git a/src/Carp-Parser/CarpRefNode.class.st b/src/Carp-Parser/CarpRefNode.class.st index 7e86d01..02a0fa7 100644 --- a/src/Carp-Parser/CarpRefNode.class.st +++ b/src/Carp-Parser/CarpRefNode.class.st @@ -32,6 +32,11 @@ CarpRefNode >> refGlyph: aSmaCCToken [ refGlyph := aSmaCCToken ] +{ #category : #accessing } +CarpRefNode >> toPharo [ + ^ {#ref . value toPharo} +] + { #category : #generated } CarpRefNode >> tokenVariables [ diff --git a/src/Carp-Parser/CarpScanner.class.st b/src/Carp-Parser/CarpScanner.class.st index 17df809..8df57a3 100644 --- a/src/Carp-Parser/CarpScanner.class.st +++ b/src/Carp-Parser/CarpScanner.class.st @@ -30,80 +30,72 @@ CarpScanner >> scan1 [ { #category : #generated } CarpScanner >> scan2 [ - - self recordMatch: #( 13 ). + self recordMatch: #(13). self step. currentCharacter isDigit ifTrue: [ ^ self scan3 ]. - (currentCharacter isLowercase or: [ - currentCharacter isUppercase or: [ - ('!$' includes: currentCharacter) or: [ - (currentCharacter between: $* and: $+) or: [ - ('-/:' includes: currentCharacter) or: [ - (currentCharacter between: $< and: $?) or: [ - currentCharacter == $_ ] ] ] ] ] ]) ifTrue: [ - [ - self recordMatch: #( 13 ). - self step. - currentCharacter isLowercase or: [ - currentCharacter isUppercase or: [ - currentCharacter isDigit or: [ - ('!$' includes: currentCharacter) or: [ - (currentCharacter between: $* and: $+) or: [ - ('-/:' includes: currentCharacter) or: [ - (currentCharacter between: $< and: $?) or: [ - currentCharacter == $_ ] ] ] ] ] ] ] ] whileTrue ]. + (currentCharacter isLowercase + or: [ currentCharacter isUppercase + or: [ ('!$' includes: currentCharacter) + or: [ (currentCharacter between: $* and: $+) + or: [ currentCharacter == $- + or: [ (currentCharacter between: $/ and: $:) + or: [ (currentCharacter between: $< and: $?) or: [ currentCharacter == $_ ] ] ] ] ] ] ]) + ifTrue: [ [ self recordMatch: #(13). + self step. + currentCharacter isLowercase + or: [ currentCharacter isUppercase + or: [ currentCharacter isDigit + or: [ ('!$' includes: currentCharacter) + or: [ (currentCharacter between: $* and: $+) + or: [ ('-/:' includes: currentCharacter) + or: [ (currentCharacter between: $< and: $?) or: [ currentCharacter == $_ ] ] ] ] ] ] ] ] + whileTrue ]. ^ self reportLastMatch ] { #category : #generated } CarpScanner >> scan3 [ - - [ - self recordMatch: #( 13 18 ). + [ self recordMatch: #(13 18). self step. currentCharacter == $. ifTrue: [ ^ self scan4 ]. currentCharacter isDigit ] whileTrue. - ('bfl' includes: currentCharacter) ifTrue: [ - self recordMatch: #( 13 18 ). - self step. - (currentCharacter isLowercase or: [ - currentCharacter isUppercase or: [ - currentCharacter isDigit or: [ - ('!$' includes: currentCharacter) or: [ - (currentCharacter between: $* and: $+) or: [ - ('-/:' includes: currentCharacter) or: [ - (currentCharacter between: $< and: $?) or: [ - currentCharacter == $_ ] ] ] ] ] ] ]) ifTrue: [ - [ - self recordMatch: #( 13 ). + ('bfl' includes: currentCharacter) + ifTrue: [ self recordMatch: #(13 18). self step. - currentCharacter isLowercase or: [ - currentCharacter isUppercase or: [ - currentCharacter isDigit or: [ - ('!$' includes: currentCharacter) or: [ - (currentCharacter between: $* and: $+) or: [ - ('-/:' includes: currentCharacter) or: [ - (currentCharacter between: $< and: $?) or: [ - currentCharacter == $_ ] ] ] ] ] ] ] ] whileTrue ]. - ^ self reportLastMatch ]. - (currentCharacter isUppercase or: [ - currentCharacter isLowercase or: [ - ('!$' includes: currentCharacter) or: [ - (currentCharacter between: $* and: $+) or: [ - ('-/:' includes: currentCharacter) or: [ - (currentCharacter between: $< and: $?) or: [ - currentCharacter == $_ ] ] ] ] ] ]) ifTrue: [ - [ - self recordMatch: #( 13 ). - self step. - currentCharacter isLowercase or: [ - currentCharacter isUppercase or: [ - currentCharacter isDigit or: [ - ('!$' includes: currentCharacter) or: [ - (currentCharacter between: $* and: $+) or: [ - ('-/:' includes: currentCharacter) or: [ - (currentCharacter between: $< and: $?) or: [ - currentCharacter == $_ ] ] ] ] ] ] ] ] whileTrue ]. + (currentCharacter isLowercase + or: [ currentCharacter isUppercase + or: [ currentCharacter isDigit + or: [ ('!$' includes: currentCharacter) + or: [ (currentCharacter between: $* and: $+) + or: [ ('-/:' includes: currentCharacter) + or: [ (currentCharacter between: $< and: $?) or: [ currentCharacter == $_ ] ] ] ] ] ] ]) + ifTrue: [ [ self recordMatch: #(13). + self step. + currentCharacter isLowercase + or: [ currentCharacter isUppercase + or: [ currentCharacter isDigit + or: [ ('!$' includes: currentCharacter) + or: [ (currentCharacter between: $* and: $+) + or: [ ('-/:' includes: currentCharacter) + or: [ (currentCharacter between: $< and: $?) or: [ currentCharacter == $_ ] ] ] ] ] ] ] ] + whileTrue ]. + ^ self reportLastMatch ]. + (currentCharacter isUppercase + or: [ currentCharacter isLowercase + or: [ ('!$' includes: currentCharacter) + or: [ (currentCharacter between: $* and: $+) + or: [ (currentCharacter between: $- and: $:) + or: [ (currentCharacter between: $< and: $?) or: [ currentCharacter == $_ ] ] ] ] ] ]) + ifTrue: [ [ self recordMatch: #(13). + self step. + currentCharacter isLowercase + or: [ currentCharacter isUppercase + or: [ currentCharacter isDigit + or: [ ('!$' includes: currentCharacter) + or: [ (currentCharacter between: $* and: $+) + or: [ ('-/:' includes: currentCharacter) + or: [ (currentCharacter between: $< and: $?) or: [ currentCharacter == $_ ] ] ] ] ] ] ] ] + whileTrue ]. ^ self reportLastMatch ] @@ -152,12 +144,9 @@ CarpScanner >> scan7 [ { #category : #generated } CarpScanner >> scanForToken [ - self step. currentCharacter == $" ifTrue: [ ^ self scan1 ]. - currentCharacter == $# ifTrue: [ ^ self recordAndReportMatch: #( 1 ) ]. - currentCharacter == $% ifTrue: [ ^ self scanForTokenX7 ]. - currentCharacter == $& ifTrue: [ ^ self recordAndReportMatch: #( 4 ) ]. + currentCharacter == $# ifTrue: [ ^ self recordAndReportMatch: #(1) ]. ^ self scanForTokenX9 ] @@ -330,47 +319,36 @@ CarpScanner >> scanForTokenX7 [ { #category : #generated } CarpScanner >> scanForTokenX8 [ - - currentCharacter == $} ifTrue: [ ^ self recordAndReportMatch: #( 7 ) ]. - currentCharacter == $~ ifTrue: [ ^ self recordAndReportMatch: #( 8 ) ]. + currentCharacter == $] ifTrue: [ ^ self recordAndReportMatch: #(17) ]. + currentCharacter == ${ ifTrue: [ ^ self recordAndReportMatch: #(6) ]. + currentCharacter == $} ifTrue: [ ^ self recordAndReportMatch: #(7) ]. + currentCharacter == $~ ifTrue: [ ^ self recordAndReportMatch: #(8) ]. currentCharacter isDigit ifTrue: [ ^ self scan5 ]. - ('''`' includes: currentCharacter) ifTrue: [ - ^ self recordAndReportMatch: #( 12 ) ]. - (currentCharacter isSeparator or: [ - currentCharacter == Character pageUp ]) ifTrue: [ - ^ self scanForTokenX6 ]. + ('''`' includes: currentCharacter) + ifTrue: [ ^ self recordAndReportMatch: #(12) ]. + (currentCharacter isSeparator or: [ currentCharacter == Character pageUp ]) + ifTrue: [ ^ self scanForTokenX6 ]. currentCharacter isUppercase ifTrue: [ ^ self scanForTokenX3 ]. - (currentCharacter isLowercase or: [ - ('!$' includes: currentCharacter) or: [ - (currentCharacter between: $* and: $+) or: [ - ('/:' includes: currentCharacter) or: [ - (currentCharacter between: $< and: $?) or: [ - currentCharacter == $_ ] ] ] ] ]) ifTrue: [ - self scanForTokenX4 ]. + (currentCharacter isLowercase + or: [ (currentCharacter between: $! and: $?) or: [ currentCharacter == $_ ] ]) + ifTrue: [ self scanForTokenX4 ]. ^ self reportLastMatch ] { #category : #generated } CarpScanner >> scanForTokenX9 [ - - currentCharacter == $( ifTrue: [ - ^ self recordAndReportMatch: #( 10 ) ]. - currentCharacter == $) ifTrue: [ - ^ self recordAndReportMatch: #( 11 ) ]. - currentCharacter == $, ifTrue: [ - ^ self recordAndReportMatch: #( 19 ) ]. + currentCharacter == $% ifTrue: [ ^ self scanForTokenX7 ]. + currentCharacter == $& ifTrue: [ ^ self recordAndReportMatch: #(4) ]. + currentCharacter == $( ifTrue: [ ^ self recordAndReportMatch: #(10) ]. + currentCharacter == $) ifTrue: [ ^ self recordAndReportMatch: #(11) ]. + currentCharacter == $, ifTrue: [ ^ self recordAndReportMatch: #(19) ]. currentCharacter == $- ifTrue: [ ^ self scan2 ]. - currentCharacter == $. ifTrue: [ - ^ self recordAndReportMatch: #( 15 ) ]. + currentCharacter == $. ifTrue: [ ^ self recordAndReportMatch: #(15) ]. currentCharacter == $0 ifTrue: [ ^ self scanForTokenX2 ]. currentCharacter == $; ifTrue: [ ^ self scanForTokenX5 ]. - currentCharacter == $@ ifTrue: [ ^ self recordAndReportMatch: #( 5 ) ]. - currentCharacter == $[ ifTrue: [ - ^ self recordAndReportMatch: #( 16 ) ]. + currentCharacter == $@ ifTrue: [ ^ self recordAndReportMatch: #(5) ]. + currentCharacter == $[ ifTrue: [ ^ self recordAndReportMatch: #(16) ]. currentCharacter == $\ ifTrue: [ ^ self scanForTokenX1 ]. - currentCharacter == $] ifTrue: [ - ^ self recordAndReportMatch: #( 17 ) ]. - currentCharacter == ${ ifTrue: [ ^ self recordAndReportMatch: #( 6 ) ]. ^ self scanForTokenX8 ] diff --git a/src/Carp-Parser/CarpUnquoteNode.class.st b/src/Carp-Parser/CarpUnquoteNode.class.st index 190302a..8336eb5 100644 --- a/src/Carp-Parser/CarpUnquoteNode.class.st +++ b/src/Carp-Parser/CarpUnquoteNode.class.st @@ -25,6 +25,11 @@ CarpUnquoteNode >> nodeVariables [ ^ #( #value ) ] +{ #category : #accessing } +CarpUnquoteNode >> toPharo [ + ^ {#unquote . value toPharo} +] + { #category : #generated } CarpUnquoteNode >> tokenVariables [ diff --git a/src/Carp/CarpApplication.class.st b/src/Carp/CarpApplication.class.st index db0a36e..a48de25 100644 --- a/src/Carp/CarpApplication.class.st +++ b/src/Carp/CarpApplication.class.st @@ -22,7 +22,7 @@ CarpApplication >> baseApplication [ CarpApplication >> debuggerClientFor: anException [ "Answer the debugger client to be used by the Gt Post Mortem debugger" - ^ GtPythonPostMortemDebugger new exception: anException + ^ CarpPostMortemDebugger new exception: anException ] { #category : #accessing } diff --git a/src/Carp/CarpCommand.class.st b/src/Carp/CarpCommand.class.st new file mode 100644 index 0000000..09bd741 --- /dev/null +++ b/src/Carp/CarpCommand.class.st @@ -0,0 +1,10 @@ +Class { + #name : #CarpCommand, + #superclass : #LanguageLinkCommand, + #category : #'Carp-LanguageLink' +} + +{ #category : #accessing } +CarpCommand >> codeForRemote [ + ^ (Character space join: self instructions) copyReplaceAll: Character cr asString with: Character lf asString +] diff --git a/src/Carp/CarpCommandFactory.class.st b/src/Carp/CarpCommandFactory.class.st index cf97cb1..0e1ec26 100644 --- a/src/Carp/CarpCommandFactory.class.st +++ b/src/Carp/CarpCommandFactory.class.st @@ -3,3 +3,13 @@ Class { #superclass : #LanguageLinkCommandFactory, #category : #'Carp-Execution' } + +{ #category : #accessing } +CarpCommandFactory >> command [ + ^ command +] + +{ #category : #accessing } +CarpCommandFactory >> instructionsWithNotifyAtEnd [ + ^ instructions +] diff --git a/src/Carp/CarpDeserializer.class.st b/src/Carp/CarpDeserializer.class.st index 4cbf7c2..17b3694 100644 --- a/src/Carp/CarpDeserializer.class.st +++ b/src/Carp/CarpDeserializer.class.st @@ -4,19 +4,19 @@ Class { #category : #'Carp-Serialization' } +{ #category : #'instance creation' } +CarpDeserializer class >> deserialize: anObject [ + ^ self new + deserialize: anObject +] + { #category : #accessing } CarpDeserializer >> buildProxyFor: rawObject [ | proxy | proxy := CarpProxyObject carpType: (rawObject at: #carptype) - var: (rawObject at: #carpvar) asJSGI + var: (rawObject at: #carpvar) application: self application. self executionHandler registerObject: proxy. ^ proxy ] - -{ #category : #accessing } -CarpDeserializer >> deserialize: anObject [ - ^ self new - deserialize: anObject -] diff --git a/src/Carp/CarpPostMortemDebugger.class.st b/src/Carp/CarpPostMortemDebugger.class.st index 8fc9caf..8e45d25 100644 --- a/src/Carp/CarpPostMortemDebugger.class.st +++ b/src/Carp/CarpPostMortemDebugger.class.st @@ -23,7 +23,7 @@ CarpPostMortemDebugger >> exception: anException [ CarpPostMortemDebugger >> initialize [ super initialize. - frameRegex := '\s+at.+\(([^:]+)\:(\d+)\:(\d+)\)' asRegexIgnoringCase. + frameRegex := '(.*)\s+at.+([^:]+)\:(\d+)\:(\d+)\.' asRegexIgnoringCase. ] { #category : #accessing } @@ -37,16 +37,19 @@ CarpPostMortemDebugger >> sourceStyler [ CarpPostMortemDebugger >> stackFrameFromLine: aString ordinal: ordinal [ "Answer a frame if the supplied string contains a valid file and line number, or nil" - | file line column | + | file line column source | ^ (frameRegex search: aString) ifTrue: [ file := frameRegex subexpression: 2. - line := frameRegex subexpression: 3. - column := frameRegex subexpression: 4. + file := frameRegex subexpression: 3. + line := frameRegex subexpression: 4. + column := frameRegex subexpression: 5. + self halt. CarpPostMortemStackFrame new ordinal: ordinal; displayString: aString; exception: exception; + source: source; file: file asFileReference; line: line asNumber; column: column asNumber ] diff --git a/src/Carp/CarpPostMortemStackFrame.class.st b/src/Carp/CarpPostMortemStackFrame.class.st index eb71e7f..52eaac8 100644 --- a/src/Carp/CarpPostMortemStackFrame.class.st +++ b/src/Carp/CarpPostMortemStackFrame.class.st @@ -1,5 +1,18 @@ Class { #name : #CarpPostMortemStackFrame, #superclass : #GtJavaScriptPostMortemStackFrame, + #instVars : [ + 'source' + ], #category : #'Carp-Debugger' } + +{ #category : #accessing } +CarpPostMortemStackFrame >> source: aString [ + source := aString +] + +{ #category : #accessing } +CarpPostMortemStackFrame >> sourceText [ + ^ source +] diff --git a/src/Carp/GtCarpCoderModel.class.st b/src/Carp/GtCarpCoderModel.class.st index cafabf9..013abcf 100644 --- a/src/Carp/GtCarpCoderModel.class.st +++ b/src/Carp/GtCarpCoderModel.class.st @@ -3,7 +3,8 @@ Class { #superclass : #GtSourceCoder, #instVars : [ 'pharoBindings', - 'carpLinkApplicationStrategy' + 'carpLinkApplicationStrategy', + 'exception' ], #category : #'Carp-Coder' } @@ -24,35 +25,37 @@ GtCarpCoderModel >> asCoderViewModel [ { #category : #accessing } GtCarpCoderModel >> bindAndExecute: sourceString [ "Answer the source code with all declared variables returned in an immediate dictionary" + - | carpSource trimmedSource ast varNames lastStatement application commandFactory | - + + | carpSource trimmedSource ast varNames lastStatement application commandFactory res | trimmedSource := SmaCCString on: sourceString trimRight. - ast := CarpParser parse: trimmedSource. - "The variables to be returned are names that are in pharoBindings" - varNames := pharoBindings bindingNames asSet. - - "Assign the final statement to snippetResult" + ast := CarpParser 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 expressions last. - trimmedSource - insert: '(defdynamic snippetResult ' + trimmedSource + insert: '(defdynamic snippetResult ' at: lastStatement startPosition. - trimmedSource - insert: ')' - at: lastStatement stopPosition. - varNames add: 'snippetResult'. - - "Get the final source to execute" - carpSource := self sourceFrom: trimmedSource asString returnedVarNames: varNames. + trimmedSource insert: ')' at: lastStatement stopPosition. + 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. + res := commandFactory + << carpSource; + sendAndWait. + (res at: #result) = 'success' ifTrue: [ ^ res at: #value ]. + exception := (PharoLinkRemoteError new + application: application; + command: commandFactory command; + trace: (res at: #value)). + exception signal ] { #category : #accessing } @@ -66,6 +69,11 @@ GtCarpCoderModel >> computeAst: theSourceString [ parseWithErrors: theSourceString ] +{ #category : #accessing } +GtCarpCoderModel >> exception [ + ^ exception +] + { #category : #accessing } GtCarpCoderModel >> initializeAddOns: addOns [ super initializeAddOns: addOns. @@ -113,36 +121,17 @@ GtCarpCoderModel >> pharoBindings: anObject [ { #category : #accessing } GtCarpCoderModel >> primitiveEvaluate: aSourceString inContext: aGtSourceCoderEvaluationContext onFailDo: anEvaluationFailBlock [ - | result | - - result := self bindAndExecute: aSourceString. - result associationsDo: [ :binding | - (pharoBindings bindingOf: binding key asSymbol) value: binding value ]. - - ^ result - at: 'snippetResult' - ifAbsent: anEvaluationFailBlock + ^ (CarpParser parse: (self bindAndExecute: aSourceString)) expressions first toPharo ] { #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 }' ] + ^ String + streamContents: [ :stream | + stream << trimmedSourceString. + stream lf << 'snippetResult' ] ] { #category : #accessing } diff --git a/src/Carp/LanguageLinkSettings.extension.st b/src/Carp/LanguageLinkSettings.extension.st index f99e22e..d7d10ab 100644 --- a/src/Carp/LanguageLinkSettings.extension.st +++ b/src/Carp/LanguageLinkSettings.extension.st @@ -12,7 +12,7 @@ LanguageLinkSettings class >> carpDefaultSettings [ serverProcessClass: CarpPythonProcess; platform: CarpPlatform new; commandFactoryClass: CarpCommandFactory; - commandClass: LanguageLinkCommand; + commandClass: CarpCommand; serializerClass: LanguageLinkSerializer; deserializerClass: CarpDeserializer; parserClass: CarpParser; diff --git a/src/Carp/LeCarpApplicationStrategy.class.st b/src/Carp/LeCarpApplicationStrategy.class.st index 894747a..dd06582 100644 --- a/src/Carp/LeCarpApplicationStrategy.class.st +++ b/src/Carp/LeCarpApplicationStrategy.class.st @@ -41,15 +41,16 @@ LeCarpApplicationStrategy >> newCarpApplicationFor: aLeDatabase [ { #category : #accessing } LeCarpApplicationStrategy >> updatedSettings: applicationCarpSettings [ "Update the supplied settings with the lepiter configuration" - | lepiterCarpSettings lepiterDatabase carpDir | + | lepiterCarpSettings lepiterDatabase carpDir | lepiterDatabase := content database. + (lepiterDatabase isKindOf: LeNullDatabase) + ifTrue: [ ^ applicationCarpSettings ]. lepiterCarpSettings := lepiterDatabase properties carpLinkSettings. - lepiterCarpSettings directory ifNotNil: - [ :relativeDir | + lepiterCarpSettings directory + ifNotNil: [ :relativeDir | carpDir := lepiterDatabase localStoreRootDirectory resolve: relativeDir. - applicationCarpSettings workingDirectory: carpDir ]. - "lepiterCarpSettings carpPath ifNotNil: + applicationCarpSettings workingDirectory: carpDir ]. "lepiterCarpSettings carpPath ifNotNil: [ :carpPath | applicationCarpSettings serverExecutable: carpPath ]." applicationCarpSettings serverDebugMode: lepiterCarpSettings serverDebugMode.