diff options
| author | krasimir <krasimir@chalmers.se> | 2009-10-02 13:25:12 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2009-10-02 13:25:12 +0000 |
| commit | 8e799548618318c37760a2e915eb994745574748 (patch) | |
| tree | eedbae4f6309c950e554631d94dc5b95a2a96abd /src/GF | |
| parent | af831e01a7baf6de9ac3a475368f7315c99797a7 (diff) | |
Implicit arguments in GF. Works only in PGF for now.
Diffstat (limited to 'src/GF')
| -rw-r--r-- | src/GF/Grammar/Grammar.hs | 3 | ||||
| -rw-r--r-- | src/GF/Grammar/Parser.y | 12 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/GF/Grammar/Grammar.hs b/src/GF/Grammar/Grammar.hs index d7af03f22..e3b4ddbae 100644 --- a/src/GF/Grammar/Grammar.hs +++ b/src/GF/Grammar/Grammar.hs @@ -122,6 +122,7 @@ data Term = | App Term Term -- ^ application: @f a@ | Abs BindType Ident Term -- ^ abstraction: @\x -> b@ | Meta {-# UNPACK #-} !MetaId -- ^ metavariable: @?i@ (only parsable: ? = ?0) + | ImplArg Term -- ^ placeholder for implicit argument @{t}@ | Prod BindType Ident Term Term -- ^ function type: @(x : A) -> B@, @A -> B@, @({x} : A) -> B@ | Typed Term Term -- ^ type-annotated term -- @@ -177,6 +178,8 @@ data Patt = | PVal Patt Type Int -- ^ parameter value number: @T # i# | PAs Ident Patt -- ^ as-pattern: x@p + + | PImplArg Patt -- ^ placeholder for pattern for implicit argument @{p}@ -- regular expression patterns | PNeg Patt -- ^ negated pattern: -p diff --git a/src/GF/Grammar/Parser.y b/src/GF/Grammar/Parser.y index 4dea6b8ec..1c6b51e77 100644 --- a/src/GF/Grammar/Parser.y +++ b/src/GF/Grammar/Parser.y @@ -414,7 +414,8 @@ Exp3 Exp4 :: { Term } Exp4 - : Exp4 Exp5 { App $1 $2 } + : Exp4 Exp5 { App $1 $2 } + | Exp4 '{' Exp '}' { App $1 (ImplArg $3) } | 'case' Exp 'of' '{' ListCase '}' { let annot = case $2 of Typed _ t -> TTyped t _ -> TRaw @@ -488,7 +489,6 @@ Patt2 | '#' Ident '.' Ident { PM $2 $4 } | '_' { PW } | Ident { PV $1 } - | '{' Ident '}' { PC $2 [] } | Ident '.' Ident { PP $1 $3 [] } | Integer { PInt $1 } | Double { PFloat $1 } @@ -522,8 +522,12 @@ ListPattAss ListPatt :: { [Patt] } ListPatt - : Patt2 { [$1] } - | Patt2 ListPatt { $1 : $2 } + : PattArg { [$1] } + | PattArg ListPatt { $1 : $2 } + +PattArg :: { Patt } + : Patt2 { $1 } + | '{' Patt2 '}' { PImplArg $2 } Arg :: { [(BindType,Ident)] } Arg |
