1
0
forked from GitHub/gf-core

Add test case for selection using records (fails)

This commit is contained in:
John J. Camilleri
2021-02-10 13:55:38 +01:00
parent d5f68970b9
commit a12f58e7b0
5 changed files with 51 additions and 1 deletions

View File

@@ -103,7 +103,7 @@ mkCanon2lpgf opts gr am = do
return $ L.LFTuple ts
C.VariantValue [] -> return L.LFEmpty
C.VariantValue (vr:_) -> val2lin vr -- TODO variants not supported, just pick first
C.VariantValue (vr:_) -> val2lin vr -- NOTE variants not supported, just pick first
C.VarValue (C.VarValueId (C.Unqual v)) -> do
ix <- eitherElemIndex (C.VarId v) varIds

6
testsuite/lpgf/Tables.gf Normal file
View File

@@ -0,0 +1,6 @@
abstract Tables = {
cat S ; F ;
fun
FtoS : F -> S ;
f1, f2, f3, f4, f5, f6 : F ;
}

View File

@@ -0,0 +1,17 @@
Tables: FtoS f1
TablesCnc: R1 _
Tables: FtoS f2
TablesCnc: R1 _
Tables: FtoS f3
TablesCnc: R1 _
Tables: FtoS f4
TablesCnc: _ _
Tables: FtoS f5
TablesCnc: _ Q2
Tables: FtoS f6
TablesCnc: R2 Q3

View File

@@ -0,0 +1,26 @@
concrete TablesCnc of Tables = {
param
R = R1 | R2 ;
Q = Q3 | Q2 | Q1 ;
oper
ParamRec: Type = { r: R; q: Q } ;
lincat
S = Str ;
F = { pr : ParamRec } ;
lin
f1 = { pr = { r = R1; q = Q1 } } ;
f2 = { pr = { r = R1; q = Q2 } } ;
f3 = { pr = { r = R1; q = Q3 } } ;
f4 = { pr = { r = R2; q = Q1 } } ;
f5 = { pr = { r = R2; q = Q2 } } ;
f6 = { pr = { r = R2; q = Q3 } } ;
FtoS f = tbl ! f.pr ;
oper
tbl = table {
{ r = R1 ; q = _ } => "R1 _" ;
{ r = _ ; q = Q2 } => "_ Q2" ;
{ r = R2 ; q = Q3 } => "R2 Q3" ;
_ => "_ _"
} ;
}

View File

@@ -18,6 +18,7 @@ main = do
doGrammar "Params"
doGrammar "Walking"
doGrammar "Foods"
doGrammar "Tables"
doGrammar :: String -> IO ()
doGrammar gname = do