SmaCC__SmaCCScannerParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 07 Dec 2016 13:18:16 +0000
changeset 26 b2c091b8cea1
parent 16 55254a6f8404
permissions -rw-r--r--
Fixed initialization of SmaCCEdge There's no `UnicodeString` anymore. Changed: WriteStream on: UnicodeString new to: String new writeStream
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
     1
"{ Package: 'stx:goodies/smaCC' }"
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
     2
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
     3
"{ NameSpace: SmaCC }"
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
     4
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
     5
SmaCCParser subclass:#SmaCCScannerParser
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
     6
	instanceVariableNames:'tokens'
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
     7
	classVariableNames:''
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
     8
	poolDictionaries:''
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
     9
	category:'SmaCC-Scanner Generator'
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    10
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    11
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    12
SmaCCScannerParser comment:'SmaCCScannerParser is the parser for the scanner definition.
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    13
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    14
Instance Variables:
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    15
	tokens	<Dictionary key: String value: SmaCCRegularExpressionNode>	the tokens that are parsed
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    16
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    17
'
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    18
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    19
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    20
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    21
!SmaCCScannerParser class methodsFor:'generated-accessing'!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    22
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    23
scannerClass
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    24
	^SmaCC::SmaCCScannerScanner
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    25
! !
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    26
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    27
!SmaCCScannerParser class methodsFor:'generated-comments'!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    28
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    29
parserDefinitionComment
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    30
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    31
	"%left   ""|"";
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    32
%left ""("" <character> <backslashcharacter> <characterblock> <anycharacter> <tokenname>;
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    33
%left ""*"" ""+"" ""?"" <repeat> ;
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    34
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    35
File: Rules      {tokens} 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    36
        |  {tokens};
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    37
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    38
Rules: Rule "";""
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    39
        | Rules Rule "";"" ;
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    40
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    41
Rule: <tokenname> "":"" Regex {'3' position: '1' startPosition. tokens at: '1' value put: '3'. nil};
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    42
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    43
Regex: RegexTerm {'1'}
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    44
        | Regex ""|"" Regex {'1' | '3'}
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    45
        | Regex RegexTerm {'1' , '2'};
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    46
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    47
RegexTerm:      <character> {SmaCCCharacterRENode characters: '1' value}
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    48
        | <anycharacter> {SmaCCCharacterRENode characters: self allCharacters}
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    49
        | <backslashcharacter> {self nodeFor: (ReadStream on: ('1' value copyFrom: 2 to: '1' value size))} 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    50
        | ""("" Regex "")"" {'2'}
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    51
        | <characterblock> {SmaCCCharacterRENode characters: (self parseCharacterBlock: '1')}
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    52
        | <tokenname> {(tokens at: '1' value) copy}
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    53
        | RegexTerm ""*"" {'1' repeat}
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    54
        | RegexTerm ""+"" {'1' repeatForAtLeast: 1}
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    55
        | RegexTerm ""?"" {'1' repeatFor: 0 to: 1}
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    56
        | RegexTerm <repeat> {| readStream start stop | 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    57
                                        readStream := ReadStream on: ('2' value copyFrom: 2 to: '2' value size - 1). 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    58
                                        start := readStream upTo: $,. 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    59
                                        stop := readStream upToEnd.
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    60
                                        '1' repeatFor: (start isEmpty ifTrue: [0] ifFalse: [start asNumber]) to: (stop isEmpty ifTrue: [(1 bitShift: 31)] ifFalse: [stop asNumber])} ;
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    61
"
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    62
! !
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    63
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    64
!SmaCCScannerParser class methodsFor:'generated-starting states'!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    65
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    66
startingStateForFile
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    67
	^1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    68
! !
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    69
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    70
!SmaCCScannerParser methodsFor:'generated-reduction actions'!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    71
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    72
reduceActionForFile1:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    73
    ^ tokens
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    74
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    75
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    76
reduceActionForFile2:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    77
    ^ tokens
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    78
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    79
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    80
reduceActionForRegex1:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    81
    ^ nodes at:1
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    82
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    83
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    84
reduceActionForRegex2:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    85
    ^ (nodes at:1) | (nodes at:3)
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    86
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    87
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    88
reduceActionForRegex3:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    89
    ^ (nodes at:1) , (nodes at:2)
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    90
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
    91
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    92
reduceActionForRegexTerm10:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    93
    |readStream start stop|
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    94
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    95
    readStream := ReadStream 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    96
                on:((nodes at:2) value copyFrom:2 to:(nodes at:2) value size - 1).
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    97
    start := readStream upTo:$,.
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    98
    stop := readStream upToEnd.
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
    99
    ^ (nodes at:1) 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   100
        repeatFor:(start isEmpty ifTrue:[ 0 ] ifFalse:[ start asNumber ])
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   101
        to:(stop isEmpty ifTrue:[ (1 bitShift:31) ] ifFalse:[ stop asNumber ])
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   102
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   103
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   104
reduceActionForRegexTerm1:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   105
    ^ SmaCCCharacterRENode characters:(nodes at:1) value
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   106
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   107
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   108
reduceActionForRegexTerm2:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   109
    ^ SmaCCCharacterRENode characters:self allCharacters
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   110
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   111
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   112
reduceActionForRegexTerm3:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   113
    ^ self nodeFor:(ReadStream 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   114
                on:((nodes at:1) value copyFrom:2 to:(nodes at:1) value size))
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   115
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   116
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   117
reduceActionForRegexTerm4:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   118
    ^ nodes at:2
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   119
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   120
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   121
reduceActionForRegexTerm5:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   122
    ^ SmaCCCharacterRENode characters:(self parseCharacterBlock:(nodes at:1))
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   123
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   124
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   125
reduceActionForRegexTerm6:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   126
    ^ (tokens at:(nodes at:1) value) copy
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   127
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   128
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   129
reduceActionForRegexTerm7:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   130
    ^ (nodes at:1) repeat
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   131
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   132
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   133
reduceActionForRegexTerm8:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   134
    ^ (nodes at:1) repeatForAtLeast:1
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   135
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   136
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   137
reduceActionForRegexTerm9:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   138
    ^ (nodes at:1) repeatFor:0 to:1
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   139
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   140
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   141
reduceActionForRule1:nodes 
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   142
    (nodes at:3) position:(nodes at:1) startPosition.
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   143
    tokens at:(nodes at:1) value put:(nodes at:3).
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   144
    ^ nil
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   145
! !
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   146
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   147
!SmaCCScannerParser methodsFor:'generated-tables'!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   148
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   149
reduceTable
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   150
	^#(
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   151
#(17 1 #reduceFor:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   152
#(18 1 #reduceActionForFile1:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   153
#(18 0 #reduceActionForFile2:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   154
#(19 1 #reduceActionForRegex1:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   155
#(19 3 #reduceActionForRegex2:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   156
#(19 2 #reduceActionForRegex3:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   157
#(20 1 #reduceActionForRegexTerm1:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   158
#(20 1 #reduceActionForRegexTerm2:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   159
#(20 1 #reduceActionForRegexTerm3:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   160
#(20 3 #reduceActionForRegexTerm4:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   161
#(20 1 #reduceActionForRegexTerm5:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   162
#(20 1 #reduceActionForRegexTerm6:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   163
#(20 2 #reduceActionForRegexTerm7:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   164
#(20 2 #reduceActionForRegexTerm8:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   165
#(20 2 #reduceActionForRegexTerm9:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   166
#(20 2 #reduceActionForRegexTerm10:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   167
#(23 2 #reduceFor:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   168
#(23 3 #reduceFor:)
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   169
#(24 3 #reduceActionForRule1:)
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   170
)
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   171
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   172
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   173
transitionTable
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   174
	^#(
16
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   175
#[1 0 9 0 12 0 13 0 18 0 14 0 21 0 17 0 23 0 21 0 24]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   176
#[0 0 25 0 7]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   177
#[0 0 0 0 21]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   178
#[1 0 9 0 12 0 10 0 21 0 29 0 24]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   179
#[0 0 33 0 8]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   180
#[1 0 37 0 1 0 41 0 9 0 45 0 10 0 49 0 12 0 53 0 15 0 57 0 16 0 61 0 19 0 65 0 20]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   181
#[0 0 69 0 8]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   182
#[0 0 70 0 12 0 21]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   183
#[1 0 37 0 1 0 41 0 9 0 45 0 10 0 49 0 12 0 53 0 15 0 57 0 16 0 73 0 19 0 65 0 20]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   184
#[0 0 38 0 1 0 2 0 3 0 4 0 5 0 6 0 8 0 9 0 10 0 12 0 14 0 15 0 16]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   185
#[0 0 46 0 1 0 2 0 3 0 4 0 5 0 6 0 8 0 9 0 10 0 12 0 14 0 15 0 16]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   186
#[0 0 50 0 1 0 2 0 3 0 4 0 5 0 6 0 8 0 9 0 10 0 12 0 14 0 15 0 16]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   187
#[0 0 30 0 1 0 2 0 3 0 4 0 5 0 6 0 8 0 9 0 10 0 12 0 14 0 15 0 16]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   188
#[0 0 34 0 1 0 2 0 3 0 4 0 5 0 6 0 8 0 9 0 10 0 12 0 14 0 15 0 16]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   189
#[1 0 37 0 1 0 77 0 2 0 78 0 8 0 41 0 9 0 45 0 10 0 49 0 12 0 53 0 15 0 57 0 16 0 81 0 20]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   190
#[1 0 18 0 1 0 18 0 2 0 85 0 3 0 18 0 4 0 89 0 5 0 93 0 6 0 18 0 8 0 18 0 9 0 18 0 10 0 18 0 12 0 97 0 14 0 18 0 15 0 18 0 16]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   191
#[0 0 74 0 12 0 21]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   192
#[1 0 37 0 1 0 77 0 2 0 101 0 4 0 41 0 9 0 45 0 10 0 49 0 12 0 53 0 15 0 57 0 16 0 81 0 20]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   193
#[1 0 37 0 1 0 41 0 9 0 45 0 10 0 49 0 12 0 53 0 15 0 57 0 16 0 105 0 19 0 65 0 20]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   194
#[1 0 26 0 1 0 26 0 2 0 85 0 3 0 26 0 4 0 89 0 5 0 93 0 6 0 26 0 8 0 26 0 9 0 26 0 10 0 26 0 12 0 97 0 14 0 26 0 15 0 26 0 16]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   195
#[0 0 54 0 1 0 2 0 3 0 4 0 5 0 6 0 8 0 9 0 10 0 12 0 14 0 15 0 16]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   196
#[0 0 58 0 1 0 2 0 3 0 4 0 5 0 6 0 8 0 9 0 10 0 12 0 14 0 15 0 16]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   197
#[0 0 62 0 1 0 2 0 3 0 4 0 5 0 6 0 8 0 9 0 10 0 12 0 14 0 15 0 16]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   198
#[0 0 66 0 1 0 2 0 3 0 4 0 5 0 6 0 8 0 9 0 10 0 12 0 14 0 15 0 16]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   199
#[0 0 42 0 1 0 2 0 3 0 4 0 5 0 6 0 8 0 9 0 10 0 12 0 14 0 15 0 16]
55254a6f8404 Generated scanners how uses Character>>is* methods on iff they
vranyj1
parents: 15
diff changeset
   200
