Added standalone Tea compiler - teak
It allows for compilation of .tea files from the command line.
"
Copyright (C) 2015-now Jan Vrany
This code is not an open-source (yet). You may use this code
for your own experiments and projects, given that:
* all modification to the code will be sent to the
original author for inclusion in future releases
* this is not used in any commercial software
This license is provisional and may (will) change in
a future.
"
"{ Package: 'jv:tea/compiler' }"
"{ NameSpace: Smalltalk }"
TestCase subclass:#TCompilerExamples
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Languages-Tea-Compiler-Examples'
!
!TCompilerExamples class methodsFor:'documentation'!
copyright
"
Copyright (C) 2015-now Jan Vrany
This code is not an open-source (yet). You may use this code
for your own experiments and projects, given that:
* all modification to the code will be sent to the
original author for inclusion in future releases
* this is not used in any commercial software
This license is provisional and may (will) change in
a future.
"
! !
!TCompilerExamples class methodsFor:'asserting'!
isTestSelector:aSelector
^ (super isTestSelector:aSelector) or:[ aSelector startsWith: 'example' ]
"Created: / 14-09-2015 / 11:56:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!TCompilerExamples methodsFor:'tests'!
example_factorialI
| environment unit compiler|
environment := TEnvironment new.
unit := TSourceReader read:'
nil subclass: #FactorialI
category: ''t-Examples''
!!
!!FactorialI class methodsFor:''examples''!!
factorialI:v <tSIntegerW> <^ tSIntegerW>
| result <tSIntegerW>
i <tSIntegerW> |
result := 0.
i := v.
[ i > 1 ] whileTrue:[
result := result * i.
i := i - 1
].
^ result
!! !!
'.
compiler := TCompiler new.
compiler compile: unit in: environment.
self halt.
"
compiler context module
"
"Created: / 19-09-2015 / 18:29:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
example_if
| environment unit compiler|
environment := TEnvironment new.
unit := TSourceReader read:'
nil subclass: #If
category: ''t-Examples''
!!
!!If class methodsFor:''examples''!!
if <^ tSIntegerW>
true ifTrue:[ ^ 1 ] ifFalse:[ ^ 0 ]
'.
compiler := TCompiler new.
compiler compile: unit in: environment.
self halt.
"
compiler context module
"
"Created: / 14-09-2015 / 12:14:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 15-09-2015 / 12:22:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
example_three_plus_four
| environment unit compiler|
environment := TEnvironment new.
unit := TSourceReader read:'
nil subclass: #ThreePlusFour
category: ''t-Examples''
!!
!!ThreePlusFour class methodsFor:''examples''!!
threePlusFour <^ tSIntegerW>
^ 3 + 4
!! !!
'.
compiler := TCompiler new.
compiler compile: unit in: environment.
self halt.
"
compiler context module
"
"Created: / 14-09-2015 / 11:56:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 14-09-2015 / 15:15:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !