author | Claus Gittinger <cg@exept.de> |
Sun, 23 Sep 2018 01:09:40 +0200 | |
changeset 4302 | 97c125843381 |
parent 4144 | 40668dc4b737 |
child 4509 | 132f89212503 |
permissions | -rw-r--r-- |
1570 | 1 |
" |
2 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
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 |
" |
|
1532 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
4144 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
2547
55ec27b3306c
ParserErrorNode now inherits from ParseNode
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1570
diff
changeset
|
16 |
ParseNode subclass:#ParseErrorNode |
3269
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
17 |
instanceVariableNames:'errorString errorToken children' |
1532 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'System-Compiler-Support' |
|
21 |
! |
|
22 |
||
1570 | 23 |
!ParseErrorNode class methodsFor:'documentation'! |
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
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 |
" |
|
3269
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
37 |
! |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
38 |
|
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
39 |
documentation |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
40 |
" |
4144 | 41 |
ParseErrorNode represent an erroneous portion of the source code. |
3269
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
42 |
Error nodes are created by error-tolerant parser. So far the only |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
43 |
user is SmallSenseParser (https://bitbucket.org/janvrany/jv-smallsense). |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
44 |
|
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
45 |
Error nodes may have children which may not be error nodes. Such |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
46 |
children represent a part of the code that actuallu could be parsed. |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
47 |
Example: |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
48 |
|
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
49 |
printValue: value |
4144 | 50 |
Transcript show: (value printStringRadix: 12 |
3269
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
51 |
Transcript cr |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
52 |
|
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
53 |
The tolerant parser may create tree like: |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
54 |
statement (StatementNode) |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
55 |
#show: (MessageNode) |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
56 |
Transcript (ContantNode) |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
57 |
<<error>> (ParseErrorNode) |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
58 |
#printStringRadix: (MessageNode) |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
59 |
value (VariableNode) |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
60 |
12 (ContantNode) |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
61 |
statement (StatementNode) |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
62 |
#cr (MessageNode) |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
63 |
Transcript (ContantNode) |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
64 |
|
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
65 |
[author:] |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
66 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
67 |
|
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
68 |
[instance variables:] |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
69 |
|
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
70 |
[class variables:] |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
71 |
|
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
72 |
[see also:] |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
73 |
|
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
74 |
" |
1570 | 75 |
! ! |
1532 | 76 |
|
77 |
!ParseErrorNode class methodsFor:'instance creation'! |
|
78 |
||
79 |
errorString:arg |
|
80 |
^ self new errorString:arg |
|
81 |
! ! |
|
82 |
||
83 |
!ParseErrorNode methodsFor:'accessing'! |
|
84 |
||
3269
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
85 |
children |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
86 |
^ children |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
87 |
! |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
88 |
|
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
89 |
children:aCollection |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
90 |
children := aCollection. |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
91 |
children do:[:each | each parent: self ]. |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
92 |
|
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
93 |
"Modified: / 15-08-2013 / 11:43:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
94 |
! |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
95 |
|
1532 | 96 |
errorString |
97 |
^ errorString |
|
98 |
! |
|
99 |
||
100 |
errorString:something |
|
101 |
errorString := something. |
|
2549 | 102 |
! |
103 |
||
2853 | 104 |
errorToken |
105 |
||
106 |
^errorToken |
|
107 |
||
108 |
"Created: / 27-11-2011 / 09:25:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
109 |
! |
|
110 |
||
111 |
errorToken:something |
|
112 |
||
113 |
errorToken := something |
|
114 |
||
115 |
"Created: / 27-11-2011 / 09:25:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
116 |
! |
|
117 |
||
2549 | 118 |
lineNumber |
119 |
||
120 |
^self objectAttributeAt: #lineNumber |
|
121 |
||
122 |
"Created: / 09-07-2011 / 22:30:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
123 |
! |
|
124 |
||
125 |
lineNumber: anInteger |
|
126 |
||
127 |
self objectAttributeAt: #lineNumber put: anInteger |
|
128 |
||
129 |
"Created: / 09-07-2011 / 22:29:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1532 | 130 |
! ! |
131 |
||
2853 | 132 |
|
133 |
!ParseErrorNode methodsFor:'printing & storing'! |
|
134 |
||
3269
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
135 |
printAllOn:aStream indent:indent |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
136 |
children do: [:each | each printAllOn:aStream indent:indent ]. |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
137 |
self printOn:aStream indent:indent |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
138 |
|
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
139 |
"Created: / 15-08-2013 / 12:29:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
140 |
! |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
141 |
|
2853 | 142 |
printOn:aStream indent:indent |
143 |
"append a user printed representation of the receiver to aStream. |
|
144 |
The format is suitable for a human - not meant to be read back." |
|
145 |
||
146 |
aStream next: indent put: Character tab. |
|
3269
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
147 |
aStream nextPutAll:'"<< parse error here'. |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
148 |
errorString notNil ifTrue:[ |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
149 |
aStream nextPutAll:': '. |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
150 |
aStream nextPutAll: errorString |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
151 |
]. |
2853 | 152 |
errorToken notNil ifTrue:[ |
3269
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
153 |
aStream nextPutAll:' (error token: '. |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
154 |
aStream nextPutAll: errorToken. |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
155 |
aStream nextPutAll: ')'. |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
156 |
]. |
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
157 |
aStream nextPutAll:'>>"' |
2853 | 158 |
|
159 |
"Created: / 20-04-2005 / 14:21:46 / cg" |
|
3269
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
160 |
"Modified: / 15-08-2013 / 12:32:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2853 | 161 |
! ! |
162 |
||
1532 | 163 |
!ParseErrorNode methodsFor:'queries'! |
164 |
||
165 |
isErrorNode |
|
166 |
^ true |
|
167 |
! ! |
|
168 |
||
2594 | 169 |
!ParseErrorNode methodsFor:'visiting'! |
170 |
||
171 |
acceptVisitor:aVisitor |
|
172 |
"Double dispatch back to the visitor, passing my type encoded in |
|
173 |
the selector (visitor pattern)" |
|
174 |
||
175 |
"stub code automatically generated - please change if required" |
|
176 |
||
177 |
^ aVisitor visitParseErrorNode:self |
|
178 |
! ! |
|
179 |
||
1532 | 180 |
!ParseErrorNode class methodsFor:'documentation'! |
181 |
||
182 |
version |
|
4144 | 183 |
^ '$Header$' |
2549 | 184 |
! |
185 |
||
186 |
version_CVS |
|
4144 | 187 |
^ '$Header$' |
1532 | 188 |
! ! |
3269
812d7cd10746
Added children nodes, better printOn: and some more documentation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2853
diff
changeset
|
189 |