Scanner.st
author Claus Gittinger <cg@exept.de>
Tue, 29 Oct 2002 10:39:37 +0100
changeset 1322 da25e31f423c
parent 1321 e34f7e7d28a0
child 1339 7dd363978456
permissions -rw-r--r--
autodefine workspace variables
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
1073
d6041f6d680c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
    13
"{ Package: 'stx:libcomp' }"
d6041f6d680c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
    14
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    15
Object subclass:#Scanner
709
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
    16
	instanceVariableNames:'typeArray actionArray source lineNr token tokenType tokenPosition
449
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    17
		tokenValue tokenName tokenLineNr hereChar peekChar peekChar2
6ad7a414ea5d just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    18
		requestor exitBlock errorFlag ignoreErrors ignoreWarnings
708
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
    19
		saveComments currentComments collectedSource
709
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
    20
		allowUnderscoreInIdentifier allowDollarInIdentifier
1261
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
    21
		allowOldStyleAssignment scanColonAsKeyword warnSTXSpecialComment
785
14d0ec37a754 added hook for subclasses which do not want to scan
Claus Gittinger <cg@exept.de>
parents: 783
diff changeset
    22
		warnUnderscoreInIdentifier warnOldStyleAssignment
14d0ec37a754 added hook for subclasses which do not want to scan
Claus Gittinger <cg@exept.de>
parents: 783
diff changeset
    23
		warnCommonMistakes outStream outCol warnSTXNameSpaceUse
1202
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
    24
		warnPossibleIncompatibilities warnDollarInIdentifier
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
    25
		inArrayLiteral'
241
418eb41350d3 no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    26
	classVariableNames:'TypeArray ActionArray AllowUnderscoreInIdentifier Warnings
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
    27
		WarnSTXSpecials WarnOldStyleAssignment WarnUnderscoreInIdentifier
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
    28
		WarnCommonMistakes WarnPossibleIncompatibilities
717
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
    29
		WarnDollarInIdentifier AllowDollarInIdentifier
922
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
    30
		EmptySourceNotificationSignal AllowSqueakExtensions
1261
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
    31
		AllowQualifiedNames AllowDolphinExtensions
1298
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    32
		AllowOldStyleAssignment AllowExtendedBinarySelectors
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    33
		AllowExtendedSTXSyntax'
241
418eb41350d3 no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    34
	poolDictionaries:''
418eb41350d3 no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    35
	category:'System-Compiler'
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    36
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    37
648
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
    38
Object subclass:#Comment
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
    39
	instanceVariableNames:'commentType commentString'
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
    40
	classVariableNames:''
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
    41
	poolDictionaries:''
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
    42
	privateIn:Scanner
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
    43
!
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
    44
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    45
!Scanner class methodsFor:'documentation'!
20
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    46
901
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    47
bugs
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    48
"
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    49
   array constant containing keywords as in:
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    50
        #(
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    51
                foo:bar:
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    52
                fee:baz:
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    53
         )
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    54
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    55
   is scanned as 4-element array containing ( #foo: #bar: #fee: #baz: )
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    56
   this MUST be fixed.
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    57
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    58
   workaround:
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    59
        #(
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    60
                #'foo:bar:'
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    61
                #'fee:baz:'
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    62
         )
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    63
        
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    64
"
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    65
!
8894cc8dda62 documentation
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
    66
20
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    67
copyright
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    68
"
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    69
 COPYRIGHT (c) 1989 by Claus Gittinger
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
    70
	      All Rights Reserved
20
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    71
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    72
 This software is furnished under a license and may be used
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    73
 only in accordance with the terms of that license and with the
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    74
 inclusion of the above copyright notice.   This software may not
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    75
 be provided or otherwise made available to, or used by, any
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    76
 other person.  No title to or ownership of the software is
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    77
 hereby transferred.
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    78
"
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    79
!
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    80
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    81
documentation
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    82
"
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    83
    Scanner reads from a stream and returns individual smalltalk tokens
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    84
    Its main method is #nextToken, which reads and returns the next token
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    85
    Possibly placing additional information (such as tokenValue) into 
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    86
    instance variables as a side effect.
75
d8b9d6b39497 *** empty log message ***
claus
parents: 74
diff changeset
    87
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    88
    TODO: 
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    89
        some testers noticed, that ST-80's scanner methods are called
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    90
        xLetter, xDigit etc. For code using these (internals), the nextNumber,
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    91
        nextIdentifier etc. methods should be renamed.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    92
        (to me, these seem to be internal private methods; 
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    93
         their public use is not a good idea ..)
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    94
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    95
        Scanner is typically subclassed for parsing and #nextToken
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    96
        invoked via #self-sends.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    97
        This should be changed and scanner ought to be an instance variable
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    98
        of Parser - this allows more flexible use of the scanner/parser
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    99
        framework (i.e. changing the scanner without affecting the parser).
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   100
1302
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
   101
    Extensions:
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
   102
        this scanner allows for 3-character binary selectors.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
   103
        also, # is a valid selector. (however, ## is currently scanned as a symbol literal).
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
   104
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   105
    [author:]
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   106
        Claus Gittinger
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   107
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   108
    [see also:]
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   109
        Parser
20
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
   110
"
41
62214c6ca833 allow turning off warnings
claus
parents: 38
diff changeset
   111
! !
62214c6ca833 allow turning off warnings
claus
parents: 38
diff changeset
   112
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   113
!Scanner class methodsFor:'initialization'!
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   114
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   115
binarySelectorCharacters
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   116
    "return a collection of characters which are allowed in
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   117
     binary selectors"
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   118
1288
a3ba417e1efe extendedBinarySelectors
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
   119
    |characters|
a3ba417e1efe extendedBinarySelectors
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
   120
a3ba417e1efe extendedBinarySelectors
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
   121
    characters := #( $& $- $+ $= $* $/ $\ $< $> $~ $@ $, $? $!! $| $% $#).
a3ba417e1efe extendedBinarySelectors
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
   122
    AllowExtendedBinarySelectors ifTrue:[
a3ba417e1efe extendedBinarySelectors
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
   123
        characters := characters asOrderedCollection.
a3ba417e1efe extendedBinarySelectors
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
   124
        characters add:(Character value:16rB1).  "/ plus-minus
a3ba417e1efe extendedBinarySelectors
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
   125
        characters add:(Character value:16rD7).  "/ times
a3ba417e1efe extendedBinarySelectors
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
   126
        characters add:(Character value:16rB7).  "/ centered dot
a3ba417e1efe extendedBinarySelectors
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
   127
        characters add:(Character value:16rF7).  "/ divide
a3ba417e1efe extendedBinarySelectors
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
   128
    ].
a3ba417e1efe extendedBinarySelectors
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
   129
    ^ characters
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   130
650
a8bcb32d1665 added #% as binop in typeTable.
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   131
    "Created: / 4.1.1997 / 14:13:24 / cg"
a8bcb32d1665 added #% as binop in typeTable.
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   132
    "Modified: / 27.2.1998 / 02:01:28 / cg"
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   133
!
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   134
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   135
setupActions
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   136
    "initialize the scanners actionTables - these are used to dispatch
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   137
     into scanner methods as characters are read"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   138
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   139
    |block|
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   140
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   141
    ActionArray := Array new:256.
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   142
    TypeArray := Array new:256.
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   143
1303
f726ae1bc0d2 comment
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   144
    "/ TODO: later versions should be configurable w.r.t separators.
f726ae1bc0d2 comment
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   145
    "/ #(9 10 12 13 26 32) do: [:i | TypeArray at:(i+1) put: #separator].
f726ae1bc0d2 comment
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   146
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   147
    block := [:s :char | s nextNumber].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   148
    ($0 asciiValue) to:($9 asciiValue) do:[:index |
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   149
        ActionArray at:index put:block
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   150
    ].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   151
87
claus
parents: 83
diff changeset
   152
    block := [:s :char | s nextSpecial].
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   153
    self binarySelectorCharacters do:[:binop |
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   154
        TypeArray at:(binop asciiValue) put:#special.
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   155
        ActionArray at:(binop asciiValue) put:block
87
claus
parents: 83
diff changeset
   156
    ].
claus
parents: 83
diff changeset
   157
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   158
    "/ that one is a special case (both binarySelector AND syntax).
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   159
    TypeArray at:($| asciiValue) put:nil.
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   160
87
claus
parents: 83
diff changeset
   161
    block := [:s :char | s nextToken:char].
1298
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   162
    #( $; $. $( $) $[ $] $^ $| $_ ${ $} ) do:[:ch |
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   163
        ActionArray at:(ch asciiValue) put:block
87
claus
parents: 83
diff changeset
   164
    ].
claus
parents: 83
diff changeset
   165
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   166
    block := [:s :char | s nextIdentifier].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   167
    ($a asciiValue) to:($z asciiValue) do:[:index |
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   168
        ActionArray at:index put:block
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   169
    ].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   170
    ($A asciiValue) to:($Z asciiValue) do:[:index |
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   171
        ActionArray at:index put:block
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   172
    ].
71
2aac7fbb5be0 *** empty log message ***
claus
parents: 69
diff changeset
   173
    AllowUnderscoreInIdentifier ifTrue:[
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   174
        ActionArray at:$_ asciiValue put:block
71
2aac7fbb5be0 *** empty log message ***
claus
parents: 69
diff changeset
   175
    ].
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   176
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   177
    "kludge: action is characterToken, but type is special"
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   178
    TypeArray at:($| asciiValue) put:#special.
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   179
80
101b42803846 *** empty log message ***
claus
parents: 76
diff changeset
   180
    "kludge: action is nextColonOrAssign, but type is special"
101b42803846 *** empty log message ***
claus
parents: 76
diff changeset
   181
    TypeArray at:($: asciiValue) put:#special.
101b42803846 *** empty log message ***
claus
parents: 76
diff changeset
   182
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   183
    ActionArray at:($' asciiValue) put:[:s :char | s nextString].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   184
    ActionArray at:($$ asciiValue) put:[:s :char | s nextCharacter].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   185
    ActionArray at:($# asciiValue) put:[:s :char | s nextHash].
1298
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   186
    ActionArray at:($!! asciiValue) put:[:s :char | s nextExcla].
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   187
    ActionArray at:($% asciiValue) put:[:s :char | s nextPrimitive].
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   188
    ActionArray at:($: asciiValue) put:[:s :char | s nextColonOrAssign]
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   189
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   190
    "
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   191
     Scanner setupActions
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   192
    "
462
6a29b0b356fc added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   193
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   194
    "Modified: 23.5.1997 / 12:07:55 / cg"
33
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   195
! !
8985ec2f9e82 *** empty log message ***
claus
parents: 30
diff changeset
   196
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   197
!Scanner class methodsFor:'instance creation'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   198
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   199
for:aStringOrStream
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   200
    "create & return a new scanner reading from aStringOrStream"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   201
1235
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   202
    ^ self basicNew initializeFor:aStringOrStream
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   203
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   204
    "Modified: 23.5.1997 / 12:08:42 / cg"
854
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
   205
!
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
   206
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
   207
new    
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
   208
    "create & return a new scanner"
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
   209
859
0e5dd0e35301 access to lineNumber added
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   210
    ^ self basicNew initialize.
854
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
   211
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
   212
    "Modified: / 23.5.1997 / 12:08:42 / cg"
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
   213
    "Created: / 26.5.1999 / 12:02:16 / stefan"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   214
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   215
717
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   216
!Scanner class methodsFor:'Signal constants'!
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   217
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   218
emptySourceNotificationSignal
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   219
    ^ EmptySourceNotificationSignal
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   220
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   221
    "Created: / 16.5.1998 / 15:55:14 / cg"
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   222
! !
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   223
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   224
!Scanner class methodsFor:'class initialization'!
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   225
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   226
initialize
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   227
    "initialize the classes defaults. Typically, these are changed
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   228
     later in the 'private.rc' file."
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   229
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   230
    EmptySourceNotificationSignal isNil ifTrue:[
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   231
        EmptySourceNotificationSignal := QuerySignal new mayProceed:true.
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   232
        EmptySourceNotificationSignal notifierString:'empty source given to evaluate'.
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   233
        EmptySourceNotificationSignal nameClass:self message:#emptySourceNotificationSignal.
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   234
    ].
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   235
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   236
    Warnings := true.
1002
bf15e400f54e default setting (allowUnderscoreInIdentifier is now true)
Claus Gittinger <cg@exept.de>
parents: 1001
diff changeset
   237
    WarnSTXSpecials := false.
bf15e400f54e default setting (allowUnderscoreInIdentifier is now true)
Claus Gittinger <cg@exept.de>
parents: 1001
diff changeset
   238
    WarnUnderscoreInIdentifier := false.
717
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   239
    WarnDollarInIdentifier := true.
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   240
    WarnOldStyleAssignment := true.
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   241
    WarnCommonMistakes := true.
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   242
    WarnPossibleIncompatibilities := false.
1002
bf15e400f54e default setting (allowUnderscoreInIdentifier is now true)
Claus Gittinger <cg@exept.de>
parents: 1001
diff changeset
   243
bf15e400f54e default setting (allowUnderscoreInIdentifier is now true)
Claus Gittinger <cg@exept.de>
parents: 1001
diff changeset
   244
    AllowUnderscoreInIdentifier := true.        "/ underscores in identifiers
922
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   245
    AllowDollarInIdentifier := false.           "/ st80-vms dollars in identifiers
1261
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   246
    AllowOldStyleAssignment := true.            "/ st80 underscore as assignment
922
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   247
    AllowSqueakExtensions := false.             "/ squeak computed array
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   248
    AllowQualifiedNames := false.               "/ vw3 qualified names
1288
a3ba417e1efe extendedBinarySelectors
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
   249
    AllowExtendedBinarySelectors := false.      "/ vw5.4 extended binary selectors
717
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   250
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   251
    "
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   252
     self initialize
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   253
    "
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   254
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   255
    "Modified: / 16.5.1998 / 15:55:41 / cg"
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   256
! !
627b2379d5ce moved signal to scanner
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   257
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   258
!Scanner class methodsFor:'defaults'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   259
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   260
allowDollarInIdentifier
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   261
    "return true, if $-characters are allowed in identifiers.
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   262
     Notice, that dollars are NEVER allowed as the first character in an identifier."
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   263
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   264
    ^ AllowDollarInIdentifier
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   265
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   266
    "Created: 7.9.1997 / 01:32:18 / cg"
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   267
    "Modified: 7.9.1997 / 01:39:44 / cg"
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   268
!
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   269
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   270
allowDollarInIdentifier:aBoolean
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   271
    "this allows turning on/off $-characters in identifiers.
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   272
     Notice, that dollars are NEVER allowed as the first character in an identifier.
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   273
     If turned off (the default), dollars are not allowed in identifiers,
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   274
     but instead are scanned as character-constant prefix.
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   275
     If turned on, dollars are in identifiers are allowed, while extra
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   276
     dollars are still scanned as constant character prefix.
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   277
     If you have to fileIn old VW-Vsn2.x classes, turn this off
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   278
     before filing them in; i.e.:
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   279
        Compiler allowDollarInIdentifiers:false"
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   280
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   281
    AllowDollarInIdentifier := aBoolean.
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   282
    self setupActions
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   283
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   284
    "Created: 7.9.1997 / 01:34:49 / cg"
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   285
    "Modified: 7.9.1997 / 01:39:30 / cg"
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   286
!
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   287
1226
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   288
allowDolphinExtensions
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   289
    "return true, if ##(..) computed literals are allowed"
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   290
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   291
    ^ AllowDolphinExtensions
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   292
!
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   293
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   294
allowDolphinExtensions:aBoolean
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   295
    "this allows turning on/off support for computed arrays ##(..) as in dolphin.
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   296
     If you want to fileIn Dolphin classes, enable this with:
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   297
        Compiler allowDolphinComputedArrays:true"
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   298
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   299
    AllowDolphinExtensions := aBoolean.
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   300
    self setupActions
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   301
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   302
    "
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   303
     self allowDolphinExtensions:true
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   304
     self allowDolphinExtensions:false
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   305
    "
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   306
!
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
   307
1261
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   308
allowOldStyleAssignment
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   309
    "return true, if underscore-assignment (pre ST-80v4 syntax) are to be allowed"
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   310
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   311
    ^ AllowOldStyleAssignment
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   312
!
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   313
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   314
allowOldStyleAssignment:aBoolean
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   315
    "this allows turning on/off recognition of underscore-assignment (pre ST-80v4 syntax).
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   316
     You must turn this off, if code with variables named '_' is to be filedIn"
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   317
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   318
    AllowOldStyleAssignment := aBoolean
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   319
!
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
   320
922
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   321
allowQualifiedNames
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   322
    "return true, if #{..} qualified names are allowed"
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   323
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   324
    ^ AllowQualifiedNames
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   325
!
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   326
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   327
allowQualifiedNames:aBoolean
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   328
    "this allows turning on/off support for qualifiedNames #{ .., } as in vw3.
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   329
     If you want to fileIn vw3 or later classes, enable this with:
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   330
        Compiler allowQualifiedNames:true
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   331
     Notice, that qualified names are not really supported semantically
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   332
     (they are parsed, but treated like regular globals)
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   333
    "
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   334
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   335
    AllowQualifiedNames := aBoolean.
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   336
    self setupActions
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   337
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   338
    "
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   339
     self allowQualifiedNames:true
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   340
     self allowQualifiedNames:false
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   341
    "
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   342
!
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   343
895
0d44de8940c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 893
diff changeset
   344
allowSqueakExtensions
893
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   345
    "return true, if {..} computed arrays are allowed"
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   346
896
8d8c4bcca4b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
   347
    ^ AllowSqueakExtensions
893
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   348
!
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   349
895
0d44de8940c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 893
diff changeset
   350
allowSqueakExtensions:aBoolean
893
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   351
    "this allows turning on/off support for computed arrays { .., } as in squeak.
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   352
     If you want to fileIn Squeak classes, enable this with:
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   353
        Compiler allowSqueakComputedArrays:true"
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   354
896
8d8c4bcca4b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
   355
    AllowSqueakExtensions := aBoolean.
893
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   356
    self setupActions
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   357
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   358
    "
895
0d44de8940c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 893
diff changeset
   359
     self allowSqueakExtensions:true
0d44de8940c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 893
diff changeset
   360
     self allowSqueakExtensions:false
893
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   361
    "
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   362
!
9fcb0294a51e changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   363
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   364
allowUnderscoreInIdentifier
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   365
    "return true, if underscores are allowed in identifiers"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   366
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   367
    ^ AllowUnderscoreInIdentifier
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   368
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   369
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   370
allowUnderscoreInIdentifier:aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   371
    "this allows turning on/off underscores in identifiers.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   372
     If turned off (the default), underscores are not allowed in identifiers,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   373
     but instead scanned as assignment character (old ST/80 syntax).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   374
     If turned on, underscores are in identifiers are allowed, while extra
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   375
     underscores are still scanned as assignment.
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   376
     If you have to fileIn old VW-Vsn2.x classes, 
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   377
     turn them off with:
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   378
        Compiler allowUnderscoreInIdentifiers:false"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   379
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   380
    AllowUnderscoreInIdentifier := aBoolean.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   381
    self setupActions
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   382
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   383
    "Modified: 7.9.1997 / 01:35:19 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   384
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   385
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   386
warnCommonMistakes
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   387
    "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
   388
1001
1fcb7ffcdd3a checkin from browser
ca
parents: 996
diff changeset
   389
    ^ Warnings and:[WarnCommonMistakes]
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   390
!
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   391
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   392
warnCommonMistakes:aBoolean
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   393
    "this allows turning on/off warnings about common beginners mistakes.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   394
     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
   395
     run time errors later.
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   396
     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
   397
     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
   398
     a line as:
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   399
	Compiler warnCommonMistakes:false
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   400
     in your 'private.rc' file"
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   401
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   402
    WarnCommonMistakes := aBoolean
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   403
!
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   404
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   405
warnDollarInIdentifier
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   406
    "return true, if $-characters in identifiers are to be warned about"
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   407
1001
1fcb7ffcdd3a checkin from browser
ca
parents: 996
diff changeset
   408
    ^ Warnings and:[WarnDollarInIdentifier]
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   409
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   410
    "Created: 7.9.1997 / 01:36:17 / cg"
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   411
!
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   412
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   413
warnDollarInIdentifier:aBoolean
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   414
    "this allows turning on/off warnings about $-characters in identifiers.
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   415
     You may find those warnings useful, to make certain that your code
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   416
     is portable to other smalltalk versions, which do not allow this
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   417
     (i.e. VW releases 2.x and maybe others).
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   418
     Notice, that dollars are NEVER allowed as the first character in an identifier.
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   419
     If you get bored by those warnings, turn them off by adding
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   420
     a line as:
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   421
        Compiler warnDollarInIdentifier:false
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   422
     in your 'private.rc' file"
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   423
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   424
    WarnDollarInIdentifier := aBoolean
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   425
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   426
    "Created: 7.9.1997 / 01:37:42 / cg"
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   427
    "Modified: 7.9.1997 / 01:40:02 / cg"
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   428
!
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   429
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   430
warnOldStyleAssignment
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   431
    "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
   432
1001
1fcb7ffcdd3a checkin from browser
ca
parents: 996
diff changeset
   433
    ^ Warnings and:[WarnOldStyleAssignment]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   434
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   435
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   436
warnOldStyleAssignment:aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   437
    "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
   438
     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
   439
     a line as:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   440
	Compiler warnOldStyleAssignment:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   441
     in your 'private.rc' file"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   442
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   443
    WarnOldStyleAssignment := aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   444
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   445
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   446
warnPossibleIncompatibilities
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   447
    "return true, if possible incompatibilities (with other ST systems)
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   448
     are to be warned about"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   449
1001
1fcb7ffcdd3a checkin from browser
ca
parents: 996
diff changeset
   450
    ^ Warnings and:[WarnPossibleIncompatibilities]
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   451
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   452
    "Modified: 23.5.1997 / 12:02:02 / cg"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   453
!
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   454
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   455
warnPossibleIncompatibilities:aBoolean
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   456
    "this turns warnings about possible incompatibilities (with other ST systems)
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   457
     on or off.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   458
     If you get bored by those warnings, turn them off by adding
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   459
     a line as:
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   460
        Compiler warnPossibleIncompatibilities:false
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   461
     in your 'private.rc' file."
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   462
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   463
    WarnPossibleIncompatibilities := aBoolean
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   464
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   465
    "Created: 23.5.1997 / 12:02:45 / cg"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   466
!
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   467
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   468
warnSTXSpecials
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   469
    "return true, if ST/X specials are to be warned about"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   470
1001
1fcb7ffcdd3a checkin from browser
ca
parents: 996
diff changeset
   471
    ^ Warnings and:[WarnSTXSpecials]
141
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   474
warnSTXSpecials:aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   475
    "this allows turning on/off warnings about stx specials.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   476
     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
   477
     a line as:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   478
	Compiler warnSTXSpecials:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   479
     in your 'private.rc' file"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   480
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   481
    WarnSTXSpecials := aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   482
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   483
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   484
warnUnderscoreInIdentifier
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   485
    "return true, if underscores in identifiers are to be warned about"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   486
1001
1fcb7ffcdd3a checkin from browser
ca
parents: 996
diff changeset
   487
    ^ Warnings and:[WarnUnderscoreInIdentifier]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   488
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   489
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   490
warnUnderscoreInIdentifier:aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   491
    "this allows turning on/off warnings about underscores in identifiers.
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   492
     You may find those warnings useful, to make certain that your code
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   493
     is portable to other smalltalk versions, which do not allow this
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   494
     (i.e. VW releases 2.x).
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   495
     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
   496
     a line as:
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   497
        Compiler warnUnderscoreInIdentifier:false
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   498
     in your 'private.rc' file"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   499
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   500
    WarnUnderscoreInIdentifier := aBoolean
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   501
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   502
    "Modified: 7.9.1997 / 01:37:13 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   503
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   504
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   505
warnings
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   506
    "return true, if any warnings are to be shown"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   507
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   508
    ^ Warnings
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   509
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   510
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   511
warnings:aBoolean
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   512
    "this allows turning on/off all warnings; the default is on.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   513
     You can turn off warnings in your 'private.rc' file with
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   514
         Compiler warnings:false
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   515
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   516
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   517
    Warnings := aBoolean
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   518
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   519
    "Modified: 23.5.1997 / 12:03:05 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   520
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   521
737
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   522
!Scanner class methodsFor:'utility scanning'!
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   523
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   524
scanNumberFrom:aStream
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   525
    "utility - helper for Number>>readSmalltalkSyntaxFrom:"
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   526
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   527
    ^ self basicNew scanNumberFrom:aStream
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   528
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   529
    "
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   530
     |s|
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   531
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   532
     s := '12345abcd' readStream.
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   533
     Transcript showCR:(self scanNumberFrom:s).
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   534
     Transcript showCR:(s upToEnd).
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   535
    "
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   536
    "
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   537
     |s|
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   538
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   539
     s := '16rffffxabcd' readStream.
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   540
     Transcript showCR:(self scanNumberFrom:s).
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   541
     Transcript showCR:(s upToEnd).
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   542
    "
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   543
    "
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   544
     |s|
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   545
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   546
     s := '1.2345abcd' readStream.
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   547
     Transcript showCR:(self scanNumberFrom:s).
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   548
     Transcript showCR:(s upToEnd).
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   549
    "
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   550
    "
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   551
     |s|
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   552
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   553
     s := '1.abcd' readStream.
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   554
     Transcript showCR:(self scanNumberFrom:s).
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   555
     Transcript showCR:(s upToEnd).
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   556
    "
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   557
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   558
    "Modified: / 18.6.1998 / 23:10:39 / cg"
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   559
! !
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
   560
1020
7f52741f59dc category renamining
Claus Gittinger <cg@exept.de>
parents: 1004
diff changeset
   561
!Scanner methodsFor:'Compatibility - ST80'!
98
claus
parents: 97
diff changeset
   562
claus
parents: 97
diff changeset
   563
endOfLastToken
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   564
    "return the position of the token which was just read.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   565
     This method was required by some PD program.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   566
     It is not maintained and may be removed without notice."
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   567
98
claus
parents: 97
diff changeset
   568
    ^ source position
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   569
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   570
    "Modified: 23.5.1997 / 12:14:27 / cg"
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   571
!
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   572
630
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   573
scan:aStringOrStream 
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   574
    "initialize the scanner: set the source-stream and
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   575
     preread the first token"
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   576
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   577
    self initializeFor:aStringOrStream.
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   578
    self nextToken
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   579
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   580
    "Created: / 30.10.1997 / 16:59:39 / cg"
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   581
!
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   582
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   583
scanToken
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   584
    "read the next token from my input stream"
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   585
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   586
    ^ self nextToken
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   587
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   588
    "Created: / 30.10.1997 / 17:00:16 / cg"
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   589
!
f2f75975b22e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   590
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   591
scanTokens:aStringOrStream
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   592
    "return a collection of symbolic tokens from the passed input"
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   593
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   594
    |tokens|
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   595
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   596
    self initializeFor:aStringOrStream.
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   597
    tokens := OrderedCollection new.
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   598
    self nextToken.
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   599
    [token notNil] whileTrue:[
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   600
        tokens add:token.
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   601
        self nextToken
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   602
    ].
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   603
    ^ tokens
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   604
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   605
    "
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   606
     Scanner new
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   607
        scanTokens:'Boolean subclass:#True
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   608
                                instanceVariableNames:''''
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   609
                                classVariableNames:''''
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   610
                                poolDictionaries:''''
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   611
                                category:''Kernel-Objects''
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   612
        '
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   613
    "
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   614
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   615
    "Modified: 20.6.1997 / 18:22:58 / cg"
98
claus
parents: 97
diff changeset
   616
! !
claus
parents: 97
diff changeset
   617
254
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   618
!Scanner methodsFor:'accessing'!
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   619
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   620
comments
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   621
    "not yet implemented"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   622
254
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   623
    ^ currentComments
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   624
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   625
    "Created: 20.4.1996 / 20:07:01 / cg"
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   626
    "Modified: 23.5.1997 / 12:14:45 / cg"
254
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   627
!
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   628
1202
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   629
inArrayLiteral:aBoolean
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   630
    inArrayLiteral := aBoolean
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   631
!
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   632
859
0e5dd0e35301 access to lineNumber added
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   633
lineNumber
0e5dd0e35301 access to lineNumber added
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   634
    ^ lineNr
0e5dd0e35301 access to lineNumber added
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   635
!
0e5dd0e35301 access to lineNumber added
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   636
795
d2c567b79091 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 793
diff changeset
   637
newSourceStream:aStream
d2c567b79091 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 793
diff changeset
   638
    source := aStream.
d2c567b79091 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 793
diff changeset
   639
    self nextToken.
d2c567b79091 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 793
diff changeset
   640
d2c567b79091 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 793
diff changeset
   641
    "Created: / 29.10.1998 / 21:59:33 / cg"
d2c567b79091 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 793
diff changeset
   642
!
d2c567b79091 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 793
diff changeset
   643
254
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   644
saveComments:aBoolean
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   645
    "not yet implemented"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   646
254
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   647
    saveComments := aBoolean
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   648
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   649
    "Created: 20.4.1996 / 20:03:56 / cg"
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   650
    "Modified: 23.5.1997 / 12:14:49 / cg"
254
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   651
!
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   652
1242
52bc5f333553 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1241
diff changeset
   653
sourcePosition
52bc5f333553 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1241
diff changeset
   654
    ^ source position
52bc5f333553 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1241
diff changeset
   655
52bc5f333553 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1241
diff changeset
   656
!
52bc5f333553 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1241
diff changeset
   657
254
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   658
sourceStream
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   659
    ^ source
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   660
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   661
    "Created: 20.4.1996 / 19:59:58 / cg"
1235
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   662
!
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   663
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   664
tokenLineNr
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   665
    ^ tokenLineNr
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   666
!
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   667
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   668
tokenName
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   669
    ^ tokenName
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   670
!
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   671
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   672
tokenPosition
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   673
    ^ tokenPosition
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   674
!
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   675
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   676
tokenType
fc0ccb509f4e accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   677
    ^ tokenType
1238
dbdc690e7170 token access
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   678
!
dbdc690e7170 token access
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   679
dbdc690e7170 token access
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   680
tokenValue
dbdc690e7170 token access
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   681
    ^ tokenValue
dbdc690e7170 token access
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   682
dbdc690e7170 token access
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
   683
    "Created: / 21.12.2001 / 22:38:08 / cg"
254
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   684
! !
edfcf93d821f changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents: 241
diff changeset
   685
81
37ebe600119c *** empty log message ***
claus
parents: 80
diff changeset
   686
!Scanner methodsFor:'directives'!
37ebe600119c *** empty log message ***
claus
parents: 80
diff changeset
   687
74
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   688
parseDirective
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   689
    "parse a directive - this is an ST/X special"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   690
81
37ebe600119c *** empty log message ***
claus
parents: 80
diff changeset
   691
    |directive packageName namespace list|
74
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   692
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   693
    source next.
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   694
    source skipSeparatorsExceptCR.
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   695
    hereChar := source peekOrNil.
74
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   696
    hereChar isLetter ifTrue:[
1247
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   697
        directive := source nextWord asLowercase.
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   698
        source peekOrNil == $: ifTrue:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   699
            source next.
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   700
            source skipSeparatorsExceptCR.
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   701
            hereChar := source peekOrNil.
74
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   702
1247
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   703
            "
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   704
             package: 'name-of-package'
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   705
             package: packageId
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   706
            "
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   707
            directive = 'package' ifTrue:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   708
                packageName := self parseDirectiveStringArg.
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   709
                packageName notNil ifTrue:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   710
                    packageName := packageName asSymbol.
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   711
                    (requestor notNil 
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   712
                    and:[requestor respondsTo:#setPackage:]) ifTrue:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   713
                        requestor setPackage:packageName
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   714
                    ] ifFalse:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   715
                        self setPackage:packageName
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   716
                    ].
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   717
                ] ifFalse:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   718
                    Transcript showCR:'unrecognized ''package'' directive'.
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   719
                    ^ false
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   720
                ]
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   721
            ].
74
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   722
1247
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   723
            "
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   724
             Namespace: 'nameSpaceIdentifier'
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   725
             Namespace: nameSpaceIdentifier
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   726
            "
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   727
            (directive = 'namespace') ifTrue:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   728
                namespace := self parseDirectiveStringArg.
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   729
                namespace notNil ifTrue:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   730
                    (requestor notNil
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   731
                    and:[requestor respondsTo:#setNameSpace:]) ifTrue:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   732
                        requestor setNameSpace:namespace 
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   733
                    ] ifFalse:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   734
                        self setNameSpace:namespace
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   735
                    ].
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   736
                ] ifFalse:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   737
                    Transcript showCR:'unrecognized ''namespace'' directive'.
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   738
                    ^ false
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   739
                ].
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   740
            ].
81
37ebe600119c *** empty log message ***
claus
parents: 80
diff changeset
   741
1247
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   742
            "
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   743
             Uses: 'nameSpace1', ... , 'nameSpaceN'
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   744
             Uses: nameSpaceId1, ... , nameSpaceIdN
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   745
            "
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   746
            directive = 'uses' ifTrue:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   747
                list := self parseDirectiveStringListArg.
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   748
                list notNil ifTrue:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   749
                    (requestor notNil
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   750
                    and:[requestor respondsTo:#addNameSpaces:]) ifTrue:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   751
                        requestor addNameSpaces:list 
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   752
                    ]
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   753
                ] ifFalse:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   754
                    Transcript showCR:'unrecognized ''uses'' directive'.
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   755
                    ^ false
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   756
                ]
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   757
            ].
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   758
1247
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   759
            "
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   760
             Prerequisites: 'name-of-package', ... , 'name-of-package'
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   761
            "
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   762
            directive = 'prerequisites' ifTrue:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   763
                list := self parseDirectiveStringListArg.
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   764
                list notNil ifTrue:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   765
                    (requestor notNil
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   766
                    and:[requestor respondsTo:#requirePackages:]) ifTrue:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   767
                        requestor requirePackages:list 
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   768
                    ].
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   769
                ] ifFalse:[
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   770
                    Transcript showCR:'unrecognized ''prerequisites'' directive'.
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   771
                    ^ false
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   772
                ]
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   773
            ].
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   774
        ]
74
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
   775
    ].
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   776
    hereChar := source peekOrNil.
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   777
    ^ true.
413
cdd4919c2e7f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   778
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   779
    "Modified: / 5.3.1998 / 02:55:32 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   780
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   781
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   782
parseDirectiveStringArg
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   783
    "helper for parsing a directive"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   784
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   785
    hereChar == $' ifTrue:[
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   786
        self nextString.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   787
        tokenType == #String ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   788
            ^ tokenValue
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   789
        ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   790
    ].
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   791
    (hereChar isLetter or:[hereChar == $_]) ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   792
        self nextIdentifier.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   793
        tokenType == #Identifier ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   794
            ^ tokenName
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   795
        ]
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   796
    ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   797
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   798
    ^ nil
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   799
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   800
    "Modified: 23.5.1997 / 12:15:46 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   801
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   802
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   803
parseDirectiveStringListArg
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   804
    "helper for parsing a directive"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   805
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   806
    |list|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   807
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   808
    list := OrderedCollection new.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   809
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   810
    [hereChar == $'] whileTrue:[
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   811
        list addLast:self parseDirectiveStringArg.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   812
        source skipSeparatorsExceptCR.
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   813
        hereChar := source peekOrNil.
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   814
        (hereChar == $,) ifTrue:[
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   815
            source next.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   816
            source skipSeparatorsExceptCR.
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   817
            hereChar := source peekOrNil.
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   818
        ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   819
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   820
    ^ list
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   821
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   822
    "Modified: / 5.3.1998 / 02:55:40 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   823
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   824
659
2bbc270156c7 support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   825
!Scanner methodsFor:'dummy - syntax highlighting'!
2bbc270156c7 support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   826
2bbc270156c7 support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   827
markCommentFrom:pos1 to:pos2
2bbc270156c7 support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   828
2bbc270156c7 support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   829
    "Created: / 31.3.1998 / 13:34:45 / cg"
661
ffb42bda9e5a more syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   830
!
ffb42bda9e5a more syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   831
671
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   832
markConstantFrom:pos1 to:pos2
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   833
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   834
    "Created: / 1.4.1998 / 13:02:56 / cg"
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   835
!
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   836
661
ffb42bda9e5a more syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   837
markStringFrom:pos1 to:pos2
ffb42bda9e5a more syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   838
ffb42bda9e5a more syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   839
    "Created: / 31.3.1998 / 16:37:18 / cg"
671
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   840
!
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   841
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   842
markSymbolFrom:pos1 to:pos2
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   843
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   844
    "Created: / 1.4.1998 / 12:58:42 / cg"
659
2bbc270156c7 support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   845
! !
2bbc270156c7 support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   846
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   847
!Scanner methodsFor:'error handling'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   848
709
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   849
correctableError:message position:pos1 to:pos2
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   850
    "report an error which can be corrected by compiler -
874
7872cc72b96e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   851
     return non-false, if correction is wanted (there is more than
7872cc72b96e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   852
     true/false returned here)"
709
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   853
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   854
    |correctIt|
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   855
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   856
    requestor isNil ifTrue:[
828
436585929a76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   857
"/        self showErrorMessage:message position:pos1.
436585929a76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   858
        correctIt := false
709
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   859
    ] ifFalse:[
828
436585929a76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   860
        correctIt := requestor correctableError:message position:pos1 to:pos2 from:self
709
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   861
    ].
873
e2b462569e7d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 859
diff changeset
   862
    correctIt == false ifTrue:[
828
436585929a76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   863
        exitBlock notNil ifTrue:[exitBlock value]
709
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   864
    ].
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   865
    ^ correctIt
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   866
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   867
    "Created: / 13.5.1998 / 16:45:56 / cg"
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   868
!
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   869
1023
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   870
correctableSelectorWarning:message position:pos1 to:pos2
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   871
    "report a warning which can be corrected by compiler -
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   872
     return non-false, if correction is wanted (there is more than
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   873
     true/false returned here)"
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   874
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   875
    |correctIt|
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   876
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   877
    requestor isNil ifTrue:[
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   878
        correctIt := false
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   879
    ] ifFalse:[
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   880
        correctIt := requestor correctableSelectorWarning:message position:pos1 to:pos2 from:self
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   881
    ].
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   882
    correctIt == false ifTrue:[
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   883
        exitBlock notNil ifTrue:[exitBlock value]
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   884
    ].
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   885
    ^ correctIt
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   886
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   887
    "Created: / 19.1.2000 / 16:28:03 / cg"
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   888
!
6d16edd3b99c correctable selectors.
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   889
1073
d6041f6d680c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   890
errorMessagePrefix
d6041f6d680c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   891
    ^ 'Error:'
d6041f6d680c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   892
!
d6041f6d680c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   893
431
058e1ce760ea added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   894
lastTokenLineNumber
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   895
    "return the line number of the token which was just read."
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   896
431
058e1ce760ea added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   897
    ^ tokenLineNr
058e1ce760ea added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   898
058e1ce760ea added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   899
    "Created: 8.11.1996 / 18:46:36 / cg"
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
   900
    "Modified: 23.5.1997 / 12:16:12 / cg"
431
058e1ce760ea added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   901
!
058e1ce760ea added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   902
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   903
notifyError:aMessage position:position to:endPos
7ad01559b262 Initial revision
claus
parents:
diff changeset
   904
    "notify requestor of an error - if there is no requestor
53
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   905
     put it on the transcript. Requestor is typically the CodeView
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   906
     in which the accept/doIt was triggered, or the PositionableStream
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   907
     which does the fileIn. The requestor may decide how to highlight the
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   908
     error (and/or to abort the compile).
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   909
     Return the result passed back by the requestor."
7ad01559b262 Initial revision
claus
parents:
diff changeset
   910
53
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   911
    ignoreErrors ifFalse:[
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   912
	requestor isNil ifTrue:[
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   913
	    self showErrorMessage:aMessage position:position.
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   914
	    ^ false
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   915
	].
83
claus
parents: 81
diff changeset
   916
	^ requestor error:aMessage position:position to:endPos from:self 
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   917
    ].
53
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   918
    ^ false
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   919
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   920
7ad01559b262 Initial revision
claus
parents:
diff changeset
   921
notifyWarning:aMessage position:position to:endPos
7ad01559b262 Initial revision
claus
parents:
diff changeset
   922
    "notify requestor of an warning - if there is no requestor
7ad01559b262 Initial revision
claus
parents:
diff changeset
   923
     put it on the transcript.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   924
     Return the result passed back by the requestor."
7ad01559b262 Initial revision
claus
parents:
diff changeset
   925
53
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   926
    ignoreWarnings ifFalse:[
828
436585929a76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   927
        requestor isNil ifTrue:[
436585929a76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   928
"/            self showErrorMessage:aMessage position:position.
436585929a76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   929
            ^ false
436585929a76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   930
        ].
436585929a76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   931
        ^ requestor warning:aMessage position:position to:endPos from:self
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   932
    ].
53
c5dd7abf8431 *** empty log message ***
claus
parents: 49
diff changeset
   933
    ^ false
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   934
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   935
709
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   936
parseError:aMessage
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   937
    "report an error"
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   938
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   939
    ^ self parseError:aMessage position:tokenPosition to:nil
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   940
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   941
    "Created: / 13.5.1998 / 16:45:13 / cg"
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   942
!
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   943
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   944
parseError:aMessage position:position
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   945
    "report an error"
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   946
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   947
    ^ self parseError:aMessage position:position to:nil
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   948
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   949
    "Created: / 13.5.1998 / 16:45:05 / cg"
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   950
!
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   951
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   952
parseError:aMessage position:position to:endPos
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   953
    "report an error"
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   954
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   955
    |m|
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   956
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   957
    errorFlag := true.
1073
d6041f6d680c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   958
    m := (self errorMessagePrefix) , ' ' , (aMessage ? '???').
709
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   959
    self notifyError:m position:position to:endPos.
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   960
    exitBlock notNil ifTrue:[exitBlock value].
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   961
    ^ false
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   962
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   963
    "Created: / 13.5.1998 / 16:44:55 / cg"
783
611d7b234115 care for nil error message (can happen when lastError is nil
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   964
    "Modified: / 28.9.1998 / 19:29:27 / cg"
709
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   965
!
b4351947a598 moved error methods up
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   966
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   967
showErrorMessage:aMessage position:pos
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   968
    "show an errormessage on the Transcript"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   969
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   970
    ignoreErrors ifFalse:[
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   971
	Smalltalk silentLoading == true ifFalse:[
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   972
	    Transcript showCR:(pos printString , ' [line: ' , tokenLineNr printString , '] ' , aMessage)
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   973
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   974
    ]
274
8e120bd82c69 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 266
diff changeset
   975
8e120bd82c69 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 266
diff changeset
   976
    "Modified: 18.5.1996 / 15:44:35 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   977
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   978
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   979
syntaxError:aMessage
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   980
    "a syntax error happened - position is not known"
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
    ^ self syntaxError:aMessage position:tokenPosition
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   983
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   984
7ad01559b262 Initial revision
claus
parents:
diff changeset
   985
syntaxError:aMessage position:position
7ad01559b262 Initial revision
claus
parents:
diff changeset
   986
    "a syntax error happened - only start position is known"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   987
7ad01559b262 Initial revision
claus
parents:
diff changeset
   988
    ^ self syntaxError:aMessage position:position to:nil
7ad01559b262 Initial revision
claus
parents:
diff changeset
   989
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   990
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   991
syntaxError:aMessage position:position to:endPos
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   992
    "a syntax error happened"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   993
1073
d6041f6d680c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   994
    self notifyError:((self errorMessagePrefix) , ' ' , aMessage) position:position to:endPos.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   995
    exitBlock notNil ifTrue:[exitBlock value].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   996
    ^ false
87
claus
parents: 83
diff changeset
   997
!
claus
parents: 83
diff changeset
   998
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   999
warnCommonMistake:msg at:position
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1000
    "warn about a common beginners mistake"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1001
311
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1002
    self warnCommonMistake:msg position:position to:position
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1003
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1004
    "Modified: 23.5.1997 / 12:16:34 / cg"
311
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1005
!
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1006
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1007
warnCommonMistake:msg position:pos1 to:pos2
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1008
    "warn about a common beginners mistake"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1009
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1010
    ignoreWarnings ifFalse:[
311
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1011
        warnCommonMistakes ifTrue:[
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1012
            self 
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1013
                warning:msg
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1014
                position:pos1 to:pos2.
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1015
        ]
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1016
    ]
311
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1017
1fcbd4311698 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1018
    "Created: 18.7.1996 / 10:28:38 / cg"
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1019
    "Modified: 23.5.1997 / 12:16:39 / cg"
310
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1020
!
27ed956b591e beginners common error warnings
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1021
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1022
warnDollarAt:position
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1023
    "warn about $-character in an identifier"
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1024
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1025
    ignoreWarnings ifFalse:[
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1026
        warnDollarInIdentifier ifTrue:[
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1027
            self 
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1028
                warning:'$-characters in identifiers/symbols are nonportable' 
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1029
                position:position to:position.
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1030
            "
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1031
             only warn once (per method)
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1032
            "
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1033
            warnDollarInIdentifier := false
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1034
        ]
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1035
    ]
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1036
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1037
    "Created: 7.9.1997 / 01:50:24 / cg"
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1038
    "Modified: 7.9.1997 / 01:51:13 / cg"
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1039
!
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1040
87
claus
parents: 83
diff changeset
  1041
warnOldStyleAssignmentAt:position
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1042
    "warn about an oldStyle assignment"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1043
87
claus
parents: 83
diff changeset
  1044
    ignoreWarnings ifFalse:[
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1045
        warnOldStyleAssignment ifTrue:[
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1046
            self 
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1047
                warning:'old style assignment - please change to use '':='''
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1048
                position:position to:position.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1049
            "
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1050
             only warn once (per method)
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1051
            "
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1052
            warnOldStyleAssignment := false
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1053
        ]
87
claus
parents: 83
diff changeset
  1054
    ]
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1055
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1056
    "Modified: 23.5.1997 / 12:16:48 / cg"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1057
