Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a single syntax for custom rules #47

Merged
merged 15 commits into from
Jan 23, 2024
3 changes: 1 addition & 2 deletions eo-phi-normalizer/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ main = defaultMainWithHooks $ simpleUserHooks
{ hookedPrograms = [ bnfcProgram ]
, postConf = \args flags packageDesc localBuildInfo -> do
#ifndef mingw32_HOST_OS
_ <- system "bnfc -d -p Language.EO.Phi --generic -o src/ grammar/EO/Phi/Syntax.cf"
_ <- system "bnfc -d -p Language.EO.Phi.Rules --generic -o src/ grammar/EO/Phi/Rules/Syntax.cf"
_ <- system "bnfc --haskell -d -p Language.EO.Phi --generic -o src/ grammar/EO/Phi/Syntax.cf"
#endif
postConf simpleUserHooks args flags packageDesc localBuildInfo
}
Expand Down
6 changes: 2 additions & 4 deletions eo-phi-normalizer/eo-phi-normalizer.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ library
Language.EO.Phi.Normalize
Language.EO.Phi.Rules.Common
Language.EO.Phi.Rules.PhiPaper
Language.EO.Phi.Rules.Syntax.Abs
Language.EO.Phi.Rules.Syntax.Lex
Language.EO.Phi.Rules.Syntax.Par
Language.EO.Phi.Rules.Syntax.Print
Language.EO.Phi.Rules.Yaml
Language.EO.Phi.Syntax
Language.EO.Phi.Syntax.Abs
Expand Down Expand Up @@ -96,7 +92,9 @@ test-suite eo-phi-normalizer-test
main-is: Spec.hs
other-modules:
Language.EO.PhiSpec
Language.EO.YamlSpec
Test.EO.Phi
Test.EO.Yaml
Paths_eo_phi_normalizer
hs-source-dirs:
test
Expand Down
47 changes: 0 additions & 47 deletions eo-phi-normalizer/grammar/EO/Phi/Rules/Syntax.cf

This file was deleted.

4 changes: 4 additions & 0 deletions eo-phi-normalizer/grammar/EO/Phi/Syntax.cf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ token Bytes ({"--"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] {"-"} | ["012345
token Function upper (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ;
token LabelId lower (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ;
token AlphaIndex ({"α0"} | {"α"} (digit - ["0"]) (digit)* ) ;
token MetaId {"!"} (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ;

Program. Program ::= "{" [Binding] "}" ;

Expand All @@ -17,11 +18,13 @@ ObjectDispatch. Object ::= Object "." Attribute ;
GlobalDispatch. Object ::= "Φ" "." Attribute ;
ThisDispatch. Object ::= "ξ" "." Attribute ;
Termination. Object ::= "⊥" ;
MetaObject. Object ::= MetaId ;

AlphaBinding. Binding ::= Attribute "↦" Object ;
EmptyBinding. Binding ::= Attribute "↦" "∅" ;
DeltaBinding. Binding ::= "Δ" "⤍" Bytes ;
LambdaBinding. Binding ::= "λ" "⤍" Function ;
MetaBindings. Binding ::= MetaId ;
separator Binding "," ;

Phi. Attribute ::= "φ" ; -- decoratee object
Expand All @@ -30,6 +33,7 @@ Sigma. Attribute ::= "σ" ; -- home object
VTX. Attribute ::= "ν" ; -- the vertex identifier (an object that represents the unique identifier of the containing object)
Label. Attribute ::= LabelId ;
Alpha. Attribute ::= AlphaIndex ;
MetaAttr. Attribute ::= MetaId ;

PeeledObject. PeeledObject ::= ObjectHead [ObjectAction] ;

Expand Down
49 changes: 0 additions & 49 deletions eo-phi-normalizer/grammar/EO/Phi/Syntax.old.cf

This file was deleted.

1 change: 1 addition & 0 deletions eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ peelObject = \case
GlobalDispatch attr -> PeeledObject HeadGlobal [ActionDispatch attr]
ThisDispatch attr -> PeeledObject HeadThis [ActionDispatch attr]
Termination -> PeeledObject HeadTermination []
MetaObject _ -> PeeledObject HeadTermination []
where
followedBy (PeeledObject object actions) action = PeeledObject object (actions ++ [action])

Expand Down
2 changes: 2 additions & 0 deletions eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ withSubObject f root =
GlobalDispatch{} -> []
ThisDispatch{} -> []
Termination -> []
MetaObject _ -> []

withSubObjectBindings :: (Object -> [Object]) -> [Binding] -> [[Binding]]
withSubObjectBindings _ [] = []
Expand All @@ -54,6 +55,7 @@ withSubObjectBinding f = \case
EmptyBinding{} -> []
DeltaBinding{} -> []
LambdaBinding{} -> []
MetaBindings _ -> []

applyOneRule :: Context -> Object -> [Object]
applyOneRule = withSubObject . applyOneRuleAtRoot
Expand Down
74 changes: 0 additions & 74 deletions eo-phi-normalizer/src/Language/EO/Phi/Rules/Syntax/Abs.hs

This file was deleted.

95 changes: 0 additions & 95 deletions eo-phi-normalizer/src/Language/EO/Phi/Rules/Syntax/Doc.txt

This file was deleted.

Loading