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