Compare commits

...

13 Commits

50 changed files with 360 additions and 8 deletions

View File

@@ -0,0 +1 @@
Im an example for checking Carp code.

View File

@@ -0,0 +1,6 @@
examples
failingCarpChecker
^ CarpChecker new
carp: '/Users/veitheller/.local/bin/carp';
dir: '/Users/veitheller/Documents/Code/Github/carp/Carp/';
file: '(def x a)'

View File

@@ -0,0 +1,6 @@
examples
succeedingCarpChecker
^ CarpChecker new
carp: '/Users/veitheller/.local/bin/carp';
dir: '/Users/veitheller/Documents/Code/Github/carp/Carp/';
file: '(def x 1)'

View File

@@ -0,0 +1,11 @@
{
"commentStamp" : "VeitHeller 12/16/2019 12:01",
"super" : "Object",
"category" : "Pond",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "CarpCheckExample",
"type" : "normal"
}

View File

@@ -0,0 +1 @@
Im a parser for the results of a Carp check.

View File

@@ -0,0 +1,7 @@
parsing
parse: aStream
| split contents |
contents := aStream upToEnd.
contents ifEmpty: [ ^ OrderedCollection new ].
split := contents splitOn: '\n'.
^ split collect: [ :s | self parseLine: s ]

View File

@@ -0,0 +1,13 @@
parsing
parseLine: aLine
| split res |
split := aLine splitOn: ':'.
split size == 3 ifFalse: [
^ CarpParseError new message: 'unparseable checker line: "' , aLine , '"'].
res := CarpParseError new
file: (split at: 1);
line: (split at: 2) asNumber.
split := (split at: 3) splitOn: ' '.
^ res
column: (split at: 1) asNumber;
message: (' ' join: split allButFirst)

View File

@@ -0,0 +1,11 @@
{
"commentStamp" : "VeitHeller 12/16/2019 11:18",
"super" : "Object",
"category" : "Pond",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "CarpCheckParser",
"type" : "normal"
}

View File

@@ -0,0 +1 @@
Im a special case of a Carp process for checking errors.

View File

@@ -0,0 +1,9 @@
checking
check
| f |
f := FileReference newTempFilePrefix: 'checker' suffix: '.carp'.
f writeStreamDo: [:stream | stream nextPutAll: file].
proc arguments: {'--check' . f pathString }.
self run.
excepted ifNotNil: [ CarpError new messageText: excepted messageText ].
self died ifFalse: [ ^ CarpCheckParser new parse: proc stdoutStream ]

View File

@@ -0,0 +1,3 @@
checking
file: aString
file := aString

View File

@@ -0,0 +1,3 @@
checking
file
^ file

View File

@@ -0,0 +1,5 @@
checking
initialize
proc := OSSUnixSubprocess new command: 'carp';
redirectStdout;
addAllEnvVariablesFromParentWithoutOverride

View File

@@ -0,0 +1,4 @@
checking
run
[ [ proc run ] on: Error do: [ :err | excepted := err ] ] fork.
(Delay forMilliseconds: 500) wait.

View File

@@ -0,0 +1,13 @@
{
"commentStamp" : "VeitHeller 12/16/2019 10:34",
"super" : "CarpProcess",
"category" : "Pond",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"file"
],
"name" : "CarpChecker",
"type" : "normal"
}

View File

@@ -0,0 +1 @@
Im a simple editor with Carp code in it.

View File

@@ -0,0 +1,8 @@
initialization
gtCheck
<gtInspectorAction>
"TODO: make carp checker configurable"
^ GLMGenericAction new
action: [ GTInspector openOn: (CarpCheckExample new succeedingCarpChecker file: editor text asString; check) ];
icon: GLMUIThemeExtraIcons glamorousRefresh;
title: 'Check'

View File

@@ -0,0 +1,6 @@
initialization
gtContent: aView
<gtInspectorPresentationOrder: 0>
(aView custom: editor)
title: 'Editor';
display: text

View File

@@ -0,0 +1,5 @@
initialization
initialize
text := ''.
"TODO: find out how to override the mode properly"
editor := GLMRubricHighlightedTextPresentation new withLineNumbers: true; editingMode: RubPlainTextMode new

