Scanner.st
author Claus Gittinger <cg@exept.de>
Fri, 11 Apr 1997 16:45:46 +0200
changeset 505 793f88ee6269
parent 500 d0679fcc520e
child 526 adb8aed3a691
permissions -rw-r--r--
handle end of input while scanning a primitive
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
     1
"
4
f6fd83437415 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
     3
	      All Rights Reserved
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
     4
7ad01559b262 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
7ad01559b262 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
7ad01559b262 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
7ad01559b262 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
7ad01559b262 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
7ad01559b262 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
7ad01559b262 Initial revision
claus
parents:
diff changeset
    11
"
7ad01559b262 Initial revision
claus
parents:
diff changeset
    12
7ad01559b262 Initial revision
claus
parents:
diff changeset
    13
Object subclass:#Scanner
311
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    14
	instanceVariableNames:'source lineNr collectedSource token tokenType tokenPosition
449
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    15
		tokenValue tokenName tokenLineNr hereChar peekChar peekChar2
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    16
		requestor exitBlock errorFlag ignoreErrors ignoreWarnings
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    17
		saveComments currentComments warnSTXSpecialComment
311
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    18
		warnUnderscoreInIdentifier warnOldStyleAssignment
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    19
		warnCommonMistakes outStream outCol warnSTXNameSpaceUse'
241
418eb41350d3 no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    20
	classVariableNames:'TypeArray ActionArray AllowUnderscoreInIdentifier Warnings
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
    21
		WarnSTXSpecials WarnOldStyleAssignment WarnUnderscoreInIdentifier
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
    22
		WarnCommonMistakes'
241
418eb41350d3 no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    23
	poolDictionaries:''
418eb41350d3 no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    24
	category:'System-Compiler'
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    25
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    26
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    27
!Scanner class methodsFor:'documentation'!
20
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    28
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    29
copyright
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    30
"
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    31
 COPYRIGHT (c) 1989 by Claus Gittinger
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
    32
	      All Rights Reserved
20
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    33
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    34
 This software is furnished under a license and may be used
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    35
 only in accordance with the terms of that license and with the
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    36
 inclusion of the above copyright notice.   This software may not
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    37
 be provided or otherwise made available to, or used by, any
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    38
 other person.  No title to or ownership of the software is
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    39
 hereby transferred.
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    40
"
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    41
!
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    42
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    43
documentation
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    44
"
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    45
    Scanner reads from a stream and returns individual smalltalk tokens
75
d8b9d6b39497 *** empty log message ***
claus
parents: 74
diff changeset
    46
d8b9d6b39497 *** empty log message ***
claus
parents: 74
diff changeset
    47
    TODO: some testers noticed, that ST-80's scanner methods are called
d8b9d6b39497 *** empty log message ***
claus
parents: 74
diff changeset
    48
    xLetter, xDigit etc. For code using these (internals), the nextNumber,
d8b9d6b39497 *** empty log message ***
claus
parents: 74
diff changeset
    49
    nextIdentifier etc. methods should be renamed.
120
claus
parents: 103
diff changeset
    50
    (to me, these seem to be internal private methods; their public use
claus
parents: 103
diff changeset
    51
     is not a good idea ..)
20
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    52
"
41
62214c6ca833 allow turning off warnings
claus
parents: 38
diff changeset
    53
! !
62214c6ca833 allow turning off warnings
claus
parents: 38
diff changeset
    54
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    55
!Scanner class methodsFor:'initialization'!
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
    56
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    57
binarySelectorCharacters
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    58
    "return a collection of characters which are allowed in
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    59
     binary selectors"
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    60
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    61
    ^ #( $& $- $+ $= $* $/ $\ $< $> $~ $@ $, $? $!! $|)
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    62
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    63
    "Created: 4.1.1997 / 14:13:24 / cg"
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    64
!
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    65
60
0db697f03def *** empty log message ***
claus
parents: 53
diff changeset
    66
initialize
0db697f03def *** empty log message ***
claus
parents: 53
diff changeset
    67
    Warnings := true.
0db697f03def *** empty log message ***
claus
parents: 53
diff changeset
    68
    WarnSTXSpecials := true.
0db697f03def *** empty log message ***
claus
parents: 53
diff changeset
    69
    WarnUnderscoreInIdentifier := true.
87
claus
parents: 83
diff changeset
    70
    WarnOldStyleAssignment := true.
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
    71
    WarnCommonMistakes := true.
60
0db697f03def *** empty log message ***
claus
parents: 53
diff changeset
    72
    AllowUnderscoreInIdentifier := false.
0db697f03def *** empty log message ***
claus
parents: 53
diff changeset
    73
!
0db697f03def *** empty log message ***
claus
parents: 53
diff changeset
    74
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
    75
setupActions
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
    76
    |block|
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
    77
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
    78
    ActionArray := Array new:256.
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
    79
    TypeArray := Array new:256.
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
    80
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
    81
    block := [:s :char | s nextNumber].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
    82
    ($0 asciiValue) to:($9 asciiValue) do:[:index |
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    83
        ActionArray at:index put:block
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
    84
    ].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
    85
87
claus
parents: 83
diff changeset
    86
    block := [:s :char | s nextSpecial].
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    87
    self binarySelectorCharacters do:[:binop |
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    88
        TypeArray at:(binop asciiValue) put:#special.
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    89
        ActionArray at:(binop asciiValue) put:block
87
claus
parents: 83
diff changeset
    90
    ].
claus
parents: 83
diff changeset
    91
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    92
    "/ that one is a special case (both binarySelector AND syntax).
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    93
    TypeArray at:($| asciiValue) put:nil.
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    94
87
claus
parents: 83
diff changeset
    95
    block := [:s :char | s nextToken:char].
89
claus
parents: 87
diff changeset
    96
    #( $; $. $( $) $[ $] "$!!" $^ $| $_ ) do:[:ch |
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
    97
        ActionArray at:(ch asciiValue) put:block
87
claus
parents: 83
diff changeset
    98
    ].
claus
parents: 83
diff changeset
    99
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   100
    block := [:s :char | s nextIdentifier].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   101
    ($a asciiValue) to:($z asciiValue) do:[:index |
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   102
        ActionArray at:index put:block
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   103
    ].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   104
    ($A asciiValue) to:($Z asciiValue) do:[:index |
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   105
        ActionArray at:index put:block
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   106
    ].
71
2aac7fbb5be0 *** empty log message ***
claus
parents: 69
diff changeset
   107
    AllowUnderscoreInIdentifier ifTrue:[
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   108
        ActionArray at:$_ asciiValue put:block
71
2aac7fbb5be0 *** empty log message ***
claus
parents: 69
diff changeset
   109
    ].
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   110
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   111
    "kludge: action is characterToken, but type is special"
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   112
    TypeArray at:($| asciiValue) put:#special.
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   113
80
101b42803846 *** empty log message ***
claus
parents: 76
diff changeset
   114
    "kludge: action is nextColonOrAssign, but type is special"