!
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1058
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1059
warnPossibleIncompatibility:msg position:pos1 to:pos2
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1060
    "warn about a possible incompatibility with other ST systems"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1061
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1062
    ignoreWarnings ifFalse:[
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1063
        warnPossibleIncompatibilities ifTrue:[
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1064
            self 
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1065
                warning:('Possible incompatibility.\\' , msg) withCRs
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1066
                position:pos1 to:pos2.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1067
        ]
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1068
    ]
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1069
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1070
    "Created: 23.5.1997 / 12:17:54 / cg"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1071
    "Modified: 23.5.1997 / 12:22:37 / cg"
87
claus
parents: 83
diff changeset
  1072
!
claus
parents: 83
diff changeset
  1073
claus
parents: 83
diff changeset
  1074
warnUnderscoreAt:position
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1075
    "warn about an underscore in an identifier"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1076
87
claus
parents: 83
diff changeset
  1077
    ignoreWarnings ifFalse:[
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1078
        warnUnderscoreInIdentifier ifTrue:[
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1079
            self 
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1080
                warning:'underscores in identifiers/symbols are nonportable' 
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1081
                position:position to:position.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1082
            "
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1083
             only warn once (per method)
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1084
            "
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1085
            warnUnderscoreInIdentifier := false
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1086
        ]
87
claus
parents: 83
diff changeset
  1087
    ]
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1088
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1089
    "Modified: 23.5.1997 / 12:17:06 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1090
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1091
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1092
warning:aMessage
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1093
    "a warning - position is not known"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1094
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1095
    ^ self warning:aMessage position:tokenPosition
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1098
warning:aMessage position:position
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1099
    "a warning - only start position is known"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1100
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1101
    ^ self warning:aMessage position:position to:nil
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
warning:aMessage position:position to:endPos
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1105
    "a warning"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1106
