compiler/PPCTokenizingConfiguration.st
changeset 532 132d7898a2a1
parent 531 dc3d13c2837d
child 534 a949c4fe44df
equal deleted inserted replaced
531:dc3d13c2837d 532:132d7898a2a1
    47 ! !
    47 ! !
    48 
    48 
    49 !PPCTokenizingConfiguration methodsFor:'error handling'!
    49 !PPCTokenizingConfiguration methodsFor:'error handling'!
    50 
    50 
    51 buildParserClazz
    51 buildParserClazz
    52     | rootMethod |
    52     self runPass: PPCTokenizingCodeGenerator.
    53 
       
    54     rootMethod := (PPCTokenizingCodeGenerator new)
       
    55             clazz:context parserClass;
       
    56             options:context options;
       
    57             visit:ir.
       
    58     context parserClass propertyAt:#rootMethod put:rootMethod
       
    59 
    53 
    60     "Modified: / 25-08-2015 / 00:07:38 / Jan Vrany <jan.vrany@fit."
    54     "Modified: / 25-08-2015 / 00:07:38 / Jan Vrany <jan.vrany@fit."
    61     "Modified: / 26-08-2015 / 19:57:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    55     "Modified: / 26-08-2015 / 22:47:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    62 !
    56 !
    63 
    57 
    64 buildScannerScans
    58 buildScannerScans
    65     | fsas  generator |
    59     | fsas  generator |
    66 
    60 
    84     "Modified: / 25-08-2015 / 00:04:43 / Jan Vrany <jan.vrany@fit."
    78     "Modified: / 25-08-2015 / 00:04:43 / Jan Vrany <jan.vrany@fit."
    85     "Modified: / 26-08-2015 / 19:57:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    79     "Modified: / 26-08-2015 / 19:57:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    86 !
    80 !
    87 
    81 
    88 buildScannerTokens
    82 buildScannerTokens
    89     | generator |
    83     self runPass: PPCTokenCodeGenerator
    90 
       
    91     generator := (PPCTokenCodeGenerator new)
       
    92             clazz:context scannerClass;
       
    93             options:context options;
       
    94             yourself.
       
    95     generator visit:ir.
       
    96 
    84 
    97     "Modified: / 25-08-2015 / 00:04:46 / Jan Vrany <jan.vrany@fit."
    85     "Modified: / 25-08-2015 / 00:04:46 / Jan Vrany <jan.vrany@fit."
    98     "Modified: / 26-08-2015 / 19:57:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    86     "Modified: / 26-08-2015 / 22:53:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    99 !
    87 !
   100 
    88 
   101 generateParser
    89 generateParser
   102     | parserClass  rootMethod |
    90     | parserClass  rootMethod |
   103 
    91 
   145     "Modified: / 25-08-2015 / 00:07:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   133     "Modified: / 25-08-2015 / 00:07:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   146 !
   134 !
   147 
   135 
   148 createLL1Choices
   136 createLL1Choices
   149     self flag:'This phase needs revisit and update'.
   137     self flag:'This phase needs revisit and update'.
   150     ir := (PPCLL1Visitor new)
   138     self runPass: PPCLL1Visitor
   151             options:context options;
   139 
   152             visit:ir.
   140     "Modified: / 26-08-2015 / 22:52:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   153     self remember:(self copyTree:ir) as:#LL1
       
   154 !
   141 !
   155 
   142 
   156 tokenize
   143 tokenize
   157     "
   144     "
   158         This will try transform the parser into the tokenizing parser"
   145         This will try transform the parser into the tokenizing parser"
   159     
   146     
   160     context options tokenize ifFalse:[
   147     context options tokenize ifFalse:[
   161         ^ self
   148         ^ self
   162     ].
   149     ].
   163     ir := (PPCTokenizingVisitor new)
   150     self runPass: PPCTokenizingVisitor
   164             options:context options;
   151 
   165             visit:ir.
   152     "Modified: / 26-08-2015 / 22:48:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   166     self remember:(self copyTree:ir) as:#tokenize
       
   167 !
   153 !
   168 
   154 
   169 unmarkConsumeTokensForInline
   155 unmarkConsumeTokensForInline
   170     "TODO JK: Hack alert, use visitor, or at leas isTokenConsume"
   156     "TODO JK: Hack alert, use visitor, or at leas isTokenConsume"
   171     ir allNodesDo: [ :node |
   157     ir allNodesDo: [ :node |