mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
Updated to latest CFG specification from gfc2java
This commit is contained in:
@@ -37,14 +37,28 @@ data Name =
|
||||
deriving (Eq,Ord,Show)
|
||||
|
||||
data Category =
|
||||
Category IdentParam Ident [Param]
|
||||
Category IdentParam Ident [Proj]
|
||||
deriving (Eq,Ord,Show)
|
||||
|
||||
data IdentParam =
|
||||
IdentParam Ident [Param]
|
||||
IdentParam Ident [Field]
|
||||
deriving (Eq,Ord,Show)
|
||||
|
||||
data Field =
|
||||
Field KeyValue
|
||||
deriving (Eq,Ord,Show)
|
||||
|
||||
data Proj =
|
||||
Proj Param
|
||||
deriving (Eq,Ord,Show)
|
||||
|
||||
data KeyValue =
|
||||
KeyValue Ident Param
|
||||
deriving (Eq,Ord,Show)
|
||||
|
||||
data Param =
|
||||
Param Ident
|
||||
ParamSimple Ident
|
||||
| ParamPatt Ident [Param]
|
||||
| ParamRec [KeyValue]
|
||||
deriving (Eq,Ord,Show)
|
||||
|
||||
|
||||
@@ -20,16 +20,29 @@ separator Integer ",";
|
||||
CatS. Symbol ::= Category;
|
||||
TermS. Symbol ::= String;
|
||||
|
||||
separator Symbol "";
|
||||
-- separator Symbol "";
|
||||
[]. [Symbol] ::= "." ;
|
||||
(:[]). [Symbol] ::= Symbol ;
|
||||
(:). [Symbol] ::= Symbol [Symbol] ;
|
||||
|
||||
|
||||
Name. Name ::= [IdentParam] Category;
|
||||
terminator IdentParam "/";
|
||||
|
||||
Category. Category ::= IdentParam "." Ident [Param] ;
|
||||
Category. Category ::= IdentParam "." Ident [Proj] ;
|
||||
|
||||
IdentParam. IdentParam ::= Ident "{" [Param] "}" ;
|
||||
IdentParam. IdentParam ::= Ident "{" [Field] "}" ;
|
||||
|
||||
Param. Param ::= "!" Ident ;
|
||||
separator Param "";
|
||||
Field. Field ::= "." KeyValue ;
|
||||
terminator Field ";" ;
|
||||
|
||||
Proj. Proj ::= "!" Param ;
|
||||
separator Proj "" ;
|
||||
|
||||
KeyValue. KeyValue ::= Ident "=" Param ;
|
||||
separator KeyValue ";" ;
|
||||
|
||||
ParamSimple. Param ::= Ident ;
|
||||
ParamPatt. Param ::= Ident "(" [Param] ")" ;
|
||||
ParamRec. Param ::= "{" [KeyValue] "}" ;
|
||||
separator Param "," ;
|
||||
|
||||
@@ -16,7 +16,7 @@ alex_base :: Array Int Int
|
||||
alex_base = listArray (0,11) [1,57,66,0,9,154,362,0,277,485,211,51]
|
||||
|
||||
alex_table :: Array Int Int
|
||||
alex_table = listArray (0,740) [0,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,2,2,2,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,3,3,11,11,11,11,11,11,11,11,11,11,3,3,-1,-1,-1,-1,-1,2,2,2,2,2,3,0,0,0,2,2,2,2,2,0,0,0,0,0,0,0,0,0,2,0,0,3,-1,3,-1,-1,-1,2,11,11,11,11,11,11,11,11,11,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,-1,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6,6,6,0,0,0,0,-1,0,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,9,0,0,-1,6,9,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,10,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
||||
|
||||
alex_check :: Array Int Int
|
||||
alex_check = listArray (0,740) [-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,9,10,11,12,13,62,-1,-1,-1,9,10,11,12,13,-1,-1,-1,-1,-1,-1,-1,-1,-1,32,-1,-1,91,92,93,94,95,96,32,48,49,50,51,52,53,54,55,56,57,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,39,-1,-1,-1,-1,-1,-1,-1,-1,48,49,50,51,52,53,54,55,56,57,-1,-1,-1,-1,215,-1,-1,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,34,-1,-1,247,95,39,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,92,-1,-1,-1,-1,-1,-1,-1,34,-1,-1,-1,-1,-1,-1,-1,-1,-1,110,-1,-1,-1,-1,-1,116,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,92,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,39,248,249,250,251,252,253,254,255,48,49,50,51,52,53,54,55,56,57,-1,-1,-1,-1,-1,-1,-1,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,-1,-1,-1,-1,95,-1,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,34,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,92,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,-1,248,249,250,251,252,253,254,255,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]
|
||||
|
||||
@@ -15,7 +15,7 @@ $i = [$l $d _ '] -- identifier character
|
||||
$u = [\0-\255] -- universal: any character
|
||||
|
||||
@rsyms = -- reserved words consisting of special symbols
|
||||
\; | \: | \. | \- \> | \[ | \] | \, | \/ | \{ | \} | \!
|
||||
\; | \: | \. | \- \> | \[ | \] | \, | \/ | \{ | \} | \! | \= | \( | \)
|
||||
|
||||
:-
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,9 @@ import ErrM
|
||||
'{' { PT _ (TS "{") }
|
||||
'}' { PT _ (TS "}") }
|
||||
'!' { PT _ (TS "!") }
|
||||
'=' { PT _ (TS "=") }
|
||||
'(' { PT _ (TS "(") }
|
||||
')' { PT _ (TS ")") }
|
||||
'end' { PT _ (TS "end") }
|
||||
'grammar' { PT _ (TS "grammar") }
|
||||
'startcat' { PT _ (TS "startcat") }
|
||||
@@ -62,7 +65,7 @@ ListFlag : {- empty -} { [] }
|
||||
|
||||
|
||||
Rule :: { Rule }
|
||||
Rule : Ident ':' Name Profile '.' Category '->' ListSymbol { Rule $1 $3 $4 $6 (reverse $8) }
|
||||
Rule : Ident ':' Name Profile '.' Category '->' ListSymbol { Rule $1 $3 $4 $6 $8 }
|
||||
|
||||
|
||||
ListRule :: { [Rule] }
|
||||
@@ -96,8 +99,9 @@ Symbol : Category { CatS $1 }
|
||||
|
||||
|
||||
ListSymbol :: { [Symbol] }
|
||||
ListSymbol : {- empty -} { [] }
|
||||
| ListSymbol Symbol { flip (:) $1 $2 }
|
||||
ListSymbol : '.' { [] }
|
||||
| Symbol { (:[]) $1 }
|
||||
| Symbol ListSymbol { (:) $1 $2 }
|
||||
|
||||
|
||||
Name :: { Name }
|
||||
@@ -110,20 +114,51 @@ ListIdentParam : {- empty -} { [] }
|
||||
|
||||
|
||||
Category :: { Category }
|
||||
Category : IdentParam '.' Ident ListParam { Category $1 $3 (reverse $4) }
|
||||
Category : IdentParam '.' Ident ListProj { Category $1 $3 (reverse $4) }
|
||||
|
||||
|
||||
IdentParam :: { IdentParam }
|
||||
IdentParam : Ident '{' ListParam '}' { IdentParam $1 (reverse $3) }
|
||||
IdentParam : Ident '{' ListField '}' { IdentParam $1 (reverse $3) }
|
||||
|
||||
|
||||
Field :: { Field }
|
||||
Field : '.' KeyValue { Field $2 }
|
||||
|
||||
|
||||
ListField :: { [Field] }
|
||||
ListField : {- empty -} { [] }
|
||||
| ListField Field ';' { flip (:) $1 $2 }
|
||||
|
||||
|
||||
Proj :: { Proj }
|
||||
Proj : '!' Param { Proj $2 }
|
||||
|
||||
|
||||
ListProj :: { [Proj] }
|
||||
ListProj : {- empty -} { [] }
|
||||
| ListProj Proj { flip (:) $1 $2 }
|
||||
|
||||
|
||||
KeyValue :: { KeyValue }
|
||||
KeyValue : Ident '=' Param { KeyValue $1 $3 }
|
||||
|
||||
|
||||
ListKeyValue :: { [KeyValue] }
|
||||
ListKeyValue : {- empty -} { [] }
|
||||
| KeyValue { (:[]) $1 }
|
||||
| KeyValue ';' ListKeyValue { (:) $1 $3 }
|
||||
|
||||
|
||||
Param :: { Param }
|
||||
Param : '!' Ident { Param $2 }
|
||||
Param : Ident { ParamSimple $1 }
|
||||
| Ident '(' ListParam ')' { ParamPatt $1 $3 }
|
||||
| '{' ListKeyValue '}' { ParamRec $2 }
|
||||
|
||||
|
||||
ListParam :: { [Param] }
|
||||
ListParam : {- empty -} { [] }
|
||||
| ListParam Param { flip (:) $1 $2 }
|
||||
| Param { (:[]) $1 }
|
||||
| Param ',' ListParam { (:) $1 $3 }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -132,7 +132,8 @@ instance Print Symbol where
|
||||
TermS str -> prPrec i 0 (concatD [prt 0 str])
|
||||
|
||||
prtList es = case es of
|
||||
[] -> (concatD [])
|
||||
[] -> (concatD [doc (showString ".")])
|
||||
[x] -> (concatD [prt 0 x])
|
||||
x:xs -> (concatD [prt 0 x , prt 0 xs])
|
||||
|
||||
instance Print Name where
|
||||
@@ -142,23 +143,51 @@ instance Print Name where
|
||||
|
||||
instance Print Category where
|
||||
prt i e = case e of
|
||||
Category identparam id params -> prPrec i 0 (concatD [prt 0 identparam , doc (showString ".") , prt 0 id , prt 0 params])
|
||||
Category identparam id projs -> prPrec i 0 (concatD [prt 0 identparam , doc (showString ".") , prt 0 id , prt 0 projs])
|
||||
|
||||
|
||||
instance Print IdentParam where
|
||||
prt i e = case e of
|
||||
IdentParam id params -> prPrec i 0 (concatD [prt 0 id , doc (showString "{") , prt 0 params , doc (showString "}")])
|
||||
IdentParam id fields -> prPrec i 0 (concatD [prt 0 id , doc (showString "{") , prt 0 fields , doc (showString "}")])
|
||||
|
||||
prtList es = case es of
|
||||
[] -> (concatD [])
|
||||
x:xs -> (concatD [prt 0 x , doc (showString "/") , prt 0 xs])
|
||||
|
||||
instance Print Param where
|
||||
instance Print Field where
|
||||
prt i e = case e of
|
||||
Param id -> prPrec i 0 (concatD [doc (showString "!") , prt 0 id])
|
||||
Field keyvalue -> prPrec i 0 (concatD [doc (showString ".") , prt 0 keyvalue])
|
||||
|
||||
prtList es = case es of
|
||||
[] -> (concatD [])
|
||||
x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
|
||||
|
||||
instance Print Proj where
|
||||
prt i e = case e of
|
||||
Proj param -> prPrec i 0 (concatD [doc (showString "!") , prt 0 param])
|
||||
|
||||
prtList es = case es of
|
||||
[] -> (concatD [])
|
||||
x:xs -> (concatD [prt 0 x , prt 0 xs])
|
||||
|
||||
instance Print KeyValue where
|
||||
prt i e = case e of
|
||||
KeyValue id param -> prPrec i 0 (concatD [prt 0 id , doc (showString "=") , prt 0 param])
|
||||
|
||||
prtList es = case es of
|
||||
[] -> (concatD [])
|
||||
[x] -> (concatD [prt 0 x])
|
||||
x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
|
||||
|
||||
instance Print Param where
|
||||
prt i e = case e of
|
||||
ParamSimple id -> prPrec i 0 (concatD [prt 0 id])
|
||||
ParamPatt id params -> prPrec i 0 (concatD [prt 0 id , doc (showString "(") , prt 0 params , doc (showString ")")])
|
||||
ParamRec keyvalues -> prPrec i 0 (concatD [doc (showString "{") , prt 0 keyvalues , doc (showString "}")])
|
||||
|
||||
prtList es = case es of
|
||||
[] -> (concatD [])
|
||||
[x] -> (concatD [prt 0 x])
|
||||
x:xs -> (concatD [prt 0 x , doc (showString ",") , prt 0 xs])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user