{ import Smalltalk/kernel } " -*- Smalltalk -*- " { import GetOpt } { import String-io } Scanner : Object ( charTable charEscapes input c token type includeStack searchPaths prevHash ) Parser : Scanner () Compiler : Parser ( program translationUnit ) Scope : Object ( level environment imports exports parent block exportSelf exportOuter exportNLR minTemp maxTemp nTemps literals blocks ) TranslationUnit : Object ( environment classes selectors outputStream ) Variable : Object () NamedVariable : Variable ( name mangledName ) GlobalVariable : NamedVariable () SelfVariable : NamedVariable () ReceiverVariable : NamedVariable ( class ) LocalVariable : NamedVariable ( isExported level offset ) RemoteReceiverVariable : Variable ( receiverVariable ) RemoteVariable : Variable ( level offset ) ParseNode : Object ( location ) ValueNode : ParseNode ( value ) BlockReturnNode : ValueNode () ReturnNode : BlockReturnNode ( level ) LiteralNode : ValueNode ( tag ) SymbolNode : LiteralNode () StringNode : LiteralNode () IntegerNode : LiteralNode () CharacterNode : LiteralNode () ArrayNode : LiteralNode () WordArrayNode : LiteralNode () ByteArrayNode : LiteralNode () VariableNode : ParseNode ( name variable ) AssignmentNode : ParseNode ( variable value ) SendNode : ParseNode ( receiver selector mangled arguments cascade supered macro ) ExternNode : ParseNode ( code ) ClassNode : ParseNode ( name mangledName typeName base slots ) SequenceNode : ParseNode ( temporaries statements literals scope ) BlockNode : SequenceNode ( arguments variadic tag ) MethodNode : BlockNode ( class selector ) ExecNode : SequenceNode () Object notImplemented: selector [ self error: self debugName , ' has not yet implemented ' , selector ] { import ParseNode } { import Variable } { import TranslationUnit } { import Compiler } [ | files searchPath outputPath | files := OrderedCollection new. searchPath := OrderedCollection new. outputPath := nil. GetOpt new at: $I put: [ :opt :arg | searchPath add: arg ]; at: $o put: [ :opt :arg | outputPath := arg ]; at: $? put: [ :opt | self error: 'illegal option: -' , opt asString ]; default: [ :arg | files add: arg ]; parse: Smalltalk arguments startingAt: 1. files size < 1 ifTrue: [self error: 'no source file specified']. files size > 1 ifTrue: [self error: 'multiple source files specified']. " ('compile: ', files printString) println. ('to: ', outputPath printString) println. ('searching: ', searchPath printString) println. " Compiler compile: (String readFromFileNamed: files first) to: outputPath searching: searchPath ]