JavaScriptScanner.st
author Claus Gittinger <cg@exept.de>
Fri, 21 Feb 2020 20:48:14 +0100
changeset 1231 b7d945ef967a
parent 1215 52483990fec6
permissions -rw-r--r--
#REFACTORING by exept class: JavaScriptParser changed: #forStatement class: JavaScriptParser class added: #forOfAllowed comment/format in: #forInAllowed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
     1
"
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
     2
 COPYRIGHT (c) 1998 by eXept Software AG
40
382a209e9150 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 30
diff changeset
     3
	      All Rights Reserved
30
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
     4
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
     5
 This software is furnished under a license and may be used
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
     6
 only in accordance with the terms of that license and with the
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
     8
 be provided or otherwise made available to, or used by, any
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
     9
 other person.  No title to or ownership of the software is
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    10
 hereby transferred.
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    11
"
47
684f35c49db2 category change
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
    12
"{ Package: 'stx:libjavascript' }"
30
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    13
856
7914119c681a class: JavaScriptScanner
Stefan Vogel <sv@exept.de>
parents: 838
diff changeset
    14
"{ NameSpace: Smalltalk }"
7914119c681a class: JavaScriptScanner
Stefan Vogel <sv@exept.de>
parents: 838
diff changeset
    15
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
Scanner subclass:#JavaScriptScanner
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    17
	instanceVariableNames:'allowDegeneratedMantissa acceptRegexString previousToken'
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    18
	classVariableNames:'Verbose SupportRegex'
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
47
684f35c49db2 category change
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
    20
	category:'Languages-JavaScript-Compiling & Parsing'
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!JavaScriptScanner class methodsFor:'documentation'!
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
30
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    25
copyright
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    26
"
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    27
 COPYRIGHT (c) 1998 by eXept Software AG
40
382a209e9150 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 30
diff changeset
    28
	      All Rights Reserved
30
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    29
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    30
 This software is furnished under a license and may be used
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    31
 only in accordance with the terms of that license and with the
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    33
 be provided or otherwise made available to, or used by, any
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    34
 other person.  No title to or ownership of the software is
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    35
 hereby transferred.
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    36
"
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    37
!
27d36560aa7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 29
diff changeset
    38
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    39
documentation
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    40
"
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    41
    tokenizer for JavaScript
1103
dfa0b860124e #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1102
diff changeset
    42
dfa0b860124e #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1102
diff changeset
    43
    news:
dfa0b860124e #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1102
diff changeset
    44
        does regex '/pattern/' vs. division operator 
dfa0b860124e #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1102
diff changeset
    45
        determination via a rule described in
dfa0b860124e #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1102
diff changeset
    46
            https://www-archive.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions
dfa0b860124e #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1102
diff changeset
    47
        if that makes problems, set the variable:
dfa0b860124e #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1102
diff changeset
    48
            SupportRegex
dfa0b860124e #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1102
diff changeset
    49
        to false, to get the previous behavior (which is: not supporting regex)
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    50
"
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    51
!
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    52
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
examples
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    54
"<<END
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    55
[exBegin]
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    |s in|
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    in := '
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
function scalefactor(value) {
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    scalevector[0]=value;
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    scalevector[1]=1.;
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    scalevector[2]=1.;
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
}
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
'.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    s := JavaScriptScanner for:in readStream.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    s nextToken  
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    68
[exEnd]
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    70
[exBegin]
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    |s in|
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    in := '
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
function scalefactor(value) {
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    scalevector[0]=value;
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    scalevector[1]=1.;
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    scalevector[2]=1.;
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
}
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
'.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    s := JavaScriptScanner new.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    s scanTokens:(in readStream).
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    82
[exEnd]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    83
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    84
[exBegin]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    85
    |s in|
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    86
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    87
    in := '
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    88
function scalefactor(value) {
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    89
    return "hello";
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    90
}
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    91
'.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    92
    s := JavaScriptScanner new.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    93
    s scanTokens:(in readStream).
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    94
[exEnd]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    95
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    96
[exBegin]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    97
    |s in|
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    98
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
    99
    in := '
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   100
function scalefactor(value) {
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   101
    return /hello/;
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   102
}
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   103
'.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   104
    in := in readStream.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   105
    s := JavaScriptScanner for:in.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   106
    [in atEnd] whileFalse:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   107
        Transcript showCR:s nextToken
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   108
    ]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   109
[exEnd]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   110
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   111
[exBegin]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   112
    |s in|
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   113
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   114
    in := '
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   115
function scalefactor(value) {
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   116
    return a /hello/;
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   117
}
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   118
'.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   119
    in := in readStream.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   120
    s := JavaScriptScanner for:in.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   121
    [in atEnd] whileFalse:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   122
        Transcript showCR:s nextToken
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   123
    ]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   124
[exEnd]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   125
END"
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    "Created: / 13.5.1998 / 14:54:06 / cg"
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
! !
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
!JavaScriptScanner class methodsFor:'initialization'!
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
setupActions
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    "initialize the scanners actionTables - these are used to dispatch
1088
6d8bc26c0629 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   134
     into scanner methods as characters are read
6d8bc26c0629 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   135
     Notice, this is only called if ActionArray is nil.
6d8bc26c0629 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   136
         ActionArray := nil
6d8bc26c0629 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   137
    "
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
1033
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   139
    |block actionArray typeArray|
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
1033
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   141
    actionArray := Array new:256.
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   142
    typeArray := Array new:256.
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    block := [:s :char | s nextNumber].
1033
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   145
    actionArray from:($0 codePoint) to:($9 codePoint) put:block.
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    block := [:s :char | s nextToken:char].
148
c371ca26e0d6 bitInvert
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
   148
    #( $: $; $. $, ${ $} $( $) $[ $] $_ $? $~) do:[:ch |
