ParseError.st
author Jan Vrany <jan.vrany@labware.com>
Thu, 27 Oct 2022 14:53:59 +0100
branchjv
changeset 4735 3b11fb3ede98
parent 4650 e9b212d470ff
permissions -rw-r--r--
Allow single underscore as method / block argument and temporaries This commit is a follow up for 38b221e.
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:[
4629
912273cade9a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4350
diff changeset
    67
        "/ avoid redundant information (in case the line number is already in the description)
912273cade9a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4350
diff changeset
    68
        (s includesString:'[Line:') ifFalse:[
912273cade9a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4350
diff changeset
    69
            s := s , ' [Line ' , lineNumber asString , ']'
912273cade9a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4350
diff changeset
    70
        ].
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    ].
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    ^ s
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
endPosition
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    76
    "the end-tokenposition, where the error is located"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    77
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    ^ endPosition
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
4261
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
    "the end-tokenposition, where the error is located"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    83
    
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    84
    endPosition := anInteger.
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    85
!
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    86
3064
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
    ^ errorMessage
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    89
!
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    90
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    91
errorMessage:aString
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    92
    errorMessage := aString.
3064
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    93
!
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    94
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
errorMessage:errorMessageArg startPosition:startPositionArg 
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    errorMessage := errorMessageArg.
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    startPosition := startPositionArg.
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
errorMessage:errorMessageArg startPosition:startPositionArg endPosition:endPositionArg 
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    errorMessage := errorMessageArg.
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    startPosition := startPositionArg.
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    endPosition := endPositionArg.
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
lineNumber
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   107
    "the lineNumber, where the error was detected"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   108
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    ^ lineNumber
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   112
lineNumber:anInteger
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   113
    "the lineNumber, where the error was detected"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   114
    
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   115
    lineNumber := anInteger.
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
parser
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    ^ originator
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
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
    "the start-tokenposition, where the error is located"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   124
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    ^ startPosition
4261
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
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   128
startPosition:anInteger
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   129
    "the start-tokenposition, where the error is located"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   130
    
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   131
    startPosition := anInteger.
4350
c00b9da65c90 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4261
diff changeset
   132
!
c00b9da65c90 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4261
diff changeset
   133
c00b9da65c90 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4261
diff changeset
   134
startPosition:startPositionArg endPosition:endPositionArg 
c00b9da65c90 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4261
diff changeset
   135
    startPosition := startPositionArg.
c00b9da65c90 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4261
diff changeset
   136
    endPosition := endPositionArg.
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
4650
e9b212d470ff #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4629
diff changeset
   139
!ParseError methodsFor:'compatibility - VW'!
e9b212d470ff #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4629
diff changeset
   140
e9b212d470ff #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4629
diff changeset
   141
position
e9b212d470ff #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4629
diff changeset
   142
    ^ startPosition
e9b212d470ff #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4629
diff changeset
   143
e9b212d470ff #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4629
diff changeset
   144
    "Created: / 03-05-2020 / 23:44:48 / cg"
e9b212d470ff #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4629
diff changeset
   145
! !
e9b212d470ff #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4629
diff changeset
   146
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
!ParseError class methodsFor:'documentation'!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
version
4035
7b356dc3e0c2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3064
diff changeset
   150
    ^ '$Header$'
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
version_CVS
4035
7b356dc3e0c2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3064
diff changeset
   154
    ^ '$Header$'
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
! !
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156