compiler/PPCCompilationContext.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 26 Aug 2015 23:34:48 +0100
changeset 533 666372dbe307
parent 531 dc3d13c2837d
child 534 a949c4fe44df
permissions -rw-r--r--
PPCConfiguration refactoring: [5/10]: Commented options in PPCCompilationOptions. So it's more clear for what the option is and how to use it. This is a base for user-documentation as options are meant to be set by the end user.
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
533
666372dbe307 PPCConfiguration refactoring: [5/10]: Commented options in PPCCompilationOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 531
diff changeset
     6
	instanceVariableNames:'options configuration 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
531
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    22
options
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    23
    ^ options
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    24
!
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    25
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    26
options:aPPCCompilationOptions
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    27
    options := aPPCCompilationOptions.
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    28
!
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    29
530
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
parserClass
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
    "Return parser class as PPCClass"
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
    parserClass isNil ifTrue:[
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
        parserClass := PPCClass new.
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
    ].
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
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
    "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
    39
!
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
scannerClass
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
    "Return scanner class as PPCClass"
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
    scannerClass isNil ifTrue:[
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
        scannerClass := PPCClass new.
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
        "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
    47
         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
    48
         for tokens."
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
        scannerClass idGen: self parserClass idGen
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
    ].
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
    ^ scannerClass
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
    "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
    54
! !
e36906742693 PPCConfiguration refactoring: [2/10]: introduced PPCCompilationContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
531
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    56
!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
    57
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    58
initialize
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    59
    "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
    60
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    61
    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
    62
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    63
    "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
    64
! !
dc3d13c2837d PPCConfiguration refactoring: [3/10]: Moved some sime instvars to context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 530
diff changeset
    65