101b42803846 *** empty log message ***
claus
parents: 76
diff changeset
   115
    TypeArray at:($: asciiValue) put:#special.
101b42803846 *** empty log message ***
claus
parents: 76
diff changeset
   116
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   117
    ActionArray at:($' asciiValue) put:[:s :char | s nextString].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   118
    ActionArray at:($$ asciiValue) put:[:s :char | s nextCharacter].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   119
    ActionArray at:($# asciiValue) put:[:s :char | s nextHash].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   120
    ActionArray at:($% asciiValue) put:[:s :char | s nextPrimitive].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   121
    ActionArray at:($: asciiValue) put:[:s :char | s nextColonOrAssign]
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   122
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   123
    "
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   124
     Scanner setupActions
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   125
    "
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   126
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   127
    "Modified: 4.1.1997 / 14:14:51 / cg"
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   128
! !
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   129
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   130
!Scanner class methodsFor:'instance creation'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   131
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   132
for:aStringOrStream
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   133
    "return a new scanner reading from aStringOrStream"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   134
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   135
    ^ (super new) initializeFor:aStringOrStream
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   136
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   137
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   138
!Scanner class methodsFor:'defaults'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   139
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   140
allowUnderscoreInIdentifier
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   141
    "return true, if underscores are allowed in identifiers"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   142
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   143
    ^ AllowUnderscoreInIdentifier
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   144
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   145
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   146
allowUnderscoreInIdentifier:aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   147
    "this allows turning on/off underscores in identifiers.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   148
     If turned off (the default), underscores are not allowed in identifiers,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   149
     but instead scanned as assignment character (old ST/80 syntax).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   150
     If turned on, underscores are in identifiers are allowed, while extra
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   151
     underscores are still scanned as assignment.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   152
     If you have to fileIn VV-Vsn2 classes, 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   153
     add a line such as:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   154
	Compiler allowUnderscoreInIdentifiers:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   155
     in your 'private.rc'/'smalltalk.rc' file"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   156
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   157
    AllowUnderscoreInIdentifier := aBoolean.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   158
    self setupActions
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   159
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   160
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   161
warnCommonMistakes
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   162
    "return true, if common beginners mistakes are to be warned about"
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   163
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   164
    ^ WarnCommonMistakes
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   165
!
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   166
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   167
warnCommonMistakes:aBoolean
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   168
    "this allows turning on/off warnings about common beginners mistakes.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   169
     Those are not really errors in the strict sense, but often lead to
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   170
     run time errors later.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   171
     Examples are: expr or:expr2, where expr2 is not a block.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   172
     If you get bored by those warnings, turn them off by adding
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   173
     a line as:
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   174
	Compiler warnCommonMistakes:false
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   175
     in your 'private.rc' file"
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   176
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   177
    WarnCommonMistakes := aBoolean
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   178
!
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   179
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   180
warnOldStyleAssignment
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   181
    "return true, if underscore-assignment (pre ST-80v4 syntax) are to be warned about"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   182
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   183
    ^ WarnOldStyleAssignment
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   184
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   185
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   186
warnOldStyleAssignment:aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   187
    "this allows turning on/off warnings about underscore-assignment (pre ST-80v4 syntax).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   188
     If you get bored by those warnings, turn them off by adding
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   189
     a line as:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   190
	Compiler warnOldStyleAssignment:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   191
     in your 'private.rc' file"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   192
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   193
    WarnOldStyleAssignment := aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   194
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   195
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   196
warnSTXSpecials
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   197
    "return true, if ST/X specials are to be warned about"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   198
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   199
    ^ WarnSTXSpecials
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   200
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   201
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   202
warnSTXSpecials:aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   203
    "this allows turning on/off warnings about stx specials.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   204
     If you get bored by those warnings, turn them off by adding
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   205
     a line as:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   206
	Compiler warnSTXSpecials:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   207
     in your 'private.rc' file"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   208
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   209
    WarnSTXSpecials := aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   210
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   211
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   212
warnUnderscoreInIdentifier
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   213
    "return true, if underscores in identifiers are to be warned about"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   214
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   215
    ^ WarnUnderscoreInIdentifier
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   216
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   217
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   218
warnUnderscoreInIdentifier:aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   219
    "this allows turning on/off warnings about underscores in identifiers.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   220
     If you get bored by those warnings, turn them off by adding
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   221
     a line as:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   222
	Compiler warnUnderscoreInIdentifier:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   223
     in your 'private.rc' file"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   224
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   225
    WarnUnderscoreInIdentifier := aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   226
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   227
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   228
warnings
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   229
    "return true, if any warnings are to be shown"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   230
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   231
    ^ Warnings
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   232
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   233
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   234
warnings:aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   235
    "this allows turning on/off warnings; the default is on.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   236
     You can turn off warnings in your 'private.rc' file with
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   237
	 Compiler warnings:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   238
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   239
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   240
    Warnings := aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   241
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   242
98
claus
parents: 97
diff changeset
   243
!Scanner methodsFor:'ST-80 compatibility'!
claus
parents: 97
diff changeset
   244
claus
parents: 97
diff changeset
   245
endOfLastToken
claus
parents: 97
diff changeset
   246
    ^ source position
claus
parents: 97
diff changeset
   247
! !
claus
parents: 97
diff changeset
   248
254
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   249
!Scanner methodsFor:'accessing'!
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   250
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   251
comments
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   252
    ^ currentComments
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   253
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   254
    "Created: 20.4.1996 / 20:07:01 / cg"
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   255
!
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   256
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   257
saveComments:aBoolean
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   258
    saveComments := aBoolean
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   259
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   260
    "Created: 20.4.1996 / 20:03:56 / cg"
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   261
!
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   262
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   263
sourceStream
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   264
    ^ source
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   265
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   266
    "Created: 20.4.1996 / 19:59:58 / cg"
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   267
! !
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   268
81
37ebe600119c *** empty log message ***
claus
parents: 80
diff changeset
   269
!Scanner methodsFor:'directives'!
37ebe600119c *** empty log message ***
claus
parents: 80
diff changeset
   270
74
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   271
parseDirective
81
37ebe600119c *** empty log message ***
claus
parents: 80
diff changeset
   272
    |directive packageName namespace list|
74
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   273
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   274
    source next.
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   275
    source skipSeparatorsExceptCR.
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   276
    hereChar := source peek.
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   277
    hereChar isLetter ifTrue:[
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   278
        directive := source nextWord.
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   279
        source peek == $: ifTrue:[
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   280
            source next.
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   281
            source skipSeparatorsExceptCR.
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   282
            hereChar := source peek.
74
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   283
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   284
            "
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   285
             Package: 'name-of-package'
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   286
             Package: packageId
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   287
            "
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   288
            directive = 'Package' ifTrue:[
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   289
                packageName := self parseDirectiveStringArg.
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   290
                packageName notNil ifTrue:[
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   291
                    (requestor respondsTo:#setPackage:) ifTrue:[
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   292
                        requestor setPackage:packageName
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   293
                    ].
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   294
                ] ifFalse:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   295
                    Transcript showCR:'unrecognized ''Package'' directive'.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   296
                    ^ false
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   297
                ]
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   298
            ].
74
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   299
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   300
            "
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   301
             Namespace: 'nameSpaceIdentifier'
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   302
             Namespace: nameSpaceIdentifier
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   303
            "
417
69263abda671 namespace support
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   304
            (directive = 'Namespace' 
69263abda671 namespace support
Claus Gittinger <cg@exept.de>
parents: 413
diff changeset
   305
            or:[directive = 'NameSpace']) ifTrue:[
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   306
                namespace := self parseDirectiveStringArg.
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   307
                namespace notNil ifTrue:[
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   308
                    (requestor respondsTo:#setNameSpace:) ifTrue:[
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   309
                        requestor setNameSpace:namespace 
426
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
   310
                    ] ifFalse:[
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
   311
                        self setNameSpace:namespace
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   312
                    ].
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   313
                ] ifFalse:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   314
                    Transcript showCR:'unrecognized ''NameSpace'' directive'.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   315
                    ^ false
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   316
                ].
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   317
            ].
81
37ebe600119c *** empty log message ***
claus
parents: 80
diff changeset
   318
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   319
            "
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   320
             Uses: 'nameSpace1', ... , 'nameSpaceN'
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   321
             Uses: nameSpaceId1, ... , nameSpaceIdN
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   322
            "
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   323
            directive = 'Uses' ifTrue:[
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   324
                list := self parseDirectiveStringListArg.
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   325
                list notNil ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   326
                    (requestor respondsTo:#addNameSpaces:) ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   327
                        requestor addNameSpaces:list 
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   328
                    ]
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   329
                ] ifFalse:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   330
                    Transcript showCR:'unrecognized ''Uses'' directive'.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   331
                    ^ false
426
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
   332
                ]
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   333
            ].
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   334
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   335
            "
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   336
             Prerequisites: 'name-of-package', ... , 'name-of-package'
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   337
            "
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   338
            directive = 'Prerequisites' ifTrue:[
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   339
                list := self parseDirectiveStringListArg.
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   340
                list notNil ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   341
                    (requestor respondsTo:#requirePackages:) ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   342
                        requestor requirePackages:list 
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   343
                    ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   344
                ] ifFalse:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   345
                    Transcript showCR:'unrecognized ''Prerequisites'' directive'.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   346
                    ^ false
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   347
                ]
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   348
            ].
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   349
        ]
