Skip to content

Commit

Permalink
Merge pull request #453 from smucclaw/20231006-alternative-rulemarker
Browse files Browse the repository at this point in the history
add support for alternative rulemarkers
  • Loading branch information
mengwong authored Oct 6, 2023
2 parents 13a8b65 + ac0fb02 commit 2407041
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/haskell/natural4/src/LS/BasicTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,32 @@ toToken "MAP" = pure FMap
toToken "AKA" = pure Aka
toToken "TYPICALLY" = pure Typically

toToken "" = pure $ RuleMarker (-1) "§"
toToken "CLAUSE" = pure $ RuleMarker 1 "§"
toToken "SECTION" = pure $ RuleMarker 1 "§"

toToken "" = pure $ RuleMarker (-1) "§"
toToken "§" = pure $ RuleMarker 1 "§"
toToken "§§" = pure $ RuleMarker 2 "§"
toToken "§§§" = pure $ RuleMarker 3 "§"
toToken "§§§§" = pure $ RuleMarker 4 "§"
toToken "§§§§§" = pure $ RuleMarker 5 "§"
toToken "§§§§§§" = pure $ RuleMarker 6 "§"

toToken "" = pure $ RuleMarker (-1) ""
toToken "" = pure $ RuleMarker 1 ""
toToken "¶¶" = pure $ RuleMarker 2 ""
toToken "¶¶¶" = pure $ RuleMarker 3 ""
toToken "¶¶¶¶" = pure $ RuleMarker 4 ""
toToken "¶¶¶¶¶" = pure $ RuleMarker 5 ""
toToken "¶¶¶¶¶¶" = pure $ RuleMarker 6 ""

toToken "H1" = pure $ RuleMarker 1 "H"
toToken "H2" = pure $ RuleMarker 2 "H"
toToken "H3" = pure $ RuleMarker 3 "H"
toToken "H4" = pure $ RuleMarker 4 "H"
toToken "H5" = pure $ RuleMarker 5 "H"
toToken "H6" = pure $ RuleMarker 6 "H"

toToken "SCENARIO" = pure ScenarioTok
toToken "EXPECT" = pure Expect
toToken "<" = pure TokLT
Expand Down Expand Up @@ -422,6 +439,7 @@ renderToken OneOf = "ONE OF"
renderToken TypeSeparator = "::"
renderToken (Other txt) = show txt
renderToken (RuleMarker 0 txt) = "§0" ++ Text.unpack txt
renderToken (RuleMarker n "H") = "H" ++ show n
renderToken (RuleMarker n txt) = concat $ replicate n (Text.unpack txt)

renderToken Semicolon = ";;"
Expand Down

0 comments on commit 2407041

Please sign in to comment.