View File

@@ -0,0 +1,3 @@
initialization
text
^ text

View File

@@ -0,0 +1,14 @@
{
"commentStamp" : "VeitHeller 12/18/2019 21:39",
"super" : "Object",
"category" : "Pond",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"text",
"editor"
],
"name" : "CarpEditor",
"type" : "normal"
}

View File

@@ -0,0 +1 @@
Im an exception that gets thrown when Carp does something funky.

View File

@@ -0,0 +1,3 @@
accessing
defaultAction
UnhandledError signalForException: self

View File

@@ -0,0 +1,3 @@
instance creation
from: anError
error := anError

View File

@@ -0,0 +1,14 @@
{
"commentStamp" : "VeitHeller 12/14/2019 17:49",
"super" : "Error",
"category" : "Pond",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"parent",
"error"
],
"name" : "CarpError",
"type" : "normal"
}

View File

@@ -0,0 +1 @@
I represent a line of Carp checker output.

View File

@@ -0,0 +1,3 @@
accessing
column: aNumber
column := aNumber

View File

@@ -0,0 +1,3 @@
accessing
file: aString
file := aString

View File

@@ -0,0 +1,3 @@
accessing
line: aNumber
line := aNumber

View File

@@ -0,0 +1,3 @@
accessing
message: aString
message := aString

View File

@@ -0,0 +1,13 @@
accessing
printOn: aStream
(file isNil or: [ line isNil or: column isNil ])
ifTrue: [ aStream nextPutAll: message ]
ifFalse: [
aStream nextPutAll: file.
aStream nextPutAll: ':'.
aStream nextPutAll: line asString.
aStream nextPutAll: ':'.
aStream nextPutAll: column asString.
aStream nextPutAll: ' '.
aStream nextPutAll: message.
]

View File

@@ -0,0 +1,16 @@
{
"commentStamp" : "VeitHeller 12/16/2019 11:26",
"super" : "Object",
"category" : "Pond",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"file",
"line",
"column",
"message"
],
"name" : "CarpParseError",
"type" : "normal"
}

View File

@@ -0,0 +1,3 @@
as yet unclassified
carp: aString
^ self new carp: aString

View File

@@ -0,0 +1,3 @@
accessing
carp: aString
proc command: aString

View File

@@ -0,0 +1,3 @@
accessing
died
^ excepted isNotNil

View File

@@ -0,0 +1,3 @@
accessing
dir: aString
proc environmentAt: 'CARP_DIR' put: aString

View File

@@ -1,3 +1,7 @@
initialization
initialize
proc := OSProcess command: 'carp'
proc := OSSUnixSubprocess new command: 'carp';
redirectStdin;
redirectStdout;
redirectStderr;
addAllEnvVariablesFromParentWithoutOverride

View File

@@ -0,0 +1,3 @@
accessing
isRunning
^ self died not and: proc pid; and: proc exitStatus isNil

View File

@@ -0,0 +1,3 @@
accessing
receiveErrorString
^ proc stderrStream upToEnd

View File

@@ -0,0 +1,3 @@
accessing
receiveString
^ proc stdoutStream upToEnd

View File

@@ -0,0 +1,3 @@
accessing
run
[ [ proc run ] on: Error do: [ :err | excepted := err ] ] fork

View File

@@ -0,0 +1,5 @@
accessing
sendString: aString
proc stdinStream nextPutAll: aString.
proc stdinStream close.
proc redirectStdin

View File

@@ -6,7 +6,8 @@
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"proc"
"proc",
"excepted"
],
"name" : "CarpProcess",
"type" : "normal"

View File