74
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   350
    ].
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   351
    hereChar := source peek.
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   352
    ^ true.
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   353
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   354
    "Modified: 3.1.1997 / 13:43:44 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   355
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   356
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   357
parseDirectiveStringArg
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   358
    hereChar == $' ifTrue:[
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   359
        self nextString.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   360
        tokenType == #String ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   361
            ^ tokenValue
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   362
        ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   363
    ].
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   364
    (hereChar isLetter or:[hereChar == $_]) ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   365
        self nextIdentifier.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   366
        tokenType == #Identifier ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   367
            ^ tokenName
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   368
        ]
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   369
    ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   370
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   371
    ^ nil
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   372
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   373
    "Modified: 3.1.1997 / 13:35:51 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   374
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   375
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   376
parseDirectiveStringListArg
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   377
    |list|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   378
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   379
    list := OrderedCollection new.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   380
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   381
    [hereChar == $'] whileTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   382
	list addLast:self parseDirectiveStringArg.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   383
	source skipSeparatorsExceptCR.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   384
	hereChar := source peek.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   385
	(hereChar == $,) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   386
	    source next.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   387
	    source skipSeparatorsExceptCR.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   388
	    hereChar := source peek.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   389
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   390
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   391
    ^ list
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   392
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   393
7ad01559b262 Initial revision
claus
parents:
diff changeset
   394
!Scanner methodsFor:'error handling'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   395
431
058e1ce760ea added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   396
lastTokenLineNumber
058e1ce760ea added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   397
    ^ tokenLineNr
058e1ce760ea added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   398
058e1ce760ea added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   399
    "Created: 8.11.1996 / 18:46:36 / cg"
058e1ce760ea added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   400
!
058e1ce760ea added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   401
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   402
notifyError:aMessage position:position to:endPos
7ad01559b262 Initial revision
claus
parents:
diff changeset
   403
    "notify requestor of an error - if there is no requestor
53
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   404
     put it on the transcript. Requestor is typically the CodeView
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   405
     in which the accept/doIt was triggered, or the PositionableStream
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   406
     which does the fileIn. The requestor may decide how to highlight the
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   407
     error (and/or to abort the compile).
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   408
     Return the result passed back by the requestor."
7ad01559b262 Initial revision
claus
parents:
diff changeset
   409
53
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   410
    ignoreErrors ifFalse:[
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   411
	requestor isNil ifTrue:[
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   412
	    self showErrorMessage:aMessage position:position.
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   413
	    ^ false
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   414
	].
83
claus
parents: 81
diff changeset
   415
	^ requestor error:aMessage position:position to:endPos from:self 
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   416
    ].
53
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   417
    ^ false
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   418
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   419
7ad01559b262 Initial revision
claus
parents:
diff changeset
   420
notifyWarning:aMessage position:position to:endPos
7ad01559b262 Initial revision
claus
parents:
diff changeset
   421
    "notify requestor of an warning - if there is no requestor
7ad01559b262 Initial revision
claus
parents:
diff changeset
   422
     put it on the transcript.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   423
     Return the result passed back by the requestor."
7ad01559b262 Initial revision
claus
parents:
diff changeset
   424
53
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   425
    ignoreWarnings ifFalse:[
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   426
	requestor isNil ifTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   427
	    self showErrorMessage:aMessage position:position.
53
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   428
	    ^ false
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   429
	].
83
claus
parents: 81
diff changeset
   430
	^ requestor warning:aMessage position:position to:endPos from:self
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   431
    ].
