packages feed

SableCC2Hs 0.0.0.1 → 0.0.0.2

raw patch · 12 files changed

+349/−1223 lines, 12 filesnew-component:exe:sable2hsPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- SableCC.ParserTypes: ASTLeaf :: PToken -> AST
- SableCC.ParserTypes: ASTList :: [AST] -> AST
- SableCC.ParserTypes: ASTNode :: String -> [AST] -> AST
- SableCC.ParserTypes: data AST
- SableCC.ParserTypes: instance Show AST
- SableCC.ParserTypes: type Input = [PToken]
- SableCC.ParserTypes: type PState = (Stack, Input)
- SableCC.ParserTypes: type Stack = [(ParserStateID, CST)]
- SableCC.ParserTypes: unASTList :: AST -> [AST]
- SableCC.ParserTypes: LexerState :: ModeID -> String -> () -> Int -> LexerState
+ SableCC.ParserTypes: LexerState :: ModeID -> String -> () -> !Int -> LexerState
- SableCC.ParserTypes: commentNestingCounter :: LexerState -> Int
+ SableCC.ParserTypes: commentNestingCounter :: LexerState -> !Int

Files

SableCC2Hs.cabal view
@@ -1,5 +1,5 @@ Name:                SableCC2Hs-Version:             0.0.0.1+Version:             0.0.0.2  Synopsis:            Generate a parser (in Haskell) with the SableCC parser generator. Description:@@ -36,7 +36,7 @@   prolog/parser.pl   prolog/trim_ast.pl -Executable sableToHs+Executable sable2hs   Build-Depends:      base >= 4.0 && < 5.0     ,containers >= 0.4 && < 0.5
haskell/MakeUntypedAST.hs view
@@ -1750,979 +1750,4 @@     \[nodeArrayList8,nodeArrayList7,nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] ->          ( ASTNode             ("son")-            ([ nodeArrayList3, nodeArrayList5, nodeArrayList7 ])-        ),-    -- rule : 259 ASubtreeExpressionKeyword-    \[nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("subtree")-            ([ nodeArrayList3, nodeArrayList5 ])-        ),-    -- rule : 260 AArityExpressionKeyword-    \[nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("arity")-            ([ nodeArrayList3, nodeArrayList5 ])-        ),-    -- rule : 261 ABin1ExpressionKeyword-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("bin")-            ([ nodeArrayList3 ])-        ),-    -- rule : 262 ABin2ExpressionKeyword-    \[nodeArrayList8,nodeArrayList7,nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("bin")-            ([ nodeArrayList3, nodeArrayList5, nodeArrayList7 ])-        ),-    -- rule : 263 ALeftExpressionKeyword-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("left")-            ([ nodeArrayList3 ])-        ),-    -- rule : 264 ARightExpressionKeyword-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("right")-            ([ nodeArrayList3 ])-        ),-    -- rule : 265 AInfixExpressionKeyword-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("infix")-            ([ nodeArrayList3 ])-        ),-    -- rule : 266 AStructExpressionKeyword-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("struct")-            ([ ( head-                   (( unASTList-                        (nodeArrayList3)-                    ))-               ) ])-        ),-    -- rule : 267 ARecExpressionKeyword-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("rec")-            ([ ( head-                   (( unASTList-                        (nodeArrayList3)-                    ))-               ) ])-        ),-    -- rule : 268 ARecordFieldExpressionKeyword-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("record_field")-            ([ nodeArrayList1, nodeArrayList3 ])-        ),-    -- rule : 269 ANextLevelExpressionKeyword-    \[nodeArrayList1] -> -        nodeArrayList1,-    -- rule : 270 ARecEntry-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("rec_entry")-            ([ nodeArrayList1, nodeArrayList3 ])-        ),-    -- rule : 271 ASingleRecEntryList-    \[nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   ([ nodeArrayList1 ])-               ) ])-        ),-    -- rule : 272 AMultiRecEntryList-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList1)-                                   ))-                              ))-                         ))-                        ([ nodeArrayList3 ])-                    ))-               ) ])-        ),-    -- rule : 273 AFunctionExpressionFunc-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("function")-            ([ nodeArrayList1, ( head-                                   (( unASTList-                                        (nodeArrayList3)-                                    ))-                               ) ])-        ),-    -- rule : 274 ANextLevelExpressionFunc-    \[nodeArrayList1] -> -        nodeArrayList1,-    -- rule : 275 AParenExpressionAtomic-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        nodeArrayList2,-    -- rule : 276 AIdentifierExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("identifier")-            ([ ( head-                   (( unASTList-                        (nodeArrayList1)-                    ))-               ) ])-        ),-    -- rule : 277 APrimedIdentifierExpressionAtomic-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("primed_identifier")-            ([ ( head-                   (( unASTList-                        (nodeArrayList1)-                    ))-               ), nodeArrayList3 ])-        ),-    -- rule : 278 AAstringexpressionatomic1ExpressionAtomic-    \[nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("string")-            ([ ])-        ),-    -- rule : 279 AAstringexpressionatomic2ExpressionAtomic-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("string")-            ([ nodeArrayList2 ])-        ),-    -- rule : 280 ATrueExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("true")-            ([ ])-        ),-    -- rule : 281 AFalseExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("false")-            ([ ])-        ),-    -- rule : 282 ASuccessorExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("successor")-            ([ ])-        ),-    -- rule : 283 APredecessorExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("predecessor")-            ([ ])-        ),-    -- rule : 284 AIntegerExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("integer")-            ([ nodeArrayList1 ])-        ),-    -- rule : 285 AMaxIntExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("max_int")-            ([ ])-        ),-    -- rule : 286 AMinIntExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("min_int")-            ([ ])-        ),-    -- rule : 287 AEmptySetExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("empty_set")-            ([ ])-        ),-    -- rule : 288 AIntegerSetExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("integer_set")-            ([ ])-        ),-    -- rule : 289 ANaturalSetExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("natural_set")-            ([ ])-        ),-    -- rule : 290 ANatural1SetExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("natural1_set")-            ([ ])-        ),-    -- rule : 291 ANatSetExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("nat_set")-            ([ ])-        ),-    -- rule : 292 ANat1SetExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("nat1_set")-            ([ ])-        ),-    -- rule : 293 AIntSetExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("int_set")-            ([ ])-        ),-    -- rule : 294 ABoolSetExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("bool_set")-            ([ ])-        ),-    -- rule : 295 AStringSetExpressionAtomic-    \[nodeArrayList1] -> -        ( ASTNode-            ("string_set")-            ([ ])-        ),-    -- rule : 296 ASingleExpressionList-    \[nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   ([ nodeArrayList1 ])-               ) ])-        ),-    -- rule : 297 AMultipleExpressionList-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList1)-                                   ))-                              ))-                         ))-                        ([ nodeArrayList3 ])-                    ))-               ) ])-        ),-    -- rule : 298 AAsequencesubstitutionl11SubstitutionL1-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("sequence")-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( ASTList-                                  ([ nodeArrayList1 ])-                              ))-                         ))-                        ([ nodeArrayList3 ])-                    ))-               ) ])-        ),-    -- rule : 299 AAsequencesubstitutionl12SubstitutionL1-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("sequence")-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( ASTList-                                  (( (++)-                                       (( unASTList-                                            (( ASTList-                                                 ([ nodeArrayList1 ])-                                             ))-                                        ))-                                       ([ nodeArrayList3 ])-                                   ))-                              ))-                         ))-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList4)-                                   ))-                              ))-                         ))-                    ))-               ) ])-        ),-    -- rule : 300 ANextLevelSubstitutionL1-    \[nodeArrayList1] -> -        nodeArrayList1,-    -- rule : 301 AAparallelsubstitutionl21SubstitutionL2-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("parallel")-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( ASTList-                                  ([ nodeArrayList1 ])-                              ))-                         ))-                        ([ nodeArrayList3 ])-                    ))-               ) ])-        ),-    -- rule : 302 AAparallelsubstitutionl22SubstitutionL2-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("parallel")-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( ASTList-                                  (( (++)-                                       (( unASTList-                                            (( ASTList-                                                 ([ nodeArrayList1 ])-                                             ))-                                        ))-                                       ([ nodeArrayList3 ])-                                   ))-                              ))-                         ))-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList4)-                                   ))-                              ))-                         ))-                    ))-               ) ])-        ),-    -- rule : 303 ANextLevelSubstitutionL2-    \[nodeArrayList1] -> -        nodeArrayList1,-    -- rule : 304 ABlockSubstitutionL3-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("block")-            ([ nodeArrayList2 ])-        ),-    -- rule : 305 ASkipSubstitutionL3-    \[nodeArrayList1] -> -        ( ASTNode-            ("skip")-            ([ ])-        ),-    -- rule : 306 AAssignSubstitutionL3-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("assign")-            ([ ( head-                   (( unASTList-                        (nodeArrayList1)-                    ))-               ), ( head-                      (( unASTList-                           (nodeArrayList3)-                       ))-                  ) ])-        ),-    -- rule : 307 APreconditionSubstitutionL3-    \[nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("precondition")-            ([ nodeArrayList2, nodeArrayList4 ])-        ),-    -- rule : 308 AAssertionSubstitutionL3-    \[nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("assertion")-            ([ nodeArrayList2, nodeArrayList4 ])-        ),-    -- rule : 309 AAchoicesubstitutionl31SubstitutionL3-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("choice")-            ([ ( ASTList-                   ([ nodeArrayList2 ])-               ) ])-        ),-    -- rule : 310 AAchoicesubstitutionl32SubstitutionL3-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("choice")-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( ASTList-                                  ([ nodeArrayList2 ])-                              ))-                         ))-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList3)-                                   ))-                              ))-                         ))-                    ))-               ) ])-        ),-    -- rule : 311 AAifsubstitutionl31SubstitutionL3-    \[nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("if")-            ([ nodeArrayList2, nodeArrayList4, ASTList [] ])-        ),-    -- rule : 312 AAifsubstitutionl32SubstitutionL3-    \[nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("if")-            ([ nodeArrayList2, nodeArrayList4, ( head-                                                   (( unASTList-                                                        (nodeArrayList5)-                                                    ))-                                               ) ])-        ),-    -- rule : 313 AAifsubstitutionl33SubstitutionL3-    \[nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("if")-            ([ nodeArrayList2, nodeArrayList4, ASTList [], nodeArrayList5 ])-        ),-    -- rule : 314 AAifsubstitutionl34SubstitutionL3-    \[nodeArrayList7,nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("if")-            ([ nodeArrayList2, nodeArrayList4, ( head-                                                   (( unASTList-                                                        (nodeArrayList5)-                                                    ))-                                               ), nodeArrayList6 ])-        ),-    -- rule : 315 AAselectsubstitutionl31SubstitutionL3-    \[nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("select")-            ([ nodeArrayList2, nodeArrayList4, ASTList [] ])-        ),-    -- rule : 316 AAselectsubstitutionl32SubstitutionL3-    \[nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("select")-            ([ nodeArrayList2, nodeArrayList4, ( head-                                                   (( unASTList-                                                        (nodeArrayList5)-                                                    ))-                                               ) ])-        ),-    -- rule : 317 AAselectsubstitutionl33SubstitutionL3-    \[nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("select")-            ([ nodeArrayList2, nodeArrayList4, ASTList [], nodeArrayList5 ])-        ),-    -- rule : 318 AAselectsubstitutionl34SubstitutionL3-    \[nodeArrayList7,nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("select")-            ([ nodeArrayList2, nodeArrayList4, ( head-                                                   (( unASTList-                                                        (nodeArrayList5)-                                                    ))-                                               ), nodeArrayList6 ])-        ),-    -- rule : 319 AAcasesubstitutionl31SubstitutionL3-    \[nodeArrayList9,nodeArrayList8,nodeArrayList7,nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("case")-            ([ nodeArrayList2, ( head-                                   (( unASTList-                                        (nodeArrayList5)-                                    ))-                               ), nodeArrayList7, ASTList [] ])-        ),-    -- rule : 320 AAcasesubstitutionl32SubstitutionL3-    \[nodeArrayList10,nodeArrayList9,nodeArrayList8,nodeArrayList7,nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("case")-            ([ nodeArrayList2, ( head-                                   (( unASTList-                                        (nodeArrayList5)-                                    ))-                               ), nodeArrayList7, ( head-                                                      (( unASTList-                                                           (nodeArrayList8)-                                                       ))-                                                  ) ])-        ),-    -- rule : 321 AAcasesubstitutionl33SubstitutionL3-    \[nodeArrayList10,nodeArrayList9,nodeArrayList8,nodeArrayList7,nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("case")-            ([ nodeArrayList2, ( head-                                   (( unASTList-                                        (nodeArrayList5)-                                    ))-                               ), nodeArrayList7, ASTList [], nodeArrayList8 ])-        ),-    -- rule : 322 AAcasesubstitutionl34SubstitutionL3-    \[nodeArrayList11,nodeArrayList10,nodeArrayList9,nodeArrayList8,nodeArrayList7,nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("case")-            ([ nodeArrayList2, ( head-                                   (( unASTList-                                        (nodeArrayList5)-                                    ))-                               ), nodeArrayList7, ( head-                                                      (( unASTList-                                                           (nodeArrayList8)-                                                       ))-                                                  ), nodeArrayList9 ])-        ),-    -- rule : 323 AAnySubstitutionL3-    \[nodeArrayList7,nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("any")-            ([ ( head-                   (( unASTList-                        (nodeArrayList2)-                    ))-               ), nodeArrayList4, nodeArrayList6 ])-        ),-    -- rule : 324 ABecomesElementOfSubstitutionL3-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("becomes_element_of")-            ([ ( head-                   (( unASTList-                        (nodeArrayList1)-                    ))-               ), nodeArrayList3 ])-        ),-    -- rule : 325 ABecomesSuchSubstitutionL3-    \[nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("becomes_such")-            ([ ( head-                   (( unASTList-                        (nodeArrayList1)-                    ))-               ), nodeArrayList4 ])-        ),-    -- rule : 326 AVarSubstitutionL3-    \[nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("var")-            ([ ( head-                   (( unASTList-                        (nodeArrayList2)-                    ))-               ), nodeArrayList4 ])-        ),-    -- rule : 327 AFuncOpSubstitutionL3-    \[nodeArrayList1] -> -        ( ASTNode-            ("func_op")-            ([ nodeArrayList1 ])-        ),-    -- rule : 328 AAopwithreturnsubstitutionl31SubstitutionL3-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("op_with_return")-            ([ ( head-                   (( unASTList-                        (nodeArrayList1)-                    ))-               ), ( head-                      (( unASTList-                           (nodeArrayList3)-                       ))-                  ), ASTList [] ])-        ),-    -- rule : 329 AAopwithreturnsubstitutionl32SubstitutionL3-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("op_with_return")-            ([ ( head-                   (( unASTList-                        (nodeArrayList1)-                    ))-               ), ( head-                      (( unASTList-                           (nodeArrayList3)-                       ))-                  ), ( head-                         (( unASTList-                              (nodeArrayList4)-                          ))-                     ) ])-        ),-    -- rule : 330 AWhileSubstitutionL3-    \[nodeArrayList9,nodeArrayList8,nodeArrayList7,nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("while")-            ([ nodeArrayList2, nodeArrayList4, nodeArrayList6, nodeArrayList8 ])-        ),-    -- rule : 331 ALetSubstitutionL3-    \[nodeArrayList7,nodeArrayList6,nodeArrayList5,nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("let")-            ([ ( head-                   (( unASTList-                        (nodeArrayList2)-                    ))-               ), nodeArrayList4, nodeArrayList6 ])-        ),-    -- rule : 332 AAdefinitionsubstitutionl31SubstitutionL3-    \[nodeArrayList1] -> -        ( ASTNode-            ("definition")-            ([ nodeArrayList1, ASTList [] ])-        ),-    -- rule : 333 AAdefinitionsubstitutionl32SubstitutionL3-    \[nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("definition")-            ([ nodeArrayList1, ( head-                                   (( unASTList-                                        (nodeArrayList2)-                                    ))-                               ) ])-        ),-    -- rule : 334 ASingleParallelSubstTail-    \[nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   ([ nodeArrayList2 ])-               ) ])-        ),-    -- rule : 335 AMultiParallelSubstTail-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( ASTList-                                  ([ nodeArrayList2 ])-                              ))-                         ))-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList3)-                                   ))-                              ))-                         ))-                    ))-               ) ])-        ),-    -- rule : 336 ASingleSequenceSubstTail-    \[nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   ([ nodeArrayList2 ])-               ) ])-        ),-    -- rule : 337 AMultiSequenceSubstTail-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( ASTList-                                  ([ nodeArrayList2 ])-                              ))-                         ))-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList3)-                                   ))-                              ))-                         ))-                    ))-               ) ])-        ),-    -- rule : 338 AChoiceOr-    \[nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("choice_or")-            ([ nodeArrayList2 ])-        ),-    -- rule : 339 AIfElsif-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("if_elsif")-            ([ nodeArrayList2, nodeArrayList4 ])-        ),-    -- rule : 340 AIfElse-    \[nodeArrayList2,nodeArrayList1] -> -        nodeArrayList2,-    -- rule : 341 ASelectWhen-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("select_when")-            ([ nodeArrayList2, nodeArrayList4 ])-        ),-    -- rule : 342 ASelectElse-    \[nodeArrayList2,nodeArrayList1] -> -        nodeArrayList2,-    -- rule : 343 ACaseOr-    \[nodeArrayList4,nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("case_or")-            ([ ( head-                   (( unASTList-                        (nodeArrayList2)-                    ))-               ), nodeArrayList4 ])-        ),-    -- rule : 344 ACaseElse-    \[nodeArrayList2,nodeArrayList1] -> -        nodeArrayList2,-    -- rule : 345 AOpParams-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( head-                   (( unASTList-                        (nodeArrayList2)-                    ))-               ) ])-        ),-    -- rule : 346 ASingleComposedIdentifier-    \[nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   ([ nodeArrayList1 ])-               ) ])-        ),-    -- rule : 347 AMultiComposedIdentifier-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList1)-                                   ))-                              ))-                         ))-                        ([ nodeArrayList3 ])-                    ))-               ) ])-        ),-    -- rule : 348 ASingleIdentifierList-    \[nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   ([ nodeArrayList1 ])-               ) ])-        ),-    -- rule : 349 AMultiIdentifierList-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList1)-                                   ))-                              ))-                         ))-                        ([ nodeArrayList3 ])-                    ))-               ) ])-        ),-    -- rule : 350 AComposedIdentifierExpression-    \[nodeArrayList1] -> -        ( ASTNode-            ("identifier")-            ([ ( head-                   (( unASTList-                        (nodeArrayList1)-                    ))-               ) ])-        ),-    -- rule : 351 ADefCallParams-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( head-                   (( unASTList-                        (nodeArrayList2)-                    ))-               ) ])-        ),-    -- rule : 352 AAoperationpattern1OperationPattern-    \[nodeArrayList1] -> -        ( ASTNode-            ("oppattern")-            ([ ( head-                   (( unASTList-                        (nodeArrayList1)-                    ))-               ), ASTList [] ])-        ),-    -- rule : 353 AAoperationpattern2OperationPattern-    \[nodeArrayList2,nodeArrayList1] -> -        ( ASTNode-            ("oppattern")-            ([ ( head-                   (( unASTList-                        (nodeArrayList1)-                    ))-               ), ( head-                      (( unASTList-                           (nodeArrayList2)-                       ))-                  ) ])-        ),-    -- rule : 354 AOpPatternParams-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( head-                   (( unASTList-                        (nodeArrayList2)-                    ))-               ) ])-        ),-    -- rule : 355 ASingleOppatternList-    \[nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   ([ nodeArrayList1 ])-               ) ])-        ),-    -- rule : 356 AMultipleOppatternList-    \[nodeArrayList3,nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList1)-                                   ))-                              ))-                         ))-                        ([ nodeArrayList3 ])-                    ))-               ) ])-        ),-    -- rule : 357 ADefOpPatternParam-    \[nodeArrayList1] -> -        ( ASTNode-            ("def")-            ([ nodeArrayList1 ])-        ),-    -- rule : 358 AUndefOpPatternParam-    \[nodeArrayList1] -> -        ( ASTNode-            ("undef")-            ([ ])-        ),-    -- rule : 359 ATerminal$ChoiceOr-    \[nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   ([ nodeArrayList1 ])-               ) ])-        ),-    -- rule : 360 ANonTerminal$ChoiceOr-    \[nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList1)-                                   ))-                              ))-                         ))-                        ([ nodeArrayList2 ])-                    ))-               ) ])-        ),-    -- rule : 361 ATerminal$IfElsif-    \[nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   ([ nodeArrayList1 ])-               ) ])-        ),-    -- rule : 362 ANonTerminal$IfElsif-    \[nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList1)-                                   ))-                              ))-                         ))-                        ([ nodeArrayList2 ])-                    ))-               ) ])-        ),-    -- rule : 363 ATerminal$SelectWhen-    \[nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   ([ nodeArrayList1 ])-               ) ])-        ),-    -- rule : 364 ANonTerminal$SelectWhen-    \[nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList1)-                                   ))-                              ))-                         ))-                        ([ nodeArrayList2 ])-                    ))-               ) ])-        ),-    -- rule : 365 ATerminal$CaseOr-    \[nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   ([ nodeArrayList1 ])-               ) ])-        ),-    -- rule : 366 ANonTerminal$CaseOr-    \[nodeArrayList2,nodeArrayList1] -> -        ( ASTList-            ([ ( ASTList-                   (( (++)-                        (( unASTList-                             (( head-                                  (( unASTList-                                       (nodeArrayList1)-                                   ))-                              ))-                         ))-                        ([ nodeArrayList2 ])-                    ))-               ) ])-        )-    ]+            ([ nodeArrayList3, nodeArrayL
haskell/Parser2.hs view
@@ -2,7 +2,7 @@ prototype of a Haskell backend for LR-parser-tables generated by SableCC this parser imports the tables with a generated Module. -}-{-# LANGUAGE GeneralizedNewtypeDeriving, RecordWildCards #-}+{-# LANGUAGE RecordWildCards,BangPatterns #-} module Parser2 where import SableCC.ParserTypes as Parser@@ -14,17 +14,21 @@ import qualified Data.Map as Map import Data.Maybe - -- The Parser-runParser :: Input -> CST++type Stack = [(ParserStateID,DAst)]+type Input = [PToken]+type PState = (Stack,Input)++runParser :: Input -> DAst runParser input   = head $ parserLoop ([(ParserStateID 0, error "dummy CST of initial parserStack")], input) -parserLoop :: PState -> [CST]+parserLoop :: PState -> [DAst] parserLoop pState@(stack,input) = case findAction pState of     Shift newState    -> case input of          [] -> error "shift action with empty input"-         (h:rest) -> parserLoop ((newState, CstLeaf h) : stack, rest)+         (h:rest) -> parserLoop ((newState, DLeaf h) : stack, rest)     Reduce reduction  -> parserLoop $ performReduction reduction pState     Accept            -> map snd stack     Error msg         -> error (Tables.errorTable ! msg)@@ -41,10 +45,11 @@  performReduction :: Reduction -> PState -> PState performReduction Reduction {..} (stack,input)-  = ((newState,cstNode) : restStack, input)+  = ((newState,astNode) : restStack, input)   where     restStack = drop popCount stack-    cstNode = CstNode reductionID $ map snd $ take popCount stack+    cl = map snd $ take popCount stack+    ! astNode = (reduceTable ! reductionID) cl     newState = lookupGotoList gotoIndex $ fst $ head restStack  lookupGotoList :: GotoIndex -> ParserStateID -> ParserStateID@@ -76,7 +81,7 @@         then acc         else lexerLoop newState (sToken : acc)       where-         newNestingCounter = case tokenID of+         !newNestingCounter = case tokenID of            LexTokenID 1 -> pred commentNestingCounter            LexTokenID 0 -> succ commentNestingCounter            _             -> commentNestingCounter
haskell/ParserTables.hs view
@@ -8778,7 +8778,7 @@ -- this works with data dynamic data DAst   = DLeaf PToken-  | DNode Dynamic+  | DNode !Dynamic   | DList [DAst]   deriving (Show) fromDList :: DAst -> [DAst]@@ -11765,6 +11765,8 @@                  (( fromDNode                       (nodeArrayList3)                   ))+                 (Nothing)+                 (Nothing)              ))         ),     -- rule : 262 ABin2ExpressionKeyword@@ -11774,11 +11776,15 @@                  (( fromDNode                       (nodeArrayList3)                   ))-                 (( fromDNode-                      (nodeArrayList5)+                 (( Just+                      (( fromDNode+                           (nodeArrayList5)+                       ))                   ))-                 (( fromDNode-                      (nodeArrayList7)+                 (( Just+                      (( fromDNode+                           (nodeArrayList7)+                       ))                   ))              ))         ),@@ -11960,14 +11966,17 @@     \[nodeArrayList2,nodeArrayList1] ->          ( toDNode             (( StringExpression+                 (Nothing)              ))         ),     -- rule : 279 AAstringexpressionatomic2ExpressionAtomic     \[nodeArrayList3,nodeArrayList2,nodeArrayList1] ->          ( toDNode             (( StringExpression-                 (( fromDNode-                      (nodeArrayList2)+                 (( Just+                      (( fromDNode+                           (nodeArrayList2)+                       ))                   ))              ))         ),@@ -12340,6 +12349,7 @@                            (DList [])                        ))                   ))+                 (Nothing)              ))         ),     -- rule : 312 AAifsubstitutionl32SubstitutionL3@@ -12363,6 +12373,7 @@                             ))                        ))                   ))+                 (Nothing)              ))         ),     -- rule : 313 AAifsubstitutionl33SubstitutionL3@@ -12382,8 +12393,10 @@                            (DList [])                        ))                   ))-                 (( fromDNode-                      (nodeArrayList5)+                 (( Just+                      (( fromDNode+                           (nodeArrayList5)+                       ))                   ))              ))         ),@@ -12408,8 +12421,10 @@                             ))                        ))                   ))-                 (( fromDNode-                      (nodeArrayList6)+                 (( Just+                      (( fromDNode+                           (nodeArrayList6)+                       ))                   ))              ))         ),@@ -12430,6 +12445,7 @@                            (DList [])                        ))                   ))+                 (Nothing)              ))         ),     -- rule : 316 AAselectsubstitutionl32SubstitutionL3@@ -12453,6 +12469,7 @@                             ))                        ))                   ))+                 (Nothing)              ))         ),     -- rule : 317 AAselectsubstitutionl33SubstitutionL3@@ -12472,8 +12489,10 @@                            (DList [])                        ))                   ))-                 (( fromDNode-                      (nodeArrayList5)+                 (( Just+                      (( fromDNode+                           (nodeArrayList5)+                       ))                   ))              ))         ),@@ -12498,8 +12517,10 @@                             ))                        ))                   ))-                 (( fromDNode-                      (nodeArrayList6)+                 (( Just+                      (( fromDNode+                           (nodeArrayList6)+                       ))                   ))              ))         ),@@ -12531,6 +12552,7 @@                            (DList [])                        ))                   ))+                 (Nothing)              ))         ),     -- rule : 320 AAcasesubstitutionl32SubstitutionL3@@ -12565,6 +12587,7 @@                             ))                        ))                   ))+                 (Nothing)              ))         ),     -- rule : 321 AAcasesubstitutionl33SubstitutionL3@@ -12595,8 +12618,10 @@                            (DList [])                        ))                   ))-                 (( fromDNode-                      (nodeArrayList8)+                 (( Just+                      (( fromDNode+                           (nodeArrayList8)+                       ))                   ))              ))         ),@@ -12632,8 +12657,10 @@                             ))                        ))                   ))-                 (( fromDNode-                      (nodeArrayList9)+                 (( Just+                      (( fromDNode+                           (nodeArrayList9)+                       ))                   ))              ))         ),
haskell/SableAst.hs view
@@ -5,26 +5,26 @@ import Data.Data -- data ParseUnit-    = AbstractMachineParseUnit Machine MachineHeader [ MachineClause ]-    | RefinementMachineParseUnit MachineHeader IdentifierLiteral [ MachineClause ]-    | ImplementationMachineParseUnit MachineHeader IdentifierLiteral [ MachineClause ]-    | DefinitionFileParseUnit MachineClause-    | PredicateParseUnit Predicate-    | ExpressionParseUnit Expression-    | SubstitutionParseUnit Substitution-    | MachineClauseParseUnit MachineClause-    | EventBContextParseUnit IdentifierLiteral [ ContextClause ]-    | EventBModelParseUnit IdentifierLiteral [ ModelClause ]+    = AbstractMachineParseUnit !Machine !MachineHeader [ MachineClause ]+    | RefinementMachineParseUnit !MachineHeader !IdentifierLiteral [ MachineClause ]+    | ImplementationMachineParseUnit !MachineHeader !IdentifierLiteral [ MachineClause ]+    | DefinitionFileParseUnit !MachineClause+    | PredicateParseUnit !Predicate+    | ExpressionParseUnit !Expression+    | SubstitutionParseUnit !Substitution+    | MachineClauseParseUnit !MachineClause+    | EventBContextParseUnit !IdentifierLiteral [ ContextClause ]+    | EventBModelParseUnit !IdentifierLiteral [ ModelClause ]     | OppatternParseUnit [ IdentifierLiteral ] [ Argpattern ]     deriving (Typeable,Data,Show) -- data Argpattern     = UndefArgpattern-    | DefArgpattern Expression+    | DefArgpattern !Expression     deriving (Typeable,Data,Show) -- data Csppattern-    = Csppattern Argtype Argpattern+    = Csppattern !Argtype !Argpattern     deriving (Typeable,Data,Show) -- data Argtype@@ -46,12 +46,12 @@     deriving (Typeable,Data,Show) -- data ModelClause-    = RefinesModelClause IdentifierLiteral+    = RefinesModelClause !IdentifierLiteral     | SeesModelClause [ IdentifierLiteral ]     | VariablesModelClause [ Expression ]     | InvariantModelClause [ Predicate ]     | TheoremsModelClause [ Predicate ]-    | VariantModelClause Expression+    | VariantModelClause !Expression     | EventsModelClause [ Event ]     deriving (Typeable,Data,Show) --@@ -68,10 +68,10 @@     | ConcreteVariablesMachineClause [ Expression ]     | AbstractConstantsMachineClause [ Expression ]     | ConstantsMachineClause [ Expression ]-    | PropertiesMachineClause Predicate-    | ConstraintsMachineClause Predicate-    | InitialisationMachineClause Substitution-    | InvariantMachineClause Predicate+    | PropertiesMachineClause !Predicate+    | ConstraintsMachineClause !Predicate+    | InitialisationMachineClause !Substitution+    | InvariantMachineClause !Predicate     | AssertionsMachineClause [ Predicate ]     | ValuesMachineClause [ ValuesEntry ]     | LocalOperationsMachineClause [ Operation ]@@ -83,10 +83,10 @@     deriving (Typeable,Data,Show) -- data Definition-    = PredicateDefinition DefLiteralPredicate [ Expression ] Predicate-    | SubstitutionDefinition DefLiteralSubstitution [ Expression ] Substitution-    | ExpressionDefinition IdentifierLiteral [ Expression ] Expression-    | FileDefinition StringBody+    = PredicateDefinition !DefLiteralPredicate [ Expression ] !Predicate+    | SubstitutionDefinition !DefLiteralSubstitution [ Expression ] !Substitution+    | ExpressionDefinition !IdentifierLiteral [ Expression ] !Expression+    | FileDefinition !StringBody     deriving (Typeable,Data,Show) -- data Set@@ -95,19 +95,19 @@     deriving (Typeable,Data,Show) -- data ValuesEntry-    = ValuesEntry [ IdentifierLiteral ] Expression+    = ValuesEntry [ IdentifierLiteral ] !Expression     deriving (Typeable,Data,Show) -- data Operation-    = Operation [ Expression ] [ IdentifierLiteral ] [ Expression ] Substitution+    = Operation [ Expression ] [ IdentifierLiteral ] [ Expression ] !Substitution     deriving (Typeable,Data,Show) -- data Event-    = Event IdentifierLiteral Eventstatus [ IdentifierLiteral ] [ Expression ] [ Predicate ] [ Predicate ] [ Substitution ] [ Witness ]+    = Event !IdentifierLiteral !Eventstatus [ IdentifierLiteral ] [ Expression ] [ Predicate ] [ Predicate ] [ Substitution ] [ Witness ]     deriving (Typeable,Data,Show) -- data Witness-    = Witness IdentifierLiteral Predicate+    = Witness !IdentifierLiteral !Predicate     deriving (Typeable,Data,Show) -- data Eventstatus@@ -117,39 +117,39 @@     deriving (Typeable,Data,Show) -- data Predicate-    = ConjunctPredicate Predicate Predicate-    | NegationPredicate Predicate-    | DisjunctPredicate Predicate Predicate-    | ImplicationPredicate Predicate Predicate-    | EquivalencePredicate Predicate Predicate-    | UniversalQuantificationPredicate [ Expression ] Predicate-    | ExistentialQuantificationPredicate [ Expression ] Predicate-    | EqualPredicate Expression Expression-    | UnequalPredicate Expression Expression-    | BelongPredicate Expression Expression-    | NotBelongPredicate Expression Expression-    | IncludePredicate Expression Expression-    | IncludeStrictlyPredicate Expression Expression-    | NotIncludePredicate Expression Expression-    | NotIncludeStrictlyPredicate Expression Expression-    | LessEqualPredicate Expression Expression-    | LessPredicate Expression Expression-    | GreaterEqualPredicate Expression Expression-    | GreaterPredicate Expression Expression+    = ConjunctPredicate !Predicate !Predicate+    | NegationPredicate !Predicate+    | DisjunctPredicate !Predicate !Predicate+    | ImplicationPredicate !Predicate !Predicate+    | EquivalencePredicate !Predicate !Predicate+    | UniversalQuantificationPredicate [ Expression ] !Predicate+    | ExistentialQuantificationPredicate [ Expression ] !Predicate+    | EqualPredicate !Expression !Expression+    | UnequalPredicate !Expression !Expression+    | BelongPredicate !Expression !Expression+    | NotBelongPredicate !Expression !Expression+    | IncludePredicate !Expression !Expression+    | IncludeStrictlyPredicate !Expression !Expression+    | NotIncludePredicate !Expression !Expression+    | NotIncludeStrictlyPredicate !Expression !Expression+    | LessEqualPredicate !Expression !Expression+    | LessPredicate !Expression !Expression+    | GreaterEqualPredicate !Expression !Expression+    | GreaterPredicate !Expression !Expression     | TruePredicate     | FalsePredicate-    | FinitePredicate Expression-    | PartitionPredicate Expression [ Expression ]-    | DefinitionPredicate DefLiteralPredicate [ Expression ]+    | FinitePredicate !Expression+    | PartitionPredicate !Expression [ Expression ]+    | DefinitionPredicate !DefLiteralPredicate [ Expression ]     deriving (Typeable,Data,Show) -- data Expression     = IdentifierExpression [ IdentifierLiteral ]-    | PrimedIdentifierExpression [ IdentifierLiteral ] IntegerLiteral-    | StringExpression StringBody+    | PrimedIdentifierExpression [ IdentifierLiteral ] !IntegerLiteral+    | StringExpression (Maybe StringBody)     | TrueExpression     | FalseExpression-    | IntegerExpression IntegerLiteral+    | IntegerExpression !IntegerLiteral     | MaxIntExpression     | MinIntExpression     | EmptySetExpression@@ -161,152 +161,152 @@     | IntSetExpression     | BoolSetExpression     | StringSetExpression-    | ConvertBoolExpression Predicate-    | AddExpression Expression Expression-    | MinusExpression Expression Expression-    | MinusOrSetSubtractExpression Expression Expression-    | UnaryExpression Expression-    | MultiplicationExpression Expression Expression-    | CartesianProductExpression Expression Expression-    | MultOrCartExpression Expression Expression-    | DivExpression Expression Expression-    | ModuloExpression Expression Expression-    | PowerOfExpression Expression Expression+    | ConvertBoolExpression !Predicate+    | AddExpression !Expression !Expression+    | MinusExpression !Expression !Expression+    | MinusOrSetSubtractExpression !Expression !Expression+    | UnaryExpression !Expression+    | MultiplicationExpression !Expression !Expression+    | CartesianProductExpression !Expression !Expression+    | MultOrCartExpression !Expression !Expression+    | DivExpression !Expression !Expression+    | ModuloExpression !Expression !Expression+    | PowerOfExpression !Expression !Expression     | SuccessorExpression     | PredecessorExpression-    | MaxExpression Expression-    | MinExpression Expression-    | CardExpression Expression-    | GeneralSumExpression [ Expression ] Predicate Expression-    | GeneralProductExpression [ Expression ] Predicate Expression+    | MaxExpression !Expression+    | MinExpression !Expression+    | CardExpression !Expression+    | GeneralSumExpression [ Expression ] !Predicate !Expression+    | GeneralProductExpression [ Expression ] !Predicate !Expression     | CoupleExpression [ Expression ]-    | ComprehensionSetExpression [ Expression ] Predicate-    | ProverComprehensionSetExpression [ Expression ] Predicate-    | EventBComprehensionSetExpression [ Expression ] Expression Predicate-    | PowSubsetExpression Expression-    | Pow1SubsetExpression Expression-    | FinSubsetExpression Expression-    | Fin1SubsetExpression Expression+    | ComprehensionSetExpression [ Expression ] !Predicate+    | ProverComprehensionSetExpression [ Expression ] !Predicate+    | EventBComprehensionSetExpression [ Expression ] !Expression !Predicate+    | PowSubsetExpression !Expression+    | Pow1SubsetExpression !Expression+    | FinSubsetExpression !Expression+    | Fin1SubsetExpression !Expression     | SetExtensionExpression [ Expression ]-    | IntervalExpression Expression Expression-    | UnionExpression Expression Expression-    | IntersectionExpression Expression Expression-    | SetSubtractionExpression Expression Expression-    | GeneralUnionExpression Expression-    | GeneralIntersectionExpression Expression-    | QuantifiedUnionExpression [ Expression ] Predicate Expression-    | QuantifiedIntersectionExpression [ Expression ] Predicate Expression-    | RelationsExpression Expression Expression-    | IdentityExpression Expression+    | IntervalExpression !Expression !Expression+    | UnionExpression !Expression !Expression+    | IntersectionExpression !Expression !Expression+    | SetSubtractionExpression !Expression !Expression+    | GeneralUnionExpression !Expression+    | GeneralIntersectionExpression !Expression+    | QuantifiedUnionExpression [ Expression ] !Predicate !Expression+    | QuantifiedIntersectionExpression [ Expression ] !Predicate !Expression+    | RelationsExpression !Expression !Expression+    | IdentityExpression !Expression     | EventBIdentityExpression-    | ReverseExpression Expression-    | FirstProjectionExpression Expression Expression-    | EventBFirstProjectionExpression Expression+    | ReverseExpression !Expression+    | FirstProjectionExpression !Expression !Expression+    | EventBFirstProjectionExpression !Expression     | EventBFirstProjectionV2Expression-    | SecondProjectionExpression Expression Expression-    | EventBSecondProjectionExpression Expression+    | SecondProjectionExpression !Expression !Expression+    | EventBSecondProjectionExpression !Expression     | EventBSecondProjectionV2Expression-    | CompositionExpression Expression Expression-    | RingExpression Expression Expression-    | DirectProductExpression Expression Expression-    | ParallelProductExpression Expression Expression-    | IterationExpression Expression Expression-    | ReflexiveClosureExpression Expression-    | ClosureExpression Expression-    | DomainExpression Expression-    | RangeExpression Expression-    | ImageExpression Expression Expression-    | DomainRestrictionExpression Expression Expression-    | DomainSubtractionExpression Expression Expression-    | RangeRestrictionExpression Expression Expression-    | RangeSubtractionExpression Expression Expression-    | OverwriteExpression Expression Expression-    | PartialFunctionExpression Expression Expression-    | TotalFunctionExpression Expression Expression-    | PartialInjectionExpression Expression Expression-    | TotalInjectionExpression Expression Expression-    | PartialSurjectionExpression Expression Expression-    | TotalSurjectionExpression Expression Expression-    | PartialBijectionExpression Expression Expression-    | TotalBijectionExpression Expression Expression-    | TotalRelationExpression Expression Expression-    | SurjectionRelationExpression Expression Expression-    | TotalSurjectionRelationExpression Expression Expression-    | LambdaExpression [ Expression ] Predicate Expression-    | TransFunctionExpression Expression-    | TransRelationExpression Expression-    | SeqExpression Expression-    | Seq1Expression Expression-    | IseqExpression Expression-    | Iseq1Expression Expression-    | PermExpression Expression+    | CompositionExpression !Expression !Expression+    | RingExpression !Expression !Expression+    | DirectProductExpression !Expression !Expression+    | ParallelProductExpression !Expression !Expression+    | IterationExpression !Expression !Expression+    | ReflexiveClosureExpression !Expression+    | ClosureExpression !Expression+    | DomainExpression !Expression+    | RangeExpression !Expression+    | ImageExpression !Expression !Expression+    | DomainRestrictionExpression !Expression !Expression+    | DomainSubtractionExpression !Expression !Expression+    | RangeRestrictionExpression !Expression !Expression+    | RangeSubtractionExpression !Expression !Expression+    | OverwriteExpression !Expression !Expression+    | PartialFunctionExpression !Expression !Expression+    | TotalFunctionExpression !Expression !Expression+    | PartialInjectionExpression !Expression !Expression+    | TotalInjectionExpression !Expression !Expression+    | PartialSurjectionExpression !Expression !Expression+    | TotalSurjectionExpression !Expression !Expression+    | PartialBijectionExpression !Expression !Expression+    | TotalBijectionExpression !Expression !Expression+    | TotalRelationExpression !Expression !Expression+    | SurjectionRelationExpression !Expression !Expression+    | TotalSurjectionRelationExpression !Expression !Expression+    | LambdaExpression [ Expression ] !Predicate !Expression+    | TransFunctionExpression !Expression+    | TransRelationExpression !Expression+    | SeqExpression !Expression+    | Seq1Expression !Expression+    | IseqExpression !Expression+    | Iseq1Expression !Expression+    | PermExpression !Expression     | EmptySequenceExpression     | SequenceExtensionExpression [ Expression ]-    | SizeExpression Expression-    | FirstExpression Expression-    | LastExpression Expression-    | FrontExpression Expression-    | TailExpression Expression-    | RevExpression Expression-    | ConcatExpression Expression Expression-    | InsertFrontExpression Expression Expression-    | InsertTailExpression Expression Expression-    | RestrictFrontExpression Expression Expression-    | RestrictTailExpression Expression Expression-    | GeneralConcatExpression Expression-    | DefinitionExpression IdentifierLiteral [ Expression ]-    | FunctionExpression Expression [ Expression ]-    | TreeExpression Expression-    | BtreeExpression Expression-    | ConstExpression Expression Expression-    | TopExpression Expression-    | SonsExpression Expression-    | PrefixExpression Expression-    | PostfixExpression Expression-    | SizetExpression Expression-    | MirrorExpression Expression-    | RankExpression Expression Expression-    | FatherExpression Expression Expression-    | SonExpression Expression Expression Expression-    | SubtreeExpression Expression Expression-    | ArityExpression Expression Expression-    | BinExpression Expression Expression Expression-    | LeftExpression Expression-    | RightExpression Expression-    | InfixExpression Expression+    | SizeExpression !Expression+    | FirstExpression !Expression+    | LastExpression !Expression+    | FrontExpression !Expression+    | TailExpression !Expression+    | RevExpression !Expression+    | ConcatExpression !Expression !Expression+    | InsertFrontExpression !Expression !Expression+    | InsertTailExpression !Expression !Expression+    | RestrictFrontExpression !Expression !Expression+    | RestrictTailExpression !Expression !Expression+    | GeneralConcatExpression !Expression+    | DefinitionExpression !IdentifierLiteral [ Expression ]+    | FunctionExpression !Expression [ Expression ]+    | TreeExpression !Expression+    | BtreeExpression !Expression+    | ConstExpression !Expression !Expression+    | TopExpression !Expression+    | SonsExpression !Expression+    | PrefixExpression !Expression+    | PostfixExpression !Expression+    | SizetExpression !Expression+    | MirrorExpression !Expression+    | RankExpression !Expression !Expression+    | FatherExpression !Expression !Expression+    | SonExpression !Expression !Expression !Expression+    | SubtreeExpression !Expression !Expression+    | ArityExpression !Expression !Expression+    | BinExpression !Expression (Maybe Expression) (Maybe Expression)+    | LeftExpression !Expression+    | RightExpression !Expression+    | InfixExpression !Expression     | StructExpression [ RecEntry ]     | RecExpression [ RecEntry ]-    | RecordFieldExpression Expression Expression+    | RecordFieldExpression !Expression !Expression     deriving (Typeable,Data,Show) -- data RecEntry-    = RecEntry Expression Expression+    = RecEntry !Expression !Expression     deriving (Typeable,Data,Show) -- data Substitution-    = BlockSubstitution Substitution+    = BlockSubstitution !Substitution     | SkipSubstitution     | AssignSubstitution [ Expression ] [ Expression ]-    | PreconditionSubstitution Predicate Substitution-    | AssertionSubstitution Predicate Substitution+    | PreconditionSubstitution !Predicate !Substitution+    | AssertionSubstitution !Predicate !Substitution     | ChoiceSubstitution [ Substitution ]-    | ChoiceOrSubstitution Substitution-    | IfSubstitution Predicate Substitution [ Substitution ] Substitution-    | IfElsifSubstitution Predicate Substitution-    | SelectSubstitution Predicate Substitution [ Substitution ] Substitution-    | SelectWhenSubstitution Predicate Substitution-    | CaseSubstitution Expression [ Expression ] Substitution [ Substitution ] Substitution-    | CaseOrSubstitution [ Expression ] Substitution-    | AnySubstitution [ Expression ] Predicate Substitution-    | LetSubstitution [ Expression ] Predicate Substitution-    | BecomesElementOfSubstitution [ Expression ] Expression-    | BecomesSuchSubstitution [ Expression ] Predicate-    | VarSubstitution [ Expression ] Substitution+    | ChoiceOrSubstitution !Substitution+    | IfSubstitution !Predicate !Substitution [ Substitution ] (Maybe Substitution)+    | IfElsifSubstitution !Predicate !Substitution+    | SelectSubstitution !Predicate !Substitution [ Substitution ] (Maybe Substitution)+    | SelectWhenSubstitution !Predicate !Substitution+    | CaseSubstitution !Expression [ Expression ] !Substitution [ Substitution ] (Maybe Substitution)+    | CaseOrSubstitution [ Expression ] !Substitution+    | AnySubstitution [ Expression ] !Predicate !Substitution+    | LetSubstitution [ Expression ] !Predicate !Substitution+    | BecomesElementOfSubstitution [ Expression ] !Expression+    | BecomesSuchSubstitution [ Expression ] !Predicate+    | VarSubstitution [ Expression ] !Substitution     | SequenceSubstitution [ Substitution ]-    | FuncOpSubstitution Expression-    | OpSubstitution Expression [ Expression ]+    | FuncOpSubstitution !Expression+    | OpSubstitution !Expression [ Expression ]     | OpWithReturnSubstitution [ Expression ] [ IdentifierLiteral ] [ Expression ]-    | WhileSubstitution Predicate Substitution Predicate Expression+    | WhileSubstitution !Predicate !Substitution !Predicate !Expression     | ParallelSubstitution [ Substitution ]-    | DefinitionSubstitution DefLiteralSubstitution [ Expression ]+    | DefinitionSubstitution !DefLiteralSubstitution [ Expression ]     deriving (Typeable,Data,Show)
haskell/Test2.hs view
@@ -1,20 +1,32 @@-module Test2+module Main where +import System.Environment import Parser2 import ParserTables import Data.Dynamic import SableAst+import SableCC.ParserTypes+import Control.DeepSeq +main = do+  [fileName] <- getArgs+  ast <- parseFile fileName+  putStrLn $ take 1000 $ show ast++ parseFile :: FilePath -> IO ParseUnit parseFile bFile = do   putStrLn "reading Source"   src <- readFile bFile   putStrLn "running Lexer and parser"   let-    lexerTokens = runLexer src-    parserTokens = trimTokens lexerTokens-    cst = runParser parserTokens-    ast:: ParseUnit-    ast = fromDNode $ cst2ast cst-  return ast+    !lexerTokens = runLexer $ deepseq src src+    !parserTokens = trimTokens $ deepseq lexerTokens lexerTokens+    ast1 = runParser $ deepseq parserTokens parserTokens+    ast2:: ParseUnit+    ast2 = fromDNode ast1+  return ast2++instance NFData LexTokenID+instance NFData ParserTokenID
src/SableCC/AstDefinition.hs view
@@ -52,6 +52,7 @@   | FromList ActionExpression   | NodeResult ActionExpression   | ListResult ActionExpression+  | ResultNothing   deriving (Show)  -- | Translate the raw parser definition that is read from the XML file@@ -101,12 +102,12 @@       other                      -> error $ "innerAction " ++ show other       where         valueOf = valueOfEnv env-        makeChildren = map valueOf . mapMaybe toArg+        makeChildren = map toArg           where             toArg a = case a of-              ActionArgNull -> Nothing-              ActionArgList s -> Just s-              ActionArg s -> Just s+              ActionArgNull -> ResultNothing+              ActionArgList s -> valueOf s+              ActionArg s -> valueOf s      smartAppendList :: ActionExpression -> ActionExpression -> ActionExpression     smartAppendList EmptyList l = l
src/SableCC/GenerateHaskell.hs view
@@ -45,9 +45,11 @@      parserDefinition = makeParserDefinition rawParser      astDefinition = makeAstDefinition rawParser      lexerDefinition = makeLexerDefinition rawParser+{-   putStrLn "writing MakeUntypedAST.hs"   writeFile "MakeUntypedAST.hs" $ render     $ makeUntypedTransformation astDefinition+-}    putStrLn "writing ParserTables.hs"   writeFile "ParserTables.hs" $ render $ vcat [@@ -71,7 +73,7 @@   putStrLn "writing SableAST.hs"   writeFile "SableAst.hs" $ render $ makeSableAst astDefinition -+{- makeUntypedTransformation :: AstDefinition -> Doc makeUntypedTransformation astDefinition = vcat [    text "-- autogenerated File do not edit!"@@ -115,6 +117,7 @@       FromList e -> fun "head" [fun "unASTList" [expr e]]       NodeResult e -> expr e       ListResult e -> fun "ASTList" [text "[" <+> expr e <+> text "]"]+-}  fun :: String -> [Doc] -> Doc fun name args = vcat [@@ -132,10 +135,10 @@   ,text "import Data.Data"   ,makeHaskellDataType $ productions astDefinition   ]--makeHaskellDataType :: [Raw.Prod] -> Doc-makeHaskellDataType = vcat . map makeProd   where+    makeHaskellDataType :: [Raw.Prod] -> Doc+    makeHaskellDataType = vcat . map makeProd+     makeProd prod =  vcat [        text "--"       ,text "data" <+> (text $ tail $ prod_ename prod)@@ -144,19 +147,20 @@       ]     makeAlt alt seperator       = text seperator <+> (text $ tail $ alt_ename alt) <+> (hsep $ map makeElem $ alt_elem alt)-    makeElem elem = if elem_is_list elem-       then text "[" <+> body <+> text "]"-       else body+    makeElem elem = case (elem_modifier elem, elem_is_list elem) of+       (Just "*", True ) -> text "[" <+> body <+> text "]"+       (Just "?", False) -> parens (text "Maybe" <+> body)+       (Nothing , False) -> text "!" <> body+       x -> error $ "makeElem: unexpected combination of modifier and islist : " ++ show x      where body = text $ tail $ elem_etype elem - makeDynamicTransformation :: AstDefinition -> Doc makeDynamicTransformation astDefinition = vcat [    text "-- reduce actions that transform the CST to a AST data type"   ,text "-- this works with data dynamic"   ,text "data DAst"   ,text "  = DLeaf PToken"-  ,text "  | DNode Dynamic"+  ,text "  | DNode !Dynamic"   ,text "  | DList [DAst]"   ,text "  deriving (Show)" @@ -205,11 +209,15 @@       FromList e -> fun "head" [fun "fromDList" [expr e]]       NodeResult e -> expr e       ListResult e -> fun "DList" [text "[" <+> expr e <+> text "]"]+--      ResultNothing -> text "Nothing"       where         mkChild :: ActionExpression -> Raw.Elem -> Doc-        mkChild e elem = if elem_is_list elem-          then fun "map" [fun "fromDNode" [], fun "fromDList" [expr e]]-          else fun "fromDNode" [expr e]+        mkChild e elem = case (e, elem_is_list elem, elem_modifier elem) of+          (_ , True, Just "*") -> fun "map" [fun "fromDNode" [], fun "fromDList" [expr e]]+          (ResultNothing,False, Just "?") -> text "Nothing"+          (_, False, Just "?") -> fun "Just" [fun "fromDNode" [expr e]]+          (_, False, Nothing ) -> fun "fromDNode" [expr e]+          combination -> error $ "GenerateHaskell expr" ++ show combination   makeLexerTables :: LexerDefinition -> Doc@@ -333,3 +341,66 @@       ]       where stPair (ParserStateID a, ParserStateID b)                = parens (text "ParserStateID" <+> int a <+> comma <+> text "ParserStateID" <+> int b)++{-+alternative translation without Dynamic.+this does not work, because Sable does not give us enough information in the XML file+(todo: patch sable or do a complete sable-reimplementation in Haskell?+-}+makeStackTransformation :: AstDefinition -> Doc+makeStackTransformation astDefinition = vcat [+   text "-- reduce actions that transform the stack for the LR-Automaton"+  ,makeStackType astDefinition+  ,text "reduceActions :: [NodeStack -> NodeStack]"+  ,text "reduceActions = ["+  ,nest 4 $ vcat $ punctuate comma $ map mkStackRule $ Array.elems $ reductionTable astDefinition+  ,nest 4 $ text "]"+  ]+  where+    makeStackType :: AstDefinition -> Doc+    makeStackType astDefinition = vcat [+       text "-- NodeStack is a heterogenous linkes list"+      ,text "data NodeStack"+      ,nest 4 $ text "= EmptyNodeStack"+      ,nest 4 $ vcat $ map makeAlt $ productions astDefinition+      ,nest 4 $ text "deriving (Show)"+      ]+    makeAlt :: Raw.Prod -> Doc+    makeAlt prod = vcat [+       hsep [text "|", text "SN_" <> typeName, text "!" <> typeName, text "!NodeStack"]+      ,hsep [text "|", text "SL_" <> typeName, text "[", typeName, text "]",text "!NodeStack"]+      ]+      where typeName = text $ tail $ prod_ename prod+++mkStackRule :: Ast.Action -> Doc+mkStackRule Action {..} = vcat [+   text "-- rule :" <+> (int $ rule_index actionRule) <+> (text $ rule_ename actionRule)+  ,text "\\[" <> (hcat $ punctuate comma popArgs) <> text "] -> "+  ,nest 4 $ expr actionExpression+  ]+  where+    popArgs = map (text . action_result . unActionArgs)+               $ filter isPopAction $ rule_actions actionRule++    expr :: ActionExpression -> Doc+    expr term = case term of+      Var s -> text s+      EmptyList -> text "[]"+      SingletonList e -> text "[" <+> expr e <+> text "]"+      AppendNode l n -> fun "(++)" [expr l , text "[" <+> expr n <+> text "]"]+      AppendList l1 l2 -> fun "(++)" [expr l1, expr l2]+      NewNode prod alt l -> fun (tail $ alt_ename alt) $ zipWith mkChild l (alt_elem alt)+      FromNode e -> expr e+      FromList e -> fun "head" [expr e]+      NodeResult e -> expr e+      ListResult e -> text "[" <+> expr e <+> text "]"+--      ResultNothing -> text "Nothing"+      where+        mkChild :: ActionExpression -> Raw.Elem -> Doc+        mkChild e elem = case (e, elem_is_list elem, elem_modifier elem) of+          (_ , True, Just "*") -> expr e+          (ResultNothing,False, Just "?") -> text "Nothing"+          (_, False, Just "?") -> fun "Just" [expr e]+          (_, False, Nothing ) -> expr e+          combination -> error $ "GenerateHaskell expr" ++ show combination
src/SableCC/GenerateProlog.hs view
@@ -227,3 +227,4 @@       FromList e -> term "head" [expr e]       NodeResult e -> expr e       ListResult e -> term "singletonList" [expr e]+      ResultNothing -> text "resultNothing"
src/SableCC/ParserTypes.hs view
@@ -54,7 +54,7 @@    lexerMode :: ModeID   ,lexerBuffer :: String   ,srcPos :: ()-  ,commentNestingCounter :: Int+  ,commentNestingCounter :: !Int   }  initLexerState :: String -> LexerState@@ -86,13 +86,7 @@ newtype ParserStateID = ParserStateID {fromParserStateID :: Int}   deriving (Eq, Ord, Enum, Ix, Show) -type Stack = [(ParserStateID,CST)]--type Input = [PToken] type ErrorMsg = String--type PState = (Stack,Input)- type GotoTable = Array GotoIndex GotoMap data GotoMap = GotoMap {    defaultGoto :: ParserStateID@@ -134,13 +128,3 @@   = CstLeaf PToken   | CstNode ReductionID [CST]   deriving (Show)--data AST-  = ASTLeaf PToken-  | ASTNode String [AST]-  | ASTList [AST]-  deriving (Show)--unASTList :: AST -> [AST]-unASTList (ASTList l) = l-unASTList e = error "unASTList : not ASTList"
src/SableCC/XML/ParserDefinitionRaw.hs view
@@ -127,7 +127,7 @@   } deriving (Show, Eq)  data Elem = Elem {-   elem_modifier :: String+   elem_modifier :: Maybe String   ,elem_name :: String   ,elem_ename :: String   ,elem_type  :: String
src/SableCC/XML/XML2Parser.hs view
@@ -186,7 +186,7 @@     toElem :: Element -> Elem     toElem doc = Raw.Elem {..}       where-        elem_modifier = getAttr $__LOCATION__ "modifier" doc+        elem_modifier = findAttr (unqual "modifier") doc         elem_name     = getAttr $__LOCATION__ "name" doc         elem_ename    = getAttr $__LOCATION__ "ename" doc         elem_type     = getAttr $__LOCATION__ "type" doc