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