1073
d6041f6d680c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
  1107
    ^ self notifyWarning:((self warningMessagePrefix) , ' ' , aMessage) position:position to:endPos
d6041f6d680c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
  1108
!
d6041f6d680c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
  1109
d6041f6d680c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
  1110
warningMessagePrefix
d6041f6d680c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
  1111
    ^ 'Warning:'
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1112
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1113
17
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1114
!Scanner methodsFor:'general scanning'!
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1115
737
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1116
scanNumberFrom:aStringOrStream
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1117
    "scan aSourceString for the next number in smalltalk syntax
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1118
     Return the number or nil."
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1119
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1120
    |oldPos|
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1121
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1122
    self initializeFor:aStringOrStream.
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1123
    oldPos := source position.
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1124
    self nextToken.
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1125
    (tokenType == #Integer or:[tokenType == #Float]) ifTrue:[
996
53dbf13d1aa0 keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents: 983
diff changeset
  1126
        "/ must keep stream positioned correctly
53dbf13d1aa0 keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents: 983
diff changeset
  1127
        "/ (undo lookahead)
53dbf13d1aa0 keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents: 983
diff changeset
  1128
        peekChar notNil ifTrue:[
53dbf13d1aa0 keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents: 983
diff changeset
  1129
            peekChar2 notNil ifTrue:[
53dbf13d1aa0 keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents: 983
diff changeset
  1130
                source skip:-1
53dbf13d1aa0 keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents: 983
diff changeset
  1131
            ].
53dbf13d1aa0 keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents: 983
diff changeset
  1132
            source skip:-1
53dbf13d1aa0 keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents: 983
diff changeset
  1133
        ].
737
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1134
        ^ tokenValue
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1135
    ].
996
53dbf13d1aa0 keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents: 983
diff changeset
  1136
    "/ backup in case of error; return nil
737
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1137
    source position:oldPos.
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1138
    ^ nil.
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1139
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1140
    "Created: / 18.6.1998 / 23:05:22 / cg"
996
53dbf13d1aa0 keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents: 983
diff changeset
  1141
    "Modified: / 19.11.1999 / 18:25:52 / cg"
737
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1142
!
4062aa740959 support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1143
17
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1144
scanPositionsFor:aTokenString inString:aSourceString
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1145
    "scan aSourceString for occurrances of aTokenString.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1146
     Return a collection of start positions.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1147
     Added for VW compatibility (to support syntax-highlight)."
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1148
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1149
    |searchType searchName searchValue positions t|
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1150
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1151
    "
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1152
     first, look what kind of token we have to search for
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1153
    "
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1154
    self initializeFor:(ReadStream on:aTokenString).
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1155
    self nextToken.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1156
    searchType := tokenType.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1157
    searchName := tokenName.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1158
    searchValue := tokenValue.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1159
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1160
    "
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1161
     start the real work ...
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1162
    "
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1163
    self initializeFor:(ReadStream on:aSourceString).
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1164
    positions := OrderedCollection new.
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1165
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1166
    [(t := self nextToken) ~~ #EOF] whileTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1167
	searchType == t ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1168
	    (searchName isNil or:[tokenName = searchName]) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1169
		(searchValue isNil or:[tokenValue = searchValue]) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1170
		    positions add:tokenPosition.
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1171
		]
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1172
	    ]
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1173
	]
17
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1174
    ].
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1175
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1176
    ^ positions
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1177
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1178
    "
30
26e2f849916a keep tokenRadix; accept E in floats
claus
parents: 20
diff changeset
  1179
     Scanner new scanPositionsFor:'hello' inString:'foo bar hello baz hello' 
26e2f849916a keep tokenRadix; accept E in floats
claus
parents: 20
diff changeset
  1180
     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
  1181
     Scanner new scanPositionsFor:'16' inString:'foo 16 bar hello 16r10 baz hello 2r10000' 
17
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1182
    "
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1183
! !
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
  1184
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1185
!Scanner methodsFor:'initialization'!
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1186
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1187
initialize
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1188
    "initialize the scanner"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1189
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1190
    errorFlag := false.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1191
    tokenPosition := 1.
610
0aa21dd74161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1192
    tokenLineNr := lineNr := 1.
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1193
    currentComments := nil.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1194
    saveComments := false.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1195
    ignoreErrors := false.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1196
    ignoreWarnings := Warnings not.
708
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1197
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1198
    warnSTXSpecialComment := WarnSTXSpecials.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1199
    warnSTXNameSpaceUse := WarnSTXSpecials.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1200
    warnUnderscoreInIdentifier := WarnUnderscoreInIdentifier.
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1201
    warnDollarInIdentifier := WarnDollarInIdentifier.
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1202
    warnOldStyleAssignment := WarnOldStyleAssignment.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1203
    warnCommonMistakes := WarnCommonMistakes.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1204
    warnPossibleIncompatibilities := WarnPossibleIncompatibilities.
708
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1205
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1206
    allowUnderscoreInIdentifier := AllowUnderscoreInIdentifier.
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1207
    allowDollarInIdentifier := AllowDollarInIdentifier.
1261
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
  1208
    allowOldStyleAssignment := AllowOldStyleAssignment.
900
2914b42fa972 comment
Claus Gittinger <cg@exept.de>
parents: 896
diff changeset
  1209
2914b42fa972 comment
Claus Gittinger <cg@exept.de>
parents: 896
diff changeset
  1210
    "/ not used here, but eases subclassing for other languages.
2914b42fa972 comment
Claus Gittinger <cg@exept.de>
parents: 896
diff changeset
  1211
    scanColonAsKeyword := true. 
