1
0
forked from GitHub/gf-core

Regenerate source GF parser from GF.cf. Now, when GF/Source/Makefile is used, no hand-hacking is needed.

This commit is contained in:
bjorn
2008-10-02 14:11:41 +00:00
parent 9e501521b4
commit fa69bd8ab3
10 changed files with 2889 additions and 7062 deletions

View File

@@ -27,6 +27,21 @@ data Transfer =
| TransferOut Open
deriving (Eq,Ord,Show)
data ModHeader =
MModule2 ComplMod ModType ModHeaderBody
deriving (Eq,Ord,Show)
data ModHeaderBody =
MBody2 Extend Opens
| MNoBody2 [Included]
| MWith2 Included [Open]
| MWithBody2 Included [Open] Opens
| MWithE2 [Included] Included [Open]
| MWithEBody2 [Included] Included [Open] Opens
| MReuse2 PIdent
| MUnion2 [Included]
deriving (Eq,Ord,Show)
data ModType =
MTAbstract PIdent
| MTResource PIdent

View File

@@ -1,26 +0,0 @@
-- BNF Converter: Error Monad
-- Copyright (C) 2004 Author: Aarne Ranta
-- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE.
module GF.Source.ErrM where
-- the Error monad: like Maybe type with error msgs
import Control.Monad (MonadPlus(..), liftM)
data Err a = Ok a | Bad String
deriving (Read, Show, Eq, Ord)
instance Monad Err where
return = Ok
fail = Bad
Ok a >>= f = f a
Bad s >>= f = Bad s
instance Functor Err where
fmap = liftM
instance MonadPlus Err where
mzero = Bad "Err.mzero"
mplus (Bad _) y = y
mplus x _ = x

View File

@@ -147,7 +147,7 @@ alexGetChar (p, _, s) =
alexInputPrevChar :: AlexInput -> Char
alexInputPrevChar (p, c, s) = c
alex_action_3 = tok (\p s -> PT p (eitherResIdent (T_PIdent . share) s))
alex_action_3 = tok (\p s -> PT p (eitherResIdent (TV . share) s))
alex_action_4 = tok (\p s -> PT p (eitherResIdent (T_LString . share) s))
alex_action_5 = tok (\p s -> PT p (eitherResIdent (T_PIdent . share) s))
alex_action_6 = tok (\p s -> PT p (eitherResIdent (TV . share) s))

View File

@@ -24,7 +24,7 @@ $u = [\0-\255] -- universal: any character
"{-" ([$u # \-] | \- [$u # \}])* ("-")+ "}" ;
$white+ ;
@rsyms { tok (\p s -> PT p (eitherResIdent (T_PIdent . share) s)) }
@rsyms { tok (\p s -> PT p (eitherResIdent (TV . share) s)) }
\' ($u # \')* \' { tok (\p s -> PT p (eitherResIdent (T_LString . share) s)) }
(\_ | $l)($l | $d | \_ | \')* { tok (\p s -> PT p (eitherResIdent (T_PIdent . share) s)) }

View File

@@ -1,6 +1,7 @@
all:
cd ../.. && bnfc -p GF.Source -bytestrings -sharestrings GF/Source/GF.cf
rm ErrM.hs
perl -i -pe 's/%name pModHeader ModHeader/%partial pModHeader ModHeader/' ParGF.y
perl -i -pe 's/GF.Source.ErrM/GF.Data.ErrM/' *.hs *.x *.y
happy -gca ParGF.y
alex -g LexGF.x

File diff suppressed because one or more lines are too long

View File

@@ -151,19 +151,19 @@ Transfer : '(' 'transfer' 'in' Open ')' { TransferIn $4 }
| '(' 'transfer' 'out' Open ')' { TransferOut $4 }
ModHeader :: { ModDef }
ModHeader : ComplMod ModType '=' ModHeaderBody { MModule $1 $2 $4 }
ModHeader :: { ModHeader }
ModHeader : ComplMod ModType '=' ModHeaderBody { MModule2 $1 $2 $4 }
ModHeaderBody :: { ModBody }
ModHeaderBody : Extend Opens { MBody $1 $2 [] }
| ListIncluded { MNoBody $1 }
| Included 'with' ListOpen { MWith $1 $3 }
| Included 'with' ListOpen '**' Opens { MWithBody $1 $3 $5 [] }
| ListIncluded '**' Included 'with' ListOpen { MWithE $1 $3 $5 }
| ListIncluded '**' Included 'with' ListOpen '**' Opens { MWithEBody $1 $3 $5 $7 [] }
| 'reuse' PIdent { MReuse $2 }
| 'union' ListIncluded { MUnion $2 }
ModHeaderBody :: { ModHeaderBody }
ModHeaderBody : Extend Opens { MBody2 $1 $2 }
| ListIncluded { MNoBody2 $1 }
| Included 'with' ListOpen { MWith2 $1 $3 }
| Included 'with' ListOpen '**' Opens { MWithBody2 $1 $3 $5 }
| ListIncluded '**' Included 'with' ListOpen { MWithE2 $1 $3 $5 }
| ListIncluded '**' Included 'with' ListOpen '**' Opens { MWithEBody2 $1 $3 $5 $7 }
| 'reuse' PIdent { MReuse2 $2 }
| 'union' ListIncluded { MUnion2 $2 }
ModType :: { ModType }

View File

@@ -128,6 +128,22 @@ instance Print Transfer where
[] -> (concatD [])
x:xs -> (concatD [prt 0 x , prt 0 xs])
instance Print ModHeader where
prt i e = case e of
MModule2 complmod modtype modheaderbody -> prPrec i 0 (concatD [prt 0 complmod , prt 0 modtype , doc (showString "=") , prt 0 modheaderbody])
instance Print ModHeaderBody where
prt i e = case e of
MBody2 extend opens -> prPrec i 0 (concatD [prt 0 extend , prt 0 opens])
MNoBody2 includeds -> prPrec i 0 (concatD [prt 0 includeds])
MWith2 included opens -> prPrec i 0 (concatD [prt 0 included , doc (showString "with") , prt 0 opens])
MWithBody2 included opens0 opens -> prPrec i 0 (concatD [prt 0 included , doc (showString "with") , prt 0 opens0 , doc (showString "**") , prt 0 opens])
MWithE2 includeds included opens -> prPrec i 0 (concatD [prt 0 includeds , doc (showString "**") , prt 0 included , doc (showString "with") , prt 0 opens])
MWithEBody2 includeds included opens0 opens -> prPrec i 0 (concatD [prt 0 includeds , doc (showString "**") , prt 0 included , doc (showString "with") , prt 0 opens0 , doc (showString "**") , prt 0 opens])
MReuse2 pident -> prPrec i 0 (concatD [doc (showString "reuse") , prt 0 pident])
MUnion2 includeds -> prPrec i 0 (concatD [doc (showString "union") , prt 0 includeds])
instance Print ModType where
prt i e = case e of