mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 19:22:50 -06:00
move the literal category names to PGF.Macros
This commit is contained in:
@@ -217,16 +217,10 @@ emptyGrammarEnv cnc_defs lincats =
|
|||||||
let (last_id,catSet) = Map.mapAccumWithKey computeCatRange 0 lincats
|
let (last_id,catSet) = Map.mapAccumWithKey computeCatRange 0 lincats
|
||||||
in GrammarEnv last_id (IntMap.singleton 0 catSet) Map.empty Map.empty Map.empty IntMap.empty
|
in GrammarEnv last_id (IntMap.singleton 0 catSet) Map.empty Map.empty Map.empty IntMap.empty
|
||||||
where
|
where
|
||||||
cidString = mkCId "String"
|
|
||||||
cidInt = mkCId "Int"
|
|
||||||
cidFloat = mkCId "Float"
|
|
||||||
cidVar = mkCId "_Var"
|
|
||||||
|
|
||||||
computeCatRange index cat ctype
|
computeCatRange index cat ctype
|
||||||
| cat == cidString = (index, (fcatString,fcatString,[]))
|
| cat == cidString = (index, (fcatString,fcatString,[]))
|
||||||
| cat == cidInt = (index, (fcatInt, fcatInt, []))
|
| cat == cidInt = (index, (fcatInt, fcatInt, []))
|
||||||
| cat == cidFloat = (index, (fcatFloat, fcatFloat, []))
|
| cat == cidFloat = (index, (fcatFloat, fcatFloat, []))
|
||||||
| cat == cidVar = (index, (fcatVar, fcatVar, []))
|
|
||||||
| otherwise = (index+size,(index,index+size-1,poly))
|
| otherwise = (index+size,(index,index+size-1,poly))
|
||||||
where
|
where
|
||||||
(size,poly) = getMultipliers 1 [] ctype
|
(size,poly) = getMultipliers 1 [] ctype
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ genRandom gen pgf cat = genTrees (randomRs (0.0, 1.0 :: Double) gen) cat where
|
|||||||
(genTrees ds2 cat) -- else (drop k ds)
|
(genTrees ds2 cat) -- else (drop k ds)
|
||||||
|
|
||||||
genTree rs = gett rs where
|
genTree rs = gett rs where
|
||||||
gett ds cid | cid == mkCId "String" = (Lit (LStr "foo"), 1)
|
gett ds cid | cid == cidString = (Lit (LStr "foo"), 1)
|
||||||
gett ds cid | cid == mkCId "Int" = (Lit (LInt 12345), 1)
|
gett ds cid | cid == cidInt = (Lit (LInt 12345), 1)
|
||||||
|
gett ds cid | cid == cidFloat = (Lit (LFlt 12345), 1)
|
||||||
gett [] _ = (Lit (LStr "TIMEOUT"), 1) ----
|
gett [] _ = (Lit (LStr "TIMEOUT"), 1) ----
|
||||||
gett ds cat = case fns cat of
|
gett ds cat = case fns cat of
|
||||||
[] -> (Meta 0,1)
|
[] -> (Meta 0,1)
|
||||||
|
|||||||
@@ -140,4 +140,8 @@ combinations t = case t of
|
|||||||
aa:uu -> [a:u | a <- aa, u <- combinations uu]
|
aa:uu -> [a:u | a <- aa, u <- combinations uu]
|
||||||
|
|
||||||
isLiteralCat :: CId -> Bool
|
isLiteralCat :: CId -> Bool
|
||||||
isLiteralCat = (`elem` [mkCId "String", mkCId "Float", mkCId "Int"])
|
isLiteralCat = (`elem` [cidString, cidFloat, cidInt])
|
||||||
|
|
||||||
|
cidString = mkCId "String"
|
||||||
|
cidInt = mkCId "Int"
|
||||||
|
cidFloat = mkCId "Float"
|
||||||
|
|||||||
Reference in New Issue
Block a user