#[1 0 37 0 1 0 22 0 2 0 22 0 4 0 22 0 8 0 41 0 9 0 45 0 10 0 49 0 12 0 53 0 15 0 57 0 16 0 81 0 20]
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   201
)
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   202
! !
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   203
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   204
!SmaCCScannerParser methodsFor:'initialize-release'!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   205
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   206
initialize
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   207
	super initialize.
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   208
	tokens := Dictionary new
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   209
! !
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   210
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   211
!SmaCCScannerParser methodsFor:'private'!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   212
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   213
allCharacters
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   214
        ^UnicodeString withAll: ((0 to: SmaCCGrammar maximumCharacterValue) 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   215
                                collect: [:each | Character value: each])
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   216
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   217
    "Modified: / 26-05-2006 / 22:16:45 / janfrog"
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   218
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   219
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   220
charactersFor: aStream in: aToken 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   221
	| characters char endCharacters |
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   222
	aStream atEnd ifTrue: [self reportCharacterBlockErrorForToken: aToken].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   223
	char := aStream next.
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   224
	characters := char == $\ 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   225
				ifTrue: [(self nodeFor: aStream) characters]
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   226
				ifFalse: [OrderedCollection with: char].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   227
	(characters size = 1 and: [aStream peekFor: $-]) ifFalse: [^characters].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   228
	endCharacters := self charactersFor: aStream in: aToken.
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   229
	endCharacters size > 1 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   230
		ifTrue: [self reportCharacterBlockErrorForToken: aToken].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   231
	^(characters first asInteger to: endCharacters first asInteger) 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   232
		collect: [:each | Character value: each]
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   233
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   234
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   235
nodeFor: aStream 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   236
	| block char value count |
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   237
	char := aStream next.
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   238
	char == $f 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   239
		ifTrue: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   240
			[^SmaCCCharacterRENode characters: (String with: (Character value: 12))].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   241
	char == $n 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   242
		ifTrue: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   243
			[^SmaCCCharacterRENode characters: (String with: (Character value: 10))].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   244
	char == $r 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   245
		ifTrue: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   246
			[^SmaCCCharacterRENode characters: (String with: (Character value: 13))].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   247
	char == $t ifTrue: [^SmaCCCharacterRENode characters: '	'].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   248
	char == $v 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   249
		ifTrue: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   250
			[^SmaCCCharacterRENode characters: (String with: (Character value: 11))].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   251
	char == $c 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   252
		ifTrue: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   253
			[^SmaCCCharacterRENode characters: (String 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   254
						with: (Character value: aStream next asInteger - $A asInteger))].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   255
	char == $x 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   256
		ifTrue: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   257
			[count := value := 0.
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   258
			
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   259
			[aStream atEnd not and: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   260
					[count < 4 and: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   261
							[char := aStream peek.
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   262
							(char between: $0 and: $9) 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   263
								or: [(char between: $A and: $F) or: [char between: $a and: $f]]]]] 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   264
					whileTrue: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   265
						[count := count + 1.
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   266
						value := value * 16 + aStream next digitValue].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   267
			^SmaCCCharacterRENode characters: (String with: (Character value: value))].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   268
	char == $d ifTrue: [block := [:each | each between: $0 and: $9]].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   269
	char == $D ifTrue: [block := [:each | (each between: $0 and: $9) not]].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   270
	char == $s 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   271
		ifTrue: [block := [:each | #[9 10 11 12 13 32] includes: each asInteger]].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   272
	char == $S 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   273
		ifTrue: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   274
			[block := [:each | (#[9 10 11 12 13 32] includes: each asInteger) not]].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   275
	char == $w 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   276
		ifTrue: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   277
			[block := 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   278
					[:each | 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   279
					(each between: $a and: $z) or: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   280
							[(each between: $A and: $Z) 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   281
								or: [(each between: $0 and: $9) or: [each == $_]]]]].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   282
	char == $W 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   283
		ifTrue: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   284
			[block := 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   285
					[:each | 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   286
					((each between: $a and: $z) or: 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   287
							[(each between: $A and: $Z) 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   288
								or: [(each between: $0 and: $9) or: [each == $_]]]) 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   289
						not]].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   290
	block isNil 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   291
		ifTrue: [^SmaCCCharacterRENode characters: (String with: char)].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   292
	^SmaCCCharacterRENode 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   293
		characters: (String withAll: (self allCharacters select: block))
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   294
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   295
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   296
parseCharacterBlock: aToken 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   297
        | characters aStream invert |
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   298
        aStream := ReadStream 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   299
                                on: (aToken value copyFrom: 2 to: aToken value size - 1).
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   300
        characters := OrderedCollection new.
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   301
        invert := aStream peekFor: $^.
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   302
        [aStream atEnd] 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   303
                whileFalse: [characters addAll: (self charactersFor: aStream in: aToken)].
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   304
        ^UnicodeString withAll: (invert 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   305
                                ifTrue: [self allCharacters reject: [:each | characters includes: each]]
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   306
                                ifFalse: [characters])
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   307
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   308
    "Modified: / 26-05-2006 / 22:17:06 / janfrog"
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   309
!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   310
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   311
reportCharacterBlockErrorForToken: aToken 
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   312
	currentToken := aToken.
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   313
	self reportErrorMessage: 'Invalid character block'
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   314
! !
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   315
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   316
!SmaCCScannerParser class methodsFor:'documentation'!
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   317
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   318
version
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   319
    ^ '$Header: /opt/data/cvs/stx/goodies/smaCC/SmaCC__SmaCCScannerParser.st,v 1.2 2006-05-28 20:10:22 vranyj1 Exp $'
15
8b8cd1701c33 added version_SVN method
vranyj1
parents: 1
diff changeset
   320
!
8b8cd1701c33 added version_SVN method
vranyj1
parents: 1
diff changeset
   321
8b8cd1701c33 added version_SVN method
vranyj1
parents: 1
diff changeset
   322
version_SVN
8b8cd1701c33 added version_SVN method
vranyj1
parents: 1
diff changeset
   323
    ^ '$Id$'
1
b8cca2663544 Initial import
vranyj1
parents:
diff changeset
   324
! !