708
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1212
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1213
    ActionArray isNil ifTrue:[
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1214
        self class setupActions
708
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1215
    ].
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1216
    actionArray := ActionArray.
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1217
    typeArray := TypeArray.
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1218
785
14d0ec37a754 added hook for subclasses which do not want to scan
Claus Gittinger <cg@exept.de>
parents: 783
diff changeset
  1219
    "Modified: / 17.10.1998 / 15:48:06 / cg"
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1220
!
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1221
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1222
initializeFor:aStringOrStream
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1223
    "initialize the new scanner & prepare for reading from aStringOrStream"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1224
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1225
    self initialize.
847
7decf59c15ba added #source:
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1226
    self source:aStringOrStream.
7decf59c15ba added #source:
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1227
!
7decf59c15ba added #source:
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1228
1242
52bc5f333553 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1241
diff changeset
  1229
setSource:newSource
52bc5f333553 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1241
diff changeset
  1230
    source := newSource
52bc5f333553 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1241
diff changeset
  1231
52bc5f333553 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1241
diff changeset
  1232
!
52bc5f333553 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1241
diff changeset
  1233
847
7decf59c15ba added #source:
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1234
source:aStringOrStream
7decf59c15ba added #source:
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1235
    "prepare for reading from aStringOrStream"
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1236
854
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
  1237
    errorFlag := false.
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
  1238
    tokenPosition := 1.
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
  1239
    tokenLineNr := lineNr := 1.
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
  1240
    currentComments := nil.
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
  1241
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1242
    aStringOrStream isStream ifFalse:[
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1243
        source := ReadStream on:aStringOrStream
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1244
    ] ifTrue:[
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1245
        source := aStringOrStream.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1246
    ].
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1247
854
4ccfe0a30d08 initialize scanner on #new
Stefan Vogel <sv@exept.de>
parents: 847
diff changeset
  1248
    "Modified: / 26.5.1999 / 12:02:16 / stefan"
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1249
! !
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1250
1237
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1251
!Scanner methodsFor:'parser interface'!
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1252
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1253
errorFlag:flagArg
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1254
    errorFlag := flagArg
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1255
!
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1256
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1257
token
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1258
    ^ token
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1259
!
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1260
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1261
tokenLineNr:lineNumberArg
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1262
    tokenLineNr := lineNumberArg
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1263
!
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1264
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1265
tokenPosition:positionArg
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1266
    tokenPosition := positionArg
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1267
! !
4c8cd98c5778 more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
  1268
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1269
!Scanner methodsFor:'private'!
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
  1270
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1271
backupPosition
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1272
    "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
  1273
     one token too many"
