ParseNodeValidator.st
author Jan Vrany <jan.vrany@labware.com>
Thu, 27 Oct 2022 14:53:59 +0100
branchjv
changeset 4735 3b11fb3ede98
parent 4384 aee25576d864
permissions -rw-r--r--
Allow single underscore as method / block argument and temporaries This commit is a follow up for 38b221e.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4384
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
     1
"
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger / eXept Software AG
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
     3
 COPYRIGHT (c) 2016 Jan Vrany
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
     4
              All Rights Reserved
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
     5
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
     6
 This software is furnished under a license and may be used
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
     7
 only in accordance with the terms of that license and with the
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
     8
 inclusion of the above copyright notice.   This software may not
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
     9
 be provided or otherwise made available to, or used by, any
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    10
 other person.  No title to or ownership of the software is
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    11
 hereby transferred.
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    12
"
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
"{ Package: 'stx:libcomp' }"
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
3841
a22f33410bdf Reduced dependencies
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2676
diff changeset
    15
"{ NameSpace: Smalltalk }"
a22f33410bdf Reduced dependencies
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2676
diff changeset
    16
2583
35296182102a Added ParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2574
diff changeset
    17
ParseNodeVisitor subclass:#ParseNodeValidator
2611
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
    18
	instanceVariableNames:'stack source'
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
	classVariableNames:''
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
	poolDictionaries:''
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
	category:'System-Compiler-Support'
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
!
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
!ParseNodeValidator class methodsFor:'documentation'!
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
4384
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    26
copyright
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    27
"
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    28
 COPYRIGHT (c) 1989 by Claus Gittinger / eXept Software AG
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    29
 COPYRIGHT (c) 2016 Jan Vrany
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    30
              All Rights Reserved
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    31
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    32
 This software is furnished under a license and may be used
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    33
 only in accordance with the terms of that license and with the
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    35
 be provided or otherwise made available to, or used by, any
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    36
 other person.  No title to or ownership of the software is
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    37
 hereby transferred.
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    38
"
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    39
!
aee25576d864 DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3841
diff changeset
    40
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
documentation
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
"
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
    A helper class used to validate parse tree, i.e. parent instvar,
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
    startPosition/endPositions. Useful only for Parser debugging/hacking.
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
    [author:]
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
        Jan Vrany <jan.vrany@fit.cvut.cz>
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
    [instance variables:]
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
    [class variables:]
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
    [see also:]
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
"
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
! !
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
!ParseNodeValidator class methodsFor:'validation'!
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
2611
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
    60
validate: aParseNode source: source
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
2611
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
    62
    ^self basicNew validate: aParseNode source: source
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
2611
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
    64
    "Created: / 27-07-2011 / 13:43:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
!
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
2622
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    67
validateClass: cls stopOnError: stopOnError
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    68
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    69
    | validate |
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    70
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    71
    validate := [:mth|
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    72
        [ 
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    73
            | src |
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    74
            src := mth source.
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    75
            self validate: (Parser parseMethod: src) tree source: src.
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    76
        ] on: Error do:[:ex|
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    77
            Transcript 
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    78
                cr;
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    79
                show: mth printString;
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    80
                show: '...FAILED!!';
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    81
                cr.                        
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    82
            stopOnError ifTrue:[
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    83
                ex pass
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    84
            ].
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    85
        ].
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    86
    ].
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    87
    cls theMetaclass methodsDo: validate.
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    88
    cls theNonMetaclass methodsDo: validate.
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    89
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    90
    "Created: / 01-08-2011 / 12:47:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    91
!
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
    92
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
validateImage
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
    self validateImage: false.
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
    "Created: / 20-07-2011 / 20:41:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
!
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
validateImage: stopOnError
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
2622
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
   102
    | i |
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
   103
    i := 0.
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
   104
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
    Smalltalk allClassesDo:[:cls|
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
        cls isLoaded ifTrue:[
2622
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
   107
            i == 50 ifTrue:[
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
   108
                Transcript cr.
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
   109
                i := 0.
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
   110
            ].
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
   111
            i := i + 1.
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
            Transcript nextPut:$..
2622
3a766e3136fa start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2611
diff changeset
   113
            self validateClass: cls stopOnError: stopOnError
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
        ].
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
    ].
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
    "Created: / 20-07-2011 / 20:42:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
! !
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
!ParseNodeValidator methodsFor:'validation'!
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   121
2611
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   122
validate: tree source: src
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
2583
35296182102a Added ParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2574
diff changeset
   124
    tree isNil ifTrue:[^self].
35296182102a Added ParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2574
diff changeset
   125
2611
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   126
    source := src.
2600
d3d8ebf7b07f - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2583
diff changeset
   127
    stack := Stack with: nil.
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
2583
35296182102a Added ParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2574
diff changeset
   129
    ^self visit: tree
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
2611
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   131
    "Created: / 27-07-2011 / 13:43:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   132
!
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   133
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   134
validateNode:node 
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   135
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   136
    self assert: node startPosition isInteger.
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   137
    self assert: node endPosition isInteger.
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   138
    self assert: node parent == stack top
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   139
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   140
    "Modified: / 27-07-2011 / 13:47:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
! !
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   142
2600
d3d8ebf7b07f - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2583
diff changeset
   143
!ParseNodeValidator methodsFor:'visiting'!
d3d8ebf7b07f - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2583
diff changeset
   144
d3d8ebf7b07f - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2583
diff changeset
   145
visit:anObject 
2611
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   146
    |accept stmt|
2600
d3d8ebf7b07f - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2583
diff changeset
   147
2611
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   148
    accept := 
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   149
            [:node | 
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   150
            stack push:node.
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   151
            node acceptVisitor:self.
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   152
            stack pop.
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   153
            self validateNode:node. ].
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   154
    ^ anObject isStatementNode 
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   155
        ifTrue:
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   156
            [ stmt := anObject.
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   157
            [ stmt isNil ] whileFalse:
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   158
                    [ accept value:stmt.
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   159
                    stmt := stmt nextStatement. ] ]
42a3145f3ff5 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2600
diff changeset
   160
        ifFalse:[ accept value:anObject. ]
2600
d3d8ebf7b07f - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2583
diff changeset
   161
d3d8ebf7b07f - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2583
diff changeset
   162
    "Created: / 25-07-2011 / 23:14:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2668
7068a6453819 added: #visitVariableNode:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2622
diff changeset
   163
!
7068a6453819 added: #visitVariableNode:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2622
diff changeset
   164
2674
8427a989cac7 added: #visitBlockNode:
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   165
visitBlockNode:anObject
8427a989cac7 added: #visitBlockNode:
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   166
8427a989cac7 added: #visitBlockNode:
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   167
    self assert: (source at: anObject startPosition) == $[.
8427a989cac7 added: #visitBlockNode:
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   168
    self assert: (source at: anObject endPosition) == $].
8427a989cac7 added: #visitBlockNode:
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   169
8427a989cac7 added: #visitBlockNode:
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   170
    super visitBlockNode: anObject.
8427a989cac7 added: #visitBlockNode:
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   171
8427a989cac7 added: #visitBlockNode:
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   172
    "Modified: / 25-07-2011 / 22:38:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8427a989cac7 added: #visitBlockNode:
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   173
    "Created: / 20-08-2011 / 23:21:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8427a989cac7 added: #visitBlockNode:
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   174
    "Created: / 21-08-2011 / 13:52:50 / cg"
8427a989cac7 added: #visitBlockNode:
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   175
!
8427a989cac7 added: #visitBlockNode:
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   176
2668
7068a6453819 added: #visitVariableNode:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2622
diff changeset
   177
visitVariableNode:anObject
7068a6453819 added: #visitVariableNode:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2622
diff changeset
   178
2676
2ede084fe2a1 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2674
diff changeset
   179
    | s e |
2ede084fe2a1 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2674
diff changeset
   180
    s := anObject startPosition.
2ede084fe2a1 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2674
diff changeset
   181
    e := anObject endPosition.
2ede084fe2a1 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2674
diff changeset
   182
    (s ~~ -1 and:[e ~~ -1 and:[                       
2ede084fe2a1 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2674
diff changeset
   183
        #(MethodVariable InstanceVariable) includes: anObject type]]) ifTrue:[
2ede084fe2a1 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2674
diff changeset
   184
            self assert: anObject name = 
2ede084fe2a1 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2674
diff changeset
   185
                (source copyFrom: anObject startPosition to: anObject endPosition).
2ede084fe2a1 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2674
diff changeset
   186
    ].
2ede084fe2a1 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2674
diff changeset
   187
2668
7068a6453819 added: #visitVariableNode:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2622
diff changeset
   188
    super visitVariableNode: anObject.
7068a6453819 added: #visitVariableNode:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2622
diff changeset
   189
7068a6453819 added: #visitVariableNode:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2622
diff changeset
   190
    "Created: / 20-08-2011 / 23:21:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2674
8427a989cac7 added: #visitBlockNode:
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   191
    "Modified: / 21-08-2011 / 13:51:55 / cg"
2676
2ede084fe2a1 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2674
diff changeset
   192
    "Modified: / 25-08-2011 / 14:03:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2600
d3d8ebf7b07f - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2583
diff changeset
   193
! !
d3d8ebf7b07f - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2583
diff changeset
   194
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   195
!ParseNodeValidator class methodsFor:'documentation'!
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   197
version
2676
2ede084fe2a1 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2674
diff changeset
   198
    ^ '$Header: /cvs/stx/stx/libcomp/ParseNodeValidator.st,v 1.8 2011-08-25 13:38:46 vrany Exp $'
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   199
!
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   200
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   201
version_CVS
2676
2ede084fe2a1 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2674
diff changeset
   202
    ^ '$Header: /cvs/stx/stx/libcomp/ParseNodeValidator.st,v 1.8 2011-08-25 13:38:46 vrany Exp $'
2574
68fb59007b8e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
! !
3841
a22f33410bdf Reduced dependencies
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2676
diff changeset
   204