compiler/PPCCompilationContext.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 07 Sep 2015 11:53:38 +0100
changeset 538 16e8536f5cfb
parent 537 fb212e14d1f4
permissions -rw-r--r--
PPCConfiguration refactoring: [10/10]: Cleaned up compilation API The main compilation method is now PPParser>>compileWithOptions: Removed oither old and unused compilation methods from PPParser and other PetitCompiler classes.
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
538
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    32
options:optionsOrOptionArray
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    33
    "Set options used for compilation. 
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    34
     `optionsOrOptionArray` may be either an instance of
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    35
     PPCCompilationOptions or and array specifing options.
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    36
     See PPCCompilationOptions class>>from: for details."
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    37
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    38
    optionsOrOptionArray isSequenceable ifTrue:[ 
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    39
        options := PPCCompilationOptions from: optionsOrOptionArray
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    40
    ] ifFalse:[
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    41
        options := optionsOrOptionArray.
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    42
    ]
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    43
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    44
    "Modified: / 07-09-2015 / 10:42:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
531
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    45
!
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    46
530
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
parserClass
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
    "Return parser 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
    parserClass isNil ifTrue:[
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
        parserClass := PPCClass new.
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
    ].
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
    ^ parserClass
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
    "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
    56
!
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
scannerClass
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
    "Return scanner class as PPCClass"
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
    scannerClass isNil ifTrue:[
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
        scannerClass := PPCClass new.
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
        "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
    64
         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
    65
         for tokens."
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
        scannerClass idGen: self parserClass idGen
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
    ].
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
    ^ scannerClass
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
    "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
    71
! !
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
531
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    73
!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
    74
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    75
initialize
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    76
    "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
    77
538
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    78
    options := PPCCompilationOptions new.
531
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    79
538
16e8536f5cfb PPCConfiguration refactoring: [10/10]: Cleaned up compilation API
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 537
diff changeset
    80
    "Modified: / 07-09-2015 / 10:22:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
531
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    81
! !
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    82