1033
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   149
        actionArray at:(ch codePoint) put:block
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    block := [:s :char | s nextIdentifier].
1033
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   153
    actionArray from:($a codePoint) to:($z codePoint) put:block.
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   154
    actionArray from:($A codePoint) to:($Z codePoint) put:block.
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   155
    actionArray at:$_ codePoint put:block.
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
1033
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   157
    actionArray at:($' codePoint) put:[:s :char | s nextString ].
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   158
    actionArray at:($" codePoint) put:[:s :char | s nextString ].
1195
4d88e4d4d051 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1185
diff changeset
   159
    actionArray at:($` codePoint) put:[:s :char | s nextString ].
1033
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   160
    actionArray at:($!! codePoint) put:[:s :char | s nextMulti:#(($= #'!!=' (($= #'!!==')))) after:char].
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   161
    actionArray at:($= codePoint) put:[:s :char | s nextMulti:#(($> #'=>') ($= #'==' (($= #'===')))) after:char].
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   162
    actionArray at:($< codePoint) put:[:s :char | s nextMulti:#(($= #'<=') ($< #'<<' (($= #'<<=')))) after:char].
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   163
    actionArray at:($> codePoint) put:[:s :char | s nextMulti:#(($= #'>=') ($> #'>>' (($> #'>>>') ($= #'>>=') ))) after:char].
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
1033
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   165
    actionArray at:($- codePoint) put:[:s :char | s nextMulti:#(($- #'--') ($= #'-=')) after:char].
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   166
    actionArray at:($+ codePoint) put:[:s :char | s nextMulti:#(($+ #'++') ($= #'+=')) after:char].
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   167
    actionArray at:($: codePoint) put:[:s :char | s nextMulti:#(($: #'::')) after:char].
1184
66e1ae9c78f1 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1152
diff changeset
   168
    actionArray at:($* codePoint) put:[:s :char | s nextMulti:#(($= #'*=') ($* #'**' (($= #'**=')))) after:char].
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   169
    actionArray at:($/ codePoint) put:[:s :char | s nextSlash].
1033
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   170
    actionArray at:($% codePoint) put:[:s :char | s nextMulti:#(($= #'%=')) after:char].
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   171
    actionArray at:($& codePoint) put:[:s :char | s nextMulti:#(($= #'&=') ($& #'&&')) after:char].
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   172
    actionArray at:($^ codePoint) put:[:s :char | s nextMulti:#(($= #'^=')) after:char].
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   173
    actionArray at:($| codePoint) put:[:s :char | s nextMulti:#(($= #'|=') ($| #'||')) after:char].
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   174
    actionArray at:($$ codePoint) put:[:s :char | s nextCharacter ].
1085
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   175
    actionArray at:($# codePoint) put:[:s :char | s nextSymbol ].
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
1033
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   177
    ActionArray := actionArray.
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   178
    TypeArray := typeArray.
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   179
    UnicodeActions := Dictionary new.
4c81fb4f1233 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   180
    
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
    "
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
     JavaScriptScanner setupActions
1184
66e1ae9c78f1 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1152
diff changeset
   183
     JavaScriptParser setupActions
66e1ae9c78f1 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1152
diff changeset
   184
     JavaScriptCompiler setupActions
66e1ae9c78f1 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1152
diff changeset
   185
     JavaScriptSyntaxHighlighter setupActions
1185
9d21fd4638d5 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   186
     self withAllSubclassesDo:#setupActions
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
    "
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
1011
f33f504317ec #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
   189
    "Created: / 14-05-1998 / 15:48:03 / cg"
f33f504317ec #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
   190
    "Modified: / 17-05-1998 / 21:03:37 / cg"
1088
6d8bc26c0629 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   191
    "Modified (comment): / 09-06-2019 / 17:04:10 / Claus Gittinger"
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
! !
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   194
!JavaScriptScanner class methodsFor:'class initialization'!
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   195
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   196
initialize
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   197
    SupportRegex := true.
1106
426c2f5bce87 #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 1105
diff changeset
   198
    "/ super initialize. -- no need for that
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   199
! !
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   200
285
4da9e473605f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 280
diff changeset
   201
!JavaScriptScanner methodsFor:'accessing'!
4da9e473605f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 280
diff changeset
   202
4da9e473605f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 280
diff changeset
   203
tokenType
4da9e473605f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 280
diff changeset
   204
    ^ tokenType
4da9e473605f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 280
diff changeset
   205
! !
4da9e473605f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 280
diff changeset
   206
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
!JavaScriptScanner methodsFor:'initialization'!
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
initialize
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    "initialize the scanner"
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    super initialize.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    "/ have my own tables ...
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
176
94f9a35ecb1b Scanner interface has changed
Stefan Vogel <sv@exept.de>
parents: 171
diff changeset
   216
    self allowUnderscoreInIdentifier:true.
94f9a35ecb1b Scanner interface has changed
Stefan Vogel <sv@exept.de>
parents: 171
diff changeset
   217
    self allowDollarInIdentifier:false.
193
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   218
    self allowOldStyleAssignment:false.
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   219
    parserFlags allowNationalCharactersInIdentifier:false.
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   220
    parserFlags allowQualifiedNames:false.
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   221
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    allowDegeneratedMantissa := true.     "/ something like 123.
27
11a73967c42b no colon-keywords.
Claus Gittinger <cg@exept.de>
parents: 21
diff changeset
   223
    scanColonAsKeyword := false.
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
298
05c20b381b34 actionArray & typeArray
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   225
    actionArray := self class actionArray.
05c20b381b34 actionArray & typeArray
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   226
    typeArray := self class typeArray.
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    "Created: / 14.5.1998 / 15:48:04 / cg"
27
11a73967c42b no colon-keywords.
Claus Gittinger <cg@exept.de>
parents: 21
diff changeset
   229
    "Modified: / 26.10.1998 / 14:50:26 / cg"
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
! !
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
!JavaScriptScanner methodsFor:'private'!
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
checkForKeyword:string
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    "check if string is a keyword (as opposed to an identifier)."
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    |firstChar|
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
    firstChar := string at:1.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
    (firstChar == $b) ifTrue:[
55
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   241
        (string = 'break') ifTrue:[tokenType := #break. ^true].
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   242
        ^ false
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    (firstChar == $c) ifTrue:[
55
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   245
        (string = 'continue') ifTrue:[tokenType := #continue. ^true].
139
8007a21b0f4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 128
diff changeset
   246
        (string = 'case') ifTrue:[tokenType := #case. ^true].
171
ab98a8121b9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   247
        (string = 'catch') ifTrue:[tokenType := #catch. ^true].
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   248
        (string = 'const') ifTrue:[
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   249
            parserFlags allowJavaScriptConst ifTrue:[
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   250
                tokenType := #const. ^true
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   251
            ].
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   252
        ].
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   253
        ^ false
139
8007a21b0f4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 128
diff changeset
   254
    ].
8007a21b0f4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 128
diff changeset
   255
    (firstChar == $d) ifTrue:[
8007a21b0f4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 128
diff changeset
   256
        (string = 'default') ifTrue:[tokenType := #default. ^true].
153
4d8da52f1822 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   257
        "/ do is not a keyword - it is also allowed as identifier
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   258
        ^ false
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
    (firstChar == $e) ifTrue:[
55
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   261
        (string = 'else') ifTrue:[tokenType := #else. ^true].
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   262
        ^ false
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
    (firstChar == $f) ifTrue:[
55
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   265
        (string = 'function') ifTrue:[tokenType := #function. ^true].
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   266
        (string = 'for') ifTrue:[tokenType := #for. ^true].
139
8007a21b0f4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 128
diff changeset
   267
"/        (string = 'foreach') ifTrue:[tokenType := #foreach. ^true].
55
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   268
        (string = 'false') ifTrue:[tokenType := #false. tokenValue := false. ^true].
199
8b512d136342 finally
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   269
        (string = 'finally') ifTrue:[tokenType := #finally. tokenValue := false. ^true].
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   270
        ^ false
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
    (firstChar == $i) ifTrue:[
55
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   273
        (string = 'if') ifTrue:[tokenType := #if. ^true].
1215
52483990fec6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
   274
        "/ import is done as Identifier - not supported by 
1214
d3a856a2ab11 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   275
        "/ (string = 'import') ifTrue:[tokenType := #import. ^true].
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   276
        ^ false
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    ].
979
a1a9d7394a96 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   278
    (firstChar == $l) ifTrue:[
980
0b100182dd54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   279
        (string = 'let') ifTrue:[tokenType := #let. ^true].
979
a1a9d7394a96 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   280
        ^ false
a1a9d7394a96 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   281
    ].
29
12c1133c2a4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 27
diff changeset
   282
    (firstChar == $n) ifTrue:[
55
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   283
        (string = 'null') ifTrue:[tokenType := #null. tokenValue := nil. ^true].
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   284
        (string = 'nil') ifTrue:[tokenType := #null. tokenValue := nil. ^true].
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   285
        ^ false
29
12c1133c2a4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 27
diff changeset
   286
    ].
12c1133c2a4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 27
diff changeset
   287
    (firstChar == $r) ifTrue:[
55
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   288
        (string = 'return') ifTrue:[tokenType := #return. ^true].
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   289
        ^ false
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    ].
139
8007a21b0f4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 128
diff changeset
   291
    (firstChar == $s) ifTrue:[
436
d95e2b8f2f31 changed: #checkForKeyword:
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   292
        "/ (string = 'static') ifTrue:[tokenType := #static. ^true]. - handled as identifier
1026
340405e32911 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1011
diff changeset
   293
        "/ (string = 'synchronized') ifTrue:[tokenType := #synchronized. ^true].
340405e32911 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1011
diff changeset
   294
        "/ (string = 'short') ifTrue:[tokenType := #short. ^true].
746
7284818eced3 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 742
diff changeset
   295
        (string = 'super') ifTrue:[tokenType := #super. ^true].
139
8007a21b0f4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 128
diff changeset
   296
        (string = 'switch') ifTrue:[tokenType := #switch. ^true].
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   297
        ^ false
139
8007a21b0f4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 128
diff changeset
   298
    ].
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
    (firstChar == $t) ifTrue:[
55
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   300
        (string = 'this') ifTrue:[tokenType := #this. ^true].
171
ab98a8121b9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   301
        (string = 'try') ifTrue:[tokenType := #try. ^true].
55
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   302
        (string = 'true') ifTrue:[tokenType := #true. tokenValue := true. ^true].
280
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   303
        (string = 'throw') ifTrue:[tokenType := #throw. ^true].
1026
340405e32911 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1011
diff changeset
   304
        "/ (string = 'transient') ifTrue:[tokenType := #transient. ^true].
340405e32911 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1011
diff changeset
   305
        "/ (string = 'throws') ifTrue:[tokenType := #throws. ^true].
442
b095800daa93 typeof fixed
Claus Gittinger <cg@exept.de>
parents: 436
diff changeset
   306
        (string = 'typeof') ifTrue:[tokenType := #typeof. ^true].
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   307
        ^ false
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
    ].
772
9e40a47b464e class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   309
    (firstChar == $u) ifTrue:[
9e40a47b464e class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   310
        (string = 'undefined') ifTrue:[tokenType := #null. tokenValue := nil. ^true].
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   311
        ^ false
772
9e40a47b464e class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   312
    ].
29
12c1133c2a4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 27
diff changeset
   313
    (firstChar == $v) ifTrue:[
55
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   314
        (string = 'var') ifTrue:[tokenType := #var. ^true].
1026
340405e32911 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1011
diff changeset
   315
        (string = 'void') ifTrue:[tokenType := #void. tokenValue := Void. ^true]. "/ - handled as identifier
340405e32911 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1011
diff changeset
   316
        "/ (string = 'volatile') ifTrue:[tokenType := #volatile. ^true].
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   317
        ^ false
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
    (firstChar == $w) ifTrue:[
55
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   320
        (string = 'with') ifTrue:[tokenType := #with. ^true].
712d980d7edd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   321
        (string = 'while') ifTrue:[tokenType := #while. ^true].
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   322
        ^ false
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    ^ false
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
442
b095800daa93 typeof fixed
Claus Gittinger <cg@exept.de>
parents: 436
diff changeset
   326
    "Created: / 14-05-1998 / 15:48:04 / cg"
932
0034ee88c711 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   327
    "Modified: / 09-08-2017 / 00:03:56 / cg"
1026
340405e32911 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1011
diff changeset
   328
    "Modified: / 31-08-2018 / 12:55:31 / Claus Gittinger"
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
!
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   331
handleCategoryDirective:categoryString
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   332
    "called when encountering a /** category: xxxx **/ comment;
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   333
     categoryString will be xxxx.
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   334
     Can be redefined in subclasses"
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   335
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   336
    "Created: / 26-10-2011 / 17:47:28 / cg"
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   337
!
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   338
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   339
handleCommentDirectivesIn:commentText
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   340
    "/ called for the text after the initial "/*"
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   341
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   342
    |plainText|
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   343
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   344
    (commentText endsWith:'**/') ifFalse:[^ self].
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   345
    (commentText startsWith:'* ') ifFalse:[^ self].
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   346
587
ec6e40cf9b82 Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 580
diff changeset
   347
    plainText := commentText copyButLast:3.
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   348
    plainText := plainText copyFrom:3.
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   349
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   350
    (plainText startsWith:'category: ') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   351
        self handleCategoryDirective:(plainText copyFrom:'category: ' size+1) withoutSeparators.
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   352
        ^ self.
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   353
    ].
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   354
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   355
    "Created: / 26-10-2011 / 17:39:35 / cg"
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   356
!
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   357
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
isCommentCharacter:ch
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
    "return true, if ch is the comment-start character"
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
    ^ false
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
    "Created: / 14.5.1998 / 20:53:33 / cg"
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   364
!
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   365
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   366
previousTokenInitiatesRegexForSlash
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   367
    "read 
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   368
        https://www-archive.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   369
     for an explanation"
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   370
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   371
    ^ (#(
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   372
        nil
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   373
        '!!' '!!=' '!!=='
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   374
        '#'   '%'   '%='   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   375
        '&'   '&&'   '&&='   '&='
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   376
        '('   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   377
        '*'   '*='   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   378
        '+'   '+='   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   379
        ','   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   380
        '-'   '-='   '->'   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   381
        '.'   '..'   '...'   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   382
        '/'   '/='   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   383
        ':'   '::'   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   384
        ';'   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   385
        '<'   '<<'   '<<='   '<='   '='   '=='   '==='
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   386
        '>'   '>='   '>>'   '>>='   '>>>'   '>>>='   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   387
        '?'   '@'   '['   '^'   '^='   '^^'   '^^='   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   388
        '{'   '|'   '|='   '||'   '||='   '~'
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   389
        'abstract'   'break'   'case'   'catch'   'const'   'continue'
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   390
        'debugger'   'default'   'delete'   'do'   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   391
        'else'   'enum'   'export'   'extends'   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   392
        'final'   'finally'   'for'   'function'   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   393
        'goto'   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   394
        'if'   'implements'  'import'   'in'   'instanceof'   'interface'   'is'   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   395
        'namespace'   'native'   'new'   'package'  
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   396
        'return'   'static'   'switch'   'synchronized'   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   397
        'throw'   'throws'   'transient'   'try'   'typeof'   
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   398
        'use'   'var'   'volatile'   'while'   'with'
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   399
    ) includes:previousToken)
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
! !
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
!JavaScriptScanner methodsFor:'reading next token'!
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   404
hex2CharacterEscape
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   405
    |x1 x2|
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   406
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   407
    x1 := source next.
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   408
    x2 := source next.
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   409
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   410
    (x1 isNil or:[x2 isNil]) ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   411
        self syntaxError:'unexpected end-of-input in String'
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   412
                position:tokenPosition to:(source position - 1).
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   413
        self markStringFrom:tokenPosition to:source position-1.
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   414
        ^ nil.
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   415
    ].
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   416
    ((x1 isDigitRadix:16) and:[(x2 isDigitRadix:16)]) ifFalse:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   417
        self syntaxError:'invalid hex-character escape'
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   418
                position:tokenPosition to:(source position - 1).
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   419
        ^ Character value:0
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   420
    ].
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   421
    ^ Character value:((x1 digitValue * 16) + (x2 digitValue))
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   422
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   423
    "Modified: / 26-10-2011 / 17:15:49 / cg"
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   424
!
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   425
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   426
hex4CharacterEscape
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   427
    |x1 x2 x3 x4|
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   428
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   429
    x1 := source next.
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   430
    x2 := source next.
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   431
    x3 := source next.
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   432
    x4 := source next.
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   433
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   434
    (x1 isNil or:[x2 isNil or:[x3 isNil or:[x4 isNil]]]) ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   435
        self syntaxError:'unexpected end-of-input in String'
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   436
                position:tokenPosition to:(source position - 1).
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   437
        self markStringFrom:tokenPosition to:source position-1.
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   438
        ^ nil.
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   439
    ].
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   440
    ((x1 isDigitRadix:16) 
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   441
    and:[(x2 isDigitRadix:16)
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   442
    and:[(x3 isDigitRadix:16)
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   443
    and:[(x4 isDigitRadix:16)]]]) ifFalse:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   444
        self syntaxError:'invalid hex-character escape'
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   445
                position:tokenPosition to:(source position - 1).
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   446
        ^ Character value:0
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   447
    ].
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   448
    ^ Character value:(((((x1 digitValue * 16) + (x2 digitValue)) * 16) + (x3 digitValue)) * 16) + (x4 digitValue).
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   449
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   450
    "Modified: / 26-10-2011 / 17:15:45 / cg"
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   451
!
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   452
193
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   453
nextCharacter
1085
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   454
    "this is a special (non-JavaScript) extension to support $'x' for character literals"
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   455
    
639
a366feb3ec37 class: JavaScriptScanner
Stefan Vogel <sv@exept.de>
parents: 587
diff changeset
   456
    |pos|
193
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   457
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   458
    pos := tokenPosition.
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   459
    source next.
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   460
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   461
    (hereChar := source peek) == $' ifTrue:[
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   462
        ^ self nextStringOrCharacter:true
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   463
    ].
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   464
1091
1eef18e145fb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1089
diff changeset
   465
    self syntaxError:'incorrect character constant (expected $''x'')'
639
a366feb3ec37 class: JavaScriptScanner
Stefan Vogel <sv@exept.de>
parents: 587
diff changeset
   466
            position:pos to:(source position).
1085
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   467
1091
1eef18e145fb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1089
diff changeset
   468
    "Modified: / 15-06-2019 / 09:56:53 / Claus Gittinger"
193
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   469
!
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   470
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
nextMulti:list after:firstChar
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
    "a char has been read - peek ahead in list"
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
    |pc|
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
    peekChar isNil ifTrue:[
147
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   477
        source next.
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
    ] ifFalse:[
147
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   479
        peekChar := nil.
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
    pc := source peek.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
    list do:[:spec |
147
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   484
        |ch tok idx chOrSelectorOrSpec|
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
147
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   486
        ch := spec at:1.
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
147
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   488
        pc == ch ifTrue:[
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   489
            tok := spec at:2.
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   490
            idx := 3.
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   491
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   492
            peekChar isNil ifTrue:[
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   493
                source next.
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   494
            ] ifFalse:[
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   495
                peekChar := nil.
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   496
            ].
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
147
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   498
            spec size > 2 ifTrue:[
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   499
                "/ continue
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   500
                chOrSelectorOrSpec := (spec at:3).
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   501
                chOrSelectorOrSpec isArray ifTrue:[
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   502
                    peekChar := source peek.
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   503
                    ^ self nextMulti:chOrSelectorOrSpec after:tok.
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   504
                ].
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   505
                source peek == chOrSelectorOrSpec ifTrue:[
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   506
                    source next.
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   507
                    tok := spec at:4.
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   508
                    idx := 5.
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   509
                ]
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   510
            ].
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
147
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   512
            tok isNil ifTrue:[
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   513
                ^ self perform:(spec at:idx).
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   514
            ].
9
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   515
147
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   516
            tokenType := token := tok.
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   517
            ^ tokenType
d781c3f05226 scanner fixes (3-char-operators)
Claus Gittinger <cg@exept.de>
parents: 144
diff changeset
   518
        ]
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
    tokenType := token := firstChar.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
    ^ tokenType
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
    "Created: / 14.5.1998 / 19:19:34 / cg"
9
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   525
    "Modified: / 16.5.1998 / 19:09:59 / cg"
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
!
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
nextNumber
121
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   529
    |nextChar value s|
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
    value := 0.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
    nextChar := source peekOrNil.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
    nextChar == $0 ifTrue:[
121
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   534
        source next.
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   535
        nextChar := source peekOrNil.
128
2cccc53bcdcb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 121
diff changeset
   536
        nextChar isNil ifTrue:[
2cccc53bcdcb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 121
diff changeset
   537
            tokenValue := token := value.
2cccc53bcdcb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 121
diff changeset
   538
            tokenType := #Integer.
2cccc53bcdcb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 121
diff changeset
   539
            ^ tokenType
2cccc53bcdcb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 121
diff changeset
   540
        ].
121
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   541
        (nextChar == $x or:[nextChar == $X]) ifTrue:[
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   542
            source next.
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   543
            value := Integer readFrom:source radix:16.
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
121
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   545
            tokenValue := token := value.
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   546
            tokenType := #Integer.
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   547
            ^ tokenType
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   548
        ].
742
590965eea525 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   549
        (nextChar == $b or:[nextChar == $b]) ifTrue:[
590965eea525 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   550
            source next.
590965eea525 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   551
            value := Integer readFrom:source radix:2.
590965eea525 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   552
590965eea525 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   553
            tokenValue := token := value.
590965eea525 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   554
            tokenType := #Integer.
590965eea525 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   555
            ^ tokenType
590965eea525 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   556
        ].
121
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   557
        (nextChar between:$0 and:$7) ifTrue:[
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   558
            value := Integer readFrom:source radix:8.
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   559
            tokenValue := token := value.
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   560
            tokenType := #Integer.
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   561
            ^ tokenType
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   562
        ].
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
    nextChar isDigit ifTrue:[
121
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   566
        value := Integer readFrom:source radix:10.
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   567
        nextChar := source peekOrNil.
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
    (nextChar == $.) ifTrue:[
121
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   571
        nextChar := source nextPeek.
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   572
        (nextChar notNil and:[nextChar isDigitRadix:10]) ifTrue:[
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   573
            value := value asFloat + (self nextMantissaAndScaledPartWithRadix:10) first.
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   574
            nextChar := source peekOrNil
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   575
        ] ifFalse:[
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   576
            allowDegeneratedMantissa == true ifTrue:[
197
aa7cedacebbe number.selector implemented
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
   577
                (nextChar notNil and:[nextChar isSeparator]) ifTrue:[
aa7cedacebbe number.selector implemented
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
   578
                    self warning:'degenerated float constant: ' , value printString , '.' .
aa7cedacebbe number.selector implemented
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
   579
                    tokenValue := token := value asFloat.
aa7cedacebbe number.selector implemented
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
   580
                    tokenType := #Float.
aa7cedacebbe number.selector implemented
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
   581
                    ^ tokenType
aa7cedacebbe number.selector implemented
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
   582
                ].
121
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   583
            ].
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
"/            nextChar == (Character cr) ifTrue:[
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
"/                lineNr := lineNr + 1.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
"/            ].
121
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   588
            nextChar := peekChar := $..
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   589
        ]
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
    ((nextChar == $e) or:[nextChar == $E]) ifTrue:[
121
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   592
        nextChar := source nextPeek.
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   593
        (nextChar notNil and:[(nextChar isDigitRadix:10) or:['+-' includes:nextChar]]) ifTrue:[
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   594
            s := 1.
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   595
            (nextChar == $+) ifTrue:[
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   596
                nextChar := source nextPeek
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   597
            ] ifFalse:[
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   598
                (nextChar == $-) ifTrue:[
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   599
                    nextChar := source nextPeek.
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   600
                    s := s negated
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   601
                ]
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   602
            ].
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   603
            value := value asFloat
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   604
                     * (10.0 raisedToInteger:((Integer readFrom:source radix:10) * s))
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   605
        ]
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
    nextChar == $- ifTrue:[
121
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   608
        self
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   609
            warnPossibleIncompatibility:'add a space before ''-'' for compatibility with other systems'
139
8007a21b0f4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 128
diff changeset
   610
            position:(source position) to:(source position).
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
    tokenValue := token := value.
121
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   614
    (value isLimitedPrecisionReal) ifTrue:[
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   615
        (nextChar == $d) ifTrue:[
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   616
            source next
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   617
        ].
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   618
        tokenType := #Float
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
    ] ifFalse:[
121
93ce8a9b0f2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 110
diff changeset
   620
        tokenType := #Integer
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
    ].
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
"/    self markConstantFrom:tokenPosition to:(source position - 1).
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
    ^ tokenType
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
    "Created: / 14.5.1998 / 20:00:25 / cg"
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
    "Modified: / 16.5.1998 / 15:51:46 / cg"
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
!
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   629
nextRegex
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   630
    "notice: initial '/' has already been read"
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   631
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   632
    |delimiter s pos endPos nextChar inString badEscapeChar|
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   633
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   634
    delimiter := hereChar.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   635
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   636
    s := (String new:20) writeStream.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   637
    pos := tokenPosition.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   638
    nextChar := source next.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   639
    inString := true.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   640
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   641
    [inString] whileTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   642
        nextChar isNil ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   643
            self syntaxError:'unexpected end-of-input in String'
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   644
                    position:pos to:(source position).
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   645
            self markStringFrom:pos to:source position.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   646
            token := tokenName := nil.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   647
            tokenType := #EOF.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   648
            ^ tokenType
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   649
        ].
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   650
        
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   651
        nextChar == $\ ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   652
            nextChar := source next.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   653
            nextChar == $b ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   654
                nextChar := Character backspace
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   655
            ] ifFalse:[ nextChar == $t ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   656
                nextChar := Character tab
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   657
            ] ifFalse:[ nextChar == $n ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   658
                nextChar := Character cr
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   659
            ] ifFalse:[ nextChar == $r ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   660
                nextChar := Character return
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   661
            ] ifFalse:[ nextChar == $f ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   662
                nextChar := Character newPage
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   663
            ] ifFalse:[ nextChar == $x ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   664
                nextChar := self hex2CharacterEscape.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   665
                nextChar isNil ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   666
                    token := tokenName := nil.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   667
                    tokenType := #EOF.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   668
                    ^ tokenType
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   669
                ].
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   670
            ] ifFalse:[ nextChar == $u ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   671
                nextChar := self hex4CharacterEscape.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   672
                nextChar isNil ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   673
                    token := nil.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   674
                    tokenType := tokenName := #EOF.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   675
                    ^ tokenType
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   676
                ].
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   677
            ] ifFalse:[ nextChar == Character cr ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   678
                nextChar := nil
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   679
            ] ifFalse:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   680
                ((nextChar == $') or:[nextChar == $" or:[nextChar == $\]]) ifFalse:[         
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   681
                    parserFlags warnAboutUnknownCharacterEscapesInJavaScriptStringConstant ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   682
                        badEscapeChar isNil ifTrue:[ badEscapeChar := nextChar asString ]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   683
                    ].
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   684
                ]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   685
            ]]]]]]]]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   686
        ] ifFalse:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   687
            (nextChar == Character cr) ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   688
                lineNr := lineNr + 1
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   689
            ] ifFalse:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   690
                (nextChar == delimiter) ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   691
                    (source peekOrNil == delimiter) ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   692
                        source next
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   693
                    ] ifFalse:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   694
                        inString := false
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   695
                    ]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   696
                ].
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   697
            ].
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   698
        ].
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   699
        inString ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   700
            nextChar notNil ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   701
                nextChar bitsPerCharacter > s contents bitsPerCharacter ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   702
                    s setCollection:(nextChar stringSpecies fromString:s collection).
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   703
                ].
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   704
                s nextPut:nextChar.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   705
            ].    
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   706
            nextChar := source next
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   707
        ]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   708
    ].
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   709
    endPos := source position.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   710
    self markStringFrom:pos to:endPos.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   711
    badEscapeChar notNil ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   712
        self warning:('Unknown character escape: "\',badEscapeChar asString,'"') position:pos to:endPos.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   713
    ].
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   714
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   715
    tokenValue := token := s contents.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   716
    tokenType := #Regex.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   717
    ^ tokenType
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   718
!
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   719
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   720
nextSlash
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   721
    |pc|
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   722
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   723
    (SupportRegex == true
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   724
    and:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   725
        acceptRegexString == true
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   726
        or:[self previousTokenInitiatesRegexForSlash ]
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   727
    ]) ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   728
        peekChar isNil ifTrue:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   729
            source next.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   730
        ] ifFalse:[
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   731
            peekChar := nil.
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   732
        ].
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   733
        pc := source peek.
1105
1eca25e3468c #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
   734
        pc == $/ ifTrue:[ source next. ^ self skipEOLComment].
1eca25e3468c #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
   735
        pc == $* ifTrue:[ source next. ^ self skipComment].
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   736
        ^ self nextRegex
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   737
    ].
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   738
    ^ self nextMulti:#(
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   739
                    ($= #'/=') 
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   740
                    ($* nil #skipComment) 
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   741
                    ($/ nil #skipEOLComment)
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   742
                    ) after:$/
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   743
!
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   744
193
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   745
nextString
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   746
    ^ self nextStringOrCharacter:false orRegex:false
193
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   747
!
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   748
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   749
nextStringOrCharacter:asCharacter
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   750
    ^ self nextStringOrCharacter:asCharacter orRegex:false
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   751
!
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   752
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   753
nextStringOrCharacter:asCharacter orRegex:asRegex
513
eab735628cc6 changed: #nextStringOrCharacter:
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
   754
    |delimiter s pos endPos nextChar inString badEscapeChar|
193
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   755
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   756
    delimiter := hereChar.
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   758
    s := (String new:20) writeStream.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   760
    pos := tokenPosition.
1089
e6313de8f4aa #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   761
    source next. "/ skip over initial quote
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
    nextChar := source next.
1152
1a2e526d9247 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   763
    "/ self assert:(nextChar isNil or:[nextChar isCharacter]).
1a2e526d9247 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   764
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
    inString := true.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   766
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   767
    [inString] whileTrue:[
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   768
        nextChar isNil ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   769
            self syntaxError:'unexpected end-of-input in String'
647
6b479c3aebd0 class: JavaScriptScanner
ab
parents: 639
diff changeset
   770
                    position:pos to:(source position).
639
a366feb3ec37 class: JavaScriptScanner
Stefan Vogel <sv@exept.de>
parents: 587
diff changeset
   771
            self markStringFrom:pos to:source position.
1075
0a14bf26d134 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
   772
            token := tokenName := nil.
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   773
            tokenType := #EOF.
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   774
            ^ tokenType
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   775
        ].
1010
623cf5c66728 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
   776
        
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   777
        nextChar == $\ ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   778
            nextChar := source next.
1152
1a2e526d9247 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   779
            "/ self assert:(nextChar isNil or:[nextChar isCharacter]).
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   780
            nextChar == $b ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   781
                nextChar := Character backspace
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   782
            ] ifFalse:[ nextChar == $t ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   783
                nextChar := Character tab
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   784
            ] ifFalse:[ nextChar == $n ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   785
                nextChar := Character cr
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   786
            ] ifFalse:[ nextChar == $r ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   787
                nextChar := Character return
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   788
            ] ifFalse:[ nextChar == $f ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   789
                nextChar := Character newPage
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   790
            ] ifFalse:[ nextChar == $x ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   791
                nextChar := self hex2CharacterEscape.
1152
1a2e526d9247 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   792
                "/ self assert:(nextChar isNil or:[nextChar isCharacter]).
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   793
                nextChar isNil ifTrue:[
1075
0a14bf26d134 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
   794
                    token := tokenName := nil.
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   795
                    tokenType := #EOF.
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   796
                    ^ tokenType
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   797
                ].
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   798
            ] ifFalse:[ nextChar == $u ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   799
                nextChar := self hex4CharacterEscape.
1152
1a2e526d9247 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   800
                "/ self assert:(nextChar isNil or:[nextChar isCharacter]).
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   801
                nextChar isNil ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   802
                    token := nil.
1075
0a14bf26d134 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
   803
                    tokenType := tokenName := #EOF.
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   804
                    ^ tokenType
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   805
                ].
1010
623cf5c66728 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
   806
            ] ifFalse:[ nextChar == Character cr ifTrue:[
623cf5c66728 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
   807
                nextChar := nil
512
0c6937eb1329 changed: #nextStringOrCharacter:
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
   808
            ] ifFalse:[
580
2b3fcd374bf0 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 517
diff changeset
   809
                ((nextChar == $') or:[nextChar == $" or:[nextChar == $\]]) ifFalse:[         
2b3fcd374bf0 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 517
diff changeset
   810
                    parserFlags warnAboutUnknownCharacterEscapesInJavaScriptStringConstant ifTrue:[
2b3fcd374bf0 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 517
diff changeset
   811
                        badEscapeChar isNil ifTrue:[ badEscapeChar := nextChar asString ]
2b3fcd374bf0 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 517
diff changeset
   812
                    ].
512
0c6937eb1329 changed: #nextStringOrCharacter:
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
   813
                ]
1010
623cf5c66728 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
   814
            ]]]]]]]]
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   815
        ] ifFalse:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   816
            (nextChar == Character cr) ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   817
                lineNr := lineNr + 1
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   818
            ] ifFalse:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   819
                (nextChar == delimiter) ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   820
                    (source peekOrNil == delimiter) ifTrue:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   821
                        source next
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   822
                    ] ifFalse:[
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   823
                        inString := false
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   824
                    ]
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   825
                ].
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   826
            ].
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   827
        ].
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   828
        inString ifTrue:[
1010
623cf5c66728 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
   829
            nextChar notNil ifTrue:[
623cf5c66728 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
   830
                nextChar bitsPerCharacter > s contents bitsPerCharacter ifTrue:[
623cf5c66728 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
   831
                    s setCollection:(nextChar stringSpecies fromString:s collection).
623cf5c66728 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
   832
                ].
623cf5c66728 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
   833
                s nextPut:nextChar.
623cf5c66728 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
   834
            ].    
1152
1a2e526d9247 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   835
            nextChar := source next.
1a2e526d9247 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   836
            "/ self assert:(nextChar isNil or:[nextChar isCharacter]).
144
47d80c89fdb1 hex character excapes
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
   837
        ]
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
    ].
639
a366feb3ec37 class: JavaScriptScanner
Stefan Vogel <sv@exept.de>
parents: 587
diff changeset
   839
    endPos := source position.
513
eab735628cc6 changed: #nextStringOrCharacter:
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
   840
    self markStringFrom:pos to:endPos.
eab735628cc6 changed: #nextStringOrCharacter:
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
   841
    badEscapeChar notNil ifTrue:[
eab735628cc6 changed: #nextStringOrCharacter:
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
   842
        self warning:('Unknown character escape: "\',badEscapeChar asString,'"') position:pos to:endPos.
eab735628cc6 changed: #nextStringOrCharacter:
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
   843
    ].
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
    tokenValue := token := s contents.
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
    tokenType := #String.
193
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   847
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   848
    asCharacter ifTrue:[
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   849
        token size ~~ 1 ifTrue:[
513
eab735628cc6 changed: #nextStringOrCharacter:
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
   850
            self syntaxError:'Character constant must be of size 1' position:pos to:endPos.
193
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   851
        ].
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   852
        tokenType := #Character.
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   853
        tokenValue := token := token first
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   854
    ].
2796c541ae81 support for characters.
Claus Gittinger <cg@exept.de>
parents: 176
diff changeset
   855
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
    ^ tokenType
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
512
0c6937eb1329 changed: #nextStringOrCharacter:
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
   858
    "Created: / 16-05-1998 / 19:53:05 / cg"
513
eab735628cc6 changed: #nextStringOrCharacter:
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
   859
    "Modified: / 04-10-2011 / 20:08:58 / cg"
1075
0a14bf26d134 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
   860
    "Modified: / 08-03-2019 / 12:41:24 / Claus Gittinger"
1089
e6313de8f4aa #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   861
    "Modified (comment): / 09-06-2019 / 17:11:51 / Claus Gittinger"
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   862
!
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
1085
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   864
nextSymbol
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   865
    "this is a special (non-JavaScript) extension to support #'x' for symbol literals"
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   866
    
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   867
    |pos|
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   868
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   869
    pos := tokenPosition.
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   870
    source next.
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   871
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   872
    (hereChar := source peek) == $' ifTrue:[
1086
b2f68985d90d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1085
diff changeset
   873
        self nextStringOrCharacter:false.
1089
e6313de8f4aa #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   874
        tokenType == #String ifTrue:[
e6313de8f4aa #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   875
            tokenValue := token := tokenValue asSymbol.
e6313de8f4aa #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   876
            tokenType := #Symbol.
e6313de8f4aa #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   877
        ].
1086
b2f68985d90d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1085
diff changeset
   878
        ^ token.
1085
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   879
    ].
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   880
1086
b2f68985d90d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1085
diff changeset
   881
    self syntaxError:'incorrect symbol constant'
1085
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   882
            position:pos to:(source position).
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   883
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   884
    "Created: / 09-06-2019 / 16:34:35 / Claus Gittinger"
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   885
!
5955ce5300a1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1075
diff changeset
   886
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
nextToken
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
    |t|
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
9
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   890
    [
355
eb08d9ce0ad3 comment
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   891
        t := super nextToken.
eb08d9ce0ad3 comment
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   892
        t isNil
9
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   893
    ] whileTrue.
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   894
    Verbose == true ifTrue:[Transcript showCR:t].
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
   895
    previousToken := token.
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
    ^ t
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   897
355
eb08d9ce0ad3 comment
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   898
    "
eb08d9ce0ad3 comment
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   899
     Verbose := true
eb08d9ce0ad3 comment
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   900
    "
eb08d9ce0ad3 comment
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   901
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   902
    "Created: / 14.5.1998 / 15:48:04 / cg"
9
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   903
    "Modified: / 16.5.1998 / 19:12:29 / cg"
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   904
!
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   905
61
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   906
skipComment
95
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   907
    "/* has already been read"
86
0f57fe8b7708 *** empty log message ***
ca
parents: 85
diff changeset
   908
500
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   909
    |nextChar startPos commentStream commentText|
95
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   910
1105
1eca25e3468c #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
   911
    startPos := (source position-1) max:1.
61
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   912
856
7914119c681a class: JavaScriptScanner
Stefan Vogel <sv@exept.de>
parents: 838
diff changeset
   913
    commentStream := CharacterWriteStream new:30.
500
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   914
61
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   915
    hereChar := source peek.
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   916
    [true] whileTrue:[
500
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   917
        hereChar isNil ifTrue:[
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   918
            "/ EOF in comment ?!!?
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   919
            commentText := commentStream contents.
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   920
            self handleCommentDirectivesIn:commentText.
500
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   921
            saveComments ifTrue:[
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   922
                self endComment:commentText type:#regularComment.
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   923
            ].
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   924
            ^ nil
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   925
        ].
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   926
        commentStream notNil ifTrue:[ commentStream nextPut:hereChar ].
500
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   927
61
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   928
        hereChar == $* ifTrue:[
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   929
            outStream notNil ifTrue:[
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   930
                outStream nextPut:hereChar.
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   931
                outCol := outCol + 1
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   932
            ].
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   933
            hereChar := source nextPeek.
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   934
            hereChar == $/ ifTrue:[
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   935
                commentStream notNil ifTrue:[ commentStream nextPut:hereChar ].
95
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   936
                self markCommentFrom:startPos to:(source position).
61
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   937
                hereChar := source nextPeek.
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   938
                commentText := commentStream contents.
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   939
                self handleCommentDirectivesIn:commentText.
500
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   940
                saveComments ifTrue:[
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   941
                    self endComment:commentText type:#regularComment.
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   942
                ].
61
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   943
                ^ nil
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   944
            ].
86
0f57fe8b7708 *** empty log message ***
ca
parents: 85
diff changeset
   945
            nextChar := hereChar.
0f57fe8b7708 *** empty log message ***
ca
parents: 85
diff changeset
   946
        ] ifFalse:[
157
ad5f9a69ccaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   947
            hereChar == Character cr ifTrue:[
ad5f9a69ccaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   948
                lineNr := lineNr + 1.
ad5f9a69ccaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   949
            ].
86
0f57fe8b7708 *** empty log message ***
ca
parents: 85
diff changeset
   950
            nextChar := source nextPeek.
61
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   951
        ].
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   952
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   953
        outStream notNil ifTrue:[
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   954
            outStream nextPut:hereChar.
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   955
            outCol := outCol + 1
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   956
        ].
86
0f57fe8b7708 *** empty log message ***
ca
parents: 85
diff changeset
   957
        hereChar := nextChar.
61
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   958
    ].
500
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   959
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   960
    "Modified: / 26-10-2011 / 17:42:14 / cg"
61
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   961
!
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 55
diff changeset
   962
9
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   963
skipEOLComment
95
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   964
    "// has already been read"
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   965
500
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   966
    |startPos commentStream commentText|
95
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   967
1104
afc90357e79d #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   968
    startPos := (source position-1) max:1.
95
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   969
856
7914119c681a class: JavaScriptScanner
Stefan Vogel <sv@exept.de>
parents: 838
diff changeset
   970
    commentStream := CharacterWriteStream new:30.
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   971
    commentStream nextPutAll:'//'.
500
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   972
9
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   973
    hereChar := source peek.
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   974
    [hereChar notNil and:[hereChar ~~ Character cr]] whileTrue:[
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   975
        commentStream notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   976
            commentStream nextPut:hereChar
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   977
        ].
95
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   978
        outStream notNil ifTrue:[
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   979
            outStream nextPut:hereChar.
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   980
            outCol := outCol + 1
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   981
        ].
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   982
        hereChar := source nextPeek.
9
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   983
    ].
95
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   984
    self markCommentFrom:startPos to:(source position).
157
ad5f9a69ccaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   985
    hereChar := source nextPeek.
9
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   986
    lineNr := lineNr + 1.
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   987
    outStream notNil ifTrue:[
95
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   988
        outStream cr.
7892defda291 *** empty log message ***
ca
parents: 86
diff changeset
   989
        outCol := 1
9
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   990
    ].
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   991
    commentText := commentStream contents.
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   992
    "/ self handleCommentDirectivesIn:commentText.
500
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   993
    saveComments ifTrue:[
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   994
        self endComment:commentText type:#eolComment.
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   995
    ].
9
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   996
    ^ nil.
496a6fe440bb handle eol-comments
Claus Gittinger <cg@exept.de>
parents: 7
diff changeset
   997
500
a305df632de2 changed:
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   998
    "Created: / 16-05-1998 / 19:11:05 / cg"
517
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   999
    "Modified: / 26-10-2011 / 17:43:46 / cg"
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
! !
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1001
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1002
!JavaScriptScanner class methodsFor:'documentation'!
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1003
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1004
version
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1005
    ^ '$Header$'
435
b1e64e400308 changed: #checkForKeyword:
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1006
!
b1e64e400308 changed: #checkForKeyword:
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1007
b1e64e400308 changed: #checkForKeyword:
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1008
version_CVS
b1e64e400308 changed: #checkForKeyword:
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1009
    ^ '$Header$'
7
5f1a1d905566 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1010
! !
580
2b3fcd374bf0 class: JavaScriptScanner
Claus Gittinger <cg@exept.de>
parents: 517
diff changeset
  1011
1102
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
  1012
3765d9a690f5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 1091
diff changeset
  1013
JavaScriptScanner initialize!