20
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
  1274
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1275
    (tokenType == #EOF) ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1276
	source position:tokenPosition
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1277
    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1278
!
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
  1279
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1280
beginComment
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1281
    ^ self
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1282
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1283
707
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1284
checkForKeyword:string
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1285
    "check if string is a keyword (as opposed to an identifier).
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1286
     That is, its one of 'self', 'super', 'nil', 'true', 'false',
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1287
     or 'thisContext'.
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1288
     'here' is handled elsewhere (since it must be treated as an
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1289
     identifier, if declared locally."
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1290
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1291
    |firstChar|
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1292
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1293
    firstChar := string at:1.
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1294
    (firstChar == $s) ifTrue:[
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1295
        (string = 'self')  ifTrue:[tokenType := #Self. ^true].
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1296
        (string = 'super') ifTrue:[tokenType := #Super. ^true]
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1297
    ].
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1298
    (firstChar == $n) ifTrue:[
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1299
        (string = 'nil') ifTrue:[tokenType := #Nil. ^true]
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1300
    ].
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1301
    (firstChar == $t) ifTrue:[
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1302
        (string = 'true') ifTrue:[tokenType := #True. ^true].
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1303
        (string = 'thisContext') ifTrue:[tokenType := #ThisContext. ^true]
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1304
    ].
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1305
    (firstChar == $f) ifTrue:[
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1306
        (string = 'false') ifTrue:[tokenType := #False. ^true]
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1307
    ].
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1308
    ^ false
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1309
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1310
    "Modified: / 13.5.1998 / 14:59:55 / cg"
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1311
!
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1312
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1313
collectedSource
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1314
    ^ collectedSource
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1315
!
74
fee7c3091f71 *** empty log message ***
claus
parents: 71
diff changeset
  1316
1236
f613f961fd99 eatPeekChar moved
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1317
eatPeekChar
f613f961fd99 eatPeekChar moved
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1318
    peekChar isNil ifTrue:[
f613f961fd99 eatPeekChar moved
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1319
        source next.
f613f961fd99 eatPeekChar moved
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1320
    ] ifFalse:[
f613f961fd99 eatPeekChar moved
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1321
        peekChar := nil.
f613f961fd99 eatPeekChar moved
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1322
    ].
f613f961fd99 eatPeekChar moved
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1323
f613f961fd99 eatPeekChar moved
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1324
    "Created: / 24.10.1998 / 17:25:39 / cg"
f613f961fd99 eatPeekChar moved
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1325
!
f613f961fd99 eatPeekChar moved
Claus Gittinger <cg@exept.de>
parents: 1235
diff changeset
  1326
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1327
endComment:comment
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1328
    saveComments ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1329
	currentComments isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1330
	    currentComments := OrderedCollection with:comment
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1331
	] ifFalse:[
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1332
	    currentComments add:comment
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  1333
	]
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
  1334
    ].
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
  1335
!
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
  1336
648
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1337
endComment:commentString type:commentType
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1338
    |comment|
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1339
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1340
    saveComments ifTrue:[
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1341
        comment := Comment new.
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1342
        comment commentString:commentString; commentType:commentType.
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1343
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1344
        currentComments isNil ifTrue:[
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1345
            currentComments := OrderedCollection with:comment
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1346
        ] ifFalse:[
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1347
            currentComments add:comment
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1348
        ]
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1349
    ].
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1350
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1351
    "Created: / 17.2.1998 / 14:48:49 / cg"
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1352
!
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1353
1321
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1354
escapeCharacterFor:aCharacter
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1355
    "only if AllowExtendedSTXSyntax is true 
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1356
     For now: do not use, since stc does not support it.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1357
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1358
     much like character escapes in C-literals;
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1359
     expands:
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1360
        `n      newLine
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1361
        `r      return
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1362
        `t      tab
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1363
        `b      backspace
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1364
        `f      formfeed
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1365
        `g      bell
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1366
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1367
        ``      backTick
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1368
        ` ...`  ignored
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1369
        `xNN    hexCharacter
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1370
        `xNN    hexCharacter
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1371
    "
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1372
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1373
    |ascii nextChar|
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1374
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1375
    aCharacter == $n ifTrue:[^ Character nl].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1376
    aCharacter == $r ifTrue:[^ Character return].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1377
    aCharacter == $t ifTrue:[^ Character tab].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1378
    aCharacter == $b ifTrue:[^ Character backspace].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1379
    aCharacter == $f ifTrue:[^ Character ff].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1380
    aCharacter == $g ifTrue:[^ Character bell].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1381
    aCharacter == $` ifTrue:[^ aCharacter].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1382
    aCharacter isSeparator ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1383
        nextChar := source next.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1384
        [nextChar notNil and:[nextChar ~~ $`]] whileTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1385
            (nextChar == Character cr) ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1386
                lineNr := lineNr + 1
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1387
            ].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1388
            nextChar := source next.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1389
        ].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1390
        ^ nil
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1391
    ].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1392
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1393
    aCharacter == $x ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1394
        ascii := 0.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1395
        nextChar := source next.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1396
        (nextChar notNil and:[nextChar isDigitRadix:16]) ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1397
            ascii := nextChar digitValue.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1398
            nextChar := source next.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1399
            (nextChar notNil and:[nextChar isDigitRadix:16]) ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1400
                ascii := (ascii bitShift:4) bitOr:nextChar digitValue.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1401
            ]
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1402
        ].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1403
        ^ Character value:ascii.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1404
    ].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1405
    aCharacter == $0 ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1406
        ascii := 0.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1407
        nextChar := source next.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1408
        (nextChar notNil and:[nextChar isDigitRadix:8]) ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1409
            ascii := nextChar digitValue.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1410
            nextChar := source next.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1411
            (nextChar notNil and:[nextChar isDigitRadix:8]) ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1412
                ascii := (ascii bitShift:3) bitOr:nextChar digitValue.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1413
                nextChar := source next.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1414
                (nextChar notNil and:[nextChar isDigitRadix:8]) ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1415
                    ascii := (ascii bitShift:3) bitOr:nextChar digitValue.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1416
                ]
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1417
            ]
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1418
        ].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1419
        ^ Character value:ascii.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1420
    ].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1421
    ^ aCharacter
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1422
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1423
    "
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1424
     AllowExtendedSTXSyntax := true
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1425
    "
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1426
    "
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1427
     'hello`nworld'          
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1428
     'hello`x08world'   
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1429
     'hello`
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1430
    `world'   
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1431
    "                      
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1432
!
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  1433
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1434
ignoreErrors
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1435
    "turn off notification of errors"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1436
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1437
    ignoreErrors := true
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1438
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1439
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1440
ignoreWarnings
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1441
    "turn off notification of warnings"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1442
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1443
    ignoreWarnings := true
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1444
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1445
714
09f35b01bbcf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 709
diff changeset
  1446
isCommentCharacter:ch
09f35b01bbcf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 709
diff changeset
  1447
    "return true, if ch is the comment-start character.
09f35b01bbcf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 709
diff changeset
  1448
     Brought into a separate method to allow for easier subclassing"
09f35b01bbcf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 709
diff changeset
  1449
09f35b01bbcf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 709
diff changeset
  1450
    ^ ch == $"
09f35b01bbcf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 709
diff changeset
  1451
09f35b01bbcf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 709
diff changeset
  1452
    "Created: / 14.5.1998 / 20:51:42 / cg"
09f35b01bbcf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 709
diff changeset
  1453
    "Modified: / 14.5.1998 / 20:53:01 / cg"
09f35b01bbcf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 709
diff changeset
  1454
!
09f35b01bbcf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 709
diff changeset
  1455
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1456
notifying:anObject
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1457
    "set the requestor to be notified"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1458
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1459
    requestor := anObject
426
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
  1460
!
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
  1461
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
  1462
setNameSpace:aNameSpace
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
  1463
    "/ ignored here
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
  1464
871231a532fc remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
  1465
    "Created: 8.11.1996 / 13:33:10 / cg"
1247
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
  1466
!
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
  1467
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
  1468
setPackage:aNameSpace
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
  1469
    "/ ignored here
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
  1470
ce0d19140248 care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
  1471
    "Created: 8.11.1996 / 13:33:10 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1472
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1473
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1474
!Scanner methodsFor:'reading next token'!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1475
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1476
nextCharacter
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1477
    "a $ has been read - return a character token"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1478
1240
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1479
    |nextChar t|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1480
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1481
    source next.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1482
    nextChar := source next.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1483
    nextChar notNil ifTrue:[
1240
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1484
        t := nextChar.
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1485
        tokenType := #Character.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1486
    ] ifFalse:[
1240
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1487
        t := nil.
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1488
        tokenType := #EOF
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1489
    ].
1240
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
  1490
    tokenValue := token := t.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1491
    ^ tokenType
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  1492
707
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1493
    "Modified: / 13.5.1998 / 15:09:50 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1494
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1495
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1496
nextColonOrAssign
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1497
    "colon has been read - look for = to make it an assign"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1498
120
claus
parents: 103
diff changeset
  1499
    "/ special kludge for identifier:= (without spaces inbetween)
claus
parents: 103
diff changeset
  1500
    "/ here we needed two characters lookahead after the identifier ...
claus
parents: 103
diff changeset
  1501
claus
parents: 103
diff changeset
  1502
    peekChar == $= ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1503
        source next.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1504
        peekChar := nil.
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  1505
        tokenType := token := #':='.
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1506
        ^ tokenType
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1507
    ].
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1508
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1509
    "/ special kludge for nameSpace:: (without spaces inbetween)
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1510
    "/ here we needed two characters lookahead after the identifier ...
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1511
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1512
    peekChar == $: ifTrue:[
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1513
        source next.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1514
        peekChar := nil.
1027
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1515
        tokenType := token := #'::'.
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1516
        ^ tokenType
120
claus
parents: 103
diff changeset
  1517
    ].
claus
parents: 103
diff changeset
  1518
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1519
    (source nextPeek == $=) ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1520
        source next.
1004
708e1ca35c3b dont unify := and _ tokens (otherwise, highlighter would not know
Claus Gittinger <cg@exept.de>
parents: 1002
diff changeset
  1521
        tokenType := token := #':='
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1522
    ] ifFalse:[
707
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1523
        tokenType := token := $:
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1524
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1525
    ^ tokenType
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1526
707
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1527
    "Modified: / 13.5.1998 / 15:10:04 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1528
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1529
1298
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1530
nextExcla
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1531
    "a !! has been read - return either
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1532
        the !! binarySelector, 
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1533
        ExclaLeftParen     (for '!!('),
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1534
        ExclaLeftBrack     (for '!!['), 
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1535
        ExclaLeftBrace     (for '!!{')
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1536
    "
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1537
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1538
    |nextChar|
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1539
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1540
    nextChar := source nextPeek.
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1541
    AllowExtendedSTXSyntax == true ifTrue:[
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1542
        (nextChar == $( ) ifTrue:[
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1543
            source next.
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1544
            token := '!!('.
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1545
            tokenType := #ExclaLeftParen.
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1546
            ^ tokenType
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1547
        ].
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1548
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1549
        (nextChar == $[ ) ifTrue:[
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1550
            source next.
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1551
            token := '!!['.
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1552
            tokenType := #ExclaLeftBrack.
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1553
            ^ tokenType
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1554
        ].
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1555
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1556
        (nextChar == ${ ) ifTrue:[
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1557
            source next.
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1558
            token := '!!{'.
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1559
            tokenType := #ExclaLeftBrace.
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1560
            ^ tokenType
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1561
        ].
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1562
    ].
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1563
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1564
    "this allows excla to be used as binop -
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1565
     I dont know, if this is correct ..."
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1566
1307
a91664d148ad also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
  1567
"/    tokenName := token := '!!'.
a91664d148ad also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
  1568
"/    tokenType := #BinaryOperator.
a91664d148ad also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
  1569
"/    ^ tokenType
a91664d148ad also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
  1570
a91664d148ad also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
  1571
    ^ self nextSpecialWith:$!!.
1298
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1572
!
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1573
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1574
nextHash
1226
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1575
    "a # has been read - return either
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1576
        a symbol, 
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1577
        HashLeftParen     (for '#('),
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1578
        HashLeftBrack     (for '#['), 
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1579
        HashLeftBrace     (for '#{'  and AllowQualifiedNames)
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1580
        HashHashLeftParen (for '##(' and AllowDolphinExtensions)
1292
380fa6f65268 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1291
diff changeset
  1581
        HashHashLeftBrack (for '##[' )
380fa6f65268 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1291
diff changeset
  1582
        HashHash          (for '##' )
1226
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1583
    "
1026
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1584
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1585
    |nextChar string part|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1586
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1587
    nextChar := source nextPeek.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1588
    nextChar notNil ifTrue:[
1279
df137a4fe0a7 #<digit> is no longer allowed as symbol
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  1589
        (nextChar isLetter
708
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1590
        or:[(allowUnderscoreInIdentifier == true) and:[nextChar == $_]]) ifTrue:[
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1591
            string := ''.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1592
            [nextChar notNil 
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1593
             and:[nextChar isLetterOrDigit 
1191
47011122e30e correctly scan #_ (i.e. a symbol consisting of a single underscore)
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  1594
                  or:[allowUnderscoreInIdentifier == true and:[nextChar == $_]]
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1595
                 ]
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1596
            ] whileTrue:[
1191
47011122e30e correctly scan #_ (i.e. a symbol consisting of a single underscore)
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  1597
                nextChar == $_ ifTrue:[
47011122e30e correctly scan #_ (i.e. a symbol consisting of a single underscore)
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  1598
                    part := nil.
47011122e30e correctly scan #_ (i.e. a symbol consisting of a single underscore)
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  1599
                ] ifFalse:[
47011122e30e correctly scan #_ (i.e. a symbol consisting of a single underscore)
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  1600
                    part := source nextAlphaNumericWord.
47011122e30e correctly scan #_ (i.e. a symbol consisting of a single underscore)
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
  1601
                ].
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1602
                part notNil ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1603
                    string := string , part.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1604
                ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1605
                nextChar := source peek.
708
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1606
                allowUnderscoreInIdentifier == true ifTrue:[
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1607
                    nextChar == $_ ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1608
                        self warnUnderscoreAt:source position.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1609
                    ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1610
                    [nextChar == $_] whileTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1611
                        string := string copyWith:nextChar.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1612
                        nextChar := source nextPeek.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1613
                        (nextChar isAlphaNumeric) ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1614
                            string := string , source nextAlphaNumericWord.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1615
                            nextChar := source peek.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1616
                        ]
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1617
                    ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1618
                ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1619
                (nextChar == $:) ifFalse:[
671
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  1620
                    self markSymbolFrom:tokenPosition to:(source position-1).
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  1621
                    tokenValue := token := string asSymbol.
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1622
                    tokenType := #Symbol.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1623
                    ^ tokenType
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1624
                ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1625
                string := string copyWith:nextChar.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1626
                nextChar := source nextPeek
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1627
            ].
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  1628
            tokenValue := token := string asSymbol.
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1629
            tokenType := #Symbol.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1630
            ^ tokenType
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1631
        ].
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1632
        (nextChar == $( ) ifTrue:[
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1633
            source next.
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  1634
            token := '#('.
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1635
            tokenType := #HashLeftParen.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1636
            ^ tokenType
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1637
        ].
922
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
  1638
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1639
        (nextChar == $[ ) ifTrue:[
922
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
  1640
            "ST-80 & ST/X support Constant ByteArrays as #[...]"
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1641
            source next.
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  1642
            token := '#['.
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1643
            tokenType := #HashLeftBrack.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1644
            ^ tokenType
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1645
        ].
922
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
  1646
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
  1647
        (nextChar == ${ ) ifTrue:[
1290
ec07b4b3740e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
  1648
            " #{ ... } is one of:
ec07b4b3740e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
  1649
                #{ Foo.Bar.Baz }            VW3 and later qualified name
ec07b4b3740e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
  1650
                #{ xx-xx-xx-xx-...-xx }     StAgents UUID
ec07b4b3740e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
  1651
                #{ URL }                    url object qualifier
1074
5539425b66f2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1652
            "
1290
ec07b4b3740e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
  1653
            source next.
ec07b4b3740e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
  1654
            token := '#{'.
ec07b4b3740e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
  1655
            tokenType := #HashLeftBrace.
ec07b4b3740e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
  1656
            ^ tokenType
ec07b4b3740e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
  1657
        ].
ec07b4b3740e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
  1658
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1659
        (nextChar == $' ) ifTrue:[
922
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
  1660
            "ST-80 and ST/X support arbitrary symbols as #'...'"
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1661
            self nextString.
671
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  1662
            self markSymbolFrom:tokenPosition to:(source position-1).
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  1663
            tokenValue := token := tokenValue asSymbol.
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1664
            tokenType := #Symbol.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1665
            ^ tokenType
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1666
        ].
922
77c58cc5bebc support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
  1667
1226
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1668
        (nextChar == $#) ifTrue:[
1294
31c8cc483db9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1669
            nextChar := source nextPeek.
1293
c33753e28dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
  1670
            AllowDolphinExtensions == true ifTrue:[
1226
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1671
                "dolphin does computed literals as ##( ... )"
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1672
                nextChar == $( ifTrue:[
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1673
                    source next.    
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1674
                    token := '##('.
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1675
                    tokenType := #HashHashLeftParen.
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1676
                    ^ tokenType
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1677
                ].
1293
c33753e28dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
  1678
            ].
c33753e28dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
  1679
            nextChar == $[ ifTrue:[
c33753e28dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
  1680
                source next.    
c33753e28dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
  1681
                token := '##('.
c33753e28dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
  1682
                tokenType := #HashHashLeftBrack.
1291
917f975e3e7e oops - HashLeftAngle was wrong.
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1683
                ^ tokenType
917f975e3e7e oops - HashLeftAngle was wrong.
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1684
            ].
1294
31c8cc483db9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1685
1293
c33753e28dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
  1686
            token := '##'.
c33753e28dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
  1687
            tokenType := #HashHash.
c33753e28dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
  1688
            ^ tokenType
1226
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1689
        ].
c0c9fcf964fb dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1690
708
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1691
        ((typeArray at:(nextChar asciiValue)) == #special) ifTrue:[
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1692
            string := source next asString.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1693
            nextChar := source peek.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1694
            nextChar notNil ifTrue:[
708
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1695
                ((typeArray at:(nextChar asciiValue)) == #special) ifTrue:[
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1696
                    source next.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1697
                    string := string copyWith:nextChar
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1698
                ]
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1699
            ].
671
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  1700
            self markSymbolFrom:tokenPosition to:(source position-1).
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  1701
            tokenValue := token := string asSymbol.
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1702
            tokenType := #Symbol.
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1703
            ^ tokenType
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1704
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1705
    ].
1298
878c759441d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1706
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1707
    "this allows hash to be used as binop -
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1708
     I dont know, if this is correct ..."
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  1709
    tokenName := token := '#'.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1710
    tokenType := #BinaryOperator.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1711
    ^ tokenType
500
d0679fcc520e handle #foo_:_:_: symbols
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1712
671
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  1713
    "Modified: / 1.4.1998 / 13:02:45 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1714
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1715
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1716
nextId
1026
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1717
    "no longer used here - remains for backwardCompatibility for
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1718
     subclass users ... (sigh)"
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1719
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1720
    |nextChar string oldString 
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1721
     index "{ Class: SmallInteger }"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1722
     max   "{ Class: SmallInteger }" |
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1723
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1724
    nextChar := source peekOrNil.
96
claus
parents: 91
diff changeset
  1725
    string := String basicNew:20.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1726
    index := 0.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1727
    max := 10.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1728
    [true] whileTrue:[
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1729
        (nextChar notNil and:[nextChar isLetterOrDigit]) ifFalse:[
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1730
            ^ string copyTo:index
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1731
        ].
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1732
        (index == max) ifTrue:[
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1733
            oldString := string.
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1734
            string := String basicNew:(max * 2).
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1735
            string replaceFrom:1 to:max with:oldString.
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1736
            max := max * 2
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1737
        ].
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1738
        index := index + 1.
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1739
        string at:index put:nextChar.
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1740
        nextChar := source nextPeek
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1741
    ]
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1742
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1743
    "Modified: / 5.3.1998 / 02:53:57 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1744
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1745
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1746
nextIdentifier
1026
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1747
    "an alpha character (or underscor if AllowUnderscore) has been read.
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1748
     Return the next identifier."
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1749
1027
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1750
    |nextChar string ok pos ch2|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1751
87
claus
parents: 83
diff changeset
  1752
    hereChar == $_ ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1753
        "/
708
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1754
        "/ no need to check for allowUnderscoreInIdentifier here;
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1755
        "/ could not arrive here if it was off
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1756
        "/
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1757
        nextChar := source nextPeek.
1261
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
  1758
        allowOldStyleAssignment ifTrue:[
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
  1759
            (nextChar isAlphaNumeric or:[nextChar == $_]) ifFalse:[
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
  1760
                "oops: a single underscore is an old-style assignement"
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
  1761
                nextChar ~~ $: ifTrue:[
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
  1762
                    self warnOldStyleAssignmentAt:tokenPosition.
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
  1763
                    source next.
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
  1764
                    tokenType := token := $_.
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
  1765
                    ^ tokenType
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
  1766
                ]
3de89ad9de69 allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents: 1247
diff changeset
  1767
            ].
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1768
        ].
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1769
        string := '_'.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1770
        self warnUnderscoreAt:tokenPosition.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1771
        [nextChar == $_] whileTrue:[
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1772
            string := string copyWith:$_.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1773
            nextChar := source nextPeek.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1774
        ].
467
feaacb47b0b5 allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
  1775
        nextChar isAlphaNumeric ifTrue:[
feaacb47b0b5 allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
  1776
            string := string , source nextAlphaNumericWord.
feaacb47b0b5 allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
  1777
        ]
87
claus
parents: 83
diff changeset
  1778
    ] ifFalse:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1779
        string := source nextAlphaNumericWord "self nextId".
87
claus
parents: 83
diff changeset
  1780
    ].
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1781
    nextChar := source peekOrNil.
87
claus
parents: 83
diff changeset
  1782
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1783
    (nextChar == $_ 
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1784
    or:[nextChar == $$]) ifTrue:[
708
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  1785
        ok := (nextChar == $_) ifTrue:[allowUnderscoreInIdentifier] ifFalse:[allowDollarInIdentifier].
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1786
        ok ifTrue:[
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1787
            pos := source position.
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1788
            nextChar == $_ ifTrue:[
610
0aa21dd74161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1789
                self warnUnderscoreAt:pos.
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1790
            ] ifFalse:[
610
0aa21dd74161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1791
                self warnDollarAt:pos.
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1792
            ].
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1793
            [ok] whileTrue:[
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1794
                string := string copyWith:nextChar.
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1795
                nextChar := source nextPeek.
802
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1796
                nextChar isNil ifTrue:[
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1797
                    ok := false
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1798
                ] ifFalse:[
802
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1799
                    (nextChar isAlphaNumeric) ifTrue:[
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1800
                        string := string , source nextAlphaNumericWord.
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1801
                        nextChar := source peekOrNil.
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1802
                    ].
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1803
                    (nextChar == $_) ifTrue:[
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1804
                        ok := allowUnderscoreInIdentifier
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1805
                    ] ifFalse:[
802
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1806
                        (nextChar == $$) ifTrue:[
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1807
                            ok := allowDollarInIdentifier
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1808
                        ] ifFalse:[
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1809
                            ok := false
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1810
                        ]
608
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1811
                    ]
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1812
                ]
faa97ce2db56 allow dollars in identifiers
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1813
            ].
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1814
        ].
60
0db697f03def *** empty log message ***
claus
parents: 53
diff changeset
  1815
    ].
0db697f03def *** empty log message ***
claus
parents: 53
diff changeset
  1816
785
14d0ec37a754 added hook for subclasses which do not want to scan
Claus Gittinger <cg@exept.de>
parents: 783
diff changeset
  1817
    (nextChar == $: and:[scanColonAsKeyword]) ifTrue:[
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1818
        source next.
1027
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1819
        ch2 := source peekOrNil.
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1820
        "/ colon follows - care for '::' (nameSpace separator) or ':=' (assignment)
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1821
        (ch2 == $=) ifFalse:[
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1822
            (ch2 == $:) ifFalse:[
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  1823
                tokenName := token := string copyWith:nextChar.
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1824
                tokenType := #Keyword.
1202
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1825
                inArrayLiteral == true ifTrue:[
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1826
                    (ch2 isLetter 
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1827
                    or:[ch2 == $_ and:[allowUnderscoreInIdentifier]]) ifTrue:[
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1828
                        "/ kludge: recurse to read the rest.
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1829
                        self nextIdentifier.
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1830
                        tokenName := token := (string copyWith:nextChar) , token.   
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1831
                        tokenType ~~ #Keyword ifTrue:[
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1832
                            self syntaxError:'invalid keyword symbol in array constant'
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1833
                                    position:tokenPosition to:(source position - 1).
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1834
                        ].
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1835
                        tokenType := #Keyword.
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1836
                    ].
95abdd4272cd scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1837
                ].
1104
0ffcaab55dbc oops - nextIdentifier must return a tokenType
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1838
                ^ tokenType
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1839
            ].
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1840
            peekChar := $:.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1841
            peekChar2 := $:.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1842
        ] ifTrue:[
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1843
            peekChar := $:.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1844
            peekChar2 := $=.
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1845
        ]
1027
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1846
    ] ifFalse:[
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1847
        (nextChar == $. and:[AllowQualifiedNames]) ifTrue:[
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1848
            "/ period follows - if next-after character is an identifier character,
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1849
            "/ make peekSym a #NameSpaceSeparator; otherwise a $.
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1850
            source next.
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1851
            ch2 := source peekOrNil.
1029
aeaed53633d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
  1852
            (ch2 notNil
aeaed53633d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
  1853
            and:[ch2 isLetter or:[ch2 == $_ and:[AllowUnderscoreInIdentifier]]]) ifTrue:[
1027
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1854
                peekChar := #'::'.
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1855
            ] ifFalse:[
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1856
                peekChar := $.
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1857
            ].
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  1858
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1859
    ].
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1860
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1861
    nextChar == $- ifTrue:[
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1862
        pos := source position.
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1863
        self
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1864
            warnPossibleIncompatibility:'add a space before ''-'' for compatibility with other systems'
610
0aa21dd74161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1865
            position:pos to:pos.
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1866
    ].
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1867
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  1868
    tokenName := token := string.
1026
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1869
    (self checkForKeyword:string) ifFalse:[
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1870
        tokenType := #Identifier.
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1871
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1872
    ^ tokenType
120
claus
parents: 103
diff changeset
  1873
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1874
    "Created: / 13.9.1995 / 12:56:42 / claus"
802
5c6e7db91d5f bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
  1875
    "Modified: / 2.2.1999 / 22:29:57 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1876
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1877
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1878
nextMantissa:radix
1026
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1879
    "read the mantissa of a radix number"
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1880
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1881
    |nextChar value factor|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1882
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1883
    value := 0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1884
    factor := 1.0 / radix.
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1885
    nextChar := source peekOrNil.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1886
    [(nextChar notNil and:[nextChar isDigitRadix:radix])] whileTrue:[
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1887
        value := value + (nextChar digitValue * factor).
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1888
        factor := factor / radix.
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1889
        nextChar := source nextPeek
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1890
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1891
    ^ value
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1892
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1893
    "Modified: / 5.3.1998 / 02:54:11 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1894
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1895
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1896
nextNumber
1026
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1897
    "scan a number; handles radix prefix, mantissa and exponent.
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1898
     Does not yet handle fixNums. Allows for e, d or q to be used as exponent
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1899
     limiter."
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1900
441
fa5637faa969 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 431
diff changeset
  1901
    |nextChar value s tokenRadix|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1902
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1903
    tokenRadix := 10.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1904
    value := Integer readFrom:source radix:tokenRadix.
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1905
    nextChar := source peekOrNil.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1906
    (nextChar == $r) ifTrue:[
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1907
        tokenRadix := value.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1908
        source next.
820
5db3668f751d syntax error if radix is not in 2..36
Claus Gittinger <cg@exept.de>
parents: 802
diff changeset
  1909
5db3668f751d syntax error if radix is not in 2..36
Claus Gittinger <cg@exept.de>
parents: 802
diff changeset
  1910
        (tokenRadix between:2 and:36) ifFalse:[
5db3668f751d syntax error if radix is not in 2..36
Claus Gittinger <cg@exept.de>
parents: 802
diff changeset
  1911
            self syntaxError:'bad radix (must be 2 .. 36)'
5db3668f751d syntax error if radix is not in 2..36
Claus Gittinger <cg@exept.de>
parents: 802
diff changeset
  1912
                    position:tokenPosition to:(source position - 1).
5db3668f751d syntax error if radix is not in 2..36
Claus Gittinger <cg@exept.de>
parents: 802
diff changeset
  1913
        ].
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1914
        s := 1.
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1915
        source peekOrNil == $- ifTrue:[
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1916
            source next.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1917
            s := -1
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1918
        ].
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1919
        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
  1920
        value := value * s.
982
f0cc45f113b3 exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1921
        nextChar := source peekOrNil.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1922
    ].
821
bc543afcc1e6 give a warning if radix>14 and an e/E is encountered in a float
Claus Gittinger <cg@exept.de>
parents: 820
diff changeset
  1923
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1924
    (nextChar == $.) ifTrue:[
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1925
        nextChar := source nextPeek.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1926
        (nextChar notNil and:[nextChar isDigitRadix:tokenRadix]) ifTrue:[
821
bc543afcc1e6 give a warning if radix>14 and an e/E is encountered in a float
Claus Gittinger <cg@exept.de>
parents: 820
diff changeset
  1927
            (tokenRadix > 14 and:[nextChar == $e or:[nextChar == $E]]) ifTrue:[
bc543afcc1e6 give a warning if radix>14 and an e/E is encountered in a float
Claus Gittinger <cg@exept.de>
parents: 820
diff changeset
  1928
                self warning:'float with radix > 14 - (e/E are valid digits; not exponent-leaders)'
bc543afcc1e6 give a warning if radix>14 and an e/E is encountered in a float
Claus Gittinger <cg@exept.de>
parents: 820
diff changeset
  1929
                    position:tokenPosition to:(source position - 1).
bc543afcc1e6 give a warning if radix>14 and an e/E is encountered in a float
Claus Gittinger <cg@exept.de>
parents: 820
diff changeset
  1930
            ].
bc543afcc1e6 give a warning if radix>14 and an e/E is encountered in a float
Claus Gittinger <cg@exept.de>
parents: 820
diff changeset
  1931
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1932
            value := value asFloat + (self nextMantissa:tokenRadix).
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  1933
            nextChar := source peekOrNil
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1934
        ] ifFalse:[
610
0aa21dd74161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1935
"/            nextChar == (Character cr) ifTrue:[
0aa21dd74161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1936
"/                lineNr := lineNr + 1.
0aa21dd74161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1937
"/            ].
499
e7052694178d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
  1938
            nextChar := peekChar := $..
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1939
        ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1940
    ].
821
bc543afcc1e6 give a warning if radix>14 and an e/E is encountered in a float
Claus Gittinger <cg@exept.de>
parents: 820
diff changeset
  1941
1026
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1942
    ('eEdDqQ' includes:nextChar) ifTrue:[
1195
a3015ee52730 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1194
diff changeset
  1943
        value := value asFloat.
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1944
        nextChar := source nextPeek.
982
f0cc45f113b3 exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1945
        (nextChar notNil and:[(nextChar isDigit"Radix:tokenRadix") or:['+-' includes:nextChar]]) ifTrue:[
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1946
            s := 1.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1947
            (nextChar == $+) ifTrue:[
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1948
                nextChar := source nextPeek
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1949
            ] ifFalse:[
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1950
                (nextChar == $-) ifTrue:[
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1951
                    nextChar := source nextPeek.
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1952
                    s := s negated
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1953
                ]
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1954
            ].
982
f0cc45f113b3 exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1955
            tokenRadix == 10 ifTrue:[
f0cc45f113b3 exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1956
                "/ for backward compatibility, generate a float with base 10
f0cc45f113b3 exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1957
                value := value asFloat
f0cc45f113b3 exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1958
                         * (10 raisedToInteger:((Integer readFrom:source) * s)).
f0cc45f113b3 exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1959
            ] ifFalse:[
f0cc45f113b3 exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1960
                value := value
f0cc45f113b3 exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1961
                         * (tokenRadix raisedToInteger:((Integer readFrom:source) * s)).
f0cc45f113b3 exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1962
            ].
983
Claus Gittinger <cg@exept.de>
parents: 982
diff changeset
  1963
            nextChar := source peek.
982
f0cc45f113b3 exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1964
        ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1965
    ].
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1966
    nextChar == $- ifTrue:[
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1967
        self
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1968
            warnPossibleIncompatibility:'add a space before ''-'' for compatibility with other systems'
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1969
            position:(source position) to:source position.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1970
    ].
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  1971
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  1972
    tokenValue := token := value.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1973
    (value isMemberOf:Float) ifTrue:[
1194
bc4172d26877 leftOver skipping of trailing 'd' removed.
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
  1974
"/        (nextChar == $d) ifTrue:[
bc4172d26877 leftOver skipping of trailing 'd' removed.
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
  1975
"/            source next
bc4172d26877 leftOver skipping of trailing 'd' removed.
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
  1976
"/        ].
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1977
        tokenType := #Float
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1978
    ] ifFalse:[
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1979
        tokenType := #Integer
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1980
    ].
671
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  1981
"/    self markConstantFrom:tokenPosition to:(source position - 1).
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1982
    ^ tokenType
313
ee72a11af9a2 handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
  1983
671
8361d4bedc9f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  1984
    "Modified: / 1.4.1998 / 13:06:28 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1985
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1986
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1987
nextPrimitive
1026
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1988
    "scan an inline C-primitive."
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  1989
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1990
    |nextChar inPrimitive string 
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1991
     index "{ Class: SmallInteger }"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1992
     len   "{ Class: SmallInteger }" |
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1993
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1994
    nextChar := source nextPeek.
1302
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  1995
    (nextChar == ${) ifFalse:[
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  1996
        ^ self nextSpecialWith:$%
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  1997
    ].
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  1998
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1999
    string := String new:500.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2000
    len := 500.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2001
    index := 1.
1302
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2002
    nextChar := source nextPeek.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2003
    inPrimitive := true.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2004
    [inPrimitive] whileTrue:[
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2005
        [nextChar == $%] whileFalse:[
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2006
            nextChar isNil ifTrue:[
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2007
                self syntaxError:'unterminated primitive'
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2008
                        position:tokenPosition to:source position.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2009
                ^ #Error
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2010
            ].
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2011
            string at:index put:nextChar.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2012
            (index == len) ifTrue:[
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2013
                string := string , (String new:len).
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2014
                len := len * 2
505
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  2015
            ].
1302
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2016
            index := index + 1.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2017
            nextChar := source next
505
793f88ee6269 handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
  2018
        ].
1302
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2019
        (source peekOrNil == $}) ifTrue:[
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2020
            inPrimitive := false
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2021
        ] ifFalse:[
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2022
            string at:index put:nextChar.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2023
            (index == len) ifTrue:[
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2024
                string := string , (String new:len).
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2025
                len := len * 2
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2026
            ].
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2027
            index := index + 1.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2028
            nextChar := source next
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2029
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2030
    ].
1302
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2031
    source next.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2032
    tokenValue := token := string copyTo:(index - 1).
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2033
    tokenType := #Primitive.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2034
    lineNr := lineNr + (tokenValue occurrencesOf:(Character cr)).
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2035
    ^ tokenType
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2036
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2037
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2038
nextSpecial
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2039
    "a special character has been read, look for another one.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2040
     also -number is handled here"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2041
1302
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2042
    |firstChar|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2043
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2044
    firstChar := source next.
1302
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2045
    ^ self nextSpecialWith:firstChar
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2046
!
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2047
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2048
nextSpecialWith:firstChar
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2049
    "a special character has been read, look for another one.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2050
     also -number is handled here"
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2051
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2052
    |secondChar thirdChar fourthChar string p|
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2053
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  2054
    secondChar := source peekOrNil.
241
418eb41350d3 no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
  2055
    ((firstChar == $-) and:[secondChar notNil]) ifTrue:[
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2056
        secondChar isDigit ifTrue:[
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2057
            self nextNumber.
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2058
            tokenValue := token := tokenValue negated.
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2059
            ^ tokenType
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2060
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2061
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2062
    string := firstChar asString.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2063
    secondChar notNil ifTrue:[
708
11837544357d made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
  2064
        ((typeArray at:(secondChar asciiValue)) == #special) ifTrue:[
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2065
            (secondChar == $-) ifTrue:[
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2066
                "special- look if minus belongs to number following"
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2067
                p := source position.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2068
                source next.
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  2069
                thirdChar := source peekOrNil.
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2070
                source position:p.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2071
                thirdChar isDigit ifTrue:[
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2072
                    tokenName := token := string.
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2073
                    tokenType := #BinaryOperator.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2074
                    self 
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2075
                        warnPossibleIncompatibility:'add a space before ''-'' for compatibility with other ST systems' 
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2076
                        position:p-1 
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2077
                        to:p.
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2078
                    ^ tokenType
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2079
                ]
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2080
            ].
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2081
            source next.
1302
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2082
            string := string copyWith:secondChar.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2083
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2084
            thirdChar := source peekOrNil.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2085
            thirdChar notNil ifTrue:[
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2086
                ((typeArray at:(thirdChar asciiValue)) == #special) ifTrue:[
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2087
                    (thirdChar == $-) ifTrue:[
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2088
                        "special- look if minus belongs to number following"
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2089
                        p := source position.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2090
                        source next.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2091
                        fourthChar := source peekOrNil.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2092
                        source position:p.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2093
                        fourthChar isDigit ifTrue:[
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2094
                            tokenName := token := string.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2095
                            tokenType := #BinaryOperator.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2096
                            self 
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2097
                                warnPossibleIncompatibility:'add a space before ''-'' for compatibility with other ST systems' 
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2098
                                position:p-1 
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2099
                                to:p.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2100
                            ^ tokenType
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2101
                        ]
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2102
                    ].
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2103
                    source next.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2104
                    string := string copyWith:thirdChar.
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2105
                ].
68c857cffd5a allow 3 character binopsö
Claus Gittinger <cg@exept.de>
parents: 1298
diff changeset
  2106
            ].
526
adb8aed3a691 added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
  2107
        ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2108
    ].
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2109
    tokenName := token := string.
45
e8331ba8ad5d *** empty log message ***
claus
parents: 41
diff changeset
  2110
    tokenType := #BinaryOperator.
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
  2111
    ^ tokenType
241
418eb41350d3 no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
  2112
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  2113
    "Modified: / 5.3.1998 / 02:54:54 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2114
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2115
264
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2116
nextString
1026
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  2117
    "a single quote has been scanned; scan the string (caring for doubled quotes"
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  2118
264
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2119
    |nextChar string pos
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2120
     index "{ Class: SmallInteger }"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2121
     len   "{ Class: SmallInteger }"
1321
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2122
     inString peekChar|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2123
96
claus
parents: 91
diff changeset
  2124
    string := String basicNew:20.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2125
    len := 20.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2126
    index := 1.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2127
    pos := source position.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2128
    source next.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2129
    nextChar := source next.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2130
    inString := true.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2131
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2132
    [inString] whileTrue:[
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2133
        nextChar isNil ifTrue:[
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2134
            self syntaxError:'unexpected end-of-input in String'
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2135
                    position:pos to:(source position - 1).
661
ffb42bda9e5a more syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
  2136
            self markStringFrom:pos to:source position-1.
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2137
            token := nil.
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2138
            tokenType := #EOF.
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2139
            ^ tokenType
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2140
        ].
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2141
        (nextChar == Character cr) ifTrue:[
610
0aa21dd74161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  2142
            lineNr := lineNr + 1
1321
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2143
        ] ifFalse:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2144
            (nextChar == Character quote) ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2145
                (source peekOrNil == Character quote) ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2146
                    source next
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2147
                ] ifFalse:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2148
                    inString := false
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2149
                ]
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2150
            ] ifFalse:[
1321
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2151
                AllowExtendedSTXSyntax == true ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2152
                    (nextChar == $`) ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2153
                        peekChar := source peekOrNil.    
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2154
                        peekChar notNil ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2155
                            source next.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2156
                            nextChar := self escapeCharacterFor:peekChar.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2157
                        ]
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2158
                    ]
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2159
                ]
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2160
            ].
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2161
        ].
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2162
        inString ifTrue:[
1321
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2163
            nextChar notNil ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2164
                string at:index put:nextChar.
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2165
                (index == len) ifTrue:[
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2166
                    string := string , (String new:len).
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2167
                    len := len * 2
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2168
                ].
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2169
                index := index + 1.
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2170
            ].
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2171
            nextChar := source next
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2172
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2173
    ].
