ParseError.st
author Claus Gittinger <cg@exept.de>
Tue, 25 Feb 2020 13:40:53 +0100
changeset 4644 117a8f63f3f8
parent 4629 912273cade9a
child 4650 e9b212d470ff
permissions -rw-r--r--
#BUGFIX by cg class: Parser changed: #stringWithEmbeddedExpressions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4629
912273cade9a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4350
diff changeset
     1
"{ Encoding: utf8 }"
912273cade9a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4350
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:[
4629
912273cade9a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4350
diff changeset
    69
        "/ 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
    70
        (s includesString:'[Line:') ifFalse:[
912273cade9a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4350
diff changeset
    71
            s := s , ' [Line ' , lineNumber asString , ']'
912273cade9a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4350
diff changeset
    72
        ].
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    ].
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    ^ s
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
endPosition
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    78
    "the end-tokenposition, where the error is located"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    79
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    ^ endPosition
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
4261
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
    "the end-tokenposition, where the error is located"
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
    endPosition := anInteger.
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    87
!
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    88
3064
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    89
errorMessage
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    90
    ^ errorMessage
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    91
!
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    92
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    93
errorMessage:aString
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
    94
    errorMessage := aString.
3064
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    95
!
179c907e32be class: ParseError
Claus Gittinger <cg@exept.de>
parents: 3062
diff changeset
    96
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
errorMessage:errorMessageArg startPosition:startPositionArg 
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
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
errorMessage:errorMessageArg startPosition:startPositionArg endPosition:endPositionArg 
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    errorMessage := errorMessageArg.
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    startPosition := startPositionArg.
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    endPosition := endPositionArg.
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
lineNumber
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   109
    "the lineNumber, where the error was detected"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   110
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    ^ lineNumber
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   114
lineNumber:anInteger
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   115
    "the lineNumber, where the error was detected"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   116
    
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   117
    lineNumber := anInteger.
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
parser
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    ^ originator
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
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
    "the start-tokenposition, where the error is located"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   126
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    ^ startPosition
4261
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   128
!
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
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   131
    "the start-tokenposition, where the error is located"
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   132
    
1b91b0f56a54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4035
diff changeset
   133
    startPosition := anInteger.
4350
c00b9da65c90 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4261
diff changeset
   134
!
c00b9da65c90 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4261
diff changeset
   135
c00b9da65c90 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4261
diff changeset
   136
startPosition:startPositionArg endPosition:endPositionArg 
c00b9da65c90 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4261
diff changeset
   137
    startPosition := startPositionArg.
c00b9da65c90 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4261
diff changeset
   138
    endPosition := endPositionArg.
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
! !
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
!ParseError class methodsFor:'documentation'!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
version
4035
7b356dc3e0c2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3064
diff changeset
   144
    ^ '$Header$'
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
!
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
version_CVS
4035
7b356dc3e0c2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3064
diff changeset
   148
    ^ '$Header$'
3062
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
! !
ab018dc93d8c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150