1
|
1 |
"{ Package: 'stx:goodies/smaCC' }"
|
|
2 |
|
|
3 |
"{ NameSpace: SmaCC }"
|
|
4 |
|
|
5 |
Object subclass:#SmaCCSymbol
|
|
6 |
instanceVariableNames:'name precedence firstItems'
|
|
7 |
classVariableNames:'EmptySymbol ErrorSymbol SentinelSymbol'
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'SmaCC-Parser Generator'
|
|
10 |
!
|
|
11 |
|
|
12 |
SmaCCSymbol comment:'SmaCCSymbol is an abstract class that represents a symbol in the grammar.
|
|
13 |
|
|
14 |
Subclasses must implement the following messages:
|
|
15 |
accessing
|
|
16 |
calculateFirstTerminals
|
|
17 |
testing
|
|
18 |
isTerminal
|
|
19 |
|
|
20 |
Instance Variables:
|
|
21 |
firstItems <Collection of: SmaCCTerminalSymbol> the first terminals that can be produced from us
|
|
22 |
name <String> our name
|
|
23 |
precedence <Integer> our precedence (in case of shift/reduce conflicts)
|
|
24 |
|
|
25 |
'
|
|
26 |
!
|
|
27 |
|
|
28 |
|
|
29 |
!SmaCCSymbol class methodsFor:'instance creation'!
|
|
30 |
|
|
31 |
empty
|
|
32 |
EmptySymbol isNil
|
|
33 |
ifTrue: [EmptySymbol := SmaCCTerminalSymbol name: 'E O F'].
|
|
34 |
^EmptySymbol
|
|
35 |
!
|
|
36 |
|
|
37 |
error
|
|
38 |
ErrorSymbol isNil
|
|
39 |
ifTrue: [ErrorSymbol := SmaCCTerminalSymbol name: 'error'].
|
|
40 |
^ErrorSymbol
|
|
41 |
!
|
|
42 |
|
|
43 |
name: aString
|
|
44 |
^(self new)
|
|
45 |
name: aString;
|
|
46 |
yourself
|
|
47 |
!
|
|
48 |
|
|
49 |
releaseObjects
|
|
50 |
EmptySymbol := nil.
|
|
51 |
SentinelSymbol := nil
|
|
52 |
!
|
|
53 |
|
|
54 |
sentinel
|
|
55 |
SentinelSymbol isNil
|
|
56 |
ifTrue: [SentinelSymbol := SmaCCTerminalSymbol name: 'S e n t i n e l'].
|
|
57 |
^SentinelSymbol
|
|
58 |
! !
|
|
59 |
|
|
60 |
!SmaCCSymbol methodsFor:'accessing'!
|
|
61 |
|
|
62 |
calculateFirstTerminals
|
|
63 |
^self subclassResponsibility
|
|
64 |
!
|
|
65 |
|
|
66 |
createIdMethod
|
|
67 |
^false
|
|
68 |
!
|
|
69 |
|
|
70 |
firstTerminals
|
|
71 |
^firstItems
|
|
72 |
!
|
|
73 |
|
|
74 |
isEmptySymbol
|
|
75 |
^self = self class empty
|
|
76 |
!
|
|
77 |
|
|
78 |
name
|
|
79 |
^name
|
|
80 |
!
|
|
81 |
|
|
82 |
precedence
|
|
83 |
^precedence
|
|
84 |
!
|
|
85 |
|
|
86 |
precedence: anInteger
|
|
87 |
precedence := anInteger
|
|
88 |
!
|
|
89 |
|
|
90 |
productionsDo: aBlock
|
|
91 |
!
|
|
92 |
|
|
93 |
regularExpression
|
|
94 |
^nil
|
|
95 |
! !
|
|
96 |
|
|
97 |
!SmaCCSymbol methodsFor:'initialize-release'!
|
|
98 |
|
|
99 |
name: aString
|
|
100 |
name := aString.
|
|
101 |
firstItems := Set new
|
|
102 |
! !
|
|
103 |
|
|
104 |
!SmaCCSymbol methodsFor:'printing'!
|
|
105 |
|
|
106 |
printOn: aStream
|
|
107 |
aStream nextPutAll: name
|
|
108 |
! !
|
|
109 |
|
|
110 |
!SmaCCSymbol methodsFor:'public'!
|
|
111 |
|
|
112 |
isStartingSymbol
|
|
113 |
^false
|
|
114 |
!
|
|
115 |
|
|
116 |
isTerminal
|
|
117 |
^self subclassResponsibility
|
|
118 |
! !
|
|
119 |
|
|
120 |
!SmaCCSymbol class methodsFor:'documentation'!
|
|
121 |
|
|
122 |
version
|
|
123 |
^ '$Header: /opt/data/cvs/stx/goodies/smaCC/SmaCC__SmaCCSymbol.st,v 1.1 2006-02-09 21:14:28 vranyj1 Exp $'
|
15
|
124 |
!
|
|
125 |
|
|
126 |
version_SVN
|
|
127 |
^ '$Id$'
|
1
|
128 |
! !
|