compiler/PPCSequenceNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 17 Aug 2015 12:13:16 +0100
changeset 515 b5316ef15274
parent 502 1e45d3c96ec5
child 516 3b81c9e53352
permissions -rw-r--r--
Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17 Name: PetitCompiler-JanKurs.160 Author: JanKurs Time: 17-08-2015, 09:52:26.291 AM UUID: 3b4bfc98-8098-4951-af83-a59e2585b121 Name: PetitCompiler-Tests-JanKurs.112 Author: JanKurs Time: 16-08-2015, 05:00:32.936 PM UUID: 85613d47-08f3-406f-9823-9cdab451e805 Name: PetitCompiler-Extras-Tests-JanKurs.25 Author: JanKurs Time: 16-08-2015, 05:00:10.328 PM UUID: 09731810-51a1-4151-8d3a-56b636fbd1f7 Name: PetitCompiler-Benchmarks-JanKurs.17 Author: JanKurs Time: 05-08-2015, 05:29:32.407 PM UUID: e544b5f1-bcf8-470b-93a6-d2363e4dfc8a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/petitparser/compiler' }"
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
422
116d2b2af905 To fold
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 421
diff changeset
     3
"{ NameSpace: Smalltalk }"
116d2b2af905 To fold
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 421
diff changeset
     4
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
PPCListNode subclass:#PPCSequenceNode
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
	instanceVariableNames:''
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	category:'PetitCompiler-Nodes'
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
!PPCSequenceNode methodsFor:'accessing'!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    14
defaultName
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    15
    ^ #seq
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    16
!
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    17
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    18
preferredChildrenVariableNames
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    19
    "Return an array of preferred variable names of variables where to store
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    20
     particular child's result value."
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    21
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    22
    | names |
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    23
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    24
    names := self propertyAt: #preferredChildrenVariableNames ifAbsent:[ nil ].
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    25
    names notNil ifTrue:[ ^ names ].
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    26
    names := OrderedCollection new.
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    27
    self children do:[:child |  
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    28
        | id |
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    29
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    30
        id := child name notNil ifTrue:[ child name ] ifFalse:[ 'c' ].
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    31
        (names includes: id) ifTrue:[ 
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    32
            | i |
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    33
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    34
            i := 1.
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    35
            [ names includes: (id , '_' , i printString) ] whileTrue:[ 
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    36
                i := i + 1.
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    37
            ].
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    38
            id := (id , '_' , i printString).
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    39
        ].
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    40
        names add: id.
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    41
    ].                
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    42
    self propertyAt: #preferredChildrenVariableNames put: names.
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    43
    ^ names
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    44
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    45
    "Created: / 04-06-2015 / 23:08:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    46
!
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    47
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    48
preferredChildrenVariableNames: aSequenceableCollection
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    49
    "Sets an array of preferred variable names"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    50
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    51
    self propertyAt: #preferredChildrenVariableNames put: aSequenceableCollection
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    52
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    53
    "Created: / 04-06-2015 / 23:09:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    54
!
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    55
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    56
returnParsedObjectsAsCollection
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    57
    ^ self propertyAt: #returnParsedObjectsAsCollection ifAbsent:[ true ]
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    58
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    59
    "Created: / 04-06-2015 / 23:43:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    60
!
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    61
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    62
returnParsedObjectsAsCollection: aBoolean
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    63
    self propertyAt: #returnParsedObjectsAsCollection put: aBoolean
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    64
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    65
    "Created: / 04-06-2015 / 23:43:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
! !
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
!PPCSequenceNode methodsFor:'analysis'!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
acceptsEpsilon
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    71
    ^ self acceptsEpsilonOpenSet: IdentitySet new.
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
acceptsEpsilonOpenSet: set
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    75
    set add: self.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    76
    ^ self children allSatisfy: [:e | e acceptsEpsilonOpenSet: set ]
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
firstSetSuchThat: block into: aCollection openSet: aSet
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    80
    (aSet includes: self) ifTrue: [ ^ aCollection ].
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    81
    aSet add: self.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    82
    
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    83
    (block value: self) ifTrue: [ aCollection add: self. ^ aCollection ].
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    84
    
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    85
    self children do: [ :child | 
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    86
        child firstSetSuchThat: block into: aCollection openSet: aSet.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    87
        child acceptsEpsilon ifFalse: [ ^ aCollection ]
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    88
    ].
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    89
    ^ aCollection
