compiler/PPCCompilationOptions.st
changeset 533 666372dbe307
parent 529 439c4057517f
child 534 a949c4fe44df
--- a/compiler/PPCCompilationOptions.st	Wed Aug 26 23:01:00 2015 +0100
+++ b/compiler/PPCCompilationOptions.st	Wed Aug 26 23:34:48 2015 +0100
@@ -21,7 +21,98 @@
         yourself
 ! !
 
-!PPCCompilationOptions methodsFor:'accessing'!
+!PPCCompilationOptions methodsFor:'initialization'!
+
+initialize
+    super initialize.
+    options := IdentityDictionary new
+! !
+
+!PPCCompilationOptions methodsFor:'options'!
+
+mode
+    ^ self at: #mode ifAbsent: #JIT
+
+    "Created: / 26-08-2015 / 23:18:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+mode: mode
+    "Set the compilation mode - valid values are #JIT or #AOT.
+
+     #JIT mode put less constraints on the original pure PetitParser
+       parser (such as action blocks are not required to be purely functional,
+       support mixing of compiled parsing code with custom PPParsers and so on).
+       However, JIT-compiled parser class SHOULD NOT be commited into the
+       repository - it won't work when loaded back. 
+
+     #AOT mode allows for parser to be pre-compiled and generated code
+       to be commited to repository. Thus, the deployed application don't need
+       to contain full PetitCompiler. However, this is at cost of more contraints
+       being put on the original Petit Parser. In other words, not all PetitParser
+       parser may be compiled in AOT mode.
+       WARNING: #AOT mode is not yet fully supported, do not use!!
+    "
+
+    (#(JIT AOT) includes: mode) ifFalse:[ 
+        PPCCompilationError new signal: 'Invalid mode: option value - must be either #JIT or #AOT'.
+    ].
+    mode == #AOT ifTrue:[ 
+        PPCCompilationWarning new signal: '#AOT mode not yet supported'.
+    ].
+    self at: #mode put: mode
+
+    "Created: / 26-08-2015 / 23:07:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parserName
+    ^ self at: #parserName ifAbsent: #PPGeneratedParser
+
+    "Modified (format): / 26-08-2015 / 23:04:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parserName: aSymbol
+    "Sets the name of the generated parser class.
+     Defaults to #PPGeneratedParser."
+
+    self set: #parserName to: aSymbol.
+
+    "Modified (comment): / 26-08-2015 / 23:05:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+scannerName
+    ^ self at: #scannerName ifAbsent: #PPGeneratedScanner
+!
+
+scannerName: value
+    "Sets the name of the generated parser class.
+     Defaults to #PPGeneratedScanner."    
+
+    self set: #scannerName to: value.
+
+    "Modified (comment): / 26-08-2015 / 23:06:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+tokenize
+    ^ self at: #tokenize ifAbsent: true
+!
+
+tokenize: aBoolean
+    "Build tokenizing parser, i.e., build scanner that tokenizes the input and then
+     parser consuming tokens produced by scanner.
+
+     Tokenizing parser more resemble hand-written top-down parser and
+     makes hand-tuning of the parser / scanner easier. However, not all
+     PetitParsers may be tokenized.
+
+     Default value is true. If the compilation fails, try to set it to
+     false
+    "    
+    self set: #tokenize to: aBoolean.
+
+    "Modified (comment): / 26-08-2015 / 23:24:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!PPCCompilationOptions methodsFor:'options - undocumented (do not use)'!
 
 cacheFirstFollow
     ^ self at: #cacheFirstFollow ifAbsent: true
@@ -31,15 +122,6 @@
     self set: #cacheFirstFollow to: value.
 !
 
-codeGenerator
-    self error: 'deprecated?'.
-    ^ self at: #codeGenerator ifAbsent: PPCCodeGenerator
-!
-
-codeGenerator: value
-    self set: #codeGenerator to: value.
-!
-
 debug
     ^ self at: #debug ifAbsent: true
 !
@@ -88,14 +170,6 @@
     self set: #merge to: value.
 !
 
-parserName
-    ^ self at: #parserName ifAbsent: #PPGeneratedParser 
-!
-
-parserName: value
-    self set: #parserName to: value.
-!
-
 parserSuperclass
     ^ self at: #parserSuperclass ifAbsent: PPTokenizingCompiledParser
 !
@@ -120,14 +194,6 @@
     self set: #recognizingComponents to: value.
 !
 
-scannerName
-    ^ self at: #scannerName ifAbsent: #PPGeneratedScanner
-!
-
-scannerName: value
-    self set: #scannerName to: value.
-!
-
 scannerSuperclass
     ^ self at: #scannerSuperclass ifAbsent: PPCDistinctScanner
 !
@@ -142,21 +208,6 @@
 
 specialize: value
     self set: #specialize to: value.
-!
-
-tokenize
-    ^ self at: #tokenize ifAbsent: true
-!
-
-tokenize: value
-    self set: #tokenize to: value.
-! !
-
-!PPCCompilationOptions methodsFor:'initialization'!
-
-initialize
-    super initialize.
-    options := IdentityDictionary new
 ! !
 
 !PPCCompilationOptions methodsFor:'private'!