@@ -11,18 +11,25 @@ a dream within a dream of knowledge only it possesses.
## Usage
This is extremely early stage, but youll need `OSProcess` support in Pharo. To
get it, run:
This is extremely early stage, but youll need `OSSubprocess` support in Pharo.
To get it, run:
```
Gofer new
squeaksource: 'OSProcess';
package: 'OSProcess';
```smalltalk
Metacello new
baseline: 'OSSubprocess';
repository: 'github://pharo-contributions/OSSubprocess:master/repository';
load.
```
in a playground.
## More info
You can read the [devlog](/devlog) where I document my progress. Mostly you can
see me fail, which is quite fun. The log as of now is a story of me trying to
get started in one of the last weeks of 2019, getting sick, and not getting very
far at all. I intend to carve out some more time soon.
<hr/>
Have fun!

View File

@@ -15,3 +15,17 @@ Ill likely spend a lot of time hunting down the right API; I just
hope that it even exists.
## Review
Time worked: 1h30m
I got the basics of reading from Carp and writing to Carp working.
`OSProcess` turned out not to be what I need, instead Im now using
a library called `OSSubProcess` that has a way more powerful API and
better documentation.
Sadly `OSSubProcess` requires me to close the `stdin` stream after the
first chunk of writing to it. Im not sure whether I can reopen the
stream, it seems not to work. I filed [an issue on Github](https://github.com/pharo-contributions/OSSubprocess/issues/51),
but I suspect that this is actually not really fixable/not a use
case that they want to support. We will see. I gave up getting more
done for today.

18
devlog/2019-12-15.md Normal file
View File

@@ -0,0 +1,18 @@
# 2019-12-15
Timebox: 3 Hours
## Goals
I want to be able to check Carp source by writing a file to the
file system, checking it, and parsing the results into a good
data structure
## Potential Roadblocks
## Review
Time worked: 0h0m
I got sick and went to sleep after dinner, which is when I wanted
to start working.

32
devlog/2019-12-16.md Normal file
View File

@@ -0,0 +1,32 @@
# 2019-12-16
Timebox: 3 Hours
## Goals
I want to be able to check Carp source by writing a file to the
file system, checking it, and parsing the results into a good
data structure. Copied from yesterday.
## Potential Roadblocks
Im still feeling a little sick and concentrating could be a little
hard.
## Review
Time worked: 1h30m
Well, this was another frustrating day with Pharo. Apparently, the
OS process abstraction Im using has a bug on my OS X where it never
terminates the process. Once again, [Ive opened an issue](https://github.com/pharo-contributions/OSSubprocess/issues/52).
The issue description is shorter than Id usually like, but I dont
quite know whats going on, so Ill just leave it at that.
Despite this frustration I was able to make it work by adding a tiny
manual delay—yuck—and then just checking the output of the command.
Its parsing the response into a data structure that Ill be able to
use in the IDE environment.
My head starts to hurt a little bit so I decided to leave it at that
for today.

24
devlog/2019-12-18.md Normal file
View File

@@ -0,0 +1,24 @@
# 2019-12-18
Timebox: 1 hour
## Goals
Today I want to create a text editor view that can send the current file to a
Carp checker and get the results back; maybe even highlight the errors already,
if I can figure out how to.
## Potential Roadblocks
Im still pretty sick and a little disoriented, and I probably shouldnt work
at all, but I really want to.
## Review
Time worked: 1:00
I was able to make it kinda sorta work. I can open an unhighlighted Carp
editor, play around in it, and try to check the results using a button that
spits out the error in a new inspector for me. This isnt quite what I
envisioned, but all the pieces are there. I just need to connect the dots
somehow now.

18
devlog/postmortem_01.md Normal file
View File

@@ -0,0 +1,18 @@
# Postmortem: Building an IDE for Carp in Pharo in December 2019
In the last week of 2019, I wanted to start building an IDE for Carp in Pharo
Smalltalk. I was unable to make much headway during that time, and I was able
to identify two factors that held me back:
- Firstly, I was fairly inexperienced with the tools Pharo provides for working
with programming languages. While I am somewhat aware of SmaCC, FAMIX, and
Moose, I was not sure how they fit together, and I decided to focus on
creating a connection to the compiler and parsing its results myself first.
This proved to be annoyingly hard to do, which demotivated me.
- I got sick. I was unable to work more than one or two hours a day due to a
cold, which of course slowed me down tremendously also, and obliterated
basically all of the motivation I still had left.
In the end, I didnt get very far, but thats okay. Im not in a rush to get my
ideas out and mostly investigate to satisfy my own self intellectual curiosity,
misguided as it might or might not be.

11
devlog/template.md Normal file
View File

@@ -0,0 +1,11 @@
# date
Timebox:
## Goals
## Potential Roadblocks
## Review
Time worked: