summaryrefslogtreecommitdiff
path: root/src/runtime/haskell
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2015-05-11 13:01:39 +0000
committerkrasimir <krasimir@chalmers.se>2015-05-11 13:01:39 +0000
commit1e0d7be4f4322836093d744c916fe02bfbcf9418 (patch)
tree21b259b2c9eb31ce9fbcfe5d168d1747f6a2c5c2 /src/runtime/haskell
parent13998e32873758c0b1964a62f738b9916e666b86 (diff)
added all orthographic primitives
Diffstat (limited to 'src/runtime/haskell')
-rw-r--r--src/runtime/haskell/PGF/Binary.hs12
-rw-r--r--src/runtime/haskell/PGF/Data.hs2
-rw-r--r--src/runtime/haskell/PGF/Haskell.hs13
-rw-r--r--src/runtime/haskell/PGF/Macros.hs2
-rw-r--r--src/runtime/haskell/PGF/Optimize.hs2
-rw-r--r--src/runtime/haskell/PGF/Parse.hs5
-rw-r--r--src/runtime/haskell/PGF/Printer.hs2
7 files changed, 29 insertions, 9 deletions
diff --git a/src/runtime/haskell/PGF/Binary.hs b/src/runtime/haskell/PGF/Binary.hs
index b2695acbb..e1054447e 100644
--- a/src/runtime/haskell/PGF/Binary.hs
+++ b/src/runtime/haskell/PGF/Binary.hs
@@ -213,8 +213,10 @@ instance Binary Symbol where
put (SymKP d vs) = putWord8 4 >> put (d,vs)
put SymBIND = putWord8 5
put SymSOFT_BIND = putWord8 6
- put SymCAPIT = putWord8 7
- put SymNE = putWord8 8
+ put SymSOFT_SPACE = putWord8 7
+ put SymCAPIT = putWord8 8
+ put SymALL_CAPIT = putWord8 9
+ put SymNE = putWord8 10
get = do tag <- getWord8
case tag of
0 -> liftM2 SymCat get get
@@ -224,8 +226,10 @@ instance Binary Symbol where
4 -> liftM2 (\d vs -> SymKP d vs) get get
5 -> return SymBIND
6 -> return SymSOFT_BIND
- 7 -> return SymCAPIT
- 8 -> return SymNE
+ 7 -> return SymSOFT_SPACE
+ 8 -> return SymCAPIT
+ 9 -> return SymALL_CAPIT
+ 10-> return SymNE
_ -> decodingError
instance Binary PArg where
diff --git a/src/runtime/haskell/PGF/Data.hs b/src/runtime/haskell/PGF/Data.hs
index 7d4750b13..a3d7c1f93 100644
--- a/src/runtime/haskell/PGF/Data.hs
+++ b/src/runtime/haskell/PGF/Data.hs
@@ -62,7 +62,9 @@ data Symbol
| SymKP [Symbol] [([Symbol],[String])]
| SymBIND -- the special BIND token
| SymSOFT_BIND -- the special SOFT_BIND token
+ | SymSOFT_SPACE -- the special SOFT_SPACE token
| SymCAPIT -- the special CAPIT token
+ | SymALL_CAPIT -- the special ALL_CAPIT token
| SymNE -- non exist (this should be last constructor to simplify the binary search in the runtime)
deriving (Eq,Ord,Show)
data Production
diff --git a/src/runtime/haskell/PGF/Haskell.hs b/src/runtime/haskell/PGF/Haskell.hs
index 81e8cffaa..38c082be4 100644
--- a/src/runtime/haskell/PGF/Haskell.hs
+++ b/src/runtime/haskell/PGF/Haskell.hs
@@ -21,14 +21,14 @@ table vs = let m = M.fromList (zip enumAll vs) in (M.!) m
type Str = [Tok] -- token sequence
-- | Tokens
-data Tok = TK String | TP [([Prefix],Str)] Str | BIND | SOFT_BIND | CAPIT
+data Tok = TK String | TP [([Prefix],Str)] Str | BIND | SOFT_BIND | SOFT_SPACE | CAPIT | ALL_CAPIT
deriving (Eq,Ord,Show)
type Prefix = String -- ^ To be matched with the prefix of a following token
-- | Render a token sequence as a 'String'
fromStr :: Str -> String
-fromStr = from False False
+fromStr = from False id
where
from space cap ts =
case ts of
@@ -36,16 +36,19 @@ fromStr = from False False
TK s:ts -> put s++from True cap ts
BIND:ts -> from False cap ts
SOFT_BIND:ts -> from False cap ts
- CAPIT:ts -> from space True ts
+ SOFT_SPACE:ts -> from True cap ts
+ CAPIT:ts -> from space toUpper1 ts
+ ALL_CAPIT:ts -> from space toUpperAll ts
TP alts def:ts -> from space cap (pick alts def r++[TK r]) -- hmm
where r = fromStr ts
where
- put s = [' '|space]++up s
- up = if cap then toUpper1 else id
+ put s = [' '|space]++cap s
toUpper1 (c:s) = toUpper c:s
toUpper1 s = s
+ toUpperAll = map toUpper
+
pick alts def r = head ([str|(ps,str)<-alts,any (`isPrefixOf` r) ps]++[def])
-- *** Common record types
diff --git a/src/runtime/haskell/PGF/Macros.hs b/src/runtime/haskell/PGF/Macros.hs
index 8ca2a4f29..42d16683a 100644
--- a/src/runtime/haskell/PGF/Macros.hs
+++ b/src/runtime/haskell/PGF/Macros.hs
@@ -220,7 +220,9 @@ computeSeq filter seq args = concatMap compute seq
compute SymNE = [LeafNE]
compute SymBIND = [LeafKS "&+"]
compute SymSOFT_BIND = []
+ compute SymSOFT_SPACE = []
compute SymCAPIT = [LeafKS "&|"]
+ compute SymALL_CAPIT = [LeafKS "&|"]
compute (SymKP syms alts) = [LeafKP (concatMap compute syms) [(concatMap compute syms,cs) | (syms,cs) <- alts]]
getArg d r
diff --git a/src/runtime/haskell/PGF/Optimize.hs b/src/runtime/haskell/PGF/Optimize.hs
index dd876baaf..45b4311a5 100644
--- a/src/runtime/haskell/PGF/Optimize.hs
+++ b/src/runtime/haskell/PGF/Optimize.hs
@@ -240,7 +240,9 @@ splitLexicalRules cnc p_prods =
seq2prefix (SymNE :syms) = TrieMap.empty
seq2prefix (SymBIND :syms) = TrieMap.fromList [wf ["&+"]]
seq2prefix (SymSOFT_BIND :syms) = TrieMap.fromList [wf []]
+ seq2prefix (SymSOFT_SPACE :syms) = TrieMap.fromList [wf []]
seq2prefix (SymCAPIT :syms) = TrieMap.fromList [wf ["&|"]]
+ seq2prefix (SymALL_CAPIT :syms) = TrieMap.fromList [wf ["&|"]]
updateConcrete abs cnc =
let p_prods0 = filterProductions IntMap.empty IntSet.empty (productions cnc)
diff --git a/src/runtime/haskell/PGF/Parse.hs b/src/runtime/haskell/PGF/Parse.hs
index c62522c1e..2cfd91ca5 100644
--- a/src/runtime/haskell/PGF/Parse.hs
+++ b/src/runtime/haskell/PGF/Parse.hs
@@ -311,13 +311,18 @@ process flit ftok cnc (item@(Active j ppos funid seqid args key0):items) acc cha
SymBIND -> let !acc' = ftok_ ["&+"] (Active j (ppos+1) funid seqid args key0) acc
in process flit ftok cnc items acc' chart
SymSOFT_BIND->process flit ftok cnc ((Active j (ppos+1) funid seqid args key0):items) acc chart
+ SymSOFT_SPACE->process flit ftok cnc ((Active j (ppos+1) funid seqid args key0):items) acc chart
SymCAPIT -> let !acc' = ftok_ ["&|"] (Active j (ppos+1) funid seqid args key0) acc
in process flit ftok cnc items acc' chart
+ SymALL_CAPIT->let !acc' = ftok_ ["&|"] (Active j (ppos+1) funid seqid args key0) acc
+ in process flit ftok cnc items acc' chart
SymKP syms vars
-> let to_tok (SymKS t) = [t]
to_tok SymBIND = ["&+"]
to_tok SymSOFT_BIND = []
+ to_tok SymSOFT_SPACE= []
to_tok SymCAPIT = ["&|"]
+ to_tok SymALL_CAPIT = ["&|"]
to_tok _ = []
!acc' = foldl (\acc syms -> ftok_ (concatMap to_tok syms) (Active j (ppos+1) funid seqid args key0) acc) acc
diff --git a/src/runtime/haskell/PGF/Printer.hs b/src/runtime/haskell/PGF/Printer.hs
index 5022cbb82..fbe9db596 100644
--- a/src/runtime/haskell/PGF/Printer.hs
+++ b/src/runtime/haskell/PGF/Printer.hs
@@ -95,7 +95,9 @@ ppSymbol (SymKS t) = doubleQuotes (text t)
ppSymbol SymNE = text "nonExist"
ppSymbol SymBIND = text "BIND"
ppSymbol SymSOFT_BIND = text "SOFT_BIND"
+ppSymbol SymSOFT_SPACE= text "SOFT_SPACE"
ppSymbol SymCAPIT = text "CAPIT"
+ppSymbol SymALL_CAPIT = text "ALL_CAPIT"
ppSymbol (SymKP syms alts) = text "pre" <+> braces (hsep (punctuate semi (hsep (map ppSymbol syms) : map ppAlt alts)))
ppAlt (syms,ps) = hsep (map ppSymbol syms) <+> char '/' <+> hsep (map (doubleQuotes . text) ps)