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