661
ffb42bda9e5a more syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
  2174
    self markStringFrom:pos to:source position-1.
ffb42bda9e5a more syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
  2175
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2176
    tokenValue := token := string copyTo:(index - 1).
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2177
    tokenType := #String.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2178
    ^ tokenType
546
db5ce842f64f added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
  2179
661
ffb42bda9e5a more syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
  2180
    "Modified: / 31.3.1998 / 17:33:14 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2181
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2182
264
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2183
nextToken
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2184
    "return the next token from the source-stream"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2185
793
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2186
    |skipping actionBlock v ch tok|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2187
793
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2188
    [true] whileTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2189
        peekChar notNil ifTrue:[
1027
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  2190
            "/ kludge - should be called peekSym.
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  2191
            "/ used when xlating Foo.Bar into Foo::Bar
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  2192
            peekChar isSymbol ifTrue:[
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  2193
                token := nil.
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  2194
                tokenType := peekChar.
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  2195
                peekChar := nil.
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  2196
                ^ tokenType
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  2197
            ].
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  2198
793
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2199
            peekChar isSeparator ifTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2200
                peekChar == (Character cr) ifTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2201
                    lineNr := lineNr + 1.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2202
                ].
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2203
                peekChar := peekChar2.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2204
                peekChar2 := nil.
