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