53
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   432
    ^ false
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   433
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   434
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   435
showErrorMessage:aMessage position:pos
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   436
    "show an errormessage on the Transcript"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   437
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   438
    ignoreErrors ifFalse:[
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   439
	Smalltalk silentLoading == true ifFalse:[
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   440
	    Transcript showCR:(pos printString , ' [line: ' , tokenLineNr printString , '] ' , aMessage)
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   441
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   442
    ]
274
8e120bd82c69 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 266
diff changeset
   443
8e120bd82c69 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 266
diff changeset
   444
    "Modified: 18.5.1996 / 15:44:35 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   445
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   446
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   447
syntaxError:aMessage
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   448
    "a syntax error happened - position is not known"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   449
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   450
    ^ self syntaxError:aMessage position:tokenPosition
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   451
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   452
7ad01559b262 Initial revision
claus
parents:
diff changeset
   453
syntaxError:aMessage position:position
7ad01559b262 Initial revision
claus
parents:
diff changeset
   454
    "a syntax error happened - only start position is known"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   455
7ad01559b262 Initial revision
claus
parents:
diff changeset
   456
    ^ self syntaxError:aMessage position:position to:nil
7ad01559b262 Initial revision
claus
parents:
diff changeset
   457
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   458
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   459
syntaxError:aMessage position:position to:endPos
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   460
    "a syntax error happened"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   461
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   462
    self notifyError:('Error:' , aMessage) position:position to:endPos.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   463
    exitBlock notNil ifTrue:[exitBlock value].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   464
    ^ false
87
claus
parents: 83
diff changeset
   465
!
claus
parents: 83
diff changeset
   466
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   467
warnCommonMistake:msg at:position
311
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   468
    self warnCommonMistake:msg position:position to:position
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   469
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   470
    "Modified: 18.7.1996 / 10:28:53 / cg"
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   471
!
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   472
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   473
warnCommonMistake:msg position:pos1 to:pos2
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   474
    ignoreWarnings ifFalse:[
311
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   475
        warnCommonMistakes ifTrue:[
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   476
            self 
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   477
                warning:msg
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   478
                position:pos1 to:pos2.
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   479
        ]
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   480
    ]
311
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   481
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   482
    "Created: 18.7.1996 / 10:28:38 / cg"
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   483
!
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   484
87
claus
parents: 83
diff changeset
   485
warnOldStyleAssignmentAt:position
claus
parents: 83
diff changeset
   486
    ignoreWarnings ifFalse:[
claus
parents: 83
diff changeset
   487
	warnOldStyleAssignment ifTrue:[
claus
parents: 83
diff changeset
   488
	    self 
claus
parents: 83
diff changeset
   489
		warning:'old style assignment - please change to use '':='''
claus
parents: 83
diff changeset
   490
		position:position to:position.
claus
parents: 83
diff changeset
   491
	    "
claus
parents: 83
diff changeset
   492
	     only warn once (per method)
claus
parents: 83
diff changeset
   493
	    "
claus
parents: 83
diff changeset
   494
	    warnOldStyleAssignment := false
claus
parents: 83
diff changeset
   495
	]
claus
parents: 83
diff changeset
   496
    ]
claus
parents: 83
diff changeset
   497
!
claus
parents: 83
diff changeset
   498
claus
parents: 83
diff changeset
   499
warnUnderscoreAt:position
claus
parents: 83
diff changeset
   500
    ignoreWarnings ifFalse:[
claus
parents: 83
diff changeset
   501
	warnUnderscoreInIdentifier ifTrue:[
claus
parents: 83
diff changeset
   502
	    self 
claus
parents: 83
diff changeset
   503
		warning:'underscores in identifiers/symbols are nonportable' 
claus
parents: 83
diff changeset
   504
		position:position to:position.
claus
parents: 83
diff changeset
   505
	    "
claus
parents: 83
diff changeset
   506
	     only warn once (per method)
claus
parents: 83
diff changeset
   507
	    "
claus
parents: 83
diff changeset
   508
	    warnUnderscoreInIdentifier := false
claus
parents: 83
diff changeset
   509
	]
claus
parents: 83
diff changeset
   510
    ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   511
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   512
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   513
warning:aMessage
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   514
    "a warning - position is not known"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   515
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   516
    ^ self warning:aMessage position:tokenPosition
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   517
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   518
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   519
warning:aMessage position:position
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   520
    "a warning - only start position is known"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   521
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   522
    ^ self warning:aMessage position:position to:nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   523
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   524
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   525
warning:aMessage position:position to:endPos
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   526
    "a warning"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   527
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   528
    ^ self notifyWarning:('Warning: ' , aMessage) position:position to:endPos
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   529
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   530
17
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   531
!Scanner methodsFor:'general scanning'!
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   532
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   533
scanPositionsFor:aTokenString inString:aSourceString
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   534
    "scan aSourceString for occurrances of aTokenString.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   535
     Return a collection of start positions.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   536
     Added for VW compatibility (to support syntax-highlight)."
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   537
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   538
    |searchType searchName searchValue positions t|
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   539
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   540
    "
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   541
     first, look what kind of token we have to search for
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   542
    "
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   543
    self initializeFor:(ReadStream on:aTokenString).
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   544
    self nextToken.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   545
    searchType := tokenType.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   546
    searchName := tokenName.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   547
    searchValue := tokenValue.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   548
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   549
    "
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   550
     start the real work ...
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   551
    "
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   552
    self initializeFor:(ReadStream on:aSourceString).
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   553
    positions := OrderedCollection new.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   554
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   555
    [(t := self nextToken) ~~ #EOF] whileTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   556
	searchType == t ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   557
	    (searchName isNil or:[tokenName = searchName]) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   558
		(searchValue isNil or:[tokenValue = searchValue]) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   559
		    positions add:tokenPosition.
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   560
		]
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   561
	    ]
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   562
	]
17
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   563
    ].
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   564
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   565
    ^ positions
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   566
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   567
    "
30
26e2f849916a keep tokenRadix; accept E in floats
claus
parents: 20
diff changeset
   568
     Scanner new scanPositionsFor:'hello' inString:'foo bar hello baz hello' 
26e2f849916a keep tokenRadix; accept E in floats
claus
parents: 20
diff changeset
   569
     Scanner new scanPositionsFor:'3.14' inString:'foo 3.145 bar hello 3.14 baz hello 3.14' 
26e2f849916a keep tokenRadix; accept E in floats
claus
parents: 20
diff changeset
   570
     Scanner new scanPositionsFor:'16' inString:'foo 16 bar hello 16r10 baz hello 2r10000' 
17
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   571
    "
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   572
! !
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   573
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   574
!Scanner methodsFor:'private'!
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   575
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   576
backupPosition
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   577
    "if reading from a stream, at the end we might have read
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   578
     one token too many"
20
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
   579
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   580
    (tokenType == #EOF) ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   581
	source position:tokenPosition
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   582
    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   583
!
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
   584
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   585
beginComment
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   586
    ^ self
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   587
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   588
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   589
collectedSource
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   590
    ^ collectedSource
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   591
!
74
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   592
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   593
endComment:comment
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   594
    saveComments ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   595
	currentComments isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   596
	    currentComments := OrderedCollection with:comment
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   597
	] ifFalse:[
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   598
	    currentComments add:comment
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   599
	]
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   600
    ].
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   601
!
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   602
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   603
ignoreErrors
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   604
    "turn off notification of errors"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   605
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   606
    ignoreErrors := true
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   607
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   608
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   609
ignoreWarnings
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   610
    "turn off notification of warnings"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   611
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   612
    ignoreWarnings := true
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   613
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   614
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   615
initialize
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   616
    "prepare a scan"
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   617
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   618
    errorFlag := false.