603
021722b8a427 correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents: 546
diff changeset
  2205
            ].
793
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2206
        ].
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2207
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2208
        peekChar notNil ifTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2209
            ch := peekChar.
603
021722b8a427 correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents: 546
diff changeset
  2210
            peekChar := peekChar2.
021722b8a427 correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents: 546
diff changeset
  2211
            peekChar2 := nil.
793
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2212
            hereChar := nil.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2213
        ] ifFalse:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2214
            skipping := true.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2215
            [skipping] whileTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2216
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2217
                outStream notNil ifTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2218
                    hereChar := source peekOrNil.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2219
                    [(hereChar == Character space)
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2220
                     or:[hereChar isSeparator]
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2221
                    ] whileTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2222
                        source next.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2223
                        outStream space. 
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2224
                        outCol := outCol + 1.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2225
                    ]
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2226
                ] ifFalse:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2227
                    hereChar := source skipSeparatorsExceptCR.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2228
                ].
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2229
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2230
                hereChar == (Character cr) ifTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2231
                    lineNr := lineNr + 1.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2232
                    source next.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2233
                    outStream notNil ifTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2234
                        outStream cr.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2235
                        outCol := 1
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2236
                    ]
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2237
                ] ifFalse:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2238
                    hereChar == (Character return) ifTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2239
                        outStream notNil ifTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2240
                            outStream nextPut:hereChar.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2241
                            outCol := 1
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2242
                        ].
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2243
                        source next.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2244
                    ] ifFalse:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2245
                        (self isCommentCharacter:hereChar) ifTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2246
                            "start of a comment"
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2247
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2248
                            self skipComment.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2249
                            hereChar := source peekOrNil.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2250
                        ] ifFalse:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2251
                            skipping := false
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2252
                        ]
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2253
                    ]
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2254
                ]
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2255
            ].
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2256
            hereChar isNil ifTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2257
                token := nil.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2258
                tokenType := #EOF.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2259
                ^ tokenType
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2260
            ].
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2261
            ch := hereChar
603
021722b8a427 correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents: 546
diff changeset
  2262
        ].
793
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2263
        tokenPosition := source position.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2264
        tokenLineNr := lineNr.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2265
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2266
        (v := ch asciiValue) == 0 ifTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2267
            v := Character space asciiValue
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2268
        ].
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2269
        actionBlock := actionArray at:v.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2270
        actionBlock notNil ifTrue:[
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2271
            tok := actionBlock value:self value:ch.
1027
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  2272
            tok notNil ifTrue:[
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  2273
                ^ tok
c944d9be2a69 silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
  2274
            ].
793
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2275
        ] ifFalse:[
1290
ec07b4b3740e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
  2276
            self syntaxError:('Scanner - invalid character: ''' , ch asString , ''' ',
793
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2277
                              '(' , v printString , ')')
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2278
                    position:tokenPosition to:tokenPosition.
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2279
            source next.
1103
b75a71996388 ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents: 1102
diff changeset
  2280
            tokenName := token := nil.
b75a71996388 ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents: 1102
diff changeset
  2281
            tokenType := #Error.
793
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2282
            ^ #Error
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2283
        ]
603
021722b8a427 correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents: 546
diff changeset
  2284
    ].
021722b8a427 correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents: 546
diff changeset
  2285
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  2286
    "Modified: / 13.9.1995 / 12:56:14 / claus"
793
3ee3ebe0145e allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  2287
    "Modified: / 22.10.1998 / 22:15:27 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2288
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2289
264
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2290
nextToken:aCharacter
1026
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  2291
    "return a character token"
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  2292
707
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2293
    tokenType := token := aCharacter.
603
021722b8a427 correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents: 546
diff changeset
  2294
    hereChar notNil ifTrue:[source next].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2295
    ^ tokenType
603
021722b8a427 correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents: 546
diff changeset
  2296
707
2fe4b3a7708a extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2297
    "Modified: / 13.5.1998 / 15:10:23 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2298
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2299
264
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2300
skipComment
1026
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  2301
    "skip over a comment; handles ST/X eol comments."
831aa102111f comments
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
  2302
648
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2303
    |commentStream commentType startPos|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2304
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2305
    saveComments ifTrue:[
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2306
        commentStream := WriteStream on:''.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2307
        self beginComment.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2308
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2309
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2310
    outStream notNil ifTrue:[
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2311
        outStream nextPut:Character doubleQuote.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2312
        outCol := outCol + 1
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2313
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2314
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2315
    startPos := source position.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2316
    source next.
656
e4249b285fd8 using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
  2317
    hereChar := source peekOrNil.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2318
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2319
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2320
     special ST/X addition:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2321
     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
  2322
     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
  2323
     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
  2324
     (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
  2325
      change it without notice)"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2326
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2327
    hereChar == $/ ifTrue:[
648
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2328
        commentType := #eolComment.
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2329
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2330
        hereChar := source nextPeek.
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2331
        [hereChar notNil and:[hereChar ~~ Character cr]] whileTrue:[
648
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2332
            commentStream notNil ifTrue:[
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2333
                commentStream nextPut:hereChar
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2334
            ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2335
            outStream notNil ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2336
                outStream nextPut:hereChar.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2337
                outCol := outCol + 1
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2338
            ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2339
            hereChar := source nextPeek.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2340
        ].
659
2bbc270156c7 support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
  2341
        self markCommentFrom:startPos to:(source position).
610
0aa21dd74161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  2342
        lineNr := lineNr + 1.
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2343
        ignoreWarnings ifFalse:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2344
            warnSTXSpecialComment ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2345
                self warning:'end-of-line comments are a nonstandard feature of ST/X' 
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2346
                     position:startPos to:(source position).
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2347
                "
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2348
                 only warn once
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2349
                "
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2350
                warnSTXSpecialComment := false
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2351
            ]
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2352
        ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2353
        outStream notNil ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2354
            outStream cr.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2355
            outCol := 1
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2356
        ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2357
    ] ifFalse:[
648
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2358
        commentType := #regularComment.
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2359
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2360
        hereChar == ${ ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2361
            "
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2362
             special ST/X addition:
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2363
             a ${ right after the initial double quote starts a directive
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2364
            "
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2365
            self parseDirective
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2366
        ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2367
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2368
        [hereChar notNil and:[hereChar ~~ (Character doubleQuote)]] whileTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2369
            hereChar == (Character cr) ifTrue:[
610
0aa21dd74161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  2370
                lineNr := lineNr + 1.
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2371
            ].
648
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2372
            commentStream notNil ifTrue:[
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2373
                commentStream nextPut:hereChar
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2374
            ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2375
            outStream notNil ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2376
                outStream nextPut:hereChar.
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2377
                outCol := outCol + 1
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2378
            ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2379
            hereChar := source nextPeek
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2380
        ].
666
bf2af3d84787 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 661
diff changeset
  2381
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2382
        hereChar isNil ifTrue:[
666
bf2af3d84787 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 661
diff changeset
  2383
            self markCommentFrom:startPos to:(source size).
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2384
            self warning:'unclosed comment' position:startPos to:(source position)
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2385
        ] ifFalse:[
666
bf2af3d84787 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 661
diff changeset
  2386
            self markCommentFrom:startPos to:(source position).
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2387
            outStream notNil ifTrue:[
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2388
                outStream nextPut:(Character doubleQuote).
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2389
                outCol := outCol + 1
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2390
            ].
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2391
        ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2392
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2393
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2394
    "skip final dQuote or cr"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2395
    source next.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2396
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2397
    saveComments ifTrue:[
648
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2398
        self endComment:(commentStream contents) type:commentType.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2399
    ].
460
c023e3713433 handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
  2400
666
bf2af3d84787 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 661
diff changeset
  2401
    "Modified: / 31.3.1998 / 23:45:26 / cg"
648
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2402
! !
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2403
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2404
!Scanner::Comment methodsFor:'accessing'!
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2405
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2406
commentString
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2407
    "return the value of the instance variable 'commentString' (automatically generated)"
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2408
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2409
    ^ commentString
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2410
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2411
    "Created: / 17.2.1998 / 14:44:33 / cg"
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2412
!
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2413
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2414
commentString:something
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2415
    "set the value of the instance variable 'commentString' (automatically generated)"
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2416
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2417
    commentString := something.
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2418
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2419
    "Created: / 17.2.1998 / 14:44:33 / cg"
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2420
!
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2421
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2422
commentType
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2423
    "return the value of the instance variable 'commentType' (automatically generated)"
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2424
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2425
    ^ commentType
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2426
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2427
    "Created: / 17.2.1998 / 14:44:33 / cg"
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2428
!
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2429
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2430
commentType:something
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2431
    "set the value of the instance variable 'commentType' (automatically generated)"
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2432
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2433
    commentType := something.
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2434
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2435
    "Created: / 17.2.1998 / 14:44:33 / cg"
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2436
!
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2437
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2438
string
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2439
    ^ commentString
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2440
f2e96d4456ec fixed keepComments.
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2441
    "Created: / 17.2.1998 / 14:49:52 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2442
! !
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2443
359
5c3718455360 support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  2444
!Scanner class methodsFor:'documentation'!
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
  2445
264
f10298cba622 oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2446
version
1321
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2447
    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.153 2002-10-15 19:52:59 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
  2448
! !
1321
e34f7e7d28a0 preps for character escapes
Claus Gittinger <cg@exept.de>
parents: 1307
diff changeset
  2449
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2450
Scanner initialize!