@@ -1,4 +1,4 @@
|
|||||||
[0;31m([0m[0;95;1;3mbegin[0m
|
[0;31m([0m[0;95;1;3mbegin[0m
|
||||||
[0m책을[0m
|
책을
|
||||||
[0m더[0m
|
더
|
||||||
[0m먹으세요~![0m[0;31m)[0m
|
먹으세요~![0;31m)[0m
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
[0;31m([0m[0;95;1;3mbegin[0m
|
[0;31m([0m[0;95;1;3mbegin[0m
|
||||||
[0m책을[0m
|
책을
|
||||||
[0m더[0m
|
더
|
||||||
[0m먹으세요~![0m[0;31m)[0m
|
먹으세요~![0;31m)[0m
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[0;31m([0m[0;95;1;3mlambda[0m
|
[0;31m([0m[0;95;1;3mlambda[0m
|
||||||
[0;33m([0m[0m어간[0m
|
[0;33m([0m어간
|
||||||
[0m어미[0m[0;33m)[0m
|
어미[0;33m)[0m
|
||||||
[0;33m([0m[0mdisplay[0m
|
[0;33m([0mdisplay
|
||||||
[0m꾸깃[0m[0;33m)[0m[0;31m)[0m
|
꾸깃[0;33m)[0m[0;31m)[0m
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
[0;31m([0m[0;95;1;3mlambda[0m [0;33m([0m[0m어간[0m [0m어미[0m[0;33m)[0m
|
[0;31m([0m[0;95;1;3mlambda[0m [0;33m([0m어간 어미[0;33m)[0m
|
||||||
[0;33m([0m[0mdisplay[0m [0m꾸깃[0m[0;33m)[0m[0;31m)[0m
|
[0;33m([0mdisplay 꾸깃[0;33m)[0m[0;31m)[0m
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
[0;31m([0m[0m가[0m
|
[0;31m([0m가
|
||||||
[0m나[0m
|
나
|
||||||
[0m다[0m
|
다
|
||||||
[0m라[0m[0;31m)[0m
|
라[0;31m)[0m
|
||||||
@@ -1 +1 @@
|
|||||||
[0;31m([0m[0m가[0m [0m나[0m [0m다[0m [0m라[0m[0;31m)[0m
|
[0;31m([0m가 나 다 라[0;31m)[0m
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/bool/source.scm"
|
{ sourceName = "golden/read/bool/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -9,8 +8,7 @@
|
|||||||
)
|
)
|
||||||
} :< SimpleF ( SimpleBoolean True )
|
} :< SimpleF ( SimpleBoolean True )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/bool/source.scm"
|
{ sourceName = "golden/read/bool/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -19,8 +17,7 @@
|
|||||||
)
|
)
|
||||||
} :< SimpleF ( SimpleBoolean True )
|
} :< SimpleF ( SimpleBoolean True )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/bool/source.scm"
|
{ sourceName = "golden/read/bool/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -29,8 +26,7 @@
|
|||||||
)
|
)
|
||||||
} :< SimpleF ( SimpleBoolean False )
|
} :< SimpleF ( SimpleBoolean False )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/bool/source.scm"
|
{ sourceName = "golden/read/bool/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/decimal/source.scm"
|
{ sourceName = "golden/read/decimal/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -10,8 +9,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleNumber 45.0 )
|
( SimpleNumber 45.0 )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/decimal/source.scm"
|
{ sourceName = "golden/read/decimal/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -21,8 +19,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleNumber 5667.0 )
|
( SimpleNumber 5667.0 )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/decimal/source.scm"
|
{ sourceName = "golden/read/decimal/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list-dot-flat/source.scm"
|
{ sourceName = "golden/read/list-dot-flat/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -11,8 +10,7 @@
|
|||||||
( DotListF
|
( DotListF
|
||||||
(
|
(
|
||||||
( MkAnn
|
( MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list-dot-flat/source.scm"
|
{ sourceName = "golden/read/list-dot-flat/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -23,8 +21,7 @@
|
|||||||
( SimpleSymbol "가" )
|
( SimpleSymbol "가" )
|
||||||
) :|
|
) :|
|
||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list-dot-flat/source.scm"
|
{ sourceName = "golden/read/list-dot-flat/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -34,8 +31,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "나" )
|
( SimpleSymbol "나" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list-dot-flat/source.scm"
|
{ sourceName = "golden/read/list-dot-flat/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -47,8 +43,7 @@
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
( MkAnn
|
( MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list-dot-flat/source.scm"
|
{ sourceName = "golden/read/list-dot-flat/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list-flat/source.scm"
|
{ sourceName = "golden/read/list-flat/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -8,10 +7,9 @@
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
} :< CompoundF
|
} :< CompoundF
|
||||||
( ListF Ordinary
|
( ListF StyleData
|
||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list-flat/source.scm"
|
{ sourceName = "golden/read/list-flat/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -21,8 +19,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "가" )
|
( SimpleSymbol "가" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list-flat/source.scm"
|
{ sourceName = "golden/read/list-flat/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -32,8 +29,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "나" )
|
( SimpleSymbol "나" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list-flat/source.scm"
|
{ sourceName = "golden/read/list-flat/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -43,8 +39,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "다" )
|
( SimpleSymbol "다" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list-flat/source.scm"
|
{ sourceName = "golden/read/list-flat/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -54,8 +49,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "라" )
|
( SimpleSymbol "라" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list-flat/source.scm"
|
{ sourceName = "golden/read/list-flat/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -65,8 +59,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleNumber 1.0 )
|
( SimpleNumber 1.0 )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list-flat/source.scm"
|
{ sourceName = "golden/read/list-flat/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -76,8 +69,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleNumber 2.0 )
|
( SimpleNumber 2.0 )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list-flat/source.scm"
|
{ sourceName = "golden/read/list-flat/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
|
|||||||
+14
-26
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list/source.scm"
|
{ sourceName = "golden/read/list/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -11,8 +10,7 @@
|
|||||||
( DotListF
|
( DotListF
|
||||||
(
|
(
|
||||||
( MkAnn
|
( MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list/source.scm"
|
{ sourceName = "golden/read/list/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -23,8 +21,7 @@
|
|||||||
( SimpleSymbol "a" )
|
( SimpleSymbol "a" )
|
||||||
) :|
|
) :|
|
||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list/source.scm"
|
{ sourceName = "golden/read/list/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -34,8 +31,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "b" )
|
( SimpleSymbol "b" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list/source.scm"
|
{ sourceName = "golden/read/list/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -43,10 +39,9 @@
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
} :< CompoundF
|
} :< CompoundF
|
||||||
( ListF Ordinary
|
( ListF StyleData
|
||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list/source.scm"
|
{ sourceName = "golden/read/list/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -56,8 +51,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "c" )
|
( SimpleSymbol "c" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list/source.scm"
|
{ sourceName = "golden/read/list/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -71,8 +65,7 @@
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
( MkAnn
|
( MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list/source.scm"
|
{ sourceName = "golden/read/list/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -80,10 +73,9 @@
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
} :< CompoundF
|
} :< CompoundF
|
||||||
( ListF Ordinary
|
( ListF StyleData
|
||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list/source.scm"
|
{ sourceName = "golden/read/list/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -93,8 +85,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "가" )
|
( SimpleSymbol "가" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list/source.scm"
|
{ sourceName = "golden/read/list/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -105,8 +96,7 @@
|
|||||||
( DotListF
|
( DotListF
|
||||||
(
|
(
|
||||||
( MkAnn
|
( MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list/source.scm"
|
{ sourceName = "golden/read/list/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -118,8 +108,7 @@
|
|||||||
) :| []
|
) :| []
|
||||||
)
|
)
|
||||||
( MkAnn
|
( MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list/source.scm"
|
{ sourceName = "golden/read/list/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -131,8 +120,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/list/source.scm"
|
{ sourceName = "golden/read/list/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/meta-expression/source.scm"
|
{ sourceName = "golden/read/meta-expression/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/meta-splice-expression/source.scm"
|
{ sourceName = "golden/read/meta-splice-expression/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/meta-splice-variable/source.scm"
|
{ sourceName = "golden/read/meta-splice-variable/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/meta-variable/source.scm"
|
{ sourceName = "golden/read/meta-variable/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -10,8 +9,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "..." )
|
( SimpleSymbol "..." )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
||||||
, sourceLine = Pos 2
|
, sourceLine = Pos 2
|
||||||
@@ -21,8 +19,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol ".." )
|
( SimpleSymbol ".." )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
||||||
, sourceLine = Pos 3
|
, sourceLine = Pos 3
|
||||||
@@ -32,8 +29,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol ".abc" )
|
( SimpleSymbol ".abc" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
||||||
, sourceLine = Pos 4
|
, sourceLine = Pos 4
|
||||||
@@ -43,8 +39,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "....abcc" )
|
( SimpleSymbol "....abcc" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
||||||
, sourceLine = Pos 5
|
, sourceLine = Pos 5
|
||||||
@@ -54,8 +49,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol ".++-" )
|
( SimpleSymbol ".++-" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
||||||
, sourceLine = Pos 6
|
, sourceLine = Pos 6
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -10,8 +9,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "+" )
|
( SimpleSymbol "+" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -21,8 +19,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "-" )
|
( SimpleSymbol "-" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
||||||
, sourceLine = Pos 3
|
, sourceLine = Pos 3
|
||||||
@@ -32,8 +29,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "+." )
|
( SimpleSymbol "+." )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
||||||
, sourceLine = Pos 3
|
, sourceLine = Pos 3
|
||||||
@@ -43,8 +39,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "+.." )
|
( SimpleSymbol "+.." )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
||||||
, sourceLine = Pos 3
|
, sourceLine = Pos 3
|
||||||
@@ -54,8 +49,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "-." )
|
( SimpleSymbol "-." )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
||||||
, sourceLine = Pos 3
|
, sourceLine = Pos 3
|
||||||
@@ -65,8 +59,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "-...abc" )
|
( SimpleSymbol "-...abc" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
||||||
, sourceLine = Pos 3
|
, sourceLine = Pos 3
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/string/source.scm"
|
{ sourceName = "golden/read/string/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier-token/source.scm"
|
{ sourceName = "golden/read/typical-identifier-token/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -10,8 +9,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "abc" )
|
( SimpleSymbol "abc" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier-token/source.scm"
|
{ sourceName = "golden/read/typical-identifier-token/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -21,8 +19,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleString "xyz" )
|
( SimpleString "xyz" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier-token/source.scm"
|
{ sourceName = "golden/read/typical-identifier-token/source.scm"
|
||||||
, sourceLine = Pos 2
|
, sourceLine = Pos 2
|
||||||
@@ -32,8 +29,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "수학" )
|
( SimpleSymbol "수학" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier-token/source.scm"
|
{ sourceName = "golden/read/typical-identifier-token/source.scm"
|
||||||
, sourceLine = Pos 2
|
, sourceLine = Pos 2
|
||||||
@@ -41,10 +37,9 @@
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
} :< CompoundF
|
} :< CompoundF
|
||||||
( ListF Ordinary
|
( ListF StyleData
|
||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier-token/source.scm"
|
{ sourceName = "golden/read/typical-identifier-token/source.scm"
|
||||||
, sourceLine = Pos 2
|
, sourceLine = Pos 2
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[ MkAnn
|
[ MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier/source.scm"
|
{ sourceName = "golden/read/typical-identifier/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -10,8 +9,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "abc" )
|
( SimpleSymbol "abc" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier/source.scm"
|
{ sourceName = "golden/read/typical-identifier/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -21,8 +19,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "bala-hwa$" )
|
( SimpleSymbol "bala-hwa$" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier/source.scm"
|
{ sourceName = "golden/read/typical-identifier/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -32,8 +29,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "x!!!" )
|
( SimpleSymbol "x!!!" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier/source.scm"
|
{ sourceName = "golden/read/typical-identifier/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -43,8 +39,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "z" )
|
( SimpleSymbol "z" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier/source.scm"
|
{ sourceName = "golden/read/typical-identifier/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -54,8 +49,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "z123" )
|
( SimpleSymbol "z123" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier/source.scm"
|
{ sourceName = "golden/read/typical-identifier/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -65,8 +59,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "나는너무졸리다" )
|
( SimpleSymbol "나는너무졸리다" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier/source.scm"
|
{ sourceName = "golden/read/typical-identifier/source.scm"
|
||||||
, sourceLine = Pos 1
|
, sourceLine = Pos 1
|
||||||
@@ -76,8 +69,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "學" )
|
( SimpleSymbol "學" )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier/source.scm"
|
{ sourceName = "golden/read/typical-identifier/source.scm"
|
||||||
, sourceLine = Pos 3
|
, sourceLine = Pos 3
|
||||||
@@ -87,8 +79,7 @@
|
|||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "車室." )
|
( SimpleSymbol "車室." )
|
||||||
, MkAnn
|
, MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Just
|
||||||
, position = Just
|
|
||||||
( SourcePos
|
( SourcePos
|
||||||
{ sourceName = "golden/read/typical-identifier/source.scm"
|
{ sourceName = "golden/read/typical-identifier/source.scm"
|
||||||
, sourceLine = Pos 5
|
, sourceLine = Pos 5
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ common ghcstuffs
|
|||||||
ghc-options:
|
ghc-options:
|
||||||
-Wall -fdefer-type-errors -fno-show-valid-hole-fits
|
-Wall -fdefer-type-errors -fno-show-valid-hole-fits
|
||||||
-fdefer-out-of-scope-variables -threaded
|
-fdefer-out-of-scope-variables -threaded
|
||||||
|
-Wno-name-shadowing -Wno-partial-type-signatures
|
||||||
|
|
||||||
default-extensions:
|
default-extensions:
|
||||||
BlockArguments
|
BlockArguments
|
||||||
@@ -54,6 +55,7 @@ executable gyehoek
|
|||||||
library
|
library
|
||||||
import: ghcstuffs, ghcstuffs-dev
|
import: ghcstuffs, ghcstuffs-dev
|
||||||
ghc-options: -fplugin=Effectful.Plugin
|
ghc-options: -fplugin=Effectful.Plugin
|
||||||
|
-- build-tool-depends: retrie:retrie
|
||||||
|
|
||||||
-- cabal-fmt: expand src
|
-- cabal-fmt: expand src
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
|
|||||||
+12
-18
@@ -5,6 +5,8 @@
|
|||||||
{-# LANGUAGE TypeFamilies #-}
|
{-# LANGUAGE TypeFamilies #-}
|
||||||
{-# LANGUAGE FunctionalDependencies #-}
|
{-# LANGUAGE FunctionalDependencies #-}
|
||||||
{-# LANGUAGE DeriveAnyClass #-}
|
{-# LANGUAGE DeriveAnyClass #-}
|
||||||
|
{- HLINT ignore "Avoid lambda using `infix`" -}
|
||||||
|
{- HLINT ignore "Redundant $" -}
|
||||||
module Gyehoek.CPS.Syntax
|
module Gyehoek.CPS.Syntax
|
||||||
( Val(..)
|
( Val(..)
|
||||||
, Kappa(..)
|
, Kappa(..)
|
||||||
@@ -59,15 +61,12 @@ import Data.Monoid (Endo)
|
|||||||
import Data.Functor.Foldable.TH
|
import Data.Functor.Foldable.TH
|
||||||
import Data.Data.Lens (uniplate)
|
import Data.Data.Lens (uniplate)
|
||||||
import Gyehoek.Prelude hiding (op)
|
import Gyehoek.Prelude hiding (op)
|
||||||
import Gyehoek.Sexp (Datum)
|
import Gyehoek.Sexp (G, (:-)(..), Datum)
|
||||||
import Gyehoek.Sexp (G, (:-)(..))
|
|
||||||
import qualified Data.InvertibleGrammar.Base as IG
|
import qualified Data.InvertibleGrammar.Base as IG
|
||||||
import Gyehoek.GenSym (Gen)
|
import Gyehoek.GenSym (Gen)
|
||||||
import Data.String (IsString)
|
import Data.String (IsString)
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import qualified Data.HashMap.Strict as H
|
import qualified Data.HashMap.Strict as H
|
||||||
import GHC.Records (HasField (..))
|
|
||||||
import Data.Bifunctor
|
|
||||||
|
|
||||||
-- Data types
|
-- Data types
|
||||||
|
|
||||||
@@ -103,6 +102,7 @@ data Obj
|
|||||||
deriving stock (Show, Generic, Data, Eq)
|
deriving stock (Show, Generic, Data, Eq)
|
||||||
deriving anyclass (NFData)
|
deriving anyclass (NFData)
|
||||||
|
|
||||||
|
pattern ObjLabel :: Label -> Obj
|
||||||
pattern ObjLabel l = ObjImm (ImmLabel l)
|
pattern ObjLabel l = ObjImm (ImmLabel l)
|
||||||
|
|
||||||
-- | a heap object.
|
-- | a heap object.
|
||||||
@@ -188,7 +188,7 @@ pattern Halt1 x = ExpContinue (ValLabel "halt") [x]
|
|||||||
data Def = DefConstant Name Exp
|
data Def = DefConstant Name Exp
|
||||||
deriving (Show, Generic, Data)
|
deriving (Show, Generic, Data)
|
||||||
|
|
||||||
data Program = MkProgram
|
newtype Program = MkProgram
|
||||||
{ body :: Lambda
|
{ body :: Lambda
|
||||||
}
|
}
|
||||||
deriving (Show, Generic, Data)
|
deriving (Show, Generic, Data)
|
||||||
@@ -272,7 +272,7 @@ instance S.DatumIso Imm where
|
|||||||
|
|
||||||
instance S.DatumIso Label where
|
instance S.DatumIso Label where
|
||||||
datumIso = S.with \g -> S.coproduct
|
datumIso = S.with \g -> S.coproduct
|
||||||
[ S.decorate S.SynConstant >>> S.datumIso @Name >>> S.prismIso
|
[ S.datumIso @Name >>> S.prismIso
|
||||||
(S.expected "label")
|
(S.expected "label")
|
||||||
(prefixed @Name "$")
|
(prefixed @Name "$")
|
||||||
, S.list $ S.el (S.sym "$") >>> S.el (S.datumIso @Name)
|
, S.list $ S.el (S.sym "$") >>> S.el (S.datumIso @Name)
|
||||||
@@ -281,7 +281,7 @@ instance S.DatumIso Label where
|
|||||||
|
|
||||||
instance S.DatumIso Reg where
|
instance S.DatumIso Reg where
|
||||||
datumIso = S.with \g ->
|
datumIso = S.with \g ->
|
||||||
S.decorate S.SynVariable >>> S.datumIso @Name >>> S.prismIso
|
S.datumIso @Name >>> S.prismIso
|
||||||
(S.expected "register")
|
(S.expected "register")
|
||||||
(prefixed @Name "%")
|
(prefixed @Name "%")
|
||||||
>>> g
|
>>> g
|
||||||
@@ -342,9 +342,9 @@ instance S.DatumIso Exp where
|
|||||||
$ S.With (. app)
|
$ S.With (. app)
|
||||||
$ S.End
|
$ S.End
|
||||||
where
|
where
|
||||||
continue = S.list $
|
continue = S.listWithStyle (S.StyleSyntax 1) $
|
||||||
S.el (S.decorate S.SynBuiltin >>> S.sym "continue")
|
S.el (S.sym "continue")
|
||||||
>>> S.el (S.decorate S.SynProcedure >>> S.datumIso)
|
>>> S.el S.datumIso
|
||||||
>>> S.rest S.datumIso
|
>>> S.rest S.datumIso
|
||||||
letrec = S.letLike "letrec" S.datumIso S.datumIso S.datumIso
|
letrec = S.letLike "letrec" S.datumIso S.datumIso S.datumIso
|
||||||
if_ = S.ifLike "if"
|
if_ = S.ifLike "if"
|
||||||
@@ -365,8 +365,8 @@ instance S.DatumIso Exp where
|
|||||||
>>> S.el (S.datumIso @Kexp)
|
>>> S.el (S.datumIso @Kexp)
|
||||||
>>> S.rest (S.datumIso @Val)
|
>>> S.rest (S.datumIso @Val)
|
||||||
>>> S.onTail S.swap
|
>>> S.onTail S.swap
|
||||||
builtin = S.list $
|
builtin = S.listWithStyle (S.StyleSyntax 1) $
|
||||||
S.el (S.decorate S.SynBuiltin >>> S.sym "builtin")
|
S.el (S.sym "builtin")
|
||||||
>>> S.el (builtinDatumIso id (S.datumIso @Val))
|
>>> S.el (builtinDatumIso id (S.datumIso @Val))
|
||||||
>>> S.el S.datumIso
|
>>> S.el S.datumIso
|
||||||
|
|
||||||
@@ -414,15 +414,9 @@ cps = S.makeSx' [| toCPS |]
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
deleteFrom :: (Foldable f, Hashable a) => f a -> HashSet a -> HashSet a
|
|
||||||
deleteFrom = flip $ foldr HS.delete
|
|
||||||
|
|
||||||
insertFrom :: (Foldable f, Hashable a) => f a -> HashSet a -> HashSet a
|
insertFrom :: (Foldable f, Hashable a) => f a -> HashSet a -> HashSet a
|
||||||
insertFrom = flip $ foldr HS.insert
|
insertFrom = flip $ foldr HS.insert
|
||||||
|
|
||||||
toHashSetOf :: Hashable a => Getting (Endo (HashSet a)) s a -> s -> HashSet a
|
|
||||||
toHashSetOf l = foldrOf l HS.insert mempty
|
|
||||||
|
|
||||||
class Free a where
|
class Free a where
|
||||||
free :: a -> HashSet Name
|
free :: a -> HashSet Name
|
||||||
free = freeWithBound mempty
|
free = freeWithBound mempty
|
||||||
|
|||||||
@@ -59,6 +59,4 @@ instance Prefixed Name where
|
|||||||
--- DatumIsos
|
--- DatumIsos
|
||||||
|
|
||||||
instance S.DatumIso Name where
|
instance S.DatumIso Name where
|
||||||
datumIso = S.decorate S.SynVariable
|
datumIso = S.symbol >>> S.iso coerce coerce
|
||||||
>>> S.symbol
|
|
||||||
>>> S.iso coerce coerce
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ hashSetGrammar g =
|
|||||||
instance S.DatumIso Key where
|
instance S.DatumIso Key where
|
||||||
datumIso = S.with \g ->
|
datumIso = S.with \g ->
|
||||||
S.list
|
S.list
|
||||||
( S.el (S.symBuiltin "@")
|
( S.el (S.sym "@")
|
||||||
>>> S.el (S.datumIso @Name)
|
>>> S.el (S.datumIso @Name)
|
||||||
>>> S.el (hashSetGrammar S.datumIso)
|
>>> S.el (hashSetGrammar S.datumIso)
|
||||||
)
|
)
|
||||||
@@ -130,7 +130,7 @@ anykw s = S.Flip $ S.PartialIso
|
|||||||
|
|
||||||
prim_if :: S.DatumIso e => S.DatumGrammar (PrimIf e)
|
prim_if :: S.DatumIso e => S.DatumGrammar (PrimIf e)
|
||||||
prim_if = S.with \g ->
|
prim_if = S.with \g ->
|
||||||
S.listWithIndentation (NSpecial 1)
|
S.listWithStyle (StyleSyntax 1)
|
||||||
(S.el (anykw "if")
|
(S.el (anykw "if")
|
||||||
>>> S.el S.datumIso
|
>>> S.el S.datumIso
|
||||||
>>> S.el S.datumIso
|
>>> S.el S.datumIso
|
||||||
@@ -145,7 +145,7 @@ prim_lambda = S.with \g ->
|
|||||||
prim_let
|
prim_let
|
||||||
:: forall e. S.DatumIso e => S.DatumGrammar (PrimLet e)
|
:: forall e. S.DatumIso e => S.DatumGrammar (PrimLet e)
|
||||||
prim_let = S.with \g ->
|
prim_let = S.with \g ->
|
||||||
(S.listWithIndentation (NSpecial 1) $
|
(S.listWithStyle (StyleSyntax 1) $
|
||||||
S.el (anykw "let")
|
S.el (anykw "let")
|
||||||
>>> optEl (S.datumIso @Name)
|
>>> optEl (S.datumIso @Name)
|
||||||
>>> S.el (S.list $ S.rest $ S.datumIso @(Name,e))
|
>>> S.el (S.list $ S.rest $ S.datumIso @(Name,e))
|
||||||
@@ -154,7 +154,7 @@ prim_let = S.with \g ->
|
|||||||
|
|
||||||
prim_let_syntax :: S.DatumIso e => S.DatumGrammar (PrimLetSyntax e)
|
prim_let_syntax :: S.DatumIso e => S.DatumGrammar (PrimLetSyntax e)
|
||||||
prim_let_syntax = S.with \g ->
|
prim_let_syntax = S.with \g ->
|
||||||
(S.listWithIndentation (NSpecial 1) $
|
(S.listWithStyle (StyleSyntax 1) $
|
||||||
S.el (anykw "let-syntax")
|
S.el (anykw "let-syntax")
|
||||||
>>> S.el (S.list $ S.rest $ S.datumIso)
|
>>> S.el (S.list $ S.rest $ S.datumIso)
|
||||||
>>> S.rest S.datumIso)
|
>>> S.rest S.datumIso)
|
||||||
@@ -163,10 +163,10 @@ prim_let_syntax = S.with \g ->
|
|||||||
instance S.DatumIso Bind where
|
instance S.DatumIso Bind where
|
||||||
datumIso = S.match
|
datumIso = S.match
|
||||||
$ S.With (\g ->
|
$ S.With (\g ->
|
||||||
S.list (S.el (S.symBuiltin "L") >>> S.el S.datumIso >>> S.el S.datumIso)
|
S.list (S.el (S.sym "L") >>> S.el S.datumIso >>> S.el S.datumIso)
|
||||||
>>> g)
|
>>> g)
|
||||||
$ S.With (\g ->
|
$ S.With (\g ->
|
||||||
S.list (S.el (S.symBuiltin "G") >>> S.el S.datumIso)
|
S.list (S.el (S.sym "G") >>> S.el S.datumIso)
|
||||||
>>> g)
|
>>> g)
|
||||||
$ S.End
|
$ S.End
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ hashSetGrammar g =
|
|||||||
instance S.DatumIso Key where
|
instance S.DatumIso Key where
|
||||||
datumIso = S.with \g ->
|
datumIso = S.with \g ->
|
||||||
S.list
|
S.list
|
||||||
( S.el (S.symBuiltin "@")
|
( S.el (S.sym "@")
|
||||||
>>> S.el (S.datumIso @Name)
|
>>> S.el (S.datumIso @Name)
|
||||||
>>> S.el (hashSetGrammar S.datumIso)
|
>>> S.el (hashSetGrammar S.datumIso)
|
||||||
)
|
)
|
||||||
@@ -130,7 +130,7 @@ anykw s = S.Flip $ S.PartialIso
|
|||||||
|
|
||||||
prim_if :: S.DatumIso e => S.DatumGrammar (PrimIf e)
|
prim_if :: S.DatumIso e => S.DatumGrammar (PrimIf e)
|
||||||
prim_if = S.with \g ->
|
prim_if = S.with \g ->
|
||||||
S.listWithIndentation (NSpecial 1)
|
S.listWithStyle (StyleSyntax 1)
|
||||||
(S.el (anykw "if")
|
(S.el (anykw "if")
|
||||||
>>> S.el S.datumIso
|
>>> S.el S.datumIso
|
||||||
>>> S.el S.datumIso
|
>>> S.el S.datumIso
|
||||||
@@ -145,7 +145,7 @@ prim_lambda = S.with \g ->
|
|||||||
prim_let
|
prim_let
|
||||||
:: forall e. S.DatumIso e => S.DatumGrammar (PrimLet e)
|
:: forall e. S.DatumIso e => S.DatumGrammar (PrimLet e)
|
||||||
prim_let = S.with \g ->
|
prim_let = S.with \g ->
|
||||||
(S.listWithIndentation (NSpecial 1) $
|
(S.listWithStyle (StyleSyntax 1) $
|
||||||
S.el (anykw "let")
|
S.el (anykw "let")
|
||||||
>>> optEl (S.datumIso @Name)
|
>>> optEl (S.datumIso @Name)
|
||||||
>>> S.el (S.list $ S.rest $ S.datumIso @(Name,e))
|
>>> S.el (S.list $ S.rest $ S.datumIso @(Name,e))
|
||||||
@@ -154,7 +154,7 @@ prim_let = S.with \g ->
|
|||||||
|
|
||||||
prim_let_syntax :: S.DatumIso e => S.DatumGrammar (PrimLetSyntax e)
|
prim_let_syntax :: S.DatumIso e => S.DatumGrammar (PrimLetSyntax e)
|
||||||
prim_let_syntax = S.with \g ->
|
prim_let_syntax = S.with \g ->
|
||||||
(S.listWithIndentation (NSpecial 1) $
|
(S.listWithStyle (StyleSyntax 1) $
|
||||||
S.el (anykw "let-syntax")
|
S.el (anykw "let-syntax")
|
||||||
>>> S.el (S.list $ S.rest $ S.datumIso)
|
>>> S.el (S.list $ S.rest $ S.datumIso)
|
||||||
>>> S.rest S.datumIso)
|
>>> S.rest S.datumIso)
|
||||||
@@ -163,10 +163,10 @@ prim_let_syntax = S.with \g ->
|
|||||||
instance S.DatumIso Bind where
|
instance S.DatumIso Bind where
|
||||||
datumIso = S.match
|
datumIso = S.match
|
||||||
$ S.With (\g ->
|
$ S.With (\g ->
|
||||||
S.list (S.el (S.symBuiltin "L") >>> S.el S.datumIso >>> S.el S.datumIso)
|
S.list (S.el (S.sym "L") >>> S.el S.datumIso >>> S.el S.datumIso)
|
||||||
>>> g)
|
>>> g)
|
||||||
$ S.With (\g ->
|
$ S.With (\g ->
|
||||||
S.list (S.el (S.symBuiltin "G") >>> S.el S.datumIso)
|
S.list (S.el (S.sym "G") >>> S.el S.datumIso)
|
||||||
>>> g)
|
>>> g)
|
||||||
$ S.End
|
$ S.End
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
{-# LANGUAGE PatternSynonyms #-}
|
{-# LANGUAGE PatternSynonyms #-}
|
||||||
{-# LANGUAGE DeriveAnyClass #-}
|
{-# LANGUAGE DeriveAnyClass #-}
|
||||||
{-# LANGUAGE ViewPatterns #-}
|
{-# LANGUAGE ViewPatterns #-}
|
||||||
|
{- HLINT ignore "Avoid lambda using `infix`" -}
|
||||||
|
{- HLINT ignore "Redundant $" -}
|
||||||
module Gyehoek.Scheme.Syntax
|
module Gyehoek.Scheme.Syntax
|
||||||
( Name(..)
|
( Name(..)
|
||||||
, Builtin(..)
|
, Builtin(..)
|
||||||
@@ -36,8 +38,6 @@ module Gyehoek.Scheme.Syntax
|
|||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
import Data.List (intersperse)
|
|
||||||
import Effectful
|
|
||||||
import Prelude hiding ((.), id)
|
import Prelude hiding ((.), id)
|
||||||
import Control.Category
|
import Control.Category
|
||||||
import Gyehoek.Sexp qualified as GS
|
import Gyehoek.Sexp qualified as GS
|
||||||
@@ -50,12 +50,7 @@ import Data.Functor.Foldable hiding (fold)
|
|||||||
import qualified Data.HashSet as HS
|
import qualified Data.HashSet as HS
|
||||||
import Data.Foldable (fold, toList)
|
import Data.Foldable (fold, toList)
|
||||||
import Language.Haskell.TH.Quote (QuasiQuoter)
|
import Language.Haskell.TH.Quote (QuasiQuoter)
|
||||||
import Effectful.FileSystem (runFileSystem)
|
|
||||||
import qualified Effectful.FileSystem.IO as FS
|
|
||||||
import qualified Data.Text.Encoding as T
|
|
||||||
import qualified Effectful.FileSystem.IO.ByteString as FB
|
|
||||||
import qualified Data.Set.Ordered as O
|
import qualified Data.Set.Ordered as O
|
||||||
import Gyehoek.Sexp.Grammar qualified as Sexp
|
|
||||||
import Gyehoek.Sexp.Grammar qualified as S
|
import Gyehoek.Sexp.Grammar qualified as S
|
||||||
import Gyehoek.Sexp.Grammar (DatumIso, G, DataIso, (:-)((:-)))
|
import Gyehoek.Sexp.Grammar (DatumIso, G, DataIso, (:-)((:-)))
|
||||||
import Gyehoek.Prelude
|
import Gyehoek.Prelude
|
||||||
@@ -247,9 +242,7 @@ makeBaseFunctor ''Exp
|
|||||||
|
|
||||||
|
|
||||||
instance DatumIso Name where
|
instance DatumIso Name where
|
||||||
datumIso = S.decorate S.SynVariable
|
datumIso = S.symbol >>> S.iso coerce coerce
|
||||||
>>> S.symbol
|
|
||||||
>>> S.iso coerce coerce
|
|
||||||
|
|
||||||
builtinDatumIso
|
builtinDatumIso
|
||||||
:: (Text -> Text)
|
:: (Text -> Text)
|
||||||
@@ -315,9 +308,9 @@ instance DatumIso Def where
|
|||||||
|
|
||||||
instance DatumIso Trans where
|
instance DatumIso Trans where
|
||||||
datumIso = S.with \g ->
|
datumIso = S.with \g ->
|
||||||
S.listWithIndentation
|
S.listWithStyle
|
||||||
(S.NSpecial 1)
|
(S.StyleSyntax 1)
|
||||||
( S.el (S.symBuiltin "syntax-rules")
|
( S.el (S.sym "syntax-rules")
|
||||||
>>> S.Iso (\(ctx:-t) -> ctx:-"...":-t) (\(ctx:-_:-t) -> ctx:-t)
|
>>> S.Iso (\(ctx:-t) -> ctx:-"...":-t) (\(ctx:-_:-t) -> ctx:-t)
|
||||||
>>> S.el (S.list $ S.rest (S.datumIso @Name))
|
>>> S.el (S.list $ S.rest (S.datumIso @Name))
|
||||||
>>> S.rest (S.datumIso @Rule)
|
>>> S.rest (S.datumIso @Rule)
|
||||||
@@ -339,8 +332,8 @@ instance DatumIso Exp where
|
|||||||
$ S.With (\app -> app . S.list (S.el S.datumIso >>> S.rest S.datumIso))
|
$ S.With (\app -> app . S.list (S.el S.datumIso >>> S.rest S.datumIso))
|
||||||
$ S.End
|
$ S.End
|
||||||
where
|
where
|
||||||
letsyntax = S.listWithIndentation (S.NSpecial 1) $
|
letsyntax = S.listWithStyle (S.StyleSyntax 1) $
|
||||||
S.el (S.symBuiltin "let-syntax")
|
S.el (S.sym "let-syntax")
|
||||||
>>> S.el (S.list $ S.rest $ S.datumIso)
|
>>> S.el (S.list $ S.rest $ S.datumIso)
|
||||||
>>> S.el S.datumIso
|
>>> S.el S.datumIso
|
||||||
lam = S.lambdaLike S.lambdaKeyword S.datumIso (S.el S.datumIso)
|
lam = S.lambdaLike S.lambdaKeyword S.datumIso (S.el S.datumIso)
|
||||||
@@ -481,16 +474,16 @@ instance DatumIso ImportSet where
|
|||||||
$ S.With (imp "rename" >>>)
|
$ S.With (imp "rename" >>>)
|
||||||
$ S.End
|
$ S.End
|
||||||
where
|
where
|
||||||
imp s = S.list $ S.el (S.symBuiltin s)
|
imp s = S.list $ S.el (S.sym s)
|
||||||
>>> S.el S.datumIso >>> S.restData S.dataIso
|
>>> S.el S.datumIso >>> S.restData S.dataIso
|
||||||
imp' s = S.list $
|
imp' s = S.list $
|
||||||
S.el (S.symBuiltin s)
|
S.el (S.sym s)
|
||||||
>>> S.el S.datumIso
|
>>> S.el S.datumIso
|
||||||
>>> S.el S.datumIso
|
>>> S.el S.datumIso
|
||||||
|
|
||||||
instance DatumIso ImportDecl where
|
instance DatumIso ImportDecl where
|
||||||
datumIso = S.with \decl ->
|
datumIso = S.with \decl ->
|
||||||
S.list (S.el (S.symBuiltin "import") >>> S.restData S.dataIso)
|
S.list (S.el (S.sym "import") >>> S.restData S.dataIso)
|
||||||
>>> decl
|
>>> decl
|
||||||
|
|
||||||
instance DataIso Program where
|
instance DataIso Program where
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
{- HLINT ignore "Avoid lambda" -}
|
||||||
-- | cribbed from sexp-grammar:Language.SexpGrammar.Base
|
-- | cribbed from sexp-grammar:Language.SexpGrammar.Base
|
||||||
module Gyehoek.Sexp.Grammar.Base
|
module Gyehoek.Sexp.Grammar.Base
|
||||||
( module Gyehoek.Sexp.Syntax
|
( module Gyehoek.Sexp.Syntax
|
||||||
@@ -8,12 +9,11 @@ module Gyehoek.Sexp.Grammar.Base
|
|||||||
, Grammar(..)
|
, Grammar(..)
|
||||||
, DatumGrammar
|
, DatumGrammar
|
||||||
, DataGrammar
|
, DataGrammar
|
||||||
, Grammar
|
|
||||||
, ListContext(..)
|
, ListContext(..)
|
||||||
, (:-)((:-))
|
, (:-)((:-))
|
||||||
-- * lists
|
-- * lists
|
||||||
, list
|
, list
|
||||||
, listWithIndentation
|
, listWithStyle
|
||||||
, el
|
, el
|
||||||
, rest
|
, rest
|
||||||
, restData
|
, restData
|
||||||
@@ -23,6 +23,7 @@ module Gyehoek.Sexp.Grammar.Base
|
|||||||
, headTagged1'
|
, headTagged1'
|
||||||
, headTagged1
|
, headTagged1
|
||||||
, headTagged2
|
, headTagged2
|
||||||
|
, headTagged2'
|
||||||
-- * atoms
|
-- * atoms
|
||||||
, simple
|
, simple
|
||||||
, string
|
, string
|
||||||
@@ -33,24 +34,22 @@ module Gyehoek.Sexp.Grammar.Base
|
|||||||
, integer
|
, integer
|
||||||
, int
|
, int
|
||||||
, unreadable
|
, unreadable
|
||||||
-- ** symbols
|
|
||||||
, symBuiltin
|
|
||||||
-- * TODO: sort lol
|
-- * TODO: sort lol
|
||||||
, prismIso
|
, prismIso
|
||||||
, isoIso, decorate
|
, isoIso
|
||||||
, snoced
|
, snoced
|
||||||
, letLike
|
, letLike
|
||||||
, ifLike
|
, ifLike
|
||||||
, lambdaLike
|
, lambdaLike
|
||||||
, lambdaKeyword
|
, lambdaKeyword
|
||||||
, kappaKeyword
|
, kappaKeyword
|
||||||
, beginLike, headTagged2', dottedList, reifyContext, recontextualise, decontextualise
|
, beginLike
|
||||||
|
, dottedList
|
||||||
|
, reifyContext, recontextualise, decontextualise, redecorate
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.InvertibleGrammar
|
import Data.InvertibleGrammar
|
||||||
import Data.InvertibleGrammar.Base
|
import Data.InvertibleGrammar.Base
|
||||||
import Data.InvertibleGrammar.Base as Re
|
|
||||||
( Grammar(..))
|
|
||||||
import Data.InvertibleGrammar.Combinators
|
import Data.InvertibleGrammar.Combinators
|
||||||
import Gyehoek.Prelude hiding (flipped, traversed, iso, cons, coerced, Iso, Simple, simple)
|
import Gyehoek.Prelude hiding (flipped, traversed, iso, cons, coerced, Iso, Simple, simple)
|
||||||
import Gyehoek.Sexp.Syntax hiding (position)
|
import Gyehoek.Sexp.Syntax hiding (position)
|
||||||
@@ -58,7 +57,6 @@ import Gyehoek.Sexp.Print (printDatum')
|
|||||||
import Data.Scientific (Scientific)
|
import Data.Scientific (Scientific)
|
||||||
import qualified Data.Scientific as Sci
|
import qualified Data.Scientific as Sci
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Control.Monad.RWS (modify)
|
|
||||||
import qualified Data.List.NonEmpty as NE
|
import qualified Data.List.NonEmpty as NE
|
||||||
import Data.Foldable (toList)
|
import Data.Foldable (toList)
|
||||||
|
|
||||||
@@ -89,14 +87,6 @@ locate =
|
|||||||
(\(_ :- t) -> t)
|
(\(_ :- t) -> t)
|
||||||
(\t -> noAnn :- t)
|
(\t -> noAnn :- t)
|
||||||
|
|
||||||
modifyAnn :: (Ann -> Ann) -> G (Datum :- t) (Datum :- t)
|
|
||||||
modifyAnn f = Iso
|
|
||||||
(\(d:-t) -> (d & ann %~ f) :- t)
|
|
||||||
(\(d:-t) -> (d & ann %~ f) :- t)
|
|
||||||
|
|
||||||
decorate :: Syn -> G (Datum :- t) (Datum :- t)
|
|
||||||
decorate s = modifyAnn $ #syntax .~ s
|
|
||||||
|
|
||||||
newtype ListContext = MkListContext { inner :: List Datum }
|
newtype ListContext = MkListContext { inner :: List Datum }
|
||||||
|
|
||||||
unexpectedSimple :: Simple -> Mismatch
|
unexpectedSimple :: Simple -> Mismatch
|
||||||
@@ -108,7 +98,7 @@ unexpectedDatum = unexpected . printDatum'
|
|||||||
list
|
list
|
||||||
:: G (ListContext :- t) (ListContext :- t')
|
:: G (ListContext :- t) (ListContext :- t')
|
||||||
-> G (Datum :- t) t'
|
-> G (Datum :- t) t'
|
||||||
list = listWithIndentation Ordinary
|
list = listWithStyle StyleData
|
||||||
|
|
||||||
-- |
|
-- |
|
||||||
-- >>> let grammar = with \g -> dottedList (el int) int >>> g
|
-- >>> let grammar = with \g -> dottedList (el int) int >>> g
|
||||||
@@ -143,11 +133,11 @@ dottedList g final = begin >>> Dive (onTail (g >>> end) >>> final)
|
|||||||
[] -> Right t
|
[] -> Right t
|
||||||
d:_ -> Left $ unexpectedDatum d)
|
d:_ -> Left $ unexpectedDatum d)
|
||||||
|
|
||||||
listWithIndentation
|
listWithStyle
|
||||||
:: Indentation
|
:: Style
|
||||||
-> G (ListContext :- t) (ListContext :- t')
|
-> G (ListContext :- t) (ListContext :- t')
|
||||||
-> G (Datum :- t) t'
|
-> G (Datum :- t) t'
|
||||||
listWithIndentation ind g = begin >>> Dive (g >>> end)
|
listWithStyle ind g = begin >>> Dive (g >>> end)
|
||||||
where
|
where
|
||||||
begin = locate >>> partialOsi
|
begin = locate >>> partialOsi
|
||||||
(\case
|
(\case
|
||||||
@@ -378,33 +368,36 @@ int = integer >>> iso fromIntegral fromIntegral
|
|||||||
|
|
||||||
-- high-level combinators
|
-- high-level combinators
|
||||||
|
|
||||||
|
redecorate :: Style -> G (Datum :- t) t' -> G (Datum :- t) t'
|
||||||
|
redecorate sty g = iso (styleWith sty) (styleWith sty) >>> g
|
||||||
|
|
||||||
headTagged0 :: Text -> G (Datum :- t) t
|
headTagged0 :: Text -> G (Datum :- t) t
|
||||||
headTagged0 s = list $ el (symProcedure s)
|
headTagged0 s = listWithStyle StyleCode $ el (sym s)
|
||||||
|
|
||||||
headTagged0' :: Text -> DatumGrammar a -> G (Datum :- t) (List a :- t)
|
headTagged0' :: Text -> DatumGrammar a -> G (Datum :- t) (List a :- t)
|
||||||
headTagged0' s gt = list $ el (symProcedure s) >>> rest gt
|
headTagged0' s gt = listWithStyle StyleCode $ el (sym s) >>> rest gt
|
||||||
|
|
||||||
headTagged1 :: Text -> DatumGrammar a -> G (Datum :- t) (a :- t)
|
headTagged1 :: Text -> DatumGrammar a -> G (Datum :- t) (a :- t)
|
||||||
headTagged1 s g1 = list $ el (symProcedure s) >>> el g1
|
headTagged1 s g1 = listWithStyle StyleCode $ el (sym s) >>> el g1
|
||||||
|
|
||||||
headTagged1'
|
headTagged1'
|
||||||
:: Text
|
:: Text
|
||||||
-> DatumGrammar a -> DatumGrammar b
|
-> DatumGrammar a -> DatumGrammar b
|
||||||
-> G (Datum :- t) (List b :- a :- t)
|
-> G (Datum :- t) (List b :- a :- t)
|
||||||
headTagged1' s g1 gt = list $ el (symProcedure s) >>> el g1 >>> rest gt
|
headTagged1' s g1 gt = list $ el (sym s) >>> el g1 >>> rest gt
|
||||||
|
|
||||||
headTagged2
|
headTagged2
|
||||||
:: Text
|
:: Text
|
||||||
-> DatumGrammar a -> DatumGrammar b
|
-> DatumGrammar a -> DatumGrammar b
|
||||||
-> G (Datum :- t) (b :- a :- t)
|
-> G (Datum :- t) (b :- a :- t)
|
||||||
headTagged2 s g1 g2 = list $ el (symProcedure s) >>> el g1 >>> el g2
|
headTagged2 s g1 g2 = listWithStyle StyleCode $ el (sym s) >>> el g1 >>> el g2
|
||||||
|
|
||||||
headTagged2'
|
headTagged2'
|
||||||
:: Text
|
:: Text
|
||||||
-> DatumGrammar a -> DatumGrammar b -> DatumGrammar c
|
-> DatumGrammar a -> DatumGrammar b -> DatumGrammar c
|
||||||
-> G (Datum :- t) (List c :- b :- a :- t)
|
-> G (Datum :- t) (List c :- b :- a :- t)
|
||||||
headTagged2' s g1 g2 gt =
|
headTagged2' s g1 g2 gt =
|
||||||
list $ el (symProcedure s) >>> el g1 >>> el g2 >>> rest gt
|
listWithStyle StyleCode $ el (sym s) >>> el g1 >>> el g2 >>> rest gt
|
||||||
|
|
||||||
ifLike
|
ifLike
|
||||||
-- | keyword
|
-- | keyword
|
||||||
@@ -417,12 +410,8 @@ ifLike
|
|||||||
-> DatumGrammar c
|
-> DatumGrammar c
|
||||||
-> G (Datum :- t) (c :- b :- a :- t)
|
-> G (Datum :- t) (c :- b :- a :- t)
|
||||||
ifLike kw c t f =
|
ifLike kw c t f =
|
||||||
listWithIndentation (NSpecial 1) $
|
listWithStyle (StyleSyntax 1) $
|
||||||
el (symBuiltin kw) >>> el c >>> el t >>> el f
|
el (sym kw) >>> el c >>> el t >>> el f
|
||||||
|
|
||||||
symBuiltin, symProcedure :: Text -> G (Datum :- t) t
|
|
||||||
symBuiltin s = decorate SynBuiltin >>> sym s
|
|
||||||
symProcedure s = decorate SynProcedure >>> sym s
|
|
||||||
|
|
||||||
letLike
|
letLike
|
||||||
:: Text
|
:: Text
|
||||||
@@ -430,8 +419,8 @@ letLike
|
|||||||
-> (forall t. G (Datum :- t) (b :- t))
|
-> (forall t. G (Datum :- t) (b :- t))
|
||||||
-> G (Datum :- List (a, b) :- t1) t2
|
-> G (Datum :- List (a, b) :- t1) t2
|
||||||
-> G (Datum :- t1) t2
|
-> G (Datum :- t1) t2
|
||||||
letLike kw name rhs e = listWithIndentation (NSpecial 1) $
|
letLike kw name rhs e = listWithStyle (StyleSyntax 1) $
|
||||||
el (symBuiltin kw) >>> el bindings >>> el e
|
el (sym kw) >>> el bindings >>> el e
|
||||||
where
|
where
|
||||||
bindings = list $ rest binding
|
bindings = list $ rest binding
|
||||||
binding :: G (Datum :- t) ((_, _) :- t)
|
binding :: G (Datum :- t) ((_, _) :- t)
|
||||||
@@ -442,8 +431,8 @@ lambdaLike
|
|||||||
-> G (Datum :- t1) (a :- t2)
|
-> G (Datum :- t1) (a :- t2)
|
||||||
-> G (ListContext :- a :- t2) (ListContext :- t3)
|
-> G (ListContext :- a :- t2) (ListContext :- t3)
|
||||||
-> G (Datum :- t1) t3
|
-> G (Datum :- t1) t3
|
||||||
lambdaLike kw formals body = listWithIndentation (NSpecial 1) $
|
lambdaLike kw formals body = listWithStyle (StyleSyntax 1) $
|
||||||
el (decorate SynBuiltin >>> kw)
|
el kw
|
||||||
>>> el formals
|
>>> el formals
|
||||||
>>> body
|
>>> body
|
||||||
|
|
||||||
@@ -458,8 +447,8 @@ beginLike
|
|||||||
-> G (ListContext :- t) (ListContext :- t')
|
-> G (ListContext :- t) (ListContext :- t')
|
||||||
-> G (Datum :- t) t'
|
-> G (Datum :- t) t'
|
||||||
beginLike kw g =
|
beginLike kw g =
|
||||||
listWithIndentation (NSpecial 0) $
|
listWithStyle (StyleSyntax 0) $
|
||||||
el (symBuiltin kw) >>> g
|
el (sym kw) >>> g
|
||||||
|
|
||||||
-- | define a printed syntax for an object which cannot be read.
|
-- | define a printed syntax for an object which cannot be read.
|
||||||
unreadable
|
unreadable
|
||||||
|
|||||||
+27
-21
@@ -1,3 +1,4 @@
|
|||||||
|
{-# OPTIONS_GHC -Wno-incomplete-patterns #-}
|
||||||
module Gyehoek.Sexp.Print
|
module Gyehoek.Sexp.Print
|
||||||
( printDatum
|
( printDatum
|
||||||
, printDatumW
|
, printDatumW
|
||||||
@@ -6,26 +7,34 @@ module Gyehoek.Sexp.Print
|
|||||||
, printData'
|
, printData'
|
||||||
, htmlDatum
|
, htmlDatum
|
||||||
, htmlData
|
, htmlData
|
||||||
|
, putDoc
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Gyehoek.Sexp.Syntax
|
import Gyehoek.Sexp.Syntax
|
||||||
import Prettyprinter
|
import Prettyprinter
|
||||||
import Data.Functor.Foldable
|
import Gyehoek.Prelude hiding (Simple)
|
||||||
import qualified Control.Comonad.Trans.Cofree as F
|
|
||||||
import Prettyprinter.Util
|
|
||||||
import Gyehoek.Prelude hiding (Simple, (:<))
|
|
||||||
import Data.Foldable (traverse_, toList)
|
|
||||||
import qualified Prettyprinter.Render.Terminal as ANSI
|
import qualified Prettyprinter.Render.Terminal as ANSI
|
||||||
import System.IO (stdout)
|
import System.IO (stdout)
|
||||||
import Prettyprinter.Render.Terminal (Color(..), color, italicized, AnsiStyle, bold, colorDull)
|
import Prettyprinter.Render.Terminal (Color(..), color, italicized, AnsiStyle, bold, colorDull)
|
||||||
import Prettyprinter.Render.Text (renderStrict)
|
import Prettyprinter.Render.Text (renderStrict)
|
||||||
import qualified Data.Scientific as Sci
|
|
||||||
import Data.List (intersperse)
|
import Data.List (intersperse)
|
||||||
import Lucid
|
import Lucid
|
||||||
import Prettyprinter.Render.Util.SimpleDocTree (treeForm)
|
import Prettyprinter.Render.Util.SimpleDocTree (treeForm)
|
||||||
import Prettyprinter.Lucid (renderHtml)
|
import Prettyprinter.Lucid (renderHtml)
|
||||||
|
import Data.Foldable (toList)
|
||||||
|
import qualified Data.Scientific as Sci
|
||||||
|
|
||||||
|
|
||||||
|
data Syn
|
||||||
|
= SynSyntax
|
||||||
|
| SynProcedure
|
||||||
|
| SynParen Int
|
||||||
|
| SynString
|
||||||
|
| SynConstant
|
||||||
|
| SynVariable
|
||||||
|
| SynNone
|
||||||
|
deriving (Show, Read, Data, Generic, Eq)
|
||||||
|
|
||||||
printDatum' :: Datum -> Text
|
printDatum' :: Datum -> Text
|
||||||
printDatum' =
|
printDatum' =
|
||||||
prettyDatum 0
|
prettyDatum 0
|
||||||
@@ -83,7 +92,7 @@ printDatumW w =
|
|||||||
|
|
||||||
prettyDatum :: Int -> Datum -> Doc Syn
|
prettyDatum :: Int -> Datum -> Doc Syn
|
||||||
prettyDatum depth datum = case datum of
|
prettyDatum depth datum = case datum of
|
||||||
Simple simp -> annotate (datum ^. syntax) $ prettySimple depth simp
|
Simple simp -> prettySimple depth simp
|
||||||
DotList xs x ->
|
DotList xs x ->
|
||||||
pparen depth . group . align $
|
pparen depth . group . align $
|
||||||
vsep [ vsep (prettyDatum (depth+1) <$> toList xs)
|
vsep [ vsep (prettyDatum (depth+1) <$> toList xs)
|
||||||
@@ -91,19 +100,21 @@ prettyDatum depth datum = case datum of
|
|||||||
, prettyDatum (depth+1) x
|
, prettyDatum (depth+1) x
|
||||||
]
|
]
|
||||||
|
|
||||||
List' indent xs ->
|
List' sty xs -> case sty of
|
||||||
case indent of
|
StyleSyntax n | keyword:args <- xs ->
|
||||||
NSpecial n | keyword:args <- xs ->
|
|
||||||
let (specialArgs,body) = splitAt n args
|
let (specialArgs,body) = splitAt n args
|
||||||
in pparen depth . nest 2 . vsep $
|
in pparen depth . nest 2 . vsep $
|
||||||
[ group . nest 2 . hcat $
|
[ group . nest 2 . hcat $
|
||||||
[ prettyDatum (depth+1) keyword
|
[ annotate SynSyntax $ prettyDatum (depth+1) keyword
|
||||||
, if null specialArgs then mempty else softline
|
, if null specialArgs then mempty else softline
|
||||||
, hsep $ prettyDatum (depth+1) <$> specialArgs
|
, hsep $ prettyDatum (depth+1) <$> specialArgs
|
||||||
]
|
]
|
||||||
, vsep $ prettyDatum (depth+1) <$> body
|
, vsep $ prettyDatum (depth+1) <$> body
|
||||||
]
|
]
|
||||||
Ordinary; NSpecial _ -> pparen depth $
|
StyleCode | f:args <- xs -> pparen depth $
|
||||||
|
group . align . vsep . (_head %~ annotate SynProcedure) $
|
||||||
|
prettyDatum (depth+1) <$> xs
|
||||||
|
StyleData; StyleSyntax _; StyleCode -> pparen depth $
|
||||||
group . align . vsep $
|
group . align . vsep $
|
||||||
prettyDatum (depth+1) <$> xs
|
prettyDatum (depth+1) <$> xs
|
||||||
_ -> error [i|unimplemented: #{datum}|]
|
_ -> error [i|unimplemented: #{datum}|]
|
||||||
@@ -111,15 +122,11 @@ prettyDatum depth datum = case datum of
|
|||||||
pparen depth = enclose (delim depth "(") (delim depth ")")
|
pparen depth = enclose (delim depth "(") (delim depth ")")
|
||||||
delim depth = annotate (SynParen depth)
|
delim depth = annotate (SynParen depth)
|
||||||
|
|
||||||
delimited :: Int -> Doc Syn -> Doc Syn -> List (Doc Syn) -> Doc Syn
|
|
||||||
delimited depth open close =
|
|
||||||
encloseSep (delim depth open) (delim depth close) softline
|
|
||||||
|
|
||||||
prettySimple :: Int -> Simple -> Doc Syn
|
prettySimple :: Int -> Simple -> Doc Syn
|
||||||
prettySimple depth = \case
|
prettySimple depth = \case
|
||||||
SimpleBoolean b -> annotate SynConstant $ if b then "#t" else "#f"
|
SimpleBoolean b -> annotate SynConstant $ if b then "#t" else "#f"
|
||||||
SimpleNumber n ->
|
SimpleNumber n -> n
|
||||||
Sci.floatingOrInteger n
|
& Sci.floatingOrInteger @Double @Integer
|
||||||
& either viaShow viaShow
|
& either viaShow viaShow
|
||||||
& annotate SynConstant
|
& annotate SynConstant
|
||||||
SimpleString s -> annotate SynString $ viaShow s
|
SimpleString s -> annotate SynString $ viaShow s
|
||||||
@@ -132,7 +139,7 @@ putDoc = ANSI.renderIO stdout
|
|||||||
|
|
||||||
highlightAnsi :: Syn -> AnsiStyle
|
highlightAnsi :: Syn -> AnsiStyle
|
||||||
highlightAnsi = \case
|
highlightAnsi = \case
|
||||||
(SynBuiltin; SynMacro) -> color Magenta <> italicized <> bold
|
SynSyntax -> color Magenta <> italicized <> bold
|
||||||
SynProcedure -> color Blue
|
SynProcedure -> color Blue
|
||||||
SynConstant -> color Yellow
|
SynConstant -> color Yellow
|
||||||
SynParen n -> colorDull $ rainbow ^?! ix n
|
SynParen n -> colorDull $ rainbow ^?! ix n
|
||||||
@@ -144,8 +151,7 @@ highlightHtml :: Syn -> Html () -> Html ()
|
|||||||
highlightHtml syn = span_ [class_ synClass]
|
highlightHtml syn = span_ [class_ synClass]
|
||||||
where
|
where
|
||||||
synClass = case syn of
|
synClass = case syn of
|
||||||
SynBuiltin -> "syn-builtin"
|
SynSyntax -> "syn-builtin"
|
||||||
SynMacro -> "syn-macro"
|
|
||||||
SynConstant -> "syn-constant"
|
SynConstant -> "syn-constant"
|
||||||
SynString -> "syn-string"
|
SynString -> "syn-string"
|
||||||
SynProcedure -> "syn-procedure"
|
SynProcedure -> "syn-procedure"
|
||||||
|
|||||||
@@ -254,9 +254,9 @@ compoundDatum = choice
|
|||||||
list :: P Compound
|
list :: P Compound
|
||||||
list = label "list" . between lparen rparen $ do
|
list = label "list" . between lparen rparen $ do
|
||||||
optional datum >>= \case
|
optional datum >>= \case
|
||||||
Nothing -> pure $ ListF Ordinary []
|
Nothing -> pure $ ListF StyleData []
|
||||||
Just x -> do
|
Just x -> do
|
||||||
xs <- many datum
|
xs <- many datum
|
||||||
optional (dot *> datum) >>= \case
|
optional (dot *> datum) >>= \case
|
||||||
Nothing -> pure $ ListF Ordinary (x:xs)
|
Nothing -> pure $ ListF StyleData (x:xs)
|
||||||
Just y -> pure $ DotListF (x:|xs) y
|
Just y -> pure $ DotListF (x:|xs) y
|
||||||
|
|||||||
+34
-47
@@ -1,6 +1,7 @@
|
|||||||
{-# LANGUAGE DeriveAnyClass #-}
|
{-# LANGUAGE DeriveAnyClass #-}
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
{-# LANGUAGE ApplicativeDo #-}
|
{-# LANGUAGE ApplicativeDo #-}
|
||||||
|
{- HLINT ignore "Use newtype instead of data" -}
|
||||||
module Gyehoek.Sexp.Syntax
|
module Gyehoek.Sexp.Syntax
|
||||||
( DatumF(..)
|
( DatumF(..)
|
||||||
, Simple(..)
|
, Simple(..)
|
||||||
@@ -13,8 +14,7 @@ module Gyehoek.Sexp.Syntax
|
|||||||
, Cofree((:<))
|
, Cofree((:<))
|
||||||
, Fix(..)
|
, Fix(..)
|
||||||
, Compound
|
, Compound
|
||||||
, Indentation(..)
|
, Style(..)
|
||||||
, Syn(..)
|
|
||||||
, pattern Simple
|
, pattern Simple
|
||||||
, pattern Compound
|
, pattern Compound
|
||||||
, pattern Labeled
|
, pattern Labeled
|
||||||
@@ -25,10 +25,8 @@ module Gyehoek.Sexp.Syntax
|
|||||||
, pattern Vector
|
, pattern Vector
|
||||||
, pattern DotList
|
, pattern DotList
|
||||||
, pattern Gyehoek.Sexp.Syntax.List
|
, pattern Gyehoek.Sexp.Syntax.List
|
||||||
, syntax
|
, style
|
||||||
, indentation
|
, styleWith
|
||||||
, adorn
|
|
||||||
, indentWith
|
|
||||||
, pattern Unreadable
|
, pattern Unreadable
|
||||||
, pattern Bytevector
|
, pattern Bytevector
|
||||||
, pattern Symbol
|
, pattern Symbol
|
||||||
@@ -45,10 +43,10 @@ module Gyehoek.Sexp.Syntax
|
|||||||
, stripAnn
|
, stripAnn
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Language.Haskell.TH.Syntax (Lift (lift), liftData)
|
import Language.Haskell.TH.Syntax (Lift (lift))
|
||||||
import Data.Scientific (Scientific)
|
import Data.Scientific (Scientific)
|
||||||
import Data.ByteString (ByteString)
|
import Data.ByteString (ByteString)
|
||||||
import Gyehoek.Prelude hiding ((:<), Simple)
|
import Gyehoek.Prelude hiding (Simple)
|
||||||
import Text.Megaparsec.Pos (SourcePos(..), sourcePosPretty)
|
import Text.Megaparsec.Pos (SourcePos(..), sourcePosPretty)
|
||||||
import Control.Comonad.Cofree (Cofree((:<)), _extract, _unwrap)
|
import Control.Comonad.Cofree (Cofree((:<)), _extract, _unwrap)
|
||||||
import Data.Fix (Fix (..))
|
import Data.Fix (Fix (..))
|
||||||
@@ -88,7 +86,7 @@ data Simple
|
|||||||
deriving anyclass (NFData)
|
deriving anyclass (NFData)
|
||||||
|
|
||||||
data CompoundF a
|
data CompoundF a
|
||||||
= ListF Indentation (List a)
|
= ListF Style (List a)
|
||||||
| DotListF (NonEmpty a) a
|
| DotListF (NonEmpty a) a
|
||||||
| VectorF (List a)
|
| VectorF (List a)
|
||||||
| AbbrevF Prefix a
|
| AbbrevF Prefix a
|
||||||
@@ -122,33 +120,21 @@ newtype Label = MkLabel Natural
|
|||||||
type Datum = Cofree DatumF Ann
|
type Datum = Cofree DatumF Ann
|
||||||
type Compound = CompoundF Datum
|
type Compound = CompoundF Datum
|
||||||
|
|
||||||
data Indentation
|
data Style
|
||||||
= NSpecial Int
|
= StyleSyntax Int
|
||||||
| Ordinary
|
| StyleCode
|
||||||
|
| StyleData
|
||||||
deriving stock (Data, Eq, Generic, Show, Lift, Read)
|
deriving stock (Data, Eq, Generic, Show, Lift, Read)
|
||||||
deriving anyclass (NFData)
|
deriving anyclass (NFData)
|
||||||
|
|
||||||
data Syn
|
|
||||||
= SynMacro
|
|
||||||
| SynBuiltin
|
|
||||||
| SynProcedure
|
|
||||||
| SynParen Int
|
|
||||||
| SynString
|
|
||||||
| SynConstant
|
|
||||||
| SynVariable
|
|
||||||
| SynNone
|
|
||||||
deriving (Show, Read, Data, Generic, Eq, Lift)
|
|
||||||
|
|
||||||
data Ann = MkAnn
|
data Ann = MkAnn
|
||||||
{ syntax :: Syn
|
{ position :: Maybe SourcePos
|
||||||
, position :: Maybe SourcePos
|
|
||||||
}
|
}
|
||||||
deriving (Show, Data, Eq, Generic)
|
deriving (Show, Data, Eq, Generic)
|
||||||
|
|
||||||
noAnn :: Ann
|
noAnn :: Ann
|
||||||
noAnn = MkAnn
|
noAnn = MkAnn
|
||||||
{ syntax = SynNone
|
{ position = Nothing
|
||||||
, position = Nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- requisite of the Pretty instance for invertible-grammar's error type.
|
-- requisite of the Pretty instance for invertible-grammar's error type.
|
||||||
@@ -160,13 +146,6 @@ deriveEq1 ''CompoundF
|
|||||||
deriveShow1 ''DatumF
|
deriveShow1 ''DatumF
|
||||||
deriveEq1 ''DatumF
|
deriveEq1 ''DatumF
|
||||||
|
|
||||||
|
|
||||||
--- optics
|
|
||||||
|
|
||||||
-- affine
|
|
||||||
cdr :: Traversal' Datum Datum
|
|
||||||
cdr k (a :< CompoundF (ListF ind xs)) = _
|
|
||||||
|
|
||||||
|
|
||||||
--- modification and extraction of annotations
|
--- modification and extraction of annotations
|
||||||
|
|
||||||
@@ -176,23 +155,18 @@ ann = _extract
|
|||||||
dat :: Lens' Datum (DatumF Datum)
|
dat :: Lens' Datum (DatumF Datum)
|
||||||
dat = _unwrap
|
dat = _unwrap
|
||||||
|
|
||||||
syntax :: Lens' Datum Syn
|
|
||||||
syntax = ann . #syntax
|
|
||||||
|
|
||||||
position :: Lens' Datum (Maybe SourcePos)
|
position :: Lens' Datum (Maybe SourcePos)
|
||||||
position = ann . #position
|
position = ann . #position
|
||||||
|
|
||||||
indentation :: Traversal' Datum Indentation
|
-- affine
|
||||||
indentation k (syn :< CompoundF (ListF ind xs)) = do
|
style :: Traversal' Datum Style
|
||||||
|
style k (syn :< CompoundF (ListF ind xs)) = do
|
||||||
ind' <- k ind
|
ind' <- k ind
|
||||||
pure $ syn :< CompoundF (ListF ind' xs)
|
pure $ syn :< CompoundF (ListF ind' xs)
|
||||||
indentation k a = pure a
|
style k a = pure a
|
||||||
|
|
||||||
adorn :: Syn -> Datum -> Datum
|
styleWith :: Style -> Datum -> Datum
|
||||||
adorn = set syntax
|
styleWith = set style
|
||||||
|
|
||||||
indentWith :: Indentation -> Datum -> Datum
|
|
||||||
indentWith = set indentation
|
|
||||||
|
|
||||||
stripAnn :: Datum -> Fix DatumF
|
stripAnn :: Datum -> Fix DatumF
|
||||||
stripAnn = hoist tailF
|
stripAnn = hoist tailF
|
||||||
@@ -226,9 +200,9 @@ pattern Meta x <- _ :< MetaF x
|
|||||||
|
|
||||||
pattern List :: List Datum -> Datum
|
pattern List :: List Datum -> Datum
|
||||||
pattern List a <- _ :< CompoundF (ListF _ a)
|
pattern List a <- _ :< CompoundF (ListF _ a)
|
||||||
where List a = noAnn :< CompoundF (ListF Ordinary a)
|
where List a = noAnn :< CompoundF (ListF StyleData a)
|
||||||
|
|
||||||
pattern List' :: Indentation -> List Datum -> Datum
|
pattern List' :: Style -> List Datum -> Datum
|
||||||
pattern List' ind a <- _ :< CompoundF (ListF ind a)
|
pattern List' ind a <- _ :< CompoundF (ListF ind a)
|
||||||
where List' ind a = noAnn :< CompoundF (ListF ind a)
|
where List' ind a = noAnn :< CompoundF (ListF ind a)
|
||||||
|
|
||||||
@@ -244,12 +218,25 @@ pattern Abbrev :: Prefix -> Datum -> Datum
|
|||||||
pattern Abbrev p a <- _ :< CompoundF (AbbrevF p a)
|
pattern Abbrev p a <- _ :< CompoundF (AbbrevF p a)
|
||||||
where Abbrev p a = noAnn :< CompoundF (AbbrevF p a)
|
where Abbrev p a = noAnn :< CompoundF (AbbrevF p a)
|
||||||
|
|
||||||
|
pattern Boolean :: Bool -> Datum
|
||||||
pattern Boolean a = Simple (SimpleBoolean a)
|
pattern Boolean a = Simple (SimpleBoolean a)
|
||||||
|
|
||||||
|
pattern Number :: Scientific -> Datum
|
||||||
pattern Number a = Simple (SimpleNumber a)
|
pattern Number a = Simple (SimpleNumber a)
|
||||||
|
|
||||||
|
pattern Character :: Char -> Datum
|
||||||
pattern Character a = Simple (SimpleCharacter a)
|
pattern Character a = Simple (SimpleCharacter a)
|
||||||
|
|
||||||
|
pattern String :: Text -> Datum
|
||||||
pattern String a = Simple (SimpleString a)
|
pattern String a = Simple (SimpleString a)
|
||||||
|
|
||||||
|
pattern Symbol :: Text -> Datum
|
||||||
pattern Symbol a = Simple (SimpleSymbol a)
|
pattern Symbol a = Simple (SimpleSymbol a)
|
||||||
|
|
||||||
|
pattern Bytevector :: ByteString -> Datum
|
||||||
pattern Bytevector a = Simple (SimpleBytevector a)
|
pattern Bytevector a = Simple (SimpleBytevector a)
|
||||||
|
|
||||||
|
pattern Unreadable :: Text -> Datum
|
||||||
pattern Unreadable a = Simple (SimpleUnreadable a)
|
pattern Unreadable a = Simple (SimpleUnreadable a)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,19 +24,19 @@ thinWide name x = testGroup name
|
|||||||
, tcaseW 4 (name <> "-thin") x
|
, tcaseW 4 (name <> "-thin") x
|
||||||
]
|
]
|
||||||
|
|
||||||
datumBegin xs = S.indentWith (S.NSpecial 0) . S.List $
|
datumBegin xs = S.styleWith (S.StyleSyntax 0) . S.List $
|
||||||
(S.adorn S.SynBuiltin . S.Symbol $ "begin") : xs
|
S.Symbol "begin" : xs
|
||||||
|
|
||||||
datumLambda formals body =
|
datumLambda formals body =
|
||||||
S.indentWith (S.NSpecial 1) . S.List $
|
S.styleWith (S.StyleSyntax 1) . S.List $
|
||||||
(S.adorn S.SynBuiltin . S.Symbol $ "lambda") : formals : body
|
S.Symbol "lambda" : formals : body
|
||||||
|
|
||||||
test_print = testGroup "sexp pretty printer" $
|
test_print = testGroup "sexp pretty printer"
|
||||||
[ tcase "null" $ S.List []
|
[ tcase "null" $ S.List []
|
||||||
, thinWide "simple-list" $
|
, thinWide "simple-list" $
|
||||||
S.List [ S.Symbol s | s <- ["가","나","다","라"] ]
|
S.List [ S.Symbol s | s <- ["가","나","다","라"] ]
|
||||||
, thinWide "begin-nonempty" $
|
, thinWide "begin-nonempty" $
|
||||||
S.indentWith (S.NSpecial 0) $
|
S.styleWith (S.StyleSyntax 0) $
|
||||||
datumBegin [ S.Symbol "책을"
|
datumBegin [ S.Symbol "책을"
|
||||||
, S.Symbol "더"
|
, S.Symbol "더"
|
||||||
, S.Symbol "먹으세요~!"
|
, S.Symbol "먹으세요~!"
|
||||||
|
|||||||
Reference in New Issue
Block a user