266
6c6c1d5a3d9d initialize tokenPosition (error/warning at first token had it nil)
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   619
    tokenPosition := 1.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   620
    tokenLineNr := 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   621
    currentComments := nil.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   622
    saveComments := false.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   623
    ignoreErrors := false.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   624
    ignoreWarnings := Warnings not.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   625
    warnSTXSpecialComment := WarnSTXSpecials.
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   626
    warnSTXNameSpaceUse := WarnSTXSpecials.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   627
    warnUnderscoreInIdentifier := WarnUnderscoreInIdentifier.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   628
    warnOldStyleAssignment := WarnOldStyleAssignment.
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   629
    warnCommonMistakes := WarnCommonMistakes.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   630
    ActionArray isNil ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   631
        self class setupActions
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   632
    ]
266
6c6c1d5a3d9d initialize tokenPosition (error/warning at first token had it nil)
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   633
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   634
    "Modified: 14.10.1996 / 19:08:22 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   635
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   636
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   637
initializeFor:aStringOrStream
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   638
    "initialize -
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   639
     if this is the first time, setup character- and action tables"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   640
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   641
    self initialize.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   642
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   643
    aStringOrStream isStream ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   644
	source := ReadStream on:aStringOrStream
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   645
    ] ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   646
	source := aStringOrStream.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   647
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   648
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   649
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   650
notifying:anObject
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   651
    "set the requestor to be notified"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   652
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   653
    requestor := anObject
426
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
   654
!
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
   655
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
   656
setNameSpace:aNameSpace
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
   657
    "/ ignored here
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
   658
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
   659
    "Created: 8.11.1996 / 13:33:10 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   660
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   661
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   662
!Scanner methodsFor:'reading next token'!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   663
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   664
nextCharacter
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   665
    "a $ has been read - return a character token"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   666
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   667
    |nextChar|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   668
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   669
    source next.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   670
    nextChar := source next.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   671
    nextChar notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   672
	tokenValue := nextChar.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   673
	tokenType := #Character
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   674
    ] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   675
	tokenType := #EOF
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   676
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   677
    ^ tokenType
7ad01559b262 Initial revision
claus
parents:
diff changeset
   678
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   679
7ad01559b262 Initial revision
claus
parents:
diff changeset
   680
nextColonOrAssign
7ad01559b262 Initial revision
claus
parents:
diff changeset
   681
    "colon has been read - look for = to make it an assign"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   682
120
claus
parents: 103
diff changeset
   683
    "/ special kludge for identifier:= (without spaces inbetween)
claus
parents: 103
diff changeset
   684
    "/ here we needed two characters lookahead after the identifier ...
claus
parents: 103
diff changeset
   685
claus
parents: 103
diff changeset
   686
    peekChar == $= ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   687
        source next.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   688
        peekChar := nil.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   689
        tokenType := #':='.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   690
        ^ tokenType
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   691
    ].
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   692
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   693
    "/ special kludge for nameSpace:: (without spaces inbetween)
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   694
    "/ here we needed two characters lookahead after the identifier ...
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   695
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   696
    peekChar == $: ifTrue:[
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   697
        source next.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   698
        peekChar := nil.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   699
        tokenType := #'::'.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   700
        ^ tokenType
120
claus
parents: 103
diff changeset
   701
    ].
claus
parents: 103
diff changeset
   702
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   703
    (source nextPeek == $=) ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   704
        source next.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   705
        tokenType := $_
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   706
    ] ifFalse:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   707
        tokenType := $:
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   708
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   709
    ^ tokenType
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   710
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   711
    "Modified: 14.10.1996 / 18:49:29 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   712
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   713
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   714
nextHash
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   715
    |nextChar string part|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   716
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   717
    nextChar := source nextPeek.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   718
    nextChar notNil ifTrue:[
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   719
        nextChar isLetterOrDigit ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   720
            string := ''.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   721
            [nextChar notNil 
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   722
             and:[nextChar isLetterOrDigit 
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   723
                  or:[AllowUnderscoreInIdentifier == true
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   724
                      and:[nextChar == $_]]
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   725
                 ]
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   726
            ] whileTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   727
                part := source nextAlphaNumericWord.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   728
                part notNil ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   729
                    string := string , part.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   730
                ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   731
                nextChar := source peek.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   732
                AllowUnderscoreInIdentifier == true ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   733
                    nextChar == $_ ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   734
                        self warnUnderscoreAt:source position.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   735
                    ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   736
                    [nextChar == $_] whileTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   737
                        string := string copyWith:nextChar.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   738
                        nextChar := source nextPeek.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   739
                        (nextChar isAlphaNumeric) ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   740
                            string := string , source nextAlphaNumericWord.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   741
                            nextChar := source peek.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   742
                        ]
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   743
                    ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   744
                ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   745
                (nextChar == $:) ifFalse:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   746
                    tokenValue := string asSymbol.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   747
                    tokenType := #Symbol.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   748
                    ^ tokenType
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   749
                ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   750
                string := string copyWith:nextChar.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   751
                nextChar := source nextPeek
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   752
            ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   753
            tokenValue := string asSymbol.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   754
            tokenType := #Symbol.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   755
            ^ tokenType
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   756
        ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   757
        (nextChar == $( ) ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   758
            source next.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   759
            tokenType := #HashLeftParen.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   760
            ^ tokenType
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   761
        ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   762
        (nextChar == $[ ) ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   763
            "it seems that ST-80 supports Constant ByteArrays as #[...]
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   764
             (seen in a PD program)"
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   765
            source next.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   766
            tokenType := #HashLeftBrack.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   767
            ^ tokenType
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   768
        ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   769
        (nextChar == $' ) ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   770
            "it seems that ST-80 supports arbitrary symbols as #'...'
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   771
             (seen in a PD program)"
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   772
            self nextString.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   773
            tokenValue := tokenValue asSymbol.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   774
            tokenType := #Symbol.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   775
            ^ tokenType
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   776
        ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   777
        ((TypeArray at:(nextChar asciiValue)) == #special) ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   778
            string := source next asString.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   779
            nextChar := source peek.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   780
            nextChar notNil ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   781
                ((TypeArray at:(nextChar asciiValue)) == #special) ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   782
                    source next.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   783
                    string := string copyWith:nextChar
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   784
                ]
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   785
            ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   786
            tokenValue := string asSymbol.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   787
            tokenType := #Symbol.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   788
            ^ tokenType
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   789
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   790
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   791
    "this allows hash to be used as binop -
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   792
     I dont know, if this is correct ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   793
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   794
    tokenName := '#'.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   795
    tokenType := #BinaryOperator.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   796
    ^ tokenType
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   797
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   798
    self syntaxError:'unexpected end-of-input in Symbol'
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   799
            position:tokenPosition to:(tokenPosition + 1).
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   800
    ^ #Error
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   801
"
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   802
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
   803
    "Modified: 5.4.1997 / 11:44:26 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   804
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   805
7ad01559b262 Initial revision
claus
parents:
diff changeset
   806
nextId
7ad01559b262 Initial revision
claus
parents:
diff changeset
   807
    |nextChar string oldString 
7ad01559b262 Initial revision
claus
parents:
diff changeset
   808
     index "{ Class: SmallInteger }"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   809
     max   "{ Class: SmallInteger }" |
7ad01559b262 Initial revision
claus
parents:
diff changeset
   810
7ad01559b262 Initial revision
claus
parents:
diff changeset
   811
    nextChar := source peek.
96
claus
parents: 91
diff changeset
   812
    string := String basicNew:20.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   813
    index := 0.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   814
    max := 10.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   815
    [true] whileTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   816
	(nextChar notNil and:[nextChar isLetterOrDigit]) ifFalse:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   817
	    ^ string copyTo:index
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   818
	].
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   819
	(index == max) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   820
	    oldString := string.
96
claus
parents: 91
diff changeset
   821
	    string := String basicNew:(max * 2).
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   822
	    string replaceFrom:1 to:max with:oldString.
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   823
	    max := max * 2
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   824
	].
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   825
	index := index + 1.
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   826
	string at:index put:nextChar.
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
   827
	nextChar := source nextPeek
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   828
    ]
7ad01559b262 Initial revision
claus
parents:
diff changeset
   829
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   830
7ad01559b262 Initial revision
claus
parents:
diff changeset
   831
nextIdentifier
97
claus
parents: 96
diff changeset
   832
    |nextChar string firstChar|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   833
87
claus
parents: 83
diff changeset
   834
    hereChar == $_ ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   835
        "/
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   836
        "/ no need to check for AllowUnderscoreInIdentifier here;
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   837
        "/ could not arrive here if it was off
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   838
        "/
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   839
        nextChar := source nextPeek.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   840
        (nextChar isAlphaNumeric or:[nextChar == $_]) ifFalse:[
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   841
            "oops: a single underscore is an old-style assignement"
467
feaacb47b0b5 allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   842
            nextChar ~~ $: ifTrue:[
feaacb47b0b5 allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   843
                self warnOldStyleAssignmentAt:tokenPosition.
feaacb47b0b5 allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   844
                source next.
feaacb47b0b5 allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   845
                tokenType := $_.
feaacb47b0b5 allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   846
                ^ tokenType
feaacb47b0b5 allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   847
            ]
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   848
        ].
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   849
        string := '_'.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   850
        self warnUnderscoreAt:tokenPosition.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   851
        [nextChar == $_] whileTrue:[
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   852
            string := string copyWith:$_.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   853
            nextChar := source nextPeek.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   854
        ].
467
feaacb47b0b5 allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   855
        nextChar isAlphaNumeric ifTrue:[
feaacb47b0b5 allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   856
            string := string , source nextAlphaNumericWord.
feaacb47b0b5 allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   857
        ]
87
claus
parents: 83
diff changeset
   858
    ] ifFalse:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   859
        string := source nextAlphaNumericWord "self nextId".
