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