diff options
| author | bringert <unknown> | 2004-09-29 15:53:46 +0000 |
|---|---|---|
| committer | bringert <unknown> | 2004-09-29 15:53:46 +0000 |
| commit | 7492cfd236352bab4beb8fcc2763cec5825c9bea (patch) | |
| tree | 8c766761ca416a987bf22c721b19f11461569c4a /src/GF/CFGM/LexCFG.x | |
| parent | df2c63c5596db36f0c1899cced6b7ee2e946741e (diff) | |
Updated to simple CFGM grammar, use CFGM pretty printer when printing cfgm grammars.
Diffstat (limited to 'src/GF/CFGM/LexCFG.x')
| -rw-r--r-- | src/GF/CFGM/LexCFG.x | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/GF/CFGM/LexCFG.x b/src/GF/CFGM/LexCFG.x index e59d8652a..322d10a18 100644 --- a/src/GF/CFGM/LexCFG.x +++ b/src/GF/CFGM/LexCFG.x @@ -15,12 +15,13 @@ $i = [$l $d _ '] -- identifier character $u = [\0-\255] -- universal: any character @rsyms = -- reserved words consisting of special symbols - \; | \: | \. | \- \> | \[ | \] | \, | \/ | \{ | \} | \! | \= | \( | \) + \; | \: | \. | \- \> | \[ | \] | \, :- $white+ ; @rsyms { tok (\p s -> PT p (TS s)) } +\' ($u # [\' \\]| \\ [\' \\]) * \' { tok (\p s -> PT p (eitherResIdent T_SingleQuoteString s)) } $l $i* { tok (\p s -> PT p (eitherResIdent TV s)) } \" ([$u # [\" \\ \n]] | (\\ (\" | \\ | \' | n | t)))* \"{ tok (\p s -> PT p (TL $ unescapeInitTail s)) } @@ -39,13 +40,14 @@ data Tok = | TV String -- identifiers | TD String -- double precision float literals | TC String -- character literals + | T_SingleQuoteString String - deriving (Eq,Show) + deriving (Eq,Show,Ord) data Token = PT Posn Tok | Err Posn - deriving Show + deriving (Eq,Show,Ord) tokenPos (PT (Pn _ l _) _ :_) = "line " ++ show l tokenPos (Err (Pn _ l _) :_) = "line " ++ show l @@ -60,6 +62,8 @@ prToken t = case t of PT _ (TV s) -> s PT _ (TD s) -> s PT _ (TC s) -> s + _ -> show t + PT _ (T_SingleQuoteString s) -> s eitherResIdent :: (String -> Tok) -> String -> Tok @@ -93,7 +97,7 @@ unescapeInitTail = unesc . tail where ------------------------------------------------------------------- data Posn = Pn !Int !Int !Int - deriving (Eq, Show) + deriving (Eq, Show,Ord) alexStartPos :: Posn alexStartPos = Pn 0 1 1 |