87
claus
parents: 83
diff changeset
   860
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   861
    nextChar := source peek.
87
claus
parents: 83
diff changeset
   862
60
0db697f03def *** empty log message ***
claus
parents: 53
diff changeset
   863
    AllowUnderscoreInIdentifier ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   864
        nextChar == $_ ifTrue:[
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   865
            self warnUnderscoreAt:(source position).
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   866
        ].
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   867
        [nextChar == $_] whileTrue:[
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   868
            string := string copyWith:nextChar.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   869
            nextChar := source nextPeek.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   870
            (nextChar isAlphaNumeric) ifTrue:[
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   871
                string := string , source nextAlphaNumericWord.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   872
                nextChar := source peek.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   873
            ]
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   874
        ].
60
0db697f03def *** empty log message ***
claus
parents: 53
diff changeset
   875
    ].
0db697f03def *** empty log message ***
claus
parents: 53
diff changeset
   876
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   877
    (nextChar == $:) ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   878
        source next.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   879
        (source peek == $=) ifFalse:[
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   880
            (source peek == $:) ifFalse:[
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   881
                tokenName := string copyWith:nextChar.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   882
                tokenType := #Keyword.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   883
                ^ self
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   884
            ].
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   885
            peekChar := $:.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   886
            peekChar2 := $:.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   887
        ] ifTrue:[
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   888
            peekChar := $:.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   889
            peekChar2 := $=.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   890
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   891
    ].
