Browse Source

Merge branch 'master' of github.com:amber-smalltalk/amber

Nicolas Petton 10 years ago
parent
commit
ea570587b5
3 changed files with 738 additions and 256 deletions
  1. 471 131
      bin/amber-cli.js
  2. 246 106
      cli/js/AmberCli.js
  3. 21 19
      cli/st/AmberCli.st

File diff suppressed because it is too large
+ 471 - 131
bin/amber-cli.js


File diff suppressed because it is too large
+ 246 - 106
cli/js/AmberCli.js


+ 21 - 19
cli/st/AmberCli.st

@@ -913,6 +913,14 @@ prompt
 
 !Repl methodsFor: 'actions'!
 
+clearScreen
+	| esc cls |
+	esc := String fromCharCode: 27.
+	cls := esc, '[2J', esc, '[0;0f'.
+	process stdout write: cls.
+	interface prompt
+!
+
 close
 	process stdin destroy
 !
@@ -936,11 +944,16 @@ eval: buffer on: anObject
 			result := Compiler new evaluateExpression: buffer on: anObject]
 		catch: [:e |
 			e isSmalltalkError
-			    ifTrue: [ErrorHandler new handleError: e]
-			    ifFalse: [process stdout write: e jsStack]]].
+			    ifTrue: [ e resignal ]
+			    ifFalse: [ process stdout write: e jsStack ]]].
 	^ result
 !
 
+printWelcome
+	Transcript show: 'Welcome to Amber version ', Smalltalk current version, ' (NodeJS ', process versions node, ').'.
+	Transcript show: 'Type :q to exit.'; cr.
+!
+
 setPrompt
 	interface setPrompt: self prompt
 ! !
@@ -983,18 +996,12 @@ assignNewVariable: buffer do: aBlock
 	^ self parseAssignment: buffer do: [ :name :expr || varName value |
 		varName := name ifNil: [self nextResultName].
 		session := self addVariableNamed: varName to: session.
-		value := self eval: varName, ' := ', (expr ifNil: [buffer]) on: session.
+		[ value := self eval: varName, ' := ', (expr ifNil: [buffer]) on: session ]
+			on: Error
+			do: [ :e | ErrorHandler new logError: e. value := nil].
 		aBlock value: varName value: value]
 !
 
-clearScreen
-	| esc cls |
-	esc := String fromCharCode: 27.
-	cls := esc, '[2J', esc, '[0;0f'.
-	process stdout write: cls.
-	interface prompt
-!
-
 encapsulateVariable: aString withValue: anObject in: aClass
 	"Add getter and setter for given variable to session."
 	| compiler |
@@ -1022,7 +1029,7 @@ instanceVariableNamesFor: aClass
 !
 
 isIdentifier: aString
-	^ aString match: '^[a-z_]\w+$' asRegexp
+	^ aString match: '^[a-z_]\w*$' asRegexp
 !
 
 isVariableDefined: aString
@@ -1047,8 +1054,8 @@ parseAssignment: aString do: aBlock
 	| assignment |
 	assignment := (aString tokenize: ':=') collect: [:s | s trimBoth].
 	^ (assignment size = 2 and: [self isIdentifier: assignment first])
-		ifTrue: [aBlock value: assignment first value: assignment last]
-		ifFalse: [aBlock value: nil value: nil]
+		ifTrue: [ aBlock value: assignment first value: assignment last ]
+		ifFalse: [ aBlock value: nil value: nil ]
 !
 
 presentResultNamed: varName withValue: value
@@ -1056,11 +1063,6 @@ presentResultNamed: varName withValue: value
 	interface prompt
 !
 
-printWelcome
-	Transcript show: 'Welcome to Amber version ', Smalltalk current version, ' (NodeJS ', process versions node, ').'.
-	Transcript show: 'Type :q to exit.'; cr.
-!
-
 processLine: buffer
 	"Processes lines entered through the readline interface."
 	| show |

Some files were not shown because too many files changed in this diff