Multiple changes:

- Add the book and a few first pages
- Add the code generator
This commit is contained in:
2022-04-17 19:48:45 +02:00
parent 0469c6dbdf
commit 199758d97d
47 changed files with 5143 additions and 41 deletions

View File

@@ -0,0 +1,55 @@
Class {
#name : #CarpModule,
#superclass : #CarpExpression,
#instVars : [
'uses',
'expressions',
'name'
],
#category : #'Carp-IDE'
}
{ #category : #'instance creation' }
CarpModule class >> named: aString [
^ self new name: aString
]
{ #category : #accessing }
CarpModule >> addExpression: anExpression [
expressions add: anExpression
]
{ #category : #accessing }
CarpModule >> addUse: aString [
uses add: aString
]
{ #category : #initialization }
CarpModule >> initialize [
uses := Set new.
expressions := OrderedCollection new.
]
{ #category : #converting }
CarpModule >> name [
^ name
]
{ #category : #accessing }
CarpModule >> name: aString [
name := aString
]
{ #category : #converting }
CarpModule >> toCarp [
^ String streamContents: [ :aStream |
aStream << '(defmodule ' << self name << ' '
<< (uses ifEmpty: [ '' ] ifNotEmpty: [
Character lf , Character tab , '(use-all '
, (' ' join: uses) , ')' ]).
expressions do: [ :expression |
aStream << Character lf << Character tab
<< expression toCarp ].
aStream << ')' ]
]