compiler/PPCCompilationContext.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 07 Sep 2015 08:20:46 +0100
changeset 537 fb212e14d1f4
parent 534 a949c4fe44df
child 538 16e8536f5cfb
permissions -rw-r--r--
PPCConfiguration refactoring: [9/10]: Renamed PPCConfiguration to PPCCompiler.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
530
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/petitparser/compiler' }"
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Smalltalk }"
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
Object subclass:#PPCCompilationContext
537
fb212e14d1f4 PPCConfiguration refactoring: [9/10]: Renamed PPCConfiguration to PPCCompiler.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 534
diff changeset
     6
	instanceVariableNames:'options compiler parserClass scannerClass'
530
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	category:'PetitCompiler-Core'
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
!PPCCompilationContext class methodsFor:'instance creation'!
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
new
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
    "return an initialized instance"
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
    ^ self basicNew initialize.
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
! !
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
!PPCCompilationContext methodsFor:'accessing'!
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
534
a949c4fe44df PPCConfiguration refactoring: [6/10]: use #runPass: instead of self-sends.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 533
diff changeset
    22
idGenerator
a949c4fe44df PPCConfiguration refactoring: [6/10]: use #runPass: instead of self-sends.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 533
diff changeset
    23
    ^ self parserClass idGen
a949c4fe44df PPCConfiguration refactoring: [6/10]: use #runPass: instead of self-sends.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 533
diff changeset
    24
a949c4fe44df PPCConfiguration refactoring: [6/10]: use #runPass: instead of self-sends.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 533
diff changeset
    25
    "Created: / 03-09-2015 / 21:27:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
a949c4fe44df PPCConfiguration refactoring: [6/10]: use #runPass: instead of self-sends.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 533
diff changeset
    26
!
a949c4fe44df PPCConfiguration refactoring: [6/10]: use #runPass: instead of self-sends.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 533
diff changeset
    27
531
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    28
options
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    29
    ^ options
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    30
!
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    31
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    32
options:aPPCCompilationOptions
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    33
    options := aPPCCompilationOptions.
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    34
!
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    35
530
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
parserClass
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
    "Return parser class as PPCClass"
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
    parserClass isNil ifTrue:[
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
        parserClass := PPCClass new.
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
    ].
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
    ^ parserClass
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
    "Created: / 24-08-2015 / 23:58:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
!
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
scannerClass
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
    "Return scanner class as PPCClass"
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
    scannerClass isNil ifTrue:[
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
        scannerClass := PPCClass new.
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
        "Both parser class and scanner class must share the
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
         same ID generator in order to to use same names 
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
         for tokens."
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
        scannerClass idGen: self parserClass idGen
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
    ].
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
    ^ scannerClass
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
    "Created: / 24-08-2015 / 23:59:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
! !
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
531
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    62
!PPCCompilationContext methodsFor:'initialization'!
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    63
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    64
initialize
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    65
    "Invoked when a new instance is created."
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    66
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    67
    options := PPCCompilationOptions default.
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    68
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    69
    "Modified: / 26-08-2015 / 19:49:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    70
! !
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    71