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