421
7e08b31e0dae Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    90
!
7e08b31e0dae Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    91
7e08b31e0dae Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    92
firstSets: aFirstDictionary into: aSet suchThat: aBlock
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    93
    | nullable |
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    94
    
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    95
    "TODO JK: aBlock is ignored by now"
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    96
    children do: [ :node |
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    97
        nullable := false.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    98
        (aFirstDictionary at: node) do: [ :each |
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    99
            each isNullable
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   100
                ifTrue: [ nullable := true ]
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   101
                ifFalse: [ aSet add: each ] ].
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   102
        nullable
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   103
            ifFalse: [ ^ self ] ].
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   104
    aSet add: PPCSentinelNode instance
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   105
!
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   106
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   107
recognizedSentencesPrim
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   108
    | retval |
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   109
    (self children anySatisfy: [ :child | child hasFiniteLanguage not ]) ifTrue: [ ^ #() ].
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   110
    
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   111
    retval := Set with: ''.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   112
    
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   113
    self children do: [ : child |
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   114
        | set |
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   115
        set := Set new.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   116
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   117
        child recognizedSentences do: [ :suffix |
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   118
            retval do: [ :prefix |
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   119
                set add: prefix, suffix.
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   120
         				]
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   121
        ].
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   122
        retval := set.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   123
    ].
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   124
    ^ retval asArray
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
! !
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
!PPCSequenceNode methodsFor:'compiling'!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
addGuard: compiler id: id
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   130
    |  guard firsts |
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   131
    (compiler guards not or: [(guard := PPCGuard on: self) makesSense not]) ifTrue: [ ^ self].
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   133
    firsts := (self firstSetSuchThat: [ :e | (e isKindOf: PPCTrimmingTokenNode) or: [ e isTerminal ] ]).
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   134
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   135
    
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   136
    (firsts allSatisfy: [ :e | e isKindOf: PPCTrimmingTokenNode ]) ifTrue: [  
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   137
        "If we start with trimming, we should invoke the whitespace parser"
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   138
        firsts anyOne compileWhitespace: compiler.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   139
        
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   140
        compiler add: 'context atEnd ifTrue: [ ^ self error ].'.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   141
        guard id: id, '_guard'.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   142
        guard compileGuard: compiler.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   143
        compiler addOnLine: 'ifFalse: [ ^ self error ].'
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   144
    ].
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   146
    (firsts allSatisfy: [ :e | e isTerminal ]) ifTrue: [  
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   147
        compiler add: 'context atEnd ifTrue: [ ^ self error ].'.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   148
        guard id: id, '_guard'.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   149
        guard compileGuard: compiler.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   150
        compiler addOnLine: 'ifFalse: [ ^ self error ].'
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   151
    ].
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
! !
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
421
7e08b31e0dae Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
   154
!PPCSequenceNode methodsFor:'first follow next'!
7e08b31e0dae Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
   155
7e08b31e0dae Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
   156
followSets: aFollowDictionary firstSets: aFirstDictionary into: aSet suchThat: aBlock
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   157
    children keysAndValuesDo: [ :index :node |
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   158
        | follow first |
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   159
        follow := aFollowDictionary at: node.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   160
        index = children size
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   161
            ifTrue: [ follow addAll: aSet ]
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   162
            ifFalse: [
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   163
                (self class withAll: (children 
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   164
                    copyFrom: index + 1 to: children size))
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   165
                        firstSets: aFirstDictionary
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   166
                        into: (first := IdentitySet new)
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   167
                        suchThat: aBlock.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   168
                (first anySatisfy: [ :each | each isNullable ])
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   169
                    ifTrue: [ follow addAll: aSet ].
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   170
                follow addAll: (first 
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   171
                    reject: [ :each | each isNullable ]) ] ]
421
7e08b31e0dae Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
   172
! !
7e08b31e0dae Merged JK's version from Monticello
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
   173
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
   174
!PPCSequenceNode methodsFor:'testing'!
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
   175
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
   176
isSequenceNode
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
   177
    ^ true
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
   178
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
   179
    "Created: / 15-06-2015 / 18:29:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
   180
! !
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
   181
438
20598d7ce9fa Updated to PetitCompiler-JanKurs.100, PetitCompiler-Tests-JanKurs.44 and PetitCompiler-Benchmarks-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 422
diff changeset
   182
!PPCSequenceNode methodsFor:'visiting'!
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
438
20598d7ce9fa Updated to PetitCompiler-JanKurs.100, PetitCompiler-Tests-JanKurs.44 and PetitCompiler-Benchmarks-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 422
diff changeset
   184
accept: visitor
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
   185
    ^ visitor visitSequenceNode: self
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
! !
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187