Initial outline of Dart parser
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 10 Jan 2013 13:21:04 +0000
changeset 146dd2b3b6974
parent 0 947ac083e76c
child 2 8fedb5e096fc
Initial outline of Dart parser
compiler/Dart__Parser.st
compiler/Dart__Scanner.st
compiler/Dart__ScannerBase.st
compiler/Make.proto
compiler/Make.spec
compiler/Makefile
compiler/abbrev.stc
compiler/bc.mak
compiler/bmake.bat
compiler/compiler.rc
compiler/jv_dart_compiler.st
compiler/lccmake.bat
compiler/libInit.cc
compiler/mingwmake.bat
compiler/vcmake.bat
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/compiler/Dart__Parser.st	Thu Jan 10 13:21:04 2013 +0000
     1.3 @@ -0,0 +1,65 @@
     1.4 +"{ Package: 'jv:dart/compiler' }"
     1.5 +
     1.6 +"{ NameSpace: Dart }"
     1.7 +
     1.8 +PPCompositeParser subclass:#Parser
     1.9 +	instanceVariableNames:''
    1.10 +	classVariableNames:''
    1.11 +	poolDictionaries:''
    1.12 +	category:'Languages-Dart-Parser'
    1.13 +!
    1.14 +
    1.15 +PPParser subclass:#TokenParser
    1.16 +	instanceVariableNames:'tokenType'
    1.17 +	classVariableNames:''
    1.18 +	poolDictionaries:''
    1.19 +	privateIn:Parser
    1.20 +!
    1.21 +
    1.22 +
    1.23 +!Parser::TokenParser class methodsFor:'instance creation'!
    1.24 +
    1.25 +for: tokenType
    1.26 +
    1.27 +    ^self new tokenType: tokenType
    1.28 +
    1.29 +    "Created: / 14-03-2012 / 23:10:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.30 +! !
    1.31 +
    1.32 +!Parser::TokenParser methodsFor:'accessing'!
    1.33 +
    1.34 +tokenType
    1.35 +    ^ tokenType
    1.36 +!
    1.37 +
    1.38 +tokenType:aSymbol
    1.39 +    tokenType := aSymbol.
    1.40 +! !
    1.41 +
    1.42 +!Parser::TokenParser methodsFor:'parsing'!
    1.43 +
    1.44 +parseOn:aJavaScanner
    1.45 +    "Parse aStream with the receiving parser and answer the parse-result or an instance of PPFailure. 
    1.46 +    Override this method in subclasses to specify custom parse behavior. Do not call this method from outside, 
    1.47 +    instead use #parse:."
    1.48 +
    1.49 +    | pos |
    1.50 +
    1.51 +    pos := aJavaScanner position.
    1.52 +
    1.53 +    ^(aJavaScanner nextToken = tokenType) ifTrue:[
    1.54 +        aJavaScanner token
    1.55 +    ] ifFalse:[
    1.56 +        aJavaScanner position: pos.
    1.57 +        PPFailure message: (tokenType printString , ' token expected (got ', aJavaScanner tokenType , ' {',(aJavaScanner tokenValue ? '<nil>') printString,'})') at: aJavaScanner position
    1.58 +    ]
    1.59 +
    1.60 +    "Modified: / 17-03-2012 / 13:34:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.61 +! !
    1.62 +
    1.63 +!Parser class methodsFor:'documentation'!
    1.64 +
    1.65 +version_HG
    1.66 +
    1.67 +    ^ '$Changeset: <not expanded> $'
    1.68 +! !
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/compiler/Dart__Scanner.st	Thu Jan 10 13:21:04 2013 +0000
     2.3 @@ -0,0 +1,1083 @@
     2.4 +"
     2.5 + COPYRIGHT (c) 2003 by Claus Gittinger
     2.6 +	      All Rights Reserved
     2.7 +
     2.8 + This software is furnished under a license and may be used
     2.9 + only in accordance with the terms of that license and with the
    2.10 + inclusion of the above copyright notice.   This software may not
    2.11 + be provided or otherwise made available to, or used by, any
    2.12 + other person.  No title to or ownership of the software is
    2.13 + hereby transferred.
    2.14 +"
    2.15 +"{ Package: 'jv:dart/compiler' }"
    2.16 +
    2.17 +"{ NameSpace: Dart }"
    2.18 +
    2.19 +ScannerBase subclass:#Scanner
    2.20 +	instanceVariableNames:'allowDegeneratedMantissa keywordTable'
    2.21 +	classVariableNames:'Verbose'
    2.22 +	poolDictionaries:''
    2.23 +	category:'Languages-Dart-Parser'
    2.24 +!
    2.25 +
    2.26 +Object subclass:#Token
    2.27 +	instanceVariableNames:'type value startPosition endPosition'
    2.28 +	classVariableNames:''
    2.29 +	poolDictionaries:''
    2.30 +	privateIn:Scanner
    2.31 +!
    2.32 +
    2.33 +!Scanner class methodsFor:'documentation'!
    2.34 +
    2.35 +copyright
    2.36 +"
    2.37 + COPYRIGHT (c) 2003 by Claus Gittinger
    2.38 +	      All Rights Reserved
    2.39 +
    2.40 + This software is furnished under a license and may be used
    2.41 + only in accordance with the terms of that license and with the
    2.42 + inclusion of the above copyright notice.   This software may not
    2.43 + be provided or otherwise made available to, or used by, any
    2.44 + other person.  No title to or ownership of the software is
    2.45 + hereby transferred.
    2.46 +"
    2.47 +!
    2.48 +
    2.49 +examples
    2.50 +"
    2.51 +    |s in|
    2.52 +
    2.53 +    in := '
    2.54 +function scalefactor(value) {
    2.55 +    scalevector[0]=value;
    2.56 +    scalevector[1]=1.;
    2.57 +    scalevector[2]=1.;
    2.58 +}
    2.59 +'.
    2.60 +
    2.61 +    s := JavaScanner for:in readStream.
    2.62 +    s nextToken
    2.63 +
    2.64 +
    2.65 +    |s in|
    2.66 +
    2.67 +    in := '
    2.68 +function scalefactor(value) {
    2.69 +    scalevector[0]=value;
    2.70 +    scalevector[1]=1.;
    2.71 +    scalevector[2]=1.;
    2.72 +}
    2.73 +'.
    2.74 +    s := JavaScanner new.
    2.75 +    s scanTokens:(in readStream).
    2.76 +
    2.77 +
    2.78 +    |s in|
    2.79 +
    2.80 +    in := '
    2.81 +function scalefactor(value) {
    2.82 +    scalevector[0]=value;
    2.83 +    scalevector[1]=1.;
    2.84 +    scalevector[2]=1.;
    2.85 +}
    2.86 +'.
    2.87 +    in := in readStream.
    2.88 +    s := JavaScanner for:in.
    2.89 +    [in atEnd] whileFalse:[
    2.90 +	Transcript showCR:s nextToken
    2.91 +    ]
    2.92 +
    2.93 +"
    2.94 +
    2.95 +    "Created: / 13.5.1998 / 14:54:06 / cg"
    2.96 +! !
    2.97 +
    2.98 +!Scanner class methodsFor:'initialization'!
    2.99 +
   2.100 +setupActions
   2.101 +    "initialize the scanners actionTables - these are used to dispatch
   2.102 +     into scanner methods as characters are read"
   2.103 +
   2.104 +    |block|
   2.105 +
   2.106 +    self setupKeywordTable.
   2.107 +
   2.108 +    ActionArray := Array new:256.
   2.109 +    TypeArray := Array new:256.
   2.110 +
   2.111 +    block := [:s :char | s nextNumber].
   2.112 +    ($0 asciiValue) to:($9 asciiValue) do:[:index |
   2.113 +        ActionArray at:index put:block
   2.114 +    ].
   2.115 +
   2.116 +    block := [:s :char | s nextSingleCharacterToken:char].
   2.117 +    #( $: $; $, ${ $} $( $) $[ $] $_ $? $@) do:[:ch |
   2.118 +        ActionArray at:(ch asciiValue) put:block
   2.119 +    ].
   2.120 +
   2.121 +    block := [:s :char | s nextIdentifier].
   2.122 +    ($a asciiValue) to:($z asciiValue) do:[:index |
   2.123 +        ActionArray at:index put:block
   2.124 +    ].
   2.125 +    ($A asciiValue) to:($Z asciiValue) do:[:index |
   2.126 +        ActionArray at:index put:block
   2.127 +    ].
   2.128 +    ActionArray at:$_ asciiValue put:block.
   2.129 +
   2.130 +    ActionArray at:$$ asciiValue put:block.
   2.131 +
   2.132 +    ActionArray at:($. asciiValue) put:[:s :char | s nextDotOrFloatOrEllipsis].
   2.133 +
   2.134 +    ActionArray at:($' asciiValue) put:[:s :char | s nextString:$' character:true].
   2.135 +    ActionArray at:($" asciiValue) put:[:s :char | s nextString:$" character:false].
   2.136 +    ActionArray at:($!! asciiValue) put:[:s :char | s nextMulti:#(($= #'!!=')) after:char].
   2.137 +    ActionArray at:($= asciiValue) put:[:s :char | s nextMulti:#(($= #'==')) after:char].
   2.138 +    ActionArray at:($< asciiValue) put:[:s :char | s nextMulti:#(($= #'<=') ($< #'<<')) after:char].
   2.139 +    ActionArray at:($> asciiValue) put:[:s :char | s nextMulti:#(($= #'>=') ($> #'>>' $> #'>>>' $= #'>>>=')) after:char].
   2.140 +
   2.141 +    ActionArray at:($- asciiValue) put:[:s :char | s nextMulti:#(($- #'--') ($= #'-=')) after:char].
   2.142 +    ActionArray at:($+ asciiValue) put:[:s :char | s nextMulti:#(($+ #'++') ($= #'+=')) after:char].
   2.143 +    ActionArray at:($* asciiValue) put:[:s :char | s nextMulti:#(($= #'*=')) after:char].
   2.144 +    ActionArray at:($/ asciiValue) put:[:s :char | s nextMulti:#(($= #'/=') ($/ nil #skipEOLComment) ($* nil #skipComment)) after:char].
   2.145 +    ActionArray at:($% asciiValue) put:[:s :char | s nextMulti:#(($= #'%=')) after:char].
   2.146 +    ActionArray at:($& asciiValue) put:[:s :char | s nextMulti:#(($= #'&=') ($& #'&&')) after:char].
   2.147 +    ActionArray at:($^ asciiValue) put:[:s :char | s nextMulti:#(($= #'^=')) after:char].
   2.148 +    ActionArray at:($~ asciiValue) put:[:s :char | s nextMulti:#(($= #'~=')) after:char].
   2.149 +    ActionArray at:($| asciiValue) put:[:s :char | s nextMulti:#(($= #'|=') ($| #'||')) after:char].
   2.150 +
   2.151 +    "
   2.152 +     self setupActions
   2.153 +    "
   2.154 +
   2.155 +    "Created: / 14-05-1998 / 15:48:03 / cg"
   2.156 +    "Modified: / 17-05-1998 / 21:03:37 / cg"
   2.157 +    "Modified: / 16-03-2012 / 23:49:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.158 +!
   2.159 +
   2.160 +setupKeywordTable
   2.161 +    "initialize the scanners actionTables - these are used to dispatch
   2.162 +     into scanner methods as characters are read"
   2.163 +
   2.164 +    KeywordTable := Dictionary new.
   2.165 +
   2.166 +    #(
   2.167 +        'abstract'              abstract
   2.168 +        'assert'                assert
   2.169 +        'class'                 class
   2.170 +        'extends'               extends
   2.171 +        'factory'               factory
   2.172 +        'get'                   get
   2.173 +        'implements'            implements
   2.174 +        'import'                import
   2.175 +        'interface'             interface
   2.176 +        'is'                    is
   2.177 +        'library'               library
   2.178 +        'native'                native
   2.179 +        'negate'                negate
   2.180 +        'operator'              operator
   2.181 +        'set'                   set
   2.182 +        'source'                source
   2.183 +        'static'                static
   2.184 +        'typedef'               typedef
   2.185 +        'this'                  this
   2.186 +        'super'                 super
   2.187 +        'null'                  null
   2.188 +        'true'                  #true
   2.189 +        'false'                 #false
   2.190 +        'const'                 const
   2.191 +        'new'                   new
   2.192 +        'void'                  void
   2.193 +        'final'                 final
   2.194 +        'var'                   var
   2.195 +        'while'                 while
   2.196 +        'do'                    do
   2.197 +        'for'                   for
   2.198 +        'in'                    in
   2.199 +        'if'                    if
   2.200 +        'else'                  else
   2.201 +        'switch'                switch
   2.202 +        'case'                  case
   2.203 +        'default'               default
   2.204 +        'try'                   try
   2.205 +        'catch'                 catch
   2.206 +        'finally'               finally
   2.207 +        'break'                 break
   2.208 +        'continue'              continue
   2.209 +        'return'                return
   2.210 +        'throw'                 throw
   2.211 +    ) pairWiseDo:[:s :kw |
   2.212 +        KeywordTable at:s put:kw
   2.213 +    ].
   2.214 +
   2.215 +    "
   2.216 +     NewJavaScanner setupKeywordTable
   2.217 +    "
   2.218 +
   2.219 +    "Created: / 14-05-1998 / 15:48:03 / cg"
   2.220 +    "Modified: / 17-05-1998 / 21:03:37 / cg"
   2.221 +    "Modified: / 10-01-2013 / 10:51:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.222 +! !
   2.223 +
   2.224 +!Scanner methodsFor:'accessing'!
   2.225 +
   2.226 +token
   2.227 +    "the previously scanned token"
   2.228 +
   2.229 +    ^Token new
   2.230 +        type: tokenType;
   2.231 +        value: tokenValue;
   2.232 +        startPosition: tokenStartPosition;
   2.233 +        endPosition: tokenEndPosition;
   2.234 +        yourself
   2.235 +
   2.236 +    "Created: / 17-03-2012 / 13:32:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.237 +    "Modified: / 10-01-2013 / 11:20:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.238 +! !
   2.239 +
   2.240 +!Scanner methodsFor:'converting'!
   2.241 +
   2.242 +asPetitStream
   2.243 +
   2.244 +    ^self
   2.245 +
   2.246 +    "Created: / 14-03-2012 / 22:51:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.247 +! !
   2.248 +
   2.249 +!Scanner methodsFor:'error handling'!
   2.250 +
   2.251 +errorMessagePrefix
   2.252 +    ^ 'Dart Error:'
   2.253 +
   2.254 +    "Modified: / 10-01-2013 / 11:21:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.255 +!
   2.256 +
   2.257 +warningMessagePrefix
   2.258 +    ^ 'Dart Warning:'
   2.259 +
   2.260 +    "Modified: / 10-01-2013 / 11:21:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.261 +! !
   2.262 +
   2.263 +!Scanner methodsFor:'initialization'!
   2.264 +
   2.265 +initialize
   2.266 +    "initialize the scanner"
   2.267 +
   2.268 +    super initialize.
   2.269 +
   2.270 +    allowDegeneratedMantissa := true.     "/ something like 123.
   2.271 +    keywordTable := self class keywordTable.
   2.272 +! !
   2.273 +
   2.274 +!Scanner methodsFor:'private'!
   2.275 +
   2.276 +checkForKeyword:string
   2.277 +    "check if string is a keyword (as opposed to an identifier)."
   2.278 +
   2.279 +    |tok|
   2.280 +
   2.281 +    (tok := keywordTable at:string ifAbsent:nil) notNil ifTrue:[
   2.282 +	tokenType := tok.
   2.283 +	^ true
   2.284 +    ].
   2.285 +    ^ false
   2.286 +!
   2.287 +
   2.288 +isCommentCharacter:ch
   2.289 +    "return true, if ch is the comment-start character"
   2.290 +
   2.291 +    ^ false
   2.292 +
   2.293 +    "Created: / 14.5.1998 / 20:53:33 / cg"
   2.294 +!
   2.295 +
   2.296 +rememberTokenStartPosition
   2.297 +    self rememberTokenStartPosition:0
   2.298 +
   2.299 +    "Created: / 17-03-2012 / 00:19:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.300 +!
   2.301 +
   2.302 +rememberTokenStartPosition: offset
   2.303 +    tokenStartPosition := source position - offset
   2.304 +
   2.305 +    "Created: / 17-03-2012 / 17:39:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.306 +! !
   2.307 +
   2.308 +!Scanner methodsFor:'reading next token'!
   2.309 +
   2.310 +characterEscape:char
   2.311 +    |ascii c |
   2.312 +
   2.313 +    char == $" ifTrue:[
   2.314 +        ^ $".
   2.315 +    ].
   2.316 +
   2.317 +    char == $b ifTrue:[
   2.318 +        ^ Character backspace
   2.319 +    ].
   2.320 +    char == $t ifTrue:[
   2.321 +        ^ Character tab
   2.322 +    ].
   2.323 +    char == $n ifTrue:[
   2.324 +        ^ Character cr
   2.325 +    ].
   2.326 +    char == $r ifTrue:[
   2.327 +        ^ Character return
   2.328 +    ].
   2.329 +    char == $f ifTrue:[
   2.330 +        ^ Character newPage
   2.331 +    ].
   2.332 +
   2.333 +    char == $u ifTrue:[
   2.334 +        ascii := 0.
   2.335 +        c := source peekOrNil.
   2.336 +        4 timesRepeat:[
   2.337 +            (c isDigitRadix:16) ifFalse:[
   2.338 +                self syntaxError:'invalid hex character constant'
   2.339 +                        position:source position-2 to:(source position - 1).
   2.340 +                ^ Character value:ascii
   2.341 +            ].
   2.342 +            ascii := (ascii bitShift:4).
   2.343 +            ascii := ascii + c digitValue.
   2.344 +            source next. c := source peekOrNil.
   2.345 +        ].
   2.346 +        ^ Character value:ascii
   2.347 +    ].
   2.348 +"/    char == $x ifTrue:[
   2.349 +"/        ascii := 0.
   2.350 +"/        c := source peekOrNil.
   2.351 +"/        2 timesRepeat:[
   2.352 +"/            (c isDigitRadix:16) ifFalse:[
   2.353 +"/                self syntaxError:'invalid hex character constant'
   2.354 +"/                        position:source position-2 to:(source position - 1).
   2.355 +"/                ^ Character value:ascii
   2.356 +"/            ].
   2.357 +"/            ascii := (ascii bitShift:4).
   2.358 +"/            ascii := ascii + c digitValue.
   2.359 +"/            source next. c := source peekOrNil.
   2.360 +"/        ].
   2.361 +"/        ^ Character value:ascii
   2.362 +"/    ].
   2.363 +    "OctalEscape ::= \ OctalDigit |
   2.364 +                     \ OctalDigit OctalDigit
   2.365 +                     \ ZeroToThree OctalDigit OctalDigit"
   2.366 +
   2.367 +    (char between:$0 and:$3) ifTrue:[
   2.368 +        ascii := char digitValue.
   2.369 +        c := source peekOrNil.
   2.370 +        (c between: $0 and: $7) ifTrue:[
   2.371 +            source next.
   2.372 +            ascii := (ascii bitShift:3).
   2.373 +            ascii := ascii + c digitValue.
   2.374 +        ].
   2.375 +        c := source peekOrNil.
   2.376 +        (c between: $0 and: $7) ifTrue:[
   2.377 +            source next.
   2.378 +            ascii := (ascii bitShift:3).
   2.379 +            ascii := ascii + c digitValue.
   2.380 +        ].
   2.381 +        ^ Character value:ascii
   2.382 +    ].
   2.383 +    (char between:$4 and: $7) ifTrue:[
   2.384 +        ascii := char digitValue.            
   2.385 +        c := source peekOrNil.
   2.386 +        (c between: $0 and: $7) ifTrue:[
   2.387 +            source next.
   2.388 +            ascii := (ascii bitShift:3).
   2.389 +            ascii := ascii + c digitValue.
   2.390 +        ].
   2.391 +        ^ Character value:ascii
   2.392 +    ].
   2.393 +
   2.394 +    ^ char
   2.395 +
   2.396 +    "Modified: / 16-03-2012 / 10:07:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.397 +!
   2.398 +
   2.399 +exponentPart:initialValue
   2.400 +    |nextChar value s|
   2.401 +
   2.402 +    value := initialValue.
   2.403 +    nextChar := source peekOrNil.
   2.404 +
   2.405 +    ((nextChar == $e) or:[nextChar == $E]) ifTrue:[
   2.406 +	nextChar := source nextPeek.
   2.407 +	(nextChar notNil and:[(nextChar isDigitRadix:10) or:['+-' includes:nextChar]]) ifTrue:[
   2.408 +	    s := 1.
   2.409 +	    (nextChar == $+) ifTrue:[
   2.410 +		nextChar := source nextPeek
   2.411 +	    ] ifFalse:[
   2.412 +		(nextChar == $-) ifTrue:[
   2.413 +		    nextChar := source nextPeek.
   2.414 +		    s := s negated
   2.415 +		]
   2.416 +	    ].
   2.417 +	    value := value asFloat
   2.418 +		     * (10.0 raisedToInteger:((Integer readFrom:source radix:10) * s))
   2.419 +	]
   2.420 +    ].
   2.421 +    ^ value
   2.422 +!
   2.423 +
   2.424 +hexponentPart:initialValue
   2.425 +    |nextChar value s|
   2.426 +
   2.427 +    value := initialValue.
   2.428 +    nextChar := source peekOrNil.
   2.429 +
   2.430 +    ((nextChar == $p) or:[nextChar == $P]) ifTrue:[
   2.431 +        nextChar := source nextPeek.
   2.432 +        (nextChar notNil and:[(nextChar isDigitRadix:16) or:['+-' includes:nextChar]]) ifTrue:[
   2.433 +            s := 1.
   2.434 +            (nextChar == $+) ifTrue:[
   2.435 +                nextChar := source nextPeek
   2.436 +            ] ifFalse:[
   2.437 +                (nextChar == $-) ifTrue:[
   2.438 +                    nextChar := source nextPeek.
   2.439 +                    s := s negated
   2.440 +                ]
   2.441 +            ].
   2.442 +            value := value asFloat
   2.443 +                     * (16.0 raisedToInteger:((Integer readFrom:source radix:16) * s))
   2.444 +        ]
   2.445 +    ].
   2.446 +    ^ value
   2.447 +
   2.448 +    "Created: / 16-03-2012 / 00:00:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.449 +!
   2.450 +
   2.451 +nextDotOrFloat
   2.452 +    |nextChar|
   2.453 +
   2.454 +    nextChar := source nextPeek.
   2.455 +    nextChar isDigit ifTrue:[
   2.456 +	^ self nextFractionalPart:0.
   2.457 +    ].
   2.458 +    tokenType := tokenValue := $. .
   2.459 +    ^ tokenType
   2.460 +!
   2.461 +
   2.462 +nextDotOrFloatOrEllipsis
   2.463 +    |nextChar nextChar2|
   2.464 +
   2.465 +    nextChar := source nextPeek.
   2.466 +    nextChar isDigit ifTrue:[
   2.467 +        ^ self nextFractionalPart:0.
   2.468 +    ].
   2.469 +    nextChar == $. ifTrue:[
   2.470 +        nextChar2 := source nextPeek.
   2.471 +        nextChar2 == $. ifTrue:[
   2.472 +            source next.
   2.473 +            tokenType := #Ellipsis.
   2.474 +            tokenValue := '...'.
   2.475 +            ^tokenType.
   2.476 +        ] ifFalse:[
   2.477 +            source skip: -1.
   2.478 +        ].
   2.479 +    ].
   2.480 +    tokenType := tokenValue := $. .
   2.481 +    ^ tokenType
   2.482 +
   2.483 +    "Created: / 15-03-2012 / 10:08:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.484 +!
   2.485 +
   2.486 +nextFractionalPart:intValue
   2.487 +    |nextChar value|
   2.488 +
   2.489 +    value := intValue.
   2.490 +    nextChar := source peekOrNil.
   2.491 +
   2.492 +    (nextChar notNil and:[nextChar isDigitRadix:10]) ifTrue:[
   2.493 +        value := value asFloat + (self nextMantissa:10).
   2.494 +        nextChar := source peekOrNil
   2.495 +    ] ifFalse:[
   2.496 +        allowDegeneratedMantissa == true ifTrue:[
   2.497 +            self warning:'degenerated float constant: ' , value printString , '.' .
   2.498 +            tokenValue := value asFloat.
   2.499 +            tokenType := #Float.
   2.500 +            ^ tokenType
   2.501 +        ].
   2.502 +        nextChar := peekChar := $..
   2.503 +    ].
   2.504 +
   2.505 +    ((nextChar == $e) or:[nextChar == $E]) ifTrue:[
   2.506 +        value := self exponentPart:value.
   2.507 +        nextChar := source peekOrNil
   2.508 +    ] ifFalse:[
   2.509 +        ((nextChar == $p) or:[nextChar == $P]) ifTrue:[
   2.510 +            value := self hexponentPart:value.
   2.511 +            nextChar := source peekOrNil
   2.512 +        ].
   2.513 +    ].
   2.514 +
   2.515 +    tokenValue := value.
   2.516 +
   2.517 +    (nextChar == $d or:[nextChar == $D]) ifTrue:[
   2.518 +        source next.
   2.519 +        tokenType := #Double.
   2.520 +    ] ifFalse:[
   2.521 +        (nextChar == $f or:[nextChar == $F]) ifTrue:[
   2.522 +            source next.
   2.523 +        ].
   2.524 +        tokenType := #Float.
   2.525 +    ].
   2.526 +
   2.527 +    ^ tokenType
   2.528 +
   2.529 +    "Created: / 14-05-1998 / 20:00:25 / cg"
   2.530 +    "Modified: / 16-05-1998 / 15:51:46 / cg"
   2.531 +    "Modified: / 16-03-2012 / 00:00:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.532 +!
   2.533 +
   2.534 +nextHexFractionalPart:intValue
   2.535 +    |nextChar value|
   2.536 +
   2.537 +    value := intValue.
   2.538 +    nextChar := source peekOrNil.
   2.539 +
   2.540 +    (nextChar notNil and:[nextChar isDigitRadix:16]) ifTrue:[
   2.541 +        value := value asFloat + (self nextMantissa:16).
   2.542 +        nextChar := source peekOrNil
   2.543 +    ] ifFalse:[
   2.544 +        allowDegeneratedMantissa == true ifTrue:[
   2.545 +            self warning:'degenerated float constant: ' , value printString , '.' .
   2.546 +            tokenValue := value asFloat.
   2.547 +            tokenType := #Float.
   2.548 +            ^ tokenType
   2.549 +        ].
   2.550 +        nextChar := peekChar := $..
   2.551 +    ].
   2.552 +
   2.553 +    ((nextChar == $e) or:[nextChar == $E]) ifTrue:[
   2.554 +        value := self exponentPart:value.
   2.555 +        nextChar := source peekOrNil
   2.556 +    ] ifFalse:[
   2.557 +        ((nextChar == $p) or:[nextChar == $P]) ifTrue:[
   2.558 +            value := self hexponentPart:value.
   2.559 +            nextChar := source peekOrNil
   2.560 +        ].
   2.561 +    ].
   2.562 +
   2.563 +    tokenValue := value.
   2.564 +
   2.565 +    (nextChar == $d or:[nextChar == $D]) ifTrue:[
   2.566 +        source next.
   2.567 +        tokenType := #Double.
   2.568 +    ] ifFalse:[
   2.569 +        (nextChar == $f or:[nextChar == $F]) ifTrue:[
   2.570 +            source next.
   2.571 +        ].
   2.572 +        tokenType := #Float.
   2.573 +    ].
   2.574 +
   2.575 +    ^ tokenType
   2.576 +
   2.577 +    "Created: / 14-05-1998 / 20:00:25 / cg"
   2.578 +    "Modified: / 16-05-1998 / 15:51:46 / cg"
   2.579 +    "Created: / 16-03-2012 / 00:16:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.580 +!
   2.581 +
   2.582 +nextIdentifier
   2.583 +    "an alpha character (or underscore) has been read.
   2.584 +     Return the next identifier."
   2.585 +
   2.586 +    |nextChar string ok pos|
   2.587 +
   2.588 +    hereChar == $_ ifTrue:[
   2.589 +        nextChar := source nextPeek.
   2.590 +        string := '_'.
   2.591 +        [nextChar == $_] whileTrue:[
   2.592 +            string := string copyWith:$_.
   2.593 +            nextChar := source nextPeek.
   2.594 +        ].
   2.595 +        nextChar isAlphaNumeric ifTrue:[
   2.596 +            string := string , source nextAlphaNumericWord.
   2.597 +        ]
   2.598 +    ] ifFalse:[
   2.599 +        string := source nextAlphaNumericWord "self nextId".
   2.600 +    ].
   2.601 +    nextChar := source peekOrNil.
   2.602 +
   2.603 +    (nextChar == $_ or:[nextChar == $$]) ifTrue:[
   2.604 +        pos := source position.
   2.605 +        ok := true.
   2.606 +        [ok] whileTrue:[
   2.607 +            string := string copyWith:nextChar.
   2.608 +            nextChar := source nextPeek.
   2.609 +            nextChar isNil ifTrue:[
   2.610 +                ok := false
   2.611 +            ] ifFalse:[
   2.612 +                (nextChar isAlphaNumeric) ifTrue:[
   2.613 +                    string := string , source nextAlphaNumericWord.
   2.614 +                    nextChar := source peekOrNil.
   2.615 +                ].
   2.616 +                (nextChar == $_ or:[nextChar == $$]) ifFalse:[
   2.617 +                    ok := false
   2.618 +                ]
   2.619 +            ]
   2.620 +        ].
   2.621 +    ].
   2.622 +
   2.623 +"/    (nextChar == $: and:[scanColonAsLabel]) ifTrue:[
   2.624 +"/        source next.
   2.625 +"/        ch2 := source peekOrNil.
   2.626 +"/        "/ colon follows - care for '::' (nameSpace separator) or ':=' (assignment)
   2.627 +"/        (ch2 == $=) ifFalse:[
   2.628 +"/            (ch2 == $:) ifFalse:[
   2.629 +"/                tokenEndPosition := source position - 1.
   2.630 +"/                token := string copyWith:nextChar.
   2.631 +"/                tokenType := #Keyword.
   2.632 +"/                ^ tokenType
   2.633 +"/            ].
   2.634 +"/            peekChar := $:.
   2.635 +"/            peekChar2 := $:.
   2.636 +"/        ] ifTrue:[
   2.637 +"/            peekChar := $:.
   2.638 +"/            peekChar2 := $=.
   2.639 +"/        ]
   2.640 +"/    ].
   2.641 +
   2.642 +    tokenValue := string.
   2.643 +    (self checkForKeyword:string) ifFalse:[
   2.644 +        tokenType := #Identifier.
   2.645 +    ].
   2.646 +    tokenEndPosition := source position - 1.
   2.647 +    peekChar2 notNil ifTrue:[
   2.648 +        tokenEndPosition := tokenEndPosition - 1
   2.649 +    ].
   2.650 +    ^ tokenType
   2.651 +
   2.652 +    "Modified: / 15-03-2012 / 20:53:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.653 +!
   2.654 +
   2.655 +nextMulti:list after:firstChar
   2.656 +    "a char has been read - peek ahead in list"
   2.657 +
   2.658 +    |pc|
   2.659 +
   2.660 +    peekChar isNil ifTrue:[
   2.661 +	source next.
   2.662 +    ] ifFalse:[
   2.663 +	peekChar := nil.
   2.664 +    ].
   2.665 +    pc := source peek.
   2.666 +
   2.667 +    list do:[:spec |
   2.668 +	|ch tok idx|
   2.669 +
   2.670 +	ch := spec at:1.
   2.671 +	tok := spec at:2.
   2.672 +	idx := 3.
   2.673 +
   2.674 +	pc == ch ifTrue:[
   2.675 +	    peekChar isNil ifTrue:[
   2.676 +		source next.
   2.677 +	    ] ifFalse:[
   2.678 +		peekChar := nil.
   2.679 +	    ].
   2.680 +
   2.681 +	    spec size > 2 ifTrue:[
   2.682 +		ch := spec at:3.
   2.683 +		source peek == ch ifTrue:[
   2.684 +		    source next.
   2.685 +		    tok := spec at:4.
   2.686 +		    idx := 5.
   2.687 +		]
   2.688 +	    ].
   2.689 +
   2.690 +	    tok isNil ifTrue:[
   2.691 +		^ self perform:(spec at:idx).
   2.692 +	    ].
   2.693 +
   2.694 +	    tokenType := tokenValue := tok.
   2.695 +	    ^ tokenType
   2.696 +	]
   2.697 +    ].
   2.698 +
   2.699 +    tokenType := tokenValue := firstChar.
   2.700 +    ^ tokenType
   2.701 +
   2.702 +    "Created: / 14.5.1998 / 19:19:34 / cg"
   2.703 +    "Modified: / 16.5.1998 / 19:09:59 / cg"
   2.704 +!
   2.705 +
   2.706 +nextNumber
   2.707 +    |nextChar value|
   2.708 +
   2.709 +    value := 0.
   2.710 +    nextChar := source peekOrNil.
   2.711 +    nextChar == $0 ifTrue:[
   2.712 +        source next.
   2.713 +        nextChar := source peekOrNil.
   2.714 +        (nextChar == $x or:[nextChar == $X]) ifTrue:[
   2.715 +            source next.
   2.716 +            value := Integer readFrom:source radix:16.
   2.717 +
   2.718 +            tokenValue := value.
   2.719 +            numberRadix := 16.
   2.720 +
   2.721 +            nextChar := source peekOrNil.
   2.722 +
   2.723 +            source peekOrNil isNil ifTrue:[
   2.724 +                tokenType := #Integer.
   2.725 +                tokenValue := 0.
   2.726 +                ^tokenType
   2.727 +            ].
   2.728 +
   2.729 +            (nextChar == $L or:[nextChar == $l]) ifTrue:[
   2.730 +                source next.
   2.731 +                tokenType := #LongInteger.
   2.732 +            ].
   2.733 +            nextChar == $. ifTrue:[
   2.734 +                source next.
   2.735 +                ^self nextHexFractionalPart: tokenValue.
   2.736 +            ].
   2.737 +            tokenType := #Integer.
   2.738 +            ^ tokenType.
   2.739 +
   2.740 +        ].
   2.741 +        (nextChar notNil and:[nextChar between:$0 and:$7]) ifTrue:[
   2.742 +            value := Integer readFrom:source radix:8.
   2.743 +            tokenValue := value.
   2.744 +            numberRadix := 8.
   2.745 +
   2.746 +            nextChar := source peekOrNil.
   2.747 +            (nextChar == $L or:[nextChar == $l]) ifTrue:[
   2.748 +                source next.
   2.749 +                tokenType := #LongInteger.
   2.750 +            ] ifFalse:[
   2.751 +                tokenType := #Integer.
   2.752 +            ].
   2.753 +            ^ tokenType
   2.754 +        ].
   2.755 +    ].
   2.756 +    (nextChar == $L or:[nextChar == $l]) ifTrue:[
   2.757 +        source next.
   2.758 +        tokenValue := value.
   2.759 +        tokenType := #LongInteger.
   2.760 +        ^ tokenType
   2.761 +    ].
   2.762 +    (nextChar == $D or:[nextChar == $d]) ifTrue:[
   2.763 +        source next.
   2.764 +        tokenValue := 0.0.
   2.765 +        tokenType := #Double.
   2.766 +        ^ tokenType
   2.767 +    ].
   2.768 +
   2.769 +
   2.770 +
   2.771 +    numberRadix := 10.
   2.772 +    nextChar isDigit ifTrue:[
   2.773 +        value := Integer readFrom:source radix:10.
   2.774 +        nextChar := source peekOrNil.
   2.775 +
   2.776 +        (nextChar == $L or:[nextChar == $l]) ifTrue:[
   2.777 +            source next.
   2.778 +            tokenValue := value.
   2.779 +            tokenType := #LongInteger.
   2.780 +            ^ tokenType
   2.781 +        ].
   2.782 +    ].
   2.783 +
   2.784 +    (nextChar == $.) ifTrue:[
   2.785 +        nextChar := source nextPeek.
   2.786 +        (nextChar notNil and:[nextChar isDigitRadix:10]) ifTrue:[
   2.787 +            value := value asFloat + (self nextMantissa:10).
   2.788 +            nextChar := source peekOrNil
   2.789 +        ] ifFalse:[
   2.790 +            allowDegeneratedMantissa == true ifTrue:[
   2.791 +                self warning:'degenerated float constant: ' , value printString , '.' .
   2.792 +                tokenValue := value asFloat.
   2.793 +                tokenType := #Float.
   2.794 +                ^ tokenType
   2.795 +            ].
   2.796 +
   2.797 +"/            nextChar == (Character cr) ifTrue:[
   2.798 +"/                lineNr := lineNr + 1.
   2.799 +"/            ].
   2.800 +            nextChar := peekChar := $..
   2.801 +        ]
   2.802 +    ].
   2.803 +    ((nextChar == $e) or:[nextChar == $E]) ifTrue:[
   2.804 +        value := self exponentPart:value.
   2.805 +        nextChar := source peekOrNil
   2.806 +    ] ifFalse:[
   2.807 +        ((nextChar == $p) or:[nextChar == $P]) ifTrue:[
   2.808 +            value := self hexponentPart:value.
   2.809 +            nextChar := source peekOrNil
   2.810 +        ]
   2.811 +    ].
   2.812 +
   2.813 +    nextChar == $- ifTrue:[
   2.814 +        self
   2.815 +            warnPossibleIncompatibility:'add a space before ''-'' for compatibility with other systems'
   2.816 +            position:(source position) to:source position.
   2.817 +    ].
   2.818 +
   2.819 +    (nextChar == $d or:[nextChar == $D]) ifTrue:[
   2.820 +        source next.
   2.821 +        tokenType := #Double.
   2.822 +        value := value asFloat.
   2.823 +    ] ifFalse:[
   2.824 +        (nextChar == $f or:[nextChar == $F]) ifTrue:[
   2.825 +            source next.
   2.826 +            tokenType := #Float.
   2.827 +            value := value asFloat.
   2.828 +        ] ifFalse:[
   2.829 +            (value isMemberOf:Float) ifTrue:[
   2.830 +                tokenType := #Float.
   2.831 +            ] ifFalse:[
   2.832 +                tokenType := #Integer.
   2.833 +            ]
   2.834 +        ]
   2.835 +    ].
   2.836 +    tokenValue := value.
   2.837 +    ^ tokenType
   2.838 +
   2.839 +    "Created: / 14-05-1998 / 20:00:25 / cg"
   2.840 +    "Modified: / 16-05-1998 / 15:51:46 / cg"
   2.841 +    "Modified: / 16-03-2012 / 23:34:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.842 +!
   2.843 +
   2.844 +nextString:delimiter character:isCharacter
   2.845 +    |s pos nextChar inString|
   2.846 +
   2.847 +    s := (String new:20) writeStream.
   2.848 +
   2.849 +    pos := source position.
   2.850 +    source next.
   2.851 +    nextChar := source next.
   2.852 +    inString := true.
   2.853 +
   2.854 +    [inString] whileTrue:[
   2.855 +	nextChar isNil ifTrue:[
   2.856 +	    self syntaxError:'unexpected end-of-input in String'
   2.857 +		    position:pos to:(source position - 1).
   2.858 +	    tokenValue := nil.
   2.859 +	    tokenType := #EOF.
   2.860 +	    ^ tokenType
   2.861 +	].
   2.862 +	nextChar == $\ ifTrue:[
   2.863 +	    nextChar := source next.
   2.864 +	    nextChar := self characterEscape:nextChar.
   2.865 +	] ifFalse:[
   2.866 +	    (nextChar == Character cr) ifTrue:[
   2.867 +		lineNr := lineNr + 1
   2.868 +	    ] ifFalse:[
   2.869 +		(nextChar == delimiter) ifTrue:[
   2.870 +		    (source peekOrNil == delimiter) ifTrue:[
   2.871 +			source next
   2.872 +		    ] ifFalse:[
   2.873 +			inString := false
   2.874 +		    ]
   2.875 +		].
   2.876 +	    ].
   2.877 +	].
   2.878 +	inString ifTrue:[
   2.879 +	    s nextPut:nextChar.
   2.880 +	    nextChar := source next
   2.881 +	]
   2.882 +    ].
   2.883 +
   2.884 +    tokenValue := s contents.
   2.885 +    isCharacter ifTrue:[
   2.886 +	tokenValue size ~~ 1 ifTrue:[
   2.887 +	    self syntaxError:'bad (multi-)character constant'
   2.888 +		    position:pos to:(source position - 1).
   2.889 +	].
   2.890 +	tokenValue := tokenValue at:1.
   2.891 +	tokenType := #Character.
   2.892 +    ] ifFalse:[
   2.893 +	tokenType := #String.
   2.894 +    ].
   2.895 +    ^ tokenType
   2.896 +
   2.897 +    "Created: / 16.5.1998 / 19:53:05 / cg"
   2.898 +    "Modified: / 16.5.1998 / 19:57:16 / cg"
   2.899 +!
   2.900 +
   2.901 +nextToken
   2.902 +    |t|
   2.903 +
   2.904 +    [
   2.905 +        t := super nextToken.
   2.906 +        tokenEndPosition := source position - 1.
   2.907 +        t isNil
   2.908 +    ] whileTrue.
   2.909 +    Verbose == true ifTrue:[
   2.910 +        Transcript 
   2.911 +            show:'JavaScanner nextToken => ';
   2.912 +            show: t storeString;
   2.913 +            show: ' | ';
   2.914 +            showCR: tokenValue.
   2.915 +    ].
   2.916 +    ^ t
   2.917 +
   2.918 +    "Created: / 14-05-1998 / 15:48:04 / cg"
   2.919 +    "Modified: / 16-05-1998 / 19:12:29 / cg"
   2.920 +    "Modified: / 17-03-2012 / 17:35:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.921 +!
   2.922 +
   2.923 +skipComment
   2.924 +    |commentStream commentType startPos|
   2.925 +
   2.926 +    startPos := source position.
   2.927 +    source next.
   2.928 +    hereChar := source peekOrNil.
   2.929 +
   2.930 +    [
   2.931 +	[hereChar notNil and:[hereChar ~~ $*]] whileTrue:[
   2.932 +	    hereChar == (Character cr) ifTrue:[
   2.933 +		lineNr := lineNr + 1.
   2.934 +	    ].
   2.935 +	    hereChar := source nextPeek
   2.936 +	].
   2.937 +    ] doUntil:[
   2.938 +	hereChar := source nextPeek.
   2.939 +	hereChar isNil or:[hereChar == $/].
   2.940 +    ].
   2.941 +
   2.942 +    "skip final /"
   2.943 +    source next.
   2.944 +
   2.945 +    hereChar isNil ifTrue:[
   2.946 +	self warning:'unclosed comment' position:startPos to:(source position)
   2.947 +    ].
   2.948 +
   2.949 +"/    saveComments ifTrue:[
   2.950 +"/        self endComment:(commentStream contents) type:commentType.
   2.951 +"/    ].
   2.952 +    ^ nil. "/ force nextToken again
   2.953 +
   2.954 +    "Modified: / 31.3.1998 / 23:45:26 / cg"
   2.955 +!
   2.956 +
   2.957 +skipEOLComment
   2.958 +    hereChar := source peek.
   2.959 +    [hereChar notNil and:[hereChar ~~ Character cr]] whileTrue:[
   2.960 +	hereChar := source nextPeek.
   2.961 +    ].
   2.962 +    lineNr := lineNr + 1.
   2.963 +
   2.964 +    ^ nil.
   2.965 +
   2.966 +    "Created: / 16.5.1998 / 19:11:05 / cg"
   2.967 +    "Modified: / 16.5.1998 / 19:15:42 / cg"
   2.968 +! !
   2.969 +
   2.970 +!Scanner methodsFor:'stream api'!
   2.971 +
   2.972 +atEnd
   2.973 +    ^ source atEnd
   2.974 +
   2.975 +    "Created: / 14-03-2012 / 22:53:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.976 +!
   2.977 +
   2.978 +next
   2.979 +    ^ source next
   2.980 +
   2.981 +    "Created: / 14-03-2012 / 22:53:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.982 +!
   2.983 +
   2.984 +next: anInteger 
   2.985 +    "Answer up to anInteger elements of my collection. Overridden for efficiency."
   2.986 +
   2.987 +    ^ source nextAvailable: anInteger
   2.988 +
   2.989 +    "Modified: / 14-03-2012 / 22:55:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.990 +!
   2.991 +
   2.992 +peek
   2.993 +    "An improved version of peek, that is slightly faster than the built in version."
   2.994 +
   2.995 +    ^source peek
   2.996 +
   2.997 +    "Modified: / 14-03-2012 / 22:46:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   2.998 +!
   2.999 +
  2.1000 +position
  2.1001 +    ^source position
  2.1002 +
  2.1003 +    "Created: / 14-03-2012 / 22:52:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2.1004 +!
  2.1005 +
  2.1006 +position: anInteger
  2.1007 +    "The receiver does not check for invalid arguments passed to this method, as it is solely used with valid indexes for backtracking."
  2.1008 +
  2.1009 +"/    anInteger = 16 ifTrue:[self halt].
  2.1010 +
  2.1011 +    ^source position: anInteger
  2.1012 +
  2.1013 +    "Modified: / 15-03-2012 / 10:59:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2.1014 +!
  2.1015 +
  2.1016 +skipSeparators
  2.1017 +
  2.1018 +    source skipSeparators
  2.1019 +
  2.1020 +    "Created: / 15-03-2012 / 10:35:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2.1021 +!
  2.1022 +
  2.1023 +uncheckedPeek
  2.1024 +    "An unchecked version of peek that throws an error if we try to peek over the end of the stream, even faster than #peek."
  2.1025 +
  2.1026 +    ^ self peek
  2.1027 +
  2.1028 +    "Modified: / 14-03-2012 / 22:46:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2.1029 +! !
  2.1030 +
  2.1031 +!Scanner::Token methodsFor:'accessing'!
  2.1032 +
  2.1033 +endPosition
  2.1034 +    ^ endPosition
  2.1035 +!
  2.1036 +
  2.1037 +endPosition:something
  2.1038 +    endPosition := something.
  2.1039 +!
  2.1040 +
  2.1041 +startPosition
  2.1042 +    ^ startPosition
  2.1043 +!
  2.1044 +
  2.1045 +startPosition:something
  2.1046 +    startPosition := something.
  2.1047 +!
  2.1048 +
  2.1049 +type
  2.1050 +    ^ type
  2.1051 +!
  2.1052 +
  2.1053 +type:something
  2.1054 +    type := something.
  2.1055 +!
  2.1056 +
  2.1057 +value
  2.1058 +    ^ value
  2.1059 +!
  2.1060 +
  2.1061 +value:something
  2.1062 +    value := something.
  2.1063 +! !
  2.1064 +
  2.1065 +!Scanner::Token methodsFor:'printing & storing'!
  2.1066 +
  2.1067 +printOn:aStream
  2.1068 +    "append a printed representation if the receiver to the argument, aStream"
  2.1069 +
  2.1070 +    super printOn:aStream.
  2.1071 +    aStream nextPutAll:'type: '.
  2.1072 +    type printOn:aStream.
  2.1073 +    aStream nextPutAll:'value: '.
  2.1074 +    value printOn:aStream.
  2.1075 +    aStream nextPutAll:'startPosition: '.
  2.1076 +    startPosition printOn:aStream.
  2.1077 +    aStream nextPutAll:'endPosition: '.
  2.1078 +    endPosition printOn:aStream.
  2.1079 +! !
  2.1080 +
  2.1081 +!Scanner class methodsFor:'documentation'!
  2.1082 +
  2.1083 +version_HG
  2.1084 +
  2.1085 +    ^ '$Changeset: <not expanded> $'
  2.1086 +! !
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/compiler/Dart__ScannerBase.st	Thu Jan 10 13:21:04 2013 +0000
     3.3 @@ -0,0 +1,804 @@
     3.4 +"
     3.5 + COPYRIGHT (c) 2003 by Claus Gittinger
     3.6 +	      All Rights Reserved
     3.7 +
     3.8 + This software is furnished under a license and may be used
     3.9 + only in accordance with the terms of that license and with the
    3.10 + inclusion of the above copyright notice.   This software may not
    3.11 + be provided or otherwise made available to, or used by, any
    3.12 + other person.  No title to or ownership of the software is
    3.13 + hereby transferred.
    3.14 +"
    3.15 +"{ Package: 'jv:dart/compiler' }"
    3.16 +
    3.17 +"{ NameSpace: Dart }"
    3.18 +
    3.19 +Object subclass:#ScannerBase
    3.20 +	instanceVariableNames:'typeArray actionArray source lineNr tokenType tokenStartPosition
    3.21 +		tokenEndPosition tokenLineNr numberRadix numberScale hereChar
    3.22 +		peekChar peekChar2 requestor saveComments currentComments
    3.23 +		tokenValue scaledMantissaValue parserFlags'
    3.24 +	classVariableNames:'Warnings'
    3.25 +	poolDictionaries:''
    3.26 +	category:'Languages-Dart-Parser'
    3.27 +!
    3.28 +
    3.29 +ScannerBase class instanceVariableNames:'TypeArray ActionArray KeywordTable'
    3.30 +
    3.31 +"
    3.32 + No other class instance variables are inherited by this class.
    3.33 +"
    3.34 +!
    3.35 +
    3.36 +!ScannerBase class methodsFor:'documentation'!
    3.37 +
    3.38 +copyright
    3.39 +"
    3.40 + COPYRIGHT (c) 2003 by Claus Gittinger
    3.41 +	      All Rights Reserved
    3.42 +
    3.43 + This software is furnished under a license and may be used
    3.44 + only in accordance with the terms of that license and with the
    3.45 + inclusion of the above copyright notice.   This software may not
    3.46 + be provided or otherwise made available to, or used by, any
    3.47 + other person.  No title to or ownership of the software is
    3.48 + hereby transferred.
    3.49 +"
    3.50 +! !
    3.51 +
    3.52 +!ScannerBase class methodsFor:'initialization'!
    3.53 +
    3.54 +initialize
    3.55 +    "initialize the classes defaults. Typically, these are changed
    3.56 +     later in the 'private.rc' file."
    3.57 +
    3.58 +"/    ScannerError isLoaded ifFalse:[
    3.59 +"/        ScannerError autoload
    3.60 +"/    ].
    3.61 +"/    EmptySourceNotification notifierString:'empty source given to evaluate'.
    3.62 +
    3.63 +    Warnings := false.
    3.64 +
    3.65 +    "ActionArray := nil.
    3.66 +     TypeArray := nil.
    3.67 +     self initialize
    3.68 +    "
    3.69 +
    3.70 +    "Modified: / 15-03-2012 / 00:05:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    3.71 +!
    3.72 +
    3.73 +setupActions
    3.74 +    "initialize the scanners tables - these are used to dispatch
    3.75 +     into scanner methods as characters are read"
    3.76 +
    3.77 +    self subclassResponsibility
    3.78 +
    3.79 +"/    |block|
    3.80 +"/
    3.81 +"/    ActionArray := Array new:256.
    3.82 +"/    TypeArray := Array new:256.
    3.83 +"/
    3.84 +"/    block := [:s :char | s nextNumber].
    3.85 +"/    ($0 asciiValue) to:($9 asciiValue) do:[:index |
    3.86 +"/        ActionArray at:index put:block
    3.87 +"/    ].
    3.88 +"/
    3.89 +"/    block := [:s :char | s nextIdentifier].
    3.90 +"/    ($a asciiValue) to:($z asciiValue) do:[:index |
    3.91 +"/        ActionArray at:index put:block
    3.92 +"/    ].
    3.93 +"/    ($A asciiValue) to:($Z asciiValue) do:[:index |
    3.94 +"/        ActionArray at:index put:block
    3.95 +"/    ].
    3.96 +"/    ActionArray at:$_ asciiValue put:block
    3.97 +"/
    3.98 +! !
    3.99 +
   3.100 +!ScannerBase class methodsFor:'instance creation'!
   3.101 +
   3.102 +for:aStringOrStream
   3.103 +    "create & return a new scanner reading from aStringOrStream"
   3.104 +
   3.105 +    ^ (super new) initializeFor:aStringOrStream
   3.106 +
   3.107 +    "Modified: 23.5.1997 / 12:08:42 / cg"
   3.108 +!
   3.109 +
   3.110 +new
   3.111 +    "create & return a new scanner"
   3.112 +
   3.113 +    ^ self basicNew initialize.
   3.114 +
   3.115 +    "Modified: / 23.5.1997 / 12:08:42 / cg"
   3.116 +    "Created: / 26.5.1999 / 12:02:16 / stefan"
   3.117 +! !
   3.118 +
   3.119 +!ScannerBase class methodsFor:'Signal constants'!
   3.120 +
   3.121 +emptySourceNotificationSignal
   3.122 +    ^ EmptySourceNotification
   3.123 +
   3.124 +    "Created: / 16.5.1998 / 15:55:14 / cg"
   3.125 +!
   3.126 +
   3.127 +errorSignal
   3.128 +    ^ ScannerError
   3.129 +
   3.130 +    "Created: / 16.5.1998 / 15:55:14 / cg"
   3.131 +!
   3.132 +
   3.133 +scannerErrorSignal
   3.134 +    ^ ScannerError
   3.135 +
   3.136 +    "Created: / 16.5.1998 / 15:55:14 / cg"
   3.137 +!
   3.138 +
   3.139 +warningSignal
   3.140 +    ^ ScannerWarning
   3.141 +
   3.142 +    "Created: / 16.5.1998 / 15:55:14 / cg"
   3.143 +! !
   3.144 +
   3.145 +!ScannerBase class methodsFor:'defaults'!
   3.146 +
   3.147 +warnings
   3.148 +    "return true, if any warnings are to be shown"
   3.149 +
   3.150 +    ^ Warnings
   3.151 +!
   3.152 +
   3.153 +warnings:aBoolean
   3.154 +    "this allows turning on/off all warnings; the default is on.
   3.155 +     You can turn off warnings in your 'private.rc' file with
   3.156 +	 Compiler warnings:false
   3.157 +    "
   3.158 +
   3.159 +    Warnings := aBoolean
   3.160 +
   3.161 +    "Modified: 23.5.1997 / 12:03:05 / cg"
   3.162 +! !
   3.163 +
   3.164 +!ScannerBase class methodsFor:'private accessing'!
   3.165 +
   3.166 +actionArray
   3.167 +    ^ ActionArray
   3.168 +!
   3.169 +
   3.170 +keywordTable
   3.171 +    ^ KeywordTable
   3.172 +!
   3.173 +
   3.174 +typeArray
   3.175 +    ^ TypeArray
   3.176 +! !
   3.177 +
   3.178 +!ScannerBase class methodsFor:'utility scanning'!
   3.179 +
   3.180 +scanNumberFrom:aStream
   3.181 +    "utility - helper for Number>>readSmalltalkSyntaxFrom:"
   3.182 +
   3.183 +    ^ self basicNew scanNumberFrom:aStream
   3.184 +
   3.185 +    "
   3.186 +     |s|
   3.187 +
   3.188 +     s := '12345abcd' readStream.
   3.189 +     Transcript showCR:(self scanNumberFrom:s).
   3.190 +     Transcript showCR:(s upToEnd).
   3.191 +    "
   3.192 +    "
   3.193 +     |s|
   3.194 +
   3.195 +     s := '16rffffxabcd' readStream.
   3.196 +     Transcript showCR:(self scanNumberFrom:s).
   3.197 +     Transcript showCR:(s upToEnd).
   3.198 +    "
   3.199 +    "
   3.200 +     |s|
   3.201 +
   3.202 +     s := '1.2345abcd' readStream.
   3.203 +     Transcript showCR:(self scanNumberFrom:s).
   3.204 +     Transcript showCR:(s upToEnd).
   3.205 +    "
   3.206 +    "
   3.207 +     |s|
   3.208 +
   3.209 +     s := '1.abcd' readStream.
   3.210 +     Transcript showCR:(self scanNumberFrom:s).
   3.211 +     Transcript showCR:(s upToEnd).
   3.212 +    "
   3.213 +
   3.214 +    "Modified: / 18.6.1998 / 23:10:39 / cg"
   3.215 +! !
   3.216 +
   3.217 +!ScannerBase methodsFor:'Compatibility - ST80'!
   3.218 +
   3.219 +endOfLastToken
   3.220 +    "return the position of the token which was just read.
   3.221 +     This method was required by some PD program.
   3.222 +     It is not maintained and may be removed without notice."
   3.223 +
   3.224 +    ^ source position
   3.225 +
   3.226 +    "Modified: 23.5.1997 / 12:14:27 / cg"
   3.227 +!
   3.228 +
   3.229 +scan:aStringOrStream
   3.230 +    "initialize the scanner: set the source-stream and
   3.231 +     preread the first token"
   3.232 +
   3.233 +    self initializeFor:aStringOrStream.
   3.234 +    self nextToken
   3.235 +
   3.236 +    "Created: / 30.10.1997 / 16:59:39 / cg"
   3.237 +!
   3.238 +
   3.239 +scanToken
   3.240 +    "read the next token from my input stream"
   3.241 +
   3.242 +    ^ self nextToken
   3.243 +
   3.244 +    "Created: / 30.10.1997 / 17:00:16 / cg"
   3.245 +!
   3.246 +
   3.247 +scanTokens:aStringOrStream
   3.248 +    "return a collection of symbolic tokens from the passed input"
   3.249 +
   3.250 +    |tokens|
   3.251 +
   3.252 +    self initializeFor:aStringOrStream.
   3.253 +    tokens := OrderedCollection new.
   3.254 +    self nextToken.
   3.255 +    [tokenValue notNil] whileTrue:[
   3.256 +	tokens add:tokenValue.
   3.257 +	self nextToken
   3.258 +    ].
   3.259 +    ^ tokens
   3.260 +
   3.261 +    "
   3.262 +     Scanner new
   3.263 +	scanTokens:'Boolean subclass:#True
   3.264 +				instanceVariableNames:''''
   3.265 +				classVariableNames:''''
   3.266 +				poolDictionaries:''''
   3.267 +				category:''Kernel-Objects''
   3.268 +	'
   3.269 +    "
   3.270 +
   3.271 +    "Modified: 20.6.1997 / 18:22:58 / cg"
   3.272 +! !
   3.273 +
   3.274 +!ScannerBase methodsFor:'accessing'!
   3.275 +
   3.276 +actionArray
   3.277 +    ^ actionArray
   3.278 +!
   3.279 +
   3.280 +actionArray:something
   3.281 +    actionArray := something.
   3.282 +!
   3.283 +
   3.284 +comments
   3.285 +    "if saveComments is on:
   3.286 +      returns the collection of collected comments (so far)
   3.287 +      clears the internal collection for the next access"
   3.288 +
   3.289 +    |ret|
   3.290 +
   3.291 +    ret := currentComments ? #().
   3.292 +    currentComments := nil.
   3.293 +    ^ ret
   3.294 +
   3.295 +    "Created: 20.4.1996 / 20:07:01 / cg"
   3.296 +    "Modified: 23.5.1997 / 12:14:45 / cg"
   3.297 +!
   3.298 +
   3.299 +lineNumber
   3.300 +    "the current line number (in the stream)"
   3.301 +
   3.302 +    ^ lineNr
   3.303 +!
   3.304 +
   3.305 +newSourceStream:aStream
   3.306 +    source := aStream.
   3.307 +    self nextToken.
   3.308 +
   3.309 +    "Created: / 29.10.1998 / 21:59:33 / cg"
   3.310 +!
   3.311 +
   3.312 +numberRadix
   3.313 +    "the radix of the previously scanned number"
   3.314 +
   3.315 +    ^ numberRadix
   3.316 +!
   3.317 +
   3.318 +parserFlags:something
   3.319 +    parserFlags := something.
   3.320 +!
   3.321 +
   3.322 +saveComments:aBoolean
   3.323 +    "toggle to turn on/off comment remembering"
   3.324 +
   3.325 +    saveComments := aBoolean
   3.326 +
   3.327 +    "Created: 20.4.1996 / 20:03:56 / cg"
   3.328 +    "Modified: 23.5.1997 / 12:14:49 / cg"
   3.329 +!
   3.330 +
   3.331 +sourceStream
   3.332 +    ^ source
   3.333 +
   3.334 +    "Created: 20.4.1996 / 19:59:58 / cg"
   3.335 +!
   3.336 +
   3.337 +token
   3.338 +    "the previously scanned token"
   3.339 +
   3.340 +    "/ generated lazily ...
   3.341 +    self halt.
   3.342 +!
   3.343 +
   3.344 +tokenEndPosition
   3.345 +    "the previously scanned tokens last character position"
   3.346 +
   3.347 +    ^ tokenEndPosition
   3.348 +!
   3.349 +
   3.350 +tokenLineNumber
   3.351 +    "the previously scanned tokens line number"
   3.352 +
   3.353 +    ^ tokenLineNr
   3.354 +!
   3.355 +
   3.356 +tokenStartPosition
   3.357 +    "the previously scanned tokens first character position"
   3.358 +
   3.359 +    ^ tokenStartPosition
   3.360 +!
   3.361 +
   3.362 +tokenType
   3.363 +    "the type (symbolic) of the previously scanned token"
   3.364 +
   3.365 +    ^ tokenType
   3.366 +!
   3.367 +
   3.368 +tokenValue
   3.369 +    "the value (string or number) of the previously scanned token"
   3.370 +
   3.371 +    ^ tokenValue
   3.372 +!
   3.373 +
   3.374 +typeArray
   3.375 +    ^ typeArray
   3.376 +!
   3.377 +
   3.378 +typeArray:something
   3.379 +    typeArray := something.
   3.380 +! !
   3.381 +
   3.382 +!ScannerBase methodsFor:'error handling'!
   3.383 +
   3.384 +correctableError:message position:pos1 to:pos2
   3.385 +    "report an error which can be corrected by compiler -
   3.386 +     return non-false, if correction is wanted (there is more than
   3.387 +     true/false returned here)"
   3.388 +
   3.389 +    |correctIt|
   3.390 +
   3.391 +    requestor isNil ifTrue:[
   3.392 +"/        self showErrorMessage:message position:pos1.
   3.393 +	correctIt := false
   3.394 +    ] ifFalse:[
   3.395 +	correctIt := requestor correctableError:message position:pos1 to:pos2 from:self
   3.396 +    ].
   3.397 +    ^ correctIt
   3.398 +
   3.399 +    "Created: / 13.5.1998 / 16:45:56 / cg"
   3.400 +!
   3.401 +
   3.402 +errorMessagePrefix
   3.403 +    ^ 'Error:'
   3.404 +!
   3.405 +
   3.406 +ignoreWarnings
   3.407 +    ^ Warnings == false
   3.408 +
   3.409 +    "Modified: / 14-03-2012 / 22:36:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   3.410 +!
   3.411 +
   3.412 +lastTokenLineNumber
   3.413 +    "return the line number of the token which was just read."
   3.414 +
   3.415 +    ^ tokenLineNr
   3.416 +
   3.417 +    "Created: 8.11.1996 / 18:46:36 / cg"
   3.418 +    "Modified: 23.5.1997 / 12:16:12 / cg"
   3.419 +!
   3.420 +
   3.421 +notifyError:aMessage position:position to:endPos
   3.422 +    "notify requestor of an error - if there is no requestor
   3.423 +     put it on the transcript. Requestor is typically the CodeView
   3.424 +     in which the accept/doIt was triggered, or the PositionableStream
   3.425 +     which does the fileIn. The requestor may decide how to highlight the
   3.426 +     error (and/or to abort the compile).
   3.427 +     Return the result passed back by the requestor."
   3.428 +
   3.429 +    requestor isNil ifTrue:[
   3.430 +	self showErrorMessage:aMessage position:position.
   3.431 +	^ false
   3.432 +    ].
   3.433 +    ^ requestor error:aMessage position:position to:endPos from:self
   3.434 +!
   3.435 +
   3.436 +notifyWarning:aMessage position:position to:endPos
   3.437 +    "notify requestor of an warning - if there is no requestor
   3.438 +     put it on the transcript.
   3.439 +     Return the result passed back by the requestor."
   3.440 +
   3.441 +    |warn|
   3.442 +
   3.443 +    self ignoreWarnings ifFalse:[
   3.444 +	requestor isNil ifTrue:[
   3.445 +	    warn := ScannerWarning new.
   3.446 +	    warn startPosition:position.
   3.447 +	    warn endPosition:endPos.
   3.448 +	    warn lineNumber:tokenLineNr.
   3.449 +	    warn errorString:((self warningMessagePrefix) , ' ' , aMessage).
   3.450 +	    warn raiseRequest.
   3.451 +	    ^ false
   3.452 +	].
   3.453 +	^ requestor warning:aMessage position:position to:endPos from:self
   3.454 +    ].
   3.455 +    ^ false
   3.456 +!
   3.457 +
   3.458 +parseError:aMessage
   3.459 +    "report an error"
   3.460 +
   3.461 +    ^ self parseError:aMessage position:tokenStartPosition to:nil
   3.462 +
   3.463 +    "Created: / 13.5.1998 / 16:45:13 / cg"
   3.464 +!
   3.465 +
   3.466 +parseError:aMessage position:position
   3.467 +    "report an error"
   3.468 +
   3.469 +    ^ self parseError:aMessage position:position to:nil
   3.470 +
   3.471 +    "Created: / 13.5.1998 / 16:45:05 / cg"
   3.472 +!
   3.473 +
   3.474 +parseError:aMessage position:position to:endPos
   3.475 +    "report an error"
   3.476 +
   3.477 +    |m|
   3.478 +
   3.479 +    m := (self errorMessagePrefix) , ' ' , (aMessage ? '???').
   3.480 +    self notifyError:m position:position to:endPos.
   3.481 +    ^ false
   3.482 +
   3.483 +    "Created: / 13.5.1998 / 16:44:55 / cg"
   3.484 +    "Modified: / 28.9.1998 / 19:29:27 / cg"
   3.485 +!
   3.486 +
   3.487 +showErrorMessage:aMessage position:pos
   3.488 +    "show an errormessage on the Transcript"
   3.489 +
   3.490 +    Transcript showCR:(pos printString , ' [line: ' , tokenLineNr printString , '] ' , aMessage)
   3.491 +!
   3.492 +
   3.493 +syntaxError:aMessage
   3.494 +    "a syntax error happened - position is not known"
   3.495 +
   3.496 +    ^ self syntaxError:aMessage position:tokenStartPosition
   3.497 +!
   3.498 +
   3.499 +syntaxError:aMessage position:position
   3.500 +    "a syntax error happened - only start position is known"
   3.501 +
   3.502 +    ^ self syntaxError:aMessage position:position to:nil
   3.503 +!
   3.504 +
   3.505 +syntaxError:aMessage position:position to:endPos
   3.506 +    "a syntax error happened"
   3.507 +
   3.508 +    |err|
   3.509 +
   3.510 +    err := ScannerError new.
   3.511 +    err startPosition:tokenStartPosition.
   3.512 +    err endPosition:tokenEndPosition.
   3.513 +    err lineNumber:tokenLineNr.
   3.514 +    err errorString:((self errorMessagePrefix) , ' ' , aMessage).
   3.515 +    err raiseRequest
   3.516 +!
   3.517 +
   3.518 +warning:aMessage
   3.519 +    "a warning - position is not known"
   3.520 +
   3.521 +    ^ self warning:aMessage position:tokenStartPosition
   3.522 +!
   3.523 +
   3.524 +warning:aMessage position:position
   3.525 +    "a warning - only start position is known"
   3.526 +
   3.527 +    ^ self warning:aMessage position:position to:nil
   3.528 +!
   3.529 +
   3.530 +warning:aMessage position:position to:endPos
   3.531 +    "a warning"
   3.532 +
   3.533 +    ^ self notifyWarning:((self warningMessagePrefix) , ' ' , aMessage) position:position to:endPos
   3.534 +!
   3.535 +
   3.536 +warningMessagePrefix
   3.537 +    ^ 'Warning:'
   3.538 +! !
   3.539 +
   3.540 +!ScannerBase methodsFor:'general scanning'!
   3.541 +
   3.542 +scanPositionsFor:aTokenString inString:aSourceString
   3.543 +    "scan aSourceString for occurrances of aTokenString.
   3.544 +     Return a collection of start positions.
   3.545 +     Added for VW compatibility (to support syntax-highlight)."
   3.546 +
   3.547 +    |searchType searchToken positions t|
   3.548 +
   3.549 +    "
   3.550 +     first, look what kind of token we have to search for
   3.551 +    "
   3.552 +    self initializeFor:(ReadStream on:aTokenString).
   3.553 +    self nextToken.
   3.554 +    searchType := tokenType.
   3.555 +    searchToken := tokenValue.
   3.556 +
   3.557 +    "
   3.558 +     start the real work ...
   3.559 +    "
   3.560 +    self initializeFor:(ReadStream on:aSourceString).
   3.561 +    positions := OrderedCollection new.
   3.562 +
   3.563 +    [(t := self nextToken) ~~ #EOF] whileTrue:[
   3.564 +	searchType == t ifTrue:[
   3.565 +	    (searchToken isNil or:[tokenValue = searchToken]) ifTrue:[
   3.566 +		positions add:tokenStartPosition.
   3.567 +	    ]
   3.568 +	]
   3.569 +    ].
   3.570 +
   3.571 +    ^ positions
   3.572 +
   3.573 +    "
   3.574 +     Scanner new scanPositionsFor:'hello' inString:'foo bar hello baz hello helloWorld'
   3.575 +     Scanner new scanPositionsFor:'3.14' inString:'foo 3.145 bar hello 3.14 baz hello 3.14 ''3.14'''
   3.576 +     Scanner new scanPositionsFor:'''3.14''' inString:'foo 3.145 bar hello 3.14 baz hello 3.14 ''3.14'' aaa'
   3.577 +     Scanner new scanPositionsFor:'16' inString:'foo 16 bar hello 16r10 baz hello 2r10000'
   3.578 +    "
   3.579 +! !
   3.580 +
   3.581 +!ScannerBase methodsFor:'initialization'!
   3.582 +
   3.583 +initialize
   3.584 +    "initialize the scanner"
   3.585 +
   3.586 +    "/actionArray notNil ifTrue:[ self halt ].
   3.587 +
   3.588 +    saveComments := false.
   3.589 +    parserFlags := ParserFlags new.
   3.590 +
   3.591 +    (actionArray := self class actionArray) isNil ifTrue:[
   3.592 +        self class setupActions.
   3.593 +        actionArray := self class actionArray
   3.594 +    ].
   3.595 +    typeArray := self class typeArray.
   3.596 +
   3.597 +    "Modified: / 14-03-2012 / 22:35:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   3.598 +!
   3.599 +
   3.600 +initializeFor:aStringOrStream
   3.601 +    "initialize the new scanner & prepare for reading from aStringOrStream"
   3.602 +
   3.603 +    self initialize.
   3.604 +    self source:aStringOrStream.
   3.605 +!
   3.606 +
   3.607 +source:aStringOrStream
   3.608 +    "prepare for reading from aStringOrStream"
   3.609 +
   3.610 +    tokenStartPosition := 1.
   3.611 +    tokenLineNr := lineNr := 1.
   3.612 +    currentComments := nil.
   3.613 +
   3.614 +    aStringOrStream isStream ifFalse:[
   3.615 +	source := ReadStream on:aStringOrStream
   3.616 +    ] ifTrue:[
   3.617 +	source := aStringOrStream.
   3.618 +    ].
   3.619 +
   3.620 +    "Modified: / 26.5.1999 / 12:02:16 / stefan"
   3.621 +! !
   3.622 +
   3.623 +!ScannerBase methodsFor:'private'!
   3.624 +
   3.625 +addComment:comment
   3.626 +    saveComments ifTrue:[
   3.627 +	currentComments isNil ifTrue:[
   3.628 +	    currentComments := OrderedCollection with:comment
   3.629 +	] ifFalse:[
   3.630 +	    currentComments add:comment
   3.631 +	]
   3.632 +    ].
   3.633 +!
   3.634 +
   3.635 +backupPosition
   3.636 +    "if reading from a stream, at the end we might have read
   3.637 +     one token too many"
   3.638 +
   3.639 +    (tokenType == #EOF) ifFalse:[
   3.640 +	source position:tokenStartPosition
   3.641 +    ]
   3.642 +!
   3.643 +
   3.644 +beginComment
   3.645 +    ^ self
   3.646 +!
   3.647 +
   3.648 +requestor:anObject
   3.649 +    "set the requestor to be notified about errors"
   3.650 +
   3.651 +    requestor := anObject
   3.652 +! !
   3.653 +
   3.654 +!ScannerBase methodsFor:'reading next token'!
   3.655 +
   3.656 +atEnd
   3.657 +    "true if at the end"
   3.658 +
   3.659 +    ^ tokenType == #EOF.
   3.660 +
   3.661 +    "Created: / 30-04-2011 / 11:24:13 / cg"
   3.662 +!
   3.663 +
   3.664 +isCommentCharacter:aCharacter
   3.665 +    self subclassResponsibility
   3.666 +!
   3.667 +
   3.668 +nextSingleCharacterToken:aCharacter
   3.669 +    "return a character token"
   3.670 +
   3.671 +    tokenEndPosition := tokenStartPosition.
   3.672 +    tokenType := tokenValue := aCharacter.
   3.673 +    hereChar notNil ifTrue:[source next].
   3.674 +    ^ tokenType
   3.675 +
   3.676 +    "Modified: / 13.5.1998 / 15:10:23 / cg"
   3.677 +!
   3.678 +
   3.679 +nextToken
   3.680 +    "scan the next token from the source-stream;
   3.681 +     as a side effect, leave info in:
   3.682 +        tokenType          - a symbol describing the kind of token
   3.683 +        token              - its value as string or number
   3.684 +        tokenStartPosition - the tokens first characters position in the input stream
   3.685 +        tokenEndPosition   - the tokens last characters position in the input stream
   3.686 +        tokenLineNr        - the tokens first characters lineNumber in the input stream
   3.687 +     returns the tokenType.
   3.688 +    "
   3.689 +
   3.690 +    |skipping actionBlock v ch tok|
   3.691 +
   3.692 +    [true] whileTrue:[
   3.693 +        peekChar notNil ifTrue:[
   3.694 +            "/ kludge - should be called peekSym.
   3.695 +            "/ used when xlating Foo.Bar into Foo::Bar
   3.696 +            peekChar isSymbol ifTrue:[
   3.697 +                tokenValue := nil.
   3.698 +                tokenType := peekChar.
   3.699 +                peekChar := nil.
   3.700 +                ^ tokenType
   3.701 +            ].
   3.702 +
   3.703 +            peekChar isSeparator ifTrue:[
   3.704 +                peekChar == (Character cr) ifTrue:[
   3.705 +                    lineNr := lineNr + 1.
   3.706 +                ].
   3.707 +                peekChar := peekChar2.
   3.708 +                peekChar2 := nil.
   3.709 +            ].
   3.710 +        ].
   3.711 +        peekChar notNil ifTrue:[
   3.712 +            ch := peekChar.
   3.713 +            peekChar := peekChar2.
   3.714 +            peekChar2 := nil.
   3.715 +            hereChar := nil.
   3.716 +            tokenStartPosition := source position - 1.
   3.717 +        ] ifFalse:[
   3.718 +            skipping := true.
   3.719 +            [skipping] whileTrue:[
   3.720 +                hereChar := source skipSeparatorsExceptCR.
   3.721 +                hereChar == (Character cr) ifTrue:[
   3.722 +                    lineNr := lineNr + 1.
   3.723 +                    source next.
   3.724 +                ] ifFalse:[
   3.725 +                    hereChar == (Character return) ifTrue:[
   3.726 +                        source next.
   3.727 +                    ] ifFalse:[
   3.728 +                        (self isCommentCharacter:hereChar) ifTrue:[
   3.729 +                            "start of a comment"
   3.730 +
   3.731 +                            self skipComment.
   3.732 +                            hereChar := source peekOrNil.
   3.733 +                        ] ifFalse:[
   3.734 +                            skipping := false
   3.735 +                        ]
   3.736 +                    ]
   3.737 +                ]
   3.738 +            ].
   3.739 +            hereChar isNil ifTrue:[
   3.740 +                tokenValue := nil.
   3.741 +                tokenType := #EOF.
   3.742 +                ^ tokenType
   3.743 +            ].
   3.744 +            ch := hereChar.
   3.745 +            tokenStartPosition := source position.
   3.746 +        ].
   3.747 +        tokenLineNr := lineNr.
   3.748 +
   3.749 +        (v := ch asciiValue) == 0 ifTrue:[
   3.750 +            v := Character space codePoint
   3.751 +        ].
   3.752 +        actionBlock := actionArray at:v.
   3.753 +        actionBlock notNil ifTrue:[
   3.754 +            tok := actionBlock value:self value:ch.
   3.755 +            tok notNil ifTrue:[
   3.756 +                ^ tok
   3.757 +            ].
   3.758 +        ] ifFalse:[
   3.759 +            self syntaxError:('invalid character: ''' , ch asString , ''' ',
   3.760 +                              '(' , v printString , ')')
   3.761 +                    position:tokenStartPosition to:tokenStartPosition.
   3.762 +            source next.
   3.763 +            tokenValue := nil.
   3.764 +            tokenType := #Error.
   3.765 +            ^ #Error
   3.766 +        ]
   3.767 +    ].
   3.768 +!
   3.769 +
   3.770 +skipComment
   3.771 +    self subclassResponsibility
   3.772 +! !
   3.773 +
   3.774 +!ScannerBase methodsFor:'reading next token - private'!
   3.775 +
   3.776 +nextMantissa:radix
   3.777 +    "read the mantissa of a radix number.
   3.778 +     Return post-decimal value (i.e. 0.xxxx); leave number of post-decimal
   3.779 +     digits in numberScale; scaled post-decimal value in scaledMantissaValue (xxx)."
   3.780 +
   3.781 +    |nextChar value factor|
   3.782 +
   3.783 +    value := scaledMantissaValue := 0.
   3.784 +    factor := 1.0 / radix.
   3.785 +    nextChar := source peekOrNil.
   3.786 +    numberScale := 0.
   3.787 +
   3.788 +    [(nextChar notNil and:[nextChar isDigitRadix:radix])] whileTrue:[
   3.789 +	scaledMantissaValue := (scaledMantissaValue * radix) + (nextChar digitValue).
   3.790 +	value := value + (nextChar digitValue * factor).
   3.791 +	factor := factor / radix.
   3.792 +	numberScale := numberScale + 1.
   3.793 +	nextChar := source nextPeek
   3.794 +    ].
   3.795 +    ^ value
   3.796 +
   3.797 +    "Modified: / 5.3.1998 / 02:54:11 / cg"
   3.798 +! !
   3.799 +
   3.800 +!ScannerBase class methodsFor:'documentation'!
   3.801 +
   3.802 +version_HG
   3.803 +
   3.804 +    ^ '$Changeset: <not expanded> $'
   3.805 +! !
   3.806 +
   3.807 +ScannerBase initialize!
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/compiler/Make.proto	Thu Jan 10 13:21:04 2013 +0000
     4.3 @@ -0,0 +1,125 @@
     4.4 +# $Header$
     4.5 +#
     4.6 +# DO NOT EDIT
     4.7 +# automagically generated from the projectDefinition: jv_dart_compiler.
     4.8 +#
     4.9 +# Warning: once you modify this file, do not rerun
    4.10 +# stmkmp or projectDefinition-build again - otherwise, your changes are lost.
    4.11 +#
    4.12 +# The Makefile as generated by this Make.proto supports the following targets:
    4.13 +#    make         - compile all st-files to a classLib
    4.14 +#    make clean   - clean all temp files
    4.15 +#    make clobber - clean all
    4.16 +#
    4.17 +# This file contains definitions for Unix based platforms.
    4.18 +# It shares common definitions with the win32-make in Make.spec.
    4.19 +
    4.20 +#
    4.21 +# position (of this package) in directory hierarchy:
    4.22 +# (must point to ST/X top directory, for tools and includes)
    4.23 +TOP=../../../stx
    4.24 +INCLUDE_TOP=$(TOP)/..
    4.25 +
    4.26 +# subdirectories where targets are to be made:
    4.27 +SUBDIRS=
    4.28 +
    4.29 +
    4.30 +# subdirectories where Makefiles are to be made:
    4.31 +# (only define if different from SUBDIRS)
    4.32 +# ALLSUBDIRS=
    4.33 +
    4.34 +REQUIRED_SUPPORT_DIRS=
    4.35 +
    4.36 +# if your embedded C code requires any system includes,
    4.37 +# add the path(es) here:,
    4.38 +# ********** OPTIONAL: MODIFY the next lines ***
    4.39 +# LOCALINCLUDES=-Ifoo -Ibar
    4.40 +LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/libbasic -I$(INCLUDE_TOP)/stx/goodies/petitparser
    4.41 +
    4.42 +
    4.43 +# if you need any additional defines for embedded C code,
    4.44 +# add them here:,
    4.45 +# ********** OPTIONAL: MODIFY the next lines ***
    4.46 +# LOCALDEFINES=-Dfoo -Dbar -DDEBUG
    4.47 +LOCALDEFINES=
    4.48 +
    4.49 +LIBNAME=libjv_dart_compiler
    4.50 +STCLOCALOPT='-package=$(PACKAGE)' -I. $(LOCALINCLUDES) $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES) -headerDir=.  -varPrefix=$(LIBNAME)
    4.51 +
    4.52 +
    4.53 +# ********** OPTIONAL: MODIFY the next line ***
    4.54 +# additional C-libraries that should be pre-linked with the class-objects
    4.55 +LD_OBJ_LIBS=
    4.56 +LOCAL_SHARED_LIBS=
    4.57 +
    4.58 +
    4.59 +# ********** OPTIONAL: MODIFY the next line ***
    4.60 +# additional C targets or libraries should be added below
    4.61 +LOCAL_EXTRA_TARGETS=
    4.62 +
    4.63 +OBJS= $(COMMON_OBJS) $(UNIX_OBJS)
    4.64 +
    4.65 +
    4.66 +
    4.67 +all:: preMake classLibRule postMake
    4.68 +
    4.69 +pre_objs::  
    4.70 +
    4.71 +
    4.72 +
    4.73 +
    4.74 +
    4.75 +
    4.76 +# Enforce recompilation of package definition class if Mercurial working
    4.77 +# copy state changes. Together with --guessVersion it ensures that package
    4.78 +# definition class always contains correct binary revision string.
    4.79 +ifneq (**NOHG**, $(shell hg root 2> /dev/null || echo -n '**NOHG**'))
    4.80 +jv_dart_compiler.$(O): $(shell hg root)/.hg/dirstate
    4.81 +endif
    4.82 +
    4.83 +
    4.84 +
    4.85 +
    4.86 +# run default testsuite for this package
    4.87 +test: $(TOP)/goodies/builder/reports
    4.88 +	$(MAKE) -C $(TOP)/goodies/builder/reports
    4.89 +	$(TOP)/goodies/builder/reports/report-runner.sh -D . -r Builder::TestReport -p $(PACKAGE)
    4.90 +
    4.91 +
    4.92 +
    4.93 +# add more install actions here
    4.94 +install::
    4.95 +
    4.96 +# add more install actions for aux-files (resources) here
    4.97 +installAux::
    4.98 +
    4.99 +# add more preMake actions here
   4.100 +preMake::
   4.101 +
   4.102 +# add more postMake actions here
   4.103 +postMake:: cleanjunk
   4.104 +
   4.105 +prereq: $(REQUIRED_SUPPORT_DIRS)
   4.106 +	cd $(TOP)/libbasic && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
   4.107 +	cd $(TOP)/librun && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
   4.108 +
   4.109 +
   4.110 +
   4.111 +cleanjunk::
   4.112 +	-rm -f *.s *.s2
   4.113 +
   4.114 +clean::
   4.115 +	-rm -f *.o *.H
   4.116 +
   4.117 +clobber:: clean
   4.118 +	-rm -f *.so *.dll
   4.119 +
   4.120 +
   4.121 +# BEGINMAKEDEPEND --- do not remove this line; make depend needs it
   4.122 +$(OUTDIR)Dart__Parser.$(O) Dart__Parser.$(H): Dart__Parser.st $(INCLUDE_TOP)/stx/goodies/petitparser/PPCompositeParser.$(H) $(INCLUDE_TOP)/stx/goodies/petitparser/PPDelegateParser.$(H) $(INCLUDE_TOP)/stx/goodies/petitparser/PPParser.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
   4.123 +$(OUTDIR)Dart__ScannerBase.$(O) Dart__ScannerBase.$(H): Dart__ScannerBase.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
   4.124 +$(OUTDIR)jv_dart_compiler.$(O) jv_dart_compiler.$(H): jv_dart_compiler.st $(INCLUDE_TOP)/stx/libbasic/LibraryDefinition.$(H) $(INCLUDE_TOP)/stx/libbasic/ProjectDefinition.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
   4.125 +$(OUTDIR)Dart__Scanner.$(O) Dart__Scanner.$(H): Dart__Scanner.st $(INCLUDE_TOP)/jv/dart/compiler/Dart__ScannerBase.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
   4.126 +
   4.127 +# ENDMAKEDEPEND --- do not remove this line
   4.128 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/compiler/Make.spec	Thu Jan 10 13:21:04 2013 +0000
     5.3 @@ -0,0 +1,68 @@
     5.4 +# $Header$
     5.5 +#
     5.6 +# DO NOT EDIT
     5.7 +# automagically generated from the projectDefinition: jv_dart_compiler.
     5.8 +#
     5.9 +# Warning: once you modify this file, do not rerun
    5.10 +# stmkmp or projectDefinition-build again - otherwise, your changes are lost.
    5.11 +#
    5.12 +# This file contains specifications which are common to all platforms.
    5.13 +#
    5.14 +
    5.15 +# Do NOT CHANGE THESE DEFINITIONS
    5.16 +# (otherwise, ST/X will have a hard time to find out the packages location from its packageID,
    5.17 +#  to find the source code of a class and to find the library for a package)
    5.18 +MODULE=jv
    5.19 +MODULE_DIR=dart/compiler
    5.20 +PACKAGE=$(MODULE):$(MODULE_DIR)
    5.21 +
    5.22 +
    5.23 +# Argument(s) to the stc compiler (stc --usage).
    5.24 +#  -headerDir=. : create header files locally
    5.25 +#                (if removed, they will be created as common
    5.26 +#  -Pxxx       : defines the package
    5.27 +#  -Zxxx       : a prefix for variables within the classLib
    5.28 +#  -Dxxx       : defines passed to to CC for inline C-code
    5.29 +#  -Ixxx       : include path passed to CC for inline C-code
    5.30 +#  +optspace   : optimized for space
    5.31 +#  +optspace2  : optimized more for space
    5.32 +#  +optspace3  : optimized even more for space
    5.33 +#  +optinline  : generate inline code for some ST constructs
    5.34 +#  +inlineNew  : additionally inline new
    5.35 +#  +inlineMath : additionally inline some floatPnt math stuff
    5.36 +#
    5.37 +# ********** OPTIONAL: MODIFY the next line(s) ***
    5.38 +# STCLOCALOPTIMIZATIONS=+optinline +inlineNew
    5.39 +# STCLOCALOPTIMIZATIONS=+optspace3
    5.40 +STCLOCALOPTIMIZATIONS=+optspace3
    5.41 +
    5.42 +
    5.43 +# Argument(s) to the stc compiler (stc --usage).
    5.44 +#  -warn            : no warnings
    5.45 +#  -warnNonStandard : no warnings about ST/X extensions
    5.46 +#  -warnEOLComments : no warnings about EOL comment extension
    5.47 +#  -warnPrivacy     : no warnings about privateClass extension
    5.48 +#
    5.49 +# ********** OPTIONAL: MODIFY the next line(s) ***
    5.50 +# STCWARNINGS=-warn
    5.51 +# STCWARNINGS=-warnNonStandard
    5.52 +# STCWARNINGS=-warnEOLComments
    5.53 +STCWARNINGS=-warnNonStandard
    5.54 +
    5.55 +COMMON_CLASSES= \
    5.56 +	jv_dart_compiler \
    5.57 +	Dart::ScannerBase \
    5.58 +	Dart::Parser \
    5.59 +	Dart::Scanner \
    5.60 +
    5.61 +
    5.62 +
    5.63 +
    5.64 +COMMON_OBJS= \
    5.65 +    $(OUTDIR)jv_dart_compiler.$(O) \
    5.66 +    $(OUTDIR)Dart__ScannerBase.$(O) \
    5.67 +    $(OUTDIR)Dart__Parser.$(O) \
    5.68 +    $(OUTDIR)Dart__Scanner.$(O) \
    5.69 +
    5.70 +
    5.71 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/compiler/Makefile	Thu Jan 10 13:21:04 2013 +0000
     6.3 @@ -0,0 +1,19 @@
     6.4 +#
     6.5 +# DO NOT EDIT
     6.6 +#
     6.7 +# make uses this file (Makefile) only, if there is no
     6.8 +# file named "makefile" (lower-case m) in the same directory.
     6.9 +# My only task is to generate the real makefile and call make again.
    6.10 +# Thereafter, I am no longer used and needed.
    6.11 +#
    6.12 +
    6.13 +.PHONY: run
    6.14 +
    6.15 +run: makefile
    6.16 +	$(MAKE) -f makefile
    6.17 +
    6.18 +#only needed for the definition of $(TOP)
    6.19 +include Make.proto
    6.20 +
    6.21 +makefile:
    6.22 +	$(TOP)/rules/stmkmf
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/compiler/abbrev.stc	Thu Jan 10 13:21:04 2013 +0000
     7.3 @@ -0,0 +1,7 @@
     7.4 +# automagically generated by the project definition
     7.5 +# this file is needed for stc to be able to compile modules independently.
     7.6 +# it provides information about a classes filename, category and especially namespace.
     7.7 +jv_dart_compiler jv_dart_compiler jv:dart/compiler '* Projects & Packages *' 3
     7.8 +Dart::ScannerBase Dart__ScannerBase jv:dart/compiler 'Languages-Dart-Parser' 3
     7.9 +Dart::Parser Dart__Parser jv:dart/compiler 'Languages-Dart-Parser' 0
    7.10 +Dart::Scanner Dart__Scanner jv:dart/compiler 'Languages-Dart-Parser' 3
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/compiler/bc.mak	Thu Jan 10 13:21:04 2013 +0000
     8.3 @@ -0,0 +1,80 @@
     8.4 +# $Header$
     8.5 +#
     8.6 +# DO NOT EDIT
     8.7 +# automagically generated from the projectDefinition: jv_dart_compiler.
     8.8 +#
     8.9 +# Warning: once you modify this file, do not rerun
    8.10 +# stmkmp or projectDefinition-build again - otherwise, your changes are lost.
    8.11 +#
    8.12 +# Notice, that the name bc.mak is historical (from times, when only borland c was supported).
    8.13 +# This file contains make rules for the win32 platform using either borland-bcc or visual-c.
    8.14 +# It shares common definitions with the unix-make in Make.spec.
    8.15 +# The bc.mak supports the following targets:
    8.16 +#    bmake         - compile all st-files to a classLib (dll)
    8.17 +#    bmake clean   - clean all temp files
    8.18 +#    bmake clobber - clean all
    8.19 +#
    8.20 +# Historic Note:
    8.21 +#  this used to contain only rules to make with borland
    8.22 +#    (called via bmake, by "make.exe -f bc.mak")
    8.23 +#  this has changed; it is now also possible to build using microsoft visual c
    8.24 +#    (called via vcmake, by "make.exe -f bc.mak -DUSEVC")
    8.25 +#
    8.26 +TOP=..\..\..\stx
    8.27 +INCLUDE_TOP=$(TOP)\..
    8.28 +
    8.29 +
    8.30 +
    8.31 +!INCLUDE $(TOP)\rules\stdHeader_bc
    8.32 +
    8.33 +!INCLUDE Make.spec
    8.34 +
    8.35 +LIBNAME=libjv_dart_compiler
    8.36 +RESFILES=compiler.res
    8.37 +
    8.38 +
    8.39 +
    8.40 +LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\libbasic -I$(INCLUDE_TOP)\stx\goodies\petitparser
    8.41 +LOCALDEFINES=
    8.42 +
    8.43 +STCLOCALOPT=-package=$(PACKAGE) -I. $(LOCALINCLUDES) -headerDir=. $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES)  -varPrefix=$(LIBNAME)
    8.44 +LOCALLIBS=
    8.45 +
    8.46 +OBJS= $(COMMON_OBJS) $(WIN32_OBJS)
    8.47 +
    8.48 +ALL::  classLibRule
    8.49 +
    8.50 +classLibRule: $(OUTDIR) $(OUTDIR)$(LIBNAME).dll
    8.51 +
    8.52 +!INCLUDE $(TOP)\rules\stdRules_bc
    8.53 +
    8.54 +# build all prerequisite packages for this package
    8.55 +prereq:
    8.56 +	pushd ..\..\..\stx\libbasic & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
    8.57 +	pushd ..\..\..\stx\librun & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
    8.58 +
    8.59 +
    8.60 +
    8.61 +
    8.62 +
    8.63 +
    8.64 +test: $(TOP)\goodies\builder\reports\NUL
    8.65 +	pushd $(TOP)\goodies\builder\reports & $(MAKE_BAT)
    8.66 +	$(TOP)\goodies\builder\reports\report-runner.bat -D . -r Builder::TestReport -p $(PACKAGE)
    8.67 +
    8.68 +# BEGINMAKEDEPEND --- do not remove this line; make depend needs it
    8.69 +$(OUTDIR)Dart__Parser.$(O) Dart__Parser.$(H): Dart__Parser.st $(INCLUDE_TOP)\stx\goodies\petitparser\PPCompositeParser.$(H) $(INCLUDE_TOP)\stx\goodies\petitparser\PPDelegateParser.$(H) $(INCLUDE_TOP)\stx\goodies\petitparser\PPParser.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
    8.70 +$(OUTDIR)Dart__ScannerBase.$(O) Dart__ScannerBase.$(H): Dart__ScannerBase.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
    8.71 +$(OUTDIR)jv_dart_compiler.$(O) jv_dart_compiler.$(H): jv_dart_compiler.st $(INCLUDE_TOP)\stx\libbasic\LibraryDefinition.$(H) $(INCLUDE_TOP)\stx\libbasic\ProjectDefinition.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
    8.72 +$(OUTDIR)Dart__Scanner.$(O) Dart__Scanner.$(H): Dart__Scanner.st $(INCLUDE_TOP)\jv\dart\compiler\Dart__ScannerBase.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
    8.73 +
    8.74 +# ENDMAKEDEPEND --- do not remove this line
    8.75 +
    8.76 +# **Must be at end**
    8.77 +
    8.78 +# Enforce recompilation of package definition class if Mercurial working
    8.79 +# copy state changes. Together with --guessVersion it ensures that package
    8.80 +# definition class always contains correct binary revision string.
    8.81 +!IFDEF HGROOT
    8.82 +$(OUTDIR)jv_dart_compiler.$(O): $(HGROOT)\.hg\dirstate
    8.83 +!ENDIF
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/compiler/bmake.bat	Thu Jan 10 13:21:04 2013 +0000
     9.3 @@ -0,0 +1,12 @@
     9.4 +@REM -------
     9.5 +@REM make using Borland bcc32
     9.6 +@REM type bmake, and wait...
     9.7 +@REM do not edit - automatically generated from ProjectDefinition
     9.8 +@REM -------
     9.9 +@SET DEFINES=
    9.10 +@REM Kludge got Mercurial, cannot be implemented in Borland make
    9.11 +@FOR /F "tokens=*" %%i in ('hg root') do SET HGROOT=%%i
    9.12 +@IF "%HGROOT%" NEQ "" SET DEFINES=%DEFINES% "-DHGROOT=%HGROOT%"
    9.13 +make.exe -N -f bc.mak  %DEFINES% %*
    9.14 +
    9.15 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/compiler/compiler.rc	Thu Jan 10 13:21:04 2013 +0000
    10.3 @@ -0,0 +1,37 @@
    10.4 +//
    10.5 +// DO NOT EDIT
    10.6 +// automagically generated from the projectDefinition: jv_dart_compiler.
    10.7 +//
    10.8 +VS_VERSION_INFO VERSIONINFO
    10.9 +  FILEVERSION     6,2,32767,32767
   10.10 +  PRODUCTVERSION  6,2,3,0
   10.11 +#if (__BORLANDC__)
   10.12 +  FILEFLAGSMASK   VS_FF_DEBUG | VS_FF_PRERELEASE
   10.13 +  FILEFLAGS       VS_FF_PRERELEASE | VS_FF_SPECIALBUILD
   10.14 +  FILEOS          VOS_NT_WINDOWS32
   10.15 +  FILETYPE        VFT_DLL
   10.16 +  FILESUBTYPE     VS_USER_DEFINED
   10.17 +#endif
   10.18 +
   10.19 +BEGIN
   10.20 +  BLOCK "StringFileInfo"
   10.21 +  BEGIN
   10.22 +    BLOCK "040904E4"
   10.23 +    BEGIN
   10.24 +      VALUE "CompanyName", "My Company\0"
   10.25 +      VALUE "FileDescription", "Class Library (LIB)\0"
   10.26 +      VALUE "FileVersion", "6.2.32767.32767\0"
   10.27 +      VALUE "InternalName", "jv:dart/compiler\0"
   10.28 +      VALUE "LegalCopyright", "My CopyRight or CopyLeft\0"
   10.29 +      VALUE "ProductName", "ProductName\0"
   10.30 +      VALUE "ProductVersion", "6.2.3.0\0"
   10.31 +      VALUE "ProductDate", "Thu, 10 Jan 2013 13:20:39 GMT\0"
   10.32 +    END
   10.33 +
   10.34 +  END
   10.35 +
   10.36 +  BLOCK "VarFileInfo"
   10.37 +  BEGIN                               //  Language   |    Translation
   10.38 +    VALUE "Translation", 0x409, 0x4E4 // U.S. English, Windows Multilingual
   10.39 +  END
   10.40 +END
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/compiler/jv_dart_compiler.st	Thu Jan 10 13:21:04 2013 +0000
    11.3 @@ -0,0 +1,106 @@
    11.4 +"{ Package: 'jv:dart/compiler' }"
    11.5 +
    11.6 +LibraryDefinition subclass:#jv_dart_compiler
    11.7 +	instanceVariableNames:''
    11.8 +	classVariableNames:''
    11.9 +	poolDictionaries:''
   11.10 +	category:'* Projects & Packages *'
   11.11 +!
   11.12 +
   11.13 +
   11.14 +!jv_dart_compiler class methodsFor:'description'!
   11.15 +
   11.16 +excludedFromPreRequisites
   11.17 +    "list all packages which should be ignored in the automatic
   11.18 +     preRequisites scan. See #preRequisites for more."
   11.19 +
   11.20 +    ^ #(
   11.21 +    )
   11.22 +!
   11.23 +
   11.24 +preRequisites
   11.25 +    "list all required packages.
   11.26 +     This list can be maintained manually or (better) generated and
   11.27 +     updated by scanning the superclass hierarchies and looking for
   11.28 +     global variable accesses. (the browser has a menu function for that)
   11.29 +     Howevery, often too much is found, and you may want to explicitely
   11.30 +     exclude individual packages in the #excludedFromPrerequisites method."
   11.31 +
   11.32 +    ^ #(
   11.33 +        #'stx:libbasic'    "LibraryDefinition - superclass of jv_dart "
   11.34 +    )
   11.35 +! !
   11.36 +
   11.37 +!jv_dart_compiler class methodsFor:'description - contents'!
   11.38 +
   11.39 +classNamesAndAttributes
   11.40 +    "lists the classes which are to be included in the project.
   11.41 +     Each entry in the list may be: a single class-name (symbol),
   11.42 +     or an array-literal consisting of class name and attributes.
   11.43 +     Attributes are: #autoload or #<os> where os is one of win32, unix,..."
   11.44 +
   11.45 +    ^ #(
   11.46 +        "<className> or (<className> attributes...) in load order"
   11.47 +        #'jv_dart_compiler'
   11.48 +        #'Dart::ScannerBase'
   11.49 +        #'Dart::Parser'
   11.50 +        #'Dart::Scanner'
   11.51 +    )
   11.52 +
   11.53 +    "Modified: / 10-01-2013 / 13:15:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   11.54 +!
   11.55 +
   11.56 +extensionMethodNames
   11.57 +    "lists the extension methods which are to be included in the project.
   11.58 +     Entries are 2-element array literals, consisting of class-name and selector."
   11.59 +
   11.60 +    ^ #(
   11.61 +    )
   11.62 +! !
   11.63 +
   11.64 +!jv_dart_compiler class methodsFor:'description - project information'!
   11.65 +
   11.66 +applicationIconFileName
   11.67 +    "Return the name (without suffix) of an icon-file (the app's icon); will be included in the rc-resource file"
   11.68 +
   11.69 +    ^ nil
   11.70 +    "/ ^ self applicationName
   11.71 +!
   11.72 +
   11.73 +companyName
   11.74 +    "Return a companyname which will appear in <lib>.rc"
   11.75 +
   11.76 +    ^ 'My Company'
   11.77 +!
   11.78 +
   11.79 +description
   11.80 +    "Return a description string which will appear in vc.def / bc.def"
   11.81 +
   11.82 +    ^ 'Class Library'
   11.83 +!
   11.84 +
   11.85 +legalCopyright
   11.86 +    "Return a copyright string which will appear in <lib>.rc"
   11.87 +
   11.88 +    ^ 'My CopyRight or CopyLeft'
   11.89 +!
   11.90 +
   11.91 +productInstallDirBaseName
   11.92 +    "Returns a default installDir which will appear in <app>.nsi.
   11.93 +     This is usually not the one you want to keep"
   11.94 +
   11.95 +    ^ (self package asCollectionOfSubstringsSeparatedByAny:':/') last
   11.96 +!
   11.97 +
   11.98 +productName
   11.99 +    "Return a product name which will appear in <lib>.rc"
  11.100 +
  11.101 +    ^ 'ProductName'
  11.102 +! !
  11.103 +
  11.104 +!jv_dart_compiler class methodsFor:'documentation'!
  11.105 +
  11.106 +version_HG
  11.107 +
  11.108 +    ^ '$Changeset: <not expanded> $'
  11.109 +! !
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/compiler/lccmake.bat	Thu Jan 10 13:21:04 2013 +0000
    12.3 @@ -0,0 +1,8 @@
    12.4 +@REM -------
    12.5 +@REM make using lcc compiler
    12.6 +@REM type lccmake, and wait...
    12.7 +@REM do not edit - automatically generated from ProjectDefinition
    12.8 +@REM -------
    12.9 +make.exe -N -f bc.mak -DUSELCC=1 %*
   12.10 +
   12.11 +
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/compiler/libInit.cc	Thu Jan 10 13:21:04 2013 +0000
    13.3 @@ -0,0 +1,37 @@
    13.4 +/*
    13.5 + * $Header$
    13.6 + *
    13.7 + * DO NOT EDIT
    13.8 + * automagically generated from the projectDefinition: jv_dart_compiler.
    13.9 + */
   13.10 +#define __INDIRECTVMINITCALLS__
   13.11 +#include <stc.h>
   13.12 +
   13.13 +#ifdef WIN32
   13.14 +# pragma codeseg INITCODE "INITCODE"
   13.15 +#endif
   13.16 +
   13.17 +#if defined(INIT_TEXT_SECTION) || defined(DLL_EXPORT)
   13.18 +DLL_EXPORT void _libjv_dart_compiler_Init() INIT_TEXT_SECTION;
   13.19 +// DLL_EXPORT void _libjv_dart_compiler_InitDefinition() INIT_TEXT_SECTION;
   13.20 +#endif
   13.21 +
   13.22 +// void _libjv_dart_compiler_InitDefinition(pass, __pRT__, snd)
   13.23 +// OBJ snd; struct __vmData__ *__pRT__; {
   13.24 +// __BEGIN_PACKAGE2__("libjv_dart_compiler__DFN", _libjv_dart_compiler_InitDefinition, "jv:dart/compiler");
   13.25 +// _jv_137dart_137compiler_Init(pass,__pRT__,snd);
   13.26 +
   13.27 +// __END_PACKAGE__();
   13.28 +// }
   13.29 +
   13.30 +void _libjv_dart_compiler_Init(pass, __pRT__, snd)
   13.31 +OBJ snd; struct __vmData__ *__pRT__; {
   13.32 +__BEGIN_PACKAGE2__("libjv_dart_compiler", _libjv_dart_compiler_Init, "jv:dart/compiler");
   13.33 +_Dart__Parser_Init(pass,__pRT__,snd);
   13.34 +_Dart__ScannerBase_Init(pass,__pRT__,snd);
   13.35 +_jv_137dart_137compiler_Init(pass,__pRT__,snd);
   13.36 +_Dart__Scanner_Init(pass,__pRT__,snd);
   13.37 +
   13.38 +
   13.39 +__END_PACKAGE__();
   13.40 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/compiler/mingwmake.bat	Thu Jan 10 13:21:04 2013 +0000
    14.3 @@ -0,0 +1,12 @@
    14.4 +@REM -------
    14.5 +@REM make using mingw gnu compiler
    14.6 +@REM type mingwmake, and wait...
    14.7 +@REM do not edit - automatically generated from ProjectDefinition
    14.8 +@REM -------
    14.9 +@SET DEFINES=
   14.10 +@REM Kludge got Mercurial, cannot be implemented in Borland make
   14.11 +@FOR /F "tokens=*" %%i in ('hg root') do SET HGROOT=%%i
   14.12 +@IF "%HGROOT%" NEQ "" SET DEFINES=%DEFINES% "-DHGROOT=%HGROOT%"
   14.13 +make.exe -N -f bc.mak -DUSEMINGW=1 %DEFINES% %*
   14.14 +
   14.15 +
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/compiler/vcmake.bat	Thu Jan 10 13:21:04 2013 +0000
    15.3 @@ -0,0 +1,18 @@
    15.4 +@REM -------
    15.5 +@REM make using Microsoft Visual C compiler
    15.6 +@REM type vcmake, and wait...
    15.7 +@REM do not edit - automatically generated from ProjectDefinition
    15.8 +@REM -------
    15.9 +
   15.10 +@if not defined VSINSTALLDIR (
   15.11 +    call ..\..\..\stx\rules\vcsetup.bat
   15.12 +)
   15.13 +@SET DEFINES=
   15.14 +@REM Kludge got Mercurial, cannot be implemented in Borland make
   15.15 +@FOR /F "tokens=*" %%i in ('hg root') do SET HGROOT=%%i
   15.16 +@IF "%HGROOT%" NEQ "" SET DEFINES=%DEFINES% "-DHGROOT=%HGROOT%"
   15.17 +make.exe -N -f bc.mak -DUSEVC=1 %DEFINES% %*
   15.18 +
   15.19 +
   15.20 +
   15.21 +