forked from GitHub/gf-core
Support dynamic param values
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
abstract Scratch = {
|
||||
abstract Params = {
|
||||
cat S ; F ;
|
||||
fun
|
||||
FtoS : F -> S ;
|
||||
5
testsuite/lpgf/Params.treebank
Normal file
5
testsuite/lpgf/Params.treebank
Normal file
@@ -0,0 +1,5 @@
|
||||
Params: FtoS f1
|
||||
ParamsCnc: PR R1 Q2
|
||||
|
||||
Params: FtoS f2
|
||||
ParamsCnc: PR R2 _
|
||||
20
testsuite/lpgf/ParamsCnc.gf
Normal file
20
testsuite/lpgf/ParamsCnc.gf
Normal file
@@ -0,0 +1,20 @@
|
||||
concrete ParamsCnc of Params = {
|
||||
param
|
||||
R = R1 | R2 ;
|
||||
P = PR R Q | PP ;
|
||||
Q = Q1 | Q2 ;
|
||||
lincat
|
||||
S = Str ;
|
||||
F = { r : R } ;
|
||||
lin
|
||||
f1 = { r = R1 } ;
|
||||
f2 = { r = R2 } ;
|
||||
FtoS f = tbl ! PR f.r Q2 ;
|
||||
oper
|
||||
tbl = table {
|
||||
PR R1 Q1 => "PR R1 Q1" ;
|
||||
PR R1 Q2 => "PR R1 Q2" ;
|
||||
PR R2 _ => "PR R2 _" ;
|
||||
PP => "PP"
|
||||
} ;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
Scratch: FtoS f1
|
||||
ScratchCnc: R1 Q2
|
||||
@@ -1,18 +0,0 @@
|
||||
concrete ScratchCnc of Scratch = {
|
||||
param
|
||||
R = R1 | R2 ;
|
||||
P = PR R Q | PP ;
|
||||
Q = Q1 | Q2 ;
|
||||
lincat
|
||||
S = Str ;
|
||||
F = { p : P => Str } ;
|
||||
lin
|
||||
f1 = f2 ;
|
||||
f2 = { p = table {
|
||||
PR R1 Q1 => "R1 Q1" ;
|
||||
PR R1 Q2 => "R1 Q2" ;
|
||||
PR R2 _ => "R2 _" ;
|
||||
PP => "PP"
|
||||
} } ;
|
||||
FtoS f = f.p ! PR R1 Q2 ;
|
||||
}
|
||||
@@ -15,9 +15,9 @@ dir = "testsuite" </> "lpgf"
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
doGrammar "Scratch"
|
||||
doGrammar "Params"
|
||||
doGrammar "Walking"
|
||||
doGrammar "Foods"
|
||||
-- doGrammar "Foods"
|
||||
|
||||
doGrammar :: String -> IO ()
|
||||
doGrammar gname = do
|
||||
@@ -55,6 +55,7 @@ doGrammar gname = do
|
||||
putStrLn ""
|
||||
error "Test failed"
|
||||
|
||||
-- | Group list of lines by blank lines
|
||||
groups :: [String] -> [[String]]
|
||||
groups [] = []
|
||||
groups ss = let (a,b) = break (=="") ss in a : groups (drop 1 b)
|
||||
|
||||
Reference in New Issue
Block a user