author | vranyj1 |
Wed, 24 Feb 2016 12:12:00 +0000 | |
changeset 25 | 5a6921729520 |
parent 15 | 8b8cd1701c33 |
permissions | -rw-r--r-- |
1 | 1 |
"{ Package: 'stx:goodies/smaCC' }" |
2 |
||
3 |
"{ NameSpace: SmaCC }" |
|
4 |
||
5 |
SmaCCSymbol subclass:#SmaCCNonTerminalSymbol |
|
6 |
instanceVariableNames:'productions' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'SmaCC-Parser Generator' |
|
10 |
! |
|
11 |
||
12 |
SmaCCNonTerminalSymbol comment:'SmaCCNonTerminalSymbol represents a non-terminal symbol in our grammar. |
|
13 |
||
14 |
Instance Variables: |
|
15 |
productions <SequenceableCollection of: SmaCCRHS> our rhs'' for the symbol' |
|
16 |
! |
|
17 |
||
18 |
||
19 |
!SmaCCNonTerminalSymbol methodsFor:'accessing'! |
|
20 |
||
21 |
addProduction: aRHS |
|
22 |
productions add: aRHS |
|
23 |
! |
|
24 |
||
25 |
calculateFirstTerminals |
|
26 |
| initialSize | |
|
27 |
initialSize := firstItems size. |
|
28 |
productions isEmpty |
|
29 |
ifTrue: [firstItems add: self class empty] |
|
30 |
ifFalse: [productions do: [:each | firstItems addAll: each firstTerminals]]. |
|
31 |
^initialSize ~= firstItems size |
|
32 |
! |
|
33 |
||
25
5a6921729520
UI improvements: added menu items to show FIRST() and LAST() sets for non-terminal symbols.
vranyj1
parents:
15
diff
changeset
|
34 |
calculateLastTerminals |
5a6921729520
UI improvements: added menu items to show FIRST() and LAST() sets for non-terminal symbols.
vranyj1
parents:
15
diff
changeset
|
35 |
| initialSize | |
5a6921729520
UI improvements: added menu items to show FIRST() and LAST() sets for non-terminal symbols.
vranyj1
parents:
15
diff
changeset
|
36 |
initialSize := lastItems size. |
5a6921729520
UI improvements: added menu items to show FIRST() and LAST() sets for non-terminal symbols.
vranyj1
parents:
15
diff
changeset
|
37 |
productions isEmpty |
5a6921729520
UI improvements: added menu items to show FIRST() and LAST() sets for non-terminal symbols.
vranyj1
parents:
15
diff
changeset
|
38 |
ifTrue: [lastItems add: self class empty] |
5a6921729520
UI improvements: added menu items to show FIRST() and LAST() sets for non-terminal symbols.
vranyj1
parents:
15
diff
changeset
|
39 |
ifFalse: [productions do: [:each | lastItems addAll: each lastTerminals]]. |
5a6921729520
UI improvements: added menu items to show FIRST() and LAST() sets for non-terminal symbols.
vranyj1
parents:
15
diff
changeset
|
40 |
^initialSize ~= lastItems size |
5a6921729520
UI improvements: added menu items to show FIRST() and LAST() sets for non-terminal symbols.
vranyj1
parents:
15
diff
changeset
|
41 |
|
5a6921729520
UI improvements: added menu items to show FIRST() and LAST() sets for non-terminal symbols.
vranyj1
parents:
15
diff
changeset
|
42 |
"Created: / 24-02-2016 / 09:39:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
5a6921729520
UI improvements: added menu items to show FIRST() and LAST() sets for non-terminal symbols.
vranyj1
parents:
15
diff
changeset
|
43 |
! |
5a6921729520
UI improvements: added menu items to show FIRST() and LAST() sets for non-terminal symbols.
vranyj1
parents:
15
diff
changeset
|
44 |
|
1 | 45 |
positionOf: aRHS |
46 |
^productions indexOf: aRHS |
|
47 |
! |
|
48 |
||
49 |
productionsDo: aBlock |
|
50 |
productions do: aBlock |
|
51 |
! |
|
52 |
||
53 |
size |
|
54 |
^productions size |
|
55 |
! ! |
|
56 |
||
57 |
!SmaCCNonTerminalSymbol methodsFor:'initialize-release'! |
|
58 |
||
59 |
name: aString |
|
60 |
super name: aString. |
|
61 |
productions := OrderedCollection new |
|
62 |
! ! |
|
63 |
||
64 |
!SmaCCNonTerminalSymbol methodsFor:'public'! |
|
65 |
||
66 |
isEmpty |
|
67 |
^productions isEmpty |
|
68 |
! |
|
69 |
||
70 |
isTerminal |
|
71 |
^false |
|
72 |
! ! |
|
73 |
||
74 |
!SmaCCNonTerminalSymbol class methodsFor:'documentation'! |
|
75 |
||
76 |
version |
|
25
5a6921729520
UI improvements: added menu items to show FIRST() and LAST() sets for non-terminal symbols.
vranyj1
parents:
15
diff
changeset
|
77 |
^ '$Id$' |
15 | 78 |
! |
79 |
||
80 |
version_SVN |
|
81 |
^ '$Id$' |
|
1 | 82 |
! ! |
25
5a6921729520
UI improvements: added menu items to show FIRST() and LAST() sets for non-terminal symbols.
vranyj1
parents:
15
diff
changeset
|
83 |