20
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
   892
    tokenName := string.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   893
    firstChar := string at:1.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   894
    (firstChar == $s) ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   895
        (string = 'self') ifTrue:[tokenType := #Self. ^self].
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   896
        (string = 'super') ifTrue:[tokenType := #Super. ^self]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   897
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   898
    (firstChar == $n) ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   899
        (string = 'nil') ifTrue:[tokenType := #Nil. ^self]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   900
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   901
    (firstChar == $t) ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   902
        (string = 'true') ifTrue:[tokenType := #True. ^self].
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   903
        (string = 'thisContext') ifTrue:[tokenType := #ThisContext. ^self]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   904
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   905
    (firstChar == $f) ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   906
        (string = 'false') ifTrue:[tokenType := #False. ^self]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   907
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   908
    tokenType := #Identifier.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   909
    ^ tokenType
120
claus
parents: 103
diff changeset
   910
claus
parents: 103
diff changeset
   911
    "Created: 13.9.1995 / 12:56:42 / claus"
467
feaacb47b0b5 allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   912
    "Modified: 7.1.1997 / 12:31:36 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   913
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   914
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   915
nextMantissa:radix
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   916
    |nextChar value factor|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   917
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   918
    value := 0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   919
    factor := 1.0 / radix.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   920
    nextChar := source peek.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   921
    [(nextChar notNil and:[nextChar isDigitRadix:radix])] whileTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   922
	value := value + (nextChar digitValue * factor).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   923
	factor := factor / radix.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   924
	nextChar := source nextPeek
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   925
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   926
    ^ value
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   927
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   928
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   929
nextNumber
441
fa5637faa969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 431
diff changeset
   930
    |nextChar value s tokenRadix|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   931
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   932
    tokenRadix := 10.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   933
    value := Integer readFrom:source radix:tokenRadix.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   934
    nextChar := source peek.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   935
    (nextChar == $r) ifTrue:[
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   936
        tokenRadix := value.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   937
        source next.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   938
        s := 1.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   939
        source peek == $- ifTrue:[
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   940
            source next.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   941
            s := -1
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   942
        ].
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   943
        value := Integer readFrom:source radix:tokenRadix.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   944
        value := value * s.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   945
        nextChar := source peek
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   946
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   947
    (nextChar == $.) ifTrue:[
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   948
        nextChar := source nextPeek.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   949
        (nextChar notNil and:[nextChar isDigitRadix:tokenRadix]) ifTrue:[
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   950
            value := value asFloat + (self nextMantissa:tokenRadix).
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   951
            nextChar := source peek
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   952
        ] ifFalse:[
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   953
            nextChar == (Character cr) ifTrue:[
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   954
                tokenLineNr := tokenLineNr + 1.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   955
            ].
499
e7052694178d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   956
            nextChar := peekChar := $..
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   957
        ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   958
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   959
    ((nextChar == $e) or:[nextChar == $E]) ifTrue:[
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   960
        nextChar := source nextPeek.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   961
        (nextChar notNil and:[(nextChar isDigitRadix:tokenRadix) or:['+-' includes:nextChar]]) ifTrue:[
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   962
            s := 1.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   963
            (nextChar == $+) ifTrue:[
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   964
                nextChar := source nextPeek
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   965
            ] ifFalse:[
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   966
                (nextChar == $-) ifTrue:[
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   967
                    nextChar := source nextPeek.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   968
                    s := s negated
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   969
                ]
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   970
            ].
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   971
            value := value asFloat
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   972
                     * (10.0 raisedToInteger:((Integer readFrom:source radix:tokenRadix) * s))
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   973
        ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   974
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   975
    tokenValue := value.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   976
    (value isMemberOf:Float) ifTrue:[
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   977
        (nextChar == $d) ifTrue:[
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   978
            source next
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   979
        ].
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   980
        tokenType := #Float
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   981
    ] ifFalse:[
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   982
        tokenType := #Integer
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   983
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   984
    ^ tokenType
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   985
498
11cae0bcd0d6 fixed scanning of digit-. without followup digit.
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   986
    "Modified: 2.4.1997 / 14:02:09 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   987
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   988
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   989
nextPrimitive
7ad01559b262 Initial revision
claus
parents:
diff changeset
   990
    |nextChar inPrimitive string 
7ad01559b262 Initial revision
claus
parents:
diff changeset
   991
     index "{ Class: SmallInteger }"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   992
     len   "{ Class: SmallInteger }" |
7ad01559b262 Initial revision
claus
parents:
diff changeset
   993
7ad01559b262 Initial revision
claus
parents:
diff changeset
   994
    nextChar := source nextPeek.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   995
    string := String new:500.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   996
    len := 500.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   997
    index := 1.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   998
    (nextChar == ${) ifTrue:[
505
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
   999
        nextChar := source nextPeek.
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1000
        inPrimitive := true.
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1001
        [inPrimitive] whileTrue:[
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1002
            [nextChar == $%] whileFalse:[
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1003
                nextChar isNil ifTrue:[
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1004
                    self syntaxError:'unterminated primitive'
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1005
                            position:tokenPosition to:source position.
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1006
                    ^ #Error
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1007
                ].
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1008
                string at:index put:nextChar.
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1009
                (index == len) ifTrue:[
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1010
                    string := string , (String new:len).
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1011
                    len := len * 2
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1012
                ].
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1013
                index := index + 1.
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1014
                nextChar := source next
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1015
            ].
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1016
            (source peek == $}) ifTrue:[
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1017
                inPrimitive := false
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1018
            ] ifFalse:[
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1019
                string at:index put:nextChar.
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1020
                (index == len) ifTrue:[
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1021
                    string := string , (String new:len).
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1022
                    len := len * 2
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1023
                ].
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1024
                index := index + 1.
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1025
                nextChar := source next
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1026
            ]
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1027
        ].
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1028
        source next.
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1029
        tokenValue := string copyTo:(index - 1).
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1030
        tokenType := #Primitive.
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1031
        tokenLineNr := tokenLineNr + (tokenValue occurrencesOf:(Character cr)).
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1032
        ^ tokenType
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1033
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1034
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1035
    "a % alone is a binary operator"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1036
    tokenName := '%'.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1037
    tokenType := #BinaryOperator.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1038
    ^ tokenType.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1039
"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1040
    self syntaxError:('invalid character: ''' , nextChar asString , '''')
505
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1041
            position:tokenPosition to:(tokenPosition + 1).
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1042
    ^ #Error
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1043
"
505
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1044
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1045
    "Modified: 11.4.1997 / 16:11:08 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1046
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1047
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1048
nextSpecial
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1049
    "a special character has been read, look for another one.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1050
     also -number is handled here"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1051
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1052
    |firstChar secondChar thirdChar string p|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1053
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1054
    firstChar := source next.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1055
    secondChar := source peek.
241
418eb41350d3 no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
  1056
    ((firstChar == $-) and:[secondChar notNil]) ifTrue:[
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1057
	secondChar isDigit ifTrue:[
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1058
	    self nextNumber.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1059
	    tokenValue := tokenValue negated.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1060
	    ^ tokenType
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1061
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1062
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1063
    string := firstChar asString.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1064
    secondChar notNil ifTrue:[
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1065
	((TypeArray at:(secondChar asciiValue)) == #special) ifTrue:[
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1066
	    (secondChar == $-) ifTrue:[
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1067
		"special- look if minus belongs to number following"
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1068
		p := source position.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1069
		source next.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1070
		thirdChar := source peek.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1071
		source position:p.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1072
		thirdChar isDigit ifTrue:[
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1073
		    tokenName := string.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1074
		    tokenType := #BinaryOperator.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1075
		    ^ tokenType
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1076
		]
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1077
	    ].
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1078
	    source next.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1079
	    string := string copyWith:secondChar
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1080
	].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1081
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1082
    tokenName := string.
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1083
    tokenType := #BinaryOperator.
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
  1084
    ^ tokenType
241
418eb41350d3 no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
  1085
418eb41350d3 no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
  1086
    "Modified: 12.4.1996 / 15:05:19 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1087
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1088
264
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1089
nextString
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1090
    |nextChar string pos
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1091
     index "{ Class: SmallInteger }"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1092
     len   "{ Class: SmallInteger }"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1093
     inString|
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1094
96
claus
parents: 91
diff changeset
  1095
    string := String basicNew:20.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1096
    len := 20.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1097
    index := 1.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1098
    pos := source position.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1099
    source next.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1100
    nextChar := source next.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1101
    inString := true.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1102
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1103
    [inString] whileTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1104
	nextChar isNil ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1105
	    self syntaxError:'unexpected end-of-input in String'
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1106
		    position:pos to:(source position - 1).
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1107
	    tokenType := #EOF.
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1108
	    ^ tokenType
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1109
	].
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1110
	(nextChar == Character cr) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1111
	    tokenLineNr := tokenLineNr + 1
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1112
	].
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1113
	(nextChar == Character quote) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1114
	    (source peek == Character quote) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1115
		source next
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1116
	    ] ifFalse:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1117
		inString := false
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1118
	    ]
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1119
	].
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1120
	inString ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1121
	    string at:index put:nextChar.
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1122
	    (index == len) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1123
		string := string , (String new:len).
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1124
		len := len * 2
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1125
	    ].
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1126
	    index := index + 1.
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1127
	    nextChar := source next
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1128
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1129
    ].
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
  1130
    tokenValue := string copyTo:(index - 1).
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1131
    tokenType := #String.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1132
    ^ tokenType
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1133
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1134
264
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1135
nextToken
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1136
    "return the next token from the source-stream"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1137
449
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1138
    |skipping actionBlock v|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1139
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1140
    peekChar notNil ifTrue:[
449
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1141
        hereChar := peekChar.
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1142
        peekChar := peekChar2.
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1143
        peekChar2 := nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1144
    ] ifFalse:[
449
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1145
        skipping := true.
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1146
        [skipping] whileTrue:[
487
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1147
449
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1148
            outStream notNil ifTrue:[
487
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1149
                hereChar := source peek.
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1150
                [(hereChar == Character space)
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1151
                 or:[hereChar isSeparator]
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1152
                ] whileTrue:[
449
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1153
                    source next.
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1154
                    outStream space. 
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1155
                    outCol := outCol + 1.
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1156
                ]
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1157
            ] ifFalse:[
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1158
                hereChar := source skipSeparatorsExceptCR.
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1159
            ].
487
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1160
449
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1161
            hereChar == (Character cr) ifTrue:[
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1162
                tokenLineNr := tokenLineNr + 1.
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1163
                source next.
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1164
                outStream notNil ifTrue:[
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1165
                    outStream cr.
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1166
                    outCol := 1
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1167
                ]
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1168
            ] ifFalse:[
487
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1169
                hereChar == (Character return) ifTrue:[
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1170
                    outStream notNil ifTrue:[
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1171
                        outStream nextPut:hereChar.
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1172
                        outCol := 1
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1173
                    ].
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1174
                    source next.
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1175
                ] ifFalse:[
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1176
                    hereChar == (Character doubleQuote) ifTrue:[
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1177
                        "start of a comment"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1178
487
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1179
                        self skipComment.
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1180
                        hereChar := source peek.
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1181
                    ] ifFalse:[
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1182
                        skipping := false
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1183
                    ]
449
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1184
                ]
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1185
            ]
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1186
        ].
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1187
        hereChar isNil ifTrue:[
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1188
            tokenType := #EOF.
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1189
            ^ tokenType
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1190
        ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1191
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1192
    tokenPosition := source position.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1193
449
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1194
    (v := hereChar asciiValue) == 0 ifTrue:[
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1195
        v := Character space asciiValue
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1196
    ].
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1197
    actionBlock := ActionArray at:v.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1198
    actionBlock notNil ifTrue:[
449
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1199
        ^ actionBlock value:self value:hereChar
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1200
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1201
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1202
    self syntaxError:('invalid character: ''' , hereChar asString , ''' ',
449
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1203
                      '(' , v printString , ')')
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1204
            position:tokenPosition to:tokenPosition.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1205
    tokenType := #Error.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1206
    ^ #Error
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1207
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1208
    "Modified: 13.9.1995 / 12:56:14 / claus"
487
4bc6586a7d67 oops - did not treat return as whiteSpace
Claus Gittinger <cg@exept.de>
parents: 467
diff changeset
  1209
    "Modified: 24.1.1997 / 10:29:38 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1210
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1211
264
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1212
nextToken:aCharacter
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1213
    tokenType := aCharacter.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1214
    source next.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1215
    ^ tokenType
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1216
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1217
264
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1218
skipComment
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1219
    |commentStream startPos|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1220
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1221
    saveComments ifTrue:[
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1222
        commentStream := WriteStream on:''.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1223
        self beginComment.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1224
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1225
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1226
    outStream notNil ifTrue:[
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1227
        outStream nextPut:Character doubleQuote.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1228
        outCol := outCol + 1
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1229
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1230
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1231
    startPos := source position.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1232
    source next.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1233
    hereChar := source peek.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1234
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1235
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1236
     special ST/X addition:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1237
     a $/ right after the initial double quote makes it an up-to-end-of-line comment,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1238
     which is very useful to comment out parts of filed-in source code.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1239
     Since this is non-standard, use it in very rare cases only. 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1240
     (maybe the upcoming ansi-standard adds something similar - in this case, I will
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1241
      change it without notice)"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1242
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1243
    hereChar == $/ ifTrue:[
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1244
        [hereChar notNil and:[hereChar ~~ Character cr]] whileTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1245
            saveComments ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1246
                commentStream nextPut:hereChar
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1247
            ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1248
            outStream notNil ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1249
                outStream nextPut:hereChar.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1250
                outCol := outCol + 1
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1251
            ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1252
            hereChar := source nextPeek.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1253
        ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1254
        tokenLineNr := tokenLineNr + 1.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1255
        ignoreWarnings ifFalse:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1256
            warnSTXSpecialComment ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1257
                self warning:'end-of-line comments are a nonstandard feature of ST/X' 
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1258
                     position:startPos to:(source position).
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1259
                "
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1260
                 only warn once
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1261
                "
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1262
                warnSTXSpecialComment := false
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1263
            ]
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1264
        ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1265
        outStream notNil ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1266
            outStream cr.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1267
            outCol := 1
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1268
        ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1269
    ] ifFalse:[
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1270
        hereChar == ${ ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1271
            "
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1272
             special ST/X addition:
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1273
             a ${ right after the initial double quote starts a directive
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1274
            "
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1275
            self parseDirective
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1276
        ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1277
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1278
        [hereChar notNil and:[hereChar ~~ (Character doubleQuote)]] whileTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1279
            hereChar == (Character cr) ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1280
                tokenLineNr := tokenLineNr + 1.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1281
            ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1282
            saveComments ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1283
                commentStream nextPut:hereChar
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1284
            ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1285
            outStream notNil ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1286
                outStream nextPut:hereChar.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1287
                outCol := outCol + 1
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1288
            ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1289
            hereChar := source nextPeek
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1290
        ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1291
        hereChar isNil ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1292
            self warning:'unclosed comment' position:startPos to:(source position)
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1293
        ] ifFalse:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1294
            outStream notNil ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1295
                outStream nextPut:(Character doubleQuote).
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1296
                outCol := outCol + 1
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1297
            ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1298
        ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1299
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1300
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1301
    "skip final dQuote or cr"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1302
    source next.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1303
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1304
    saveComments ifTrue:[
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1305
        self endComment:commentStream contents.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1306
    ].
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1307
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  1308
    "Modified: 3.1.1997 / 13:44:43 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1309
! !
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1310
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1311
!Scanner class methodsFor:'documentation'!
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
  1312
264
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1313
version
505
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  1314
    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.65 1997-04-11 14:45:46 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
  1315
! !
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1316
Scanner initialize!