summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Grammar
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-05-24 07:44:16 +0000
committeraarne <aarne@cs.chalmers.se>2008-05-24 07:44:16 +0000
commit77178cd2abf6774397259af547aec75ac07be26d (patch)
treea39604a037485d64577d38bf4f12f4b786f5a57a /src-3.0/GF/Grammar
parent1eb1d7e055ce91e4e972079c906deb24ebbf2fbd (diff)
sort records so that s field is first (use Macros.sortRec)
Diffstat (limited to 'src-3.0/GF/Grammar')
-rw-r--r--src-3.0/GF/Grammar/Macros.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src-3.0/GF/Grammar/Macros.hs b/src-3.0/GF/Grammar/Macros.hs
index f6543ea6c..be03c02a7 100644
--- a/src-3.0/GF/Grammar/Macros.hs
+++ b/src-3.0/GF/Grammar/Macros.hs
@@ -28,6 +28,7 @@ import GF.Grammar.PrGrammar
import Control.Monad (liftM, liftM2)
import Data.Char (isDigit)
+import Data.List (sortBy)
firstTypeForm :: Type -> Err (Context, Type)
firstTypeForm t = case t of
@@ -719,3 +720,14 @@ isInOneType t = case t of
Prod _ a b -> a == b
_ -> False
+-- normalize records and record types; put s first
+
+sortRec :: [(Label,a)] -> [(Label,a)]
+sortRec = sortBy ordLabel where
+ ordLabel (r1,_) (r2,_) = case (prt r1, prt r2) of
+ ("s",_) -> LT
+ (_,"s") -> GT
+ (s1,s2) -> compare s1 s2
+
+
+