ParseError.st
author Claus Gittinger <cg@exept.de>
Fri, 08 Feb 2019 11:23:51 +0100
changeset 4331 b4baf7ebed5a
parent 4261 1b91b0f56a54
child 4350 c00b9da65c90
permissions -rw-r--r--
#FEATURE by cg class: Scanner added: #notifyError:position:to:lineNr: comment/format in: #showErrorMessage:position: changed: #notifyError:position:to:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
     1
"{ Encoding: utf8 }"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
     2
3064
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
     3
"
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
     4
 COPYRIGHT (c) 1989 by Claus Gittinger
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
     5
              All Rights Reserved
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
     6
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
     7
 This software is furnished under a license and may be used
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
     8
 only in accordance with the terms of that license and with the
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    10
 be provided or otherwise made available to, or used by, any
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    11
 other person.  No title to or ownership of the software is
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    12
 hereby transferred.
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    13
"
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libcomp' }"
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
4035
7b356dc3e0c2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3064
diff changeset
    16
"{ NameSpace: Smalltalk }"
7b356dc3e0c2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3064
diff changeset
    17
3064
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    18
ProceedableError subclass:#ParseError
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    19
	instanceVariableNames:'errorMessage startPosition endPosition lineNumber'
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'System-Compiler'
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
3064
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    25
!ParseError class methodsFor:'documentation'!
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    26
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    27
copyright
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    28
"
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    29
 COPYRIGHT (c) 1989 by Claus Gittinger
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    30
              All Rights Reserved
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    31
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    32
 This software is furnished under a license and may be used
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    33
 only in accordance with the terms of that license and with the
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    35
 be provided or otherwise made available to, or used by, any
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    36
 other person.  No title to or ownership of the software is
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    37
 hereby transferred.
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    38
"
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    39
!
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    40
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    41
documentation
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    42
"
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    43
    raised for any compilation-related errors.
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    44
    (originally, I wanted to subclass this from compilationError,
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    45
    and raise different error for code generator issues (i.e. method too
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    46
    big, etc.) But all users of the parser in the system (RB-stuff, Lint stuff,
4035
7b356dc3e0c2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3064
diff changeset
    47
    fileIn etc.) always handle the ParseError, and I don't want them to be forced to change.
3064
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    48
    So we subclass the codeGenerator issues from this one.
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    49
"
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    50
! !
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
!ParseError methodsFor:'accessing'!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
description
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    55
    "construct the description from my default description (i.e. 'Parse Error:'),
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    56
     followed by the actual parse-error-message, followed by the lineNumber (if known)"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    57
     
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    |s|
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    s := super description.
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    61
    
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    s last isSeparator ifFalse:[
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
        errorMessage notEmptyOrNil ifTrue:[
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
            s := s , ' '
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
        ]
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    ].
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    s := s , (errorMessage ? '').
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    lineNumber notNil ifTrue:[
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
        s := s , ' [Line ' , lineNumber asString , ']'
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    ].
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    ^ s
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
endPosition
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    75
    "the end-tokenposition, where the error is located"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    76
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    ^ endPosition
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    80
endPosition:anInteger
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    81
    "the end-tokenposition, where the error is located"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    82
    
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    83
    endPosition := anInteger.
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    84
!
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    85
3064
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    86
errorMessage
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    87
    ^ errorMessage
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    88
!
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    89
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    90
errorMessage:aString
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    91
    errorMessage := aString.
3064
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    92
!
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    93
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
errorMessage:errorMessageArg startPosition:startPositionArg 
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    errorMessage := errorMessageArg.
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    startPosition := startPositionArg.
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
errorMessage:errorMessageArg startPosition:startPositionArg endPosition:endPositionArg 
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    errorMessage := errorMessageArg.
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    startPosition := startPositionArg.
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    endPosition := endPositionArg.
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
lineNumber
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   106
    "the lineNumber, where the error was detected"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   107
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    ^ lineNumber
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   111
lineNumber:anInteger
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   112
    "the lineNumber, where the error was detected"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   113
    
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   114
    lineNumber := anInteger.
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
parser
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    ^ originator
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
startPosition
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   122
    "the start-tokenposition, where the error is located"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   123
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    ^ startPosition
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   125
!
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   126
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   127
startPosition:anInteger
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   128
    "the start-tokenposition, where the error is located"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   129
    
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   130
    startPosition := anInteger.
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
! !
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
!ParseError class methodsFor:'documentation'!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
version
4035
7b356dc3e0c2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3064
diff changeset
   136
    ^ '$Header$'
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
version_CVS
4035
7b356dc3e0c2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3064
diff changeset
   140
    ^ '$Header$'
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
! !
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142