This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM haskell:9.2.8 | |
RUN apt-get update \ | |
&& apt-get install -y \ | |
curl \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Install the C runtime of GF from source | |
WORKDIR /tmp | |
ARG GF_VERSION=c2182274df0a0f730b4d4a41ea4a537cdb388ecd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PGF | |
import Debug.Trace (trace) | |
import Data.Foldable (asum) | |
import Test | |
getMeta :: Expr -> Int | |
getMeta expr = case go expr of | |
Just i -> trace (unwords ["expression", showExpr [] expr, "contains the metavariable", show i, ", returning it"]) i | |
Nothing -> trace (unwords ["expression", showExpr [] expr, "doesn't contain a metavariable, defaulting to 42"]) 42 | |
where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract FoodsList = { | |
flags coding = utf8 ; | |
flags startcat = Comment ; | |
cat | |
Comment ; Item ; Kind ; Quality ; | |
[Comment]{2} ; -- List of Comments | |
fun | |
-- BaseComment and ConsComment are added automatically | |
-- We only have to define a function from list to a single comment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract Worker = Numeral -- We extend the Numeral abstract syntax to get Digits | |
** { | |
flags startcat = Clause ; | |
cat | |
Kind ; | |
Clause ; | |
-- The categories Int, Float and String are present in all grammars | |
-- The categories Dig and Digits come from Numeral. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract OmitParticles = | |
Grammar [ -- "Embedded DSL" on top of some RGL categories | |
N, CN, NP, UseN, MassNP | |
, V2 | |
, S, Cl, Temp, Pol, Tense, Ant | |
, UseCl, PPos, PNeg, TTAnt, TPres, TPast, ASimul | |
] | |
, Lexicon -- to get some lexicon | |
** { | |
flags startcat = S ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract Fields = { | |
flags startcat = S ; | |
cat | |
S ; CN ; Adv ; | |
fun | |
ThereIs : CN -> S ; -- there is a house | |
ThereAre : CN -> S ; -- there are houses | |
ModCN : CN -> Adv -> CN ; -- house on a hill | |
house_CN : CN ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource Tables = { | |
param | |
Number = Sg | Pl ; | |
Gender = Fem | Masc ; | |
oper | |
-- Single tables, no nesting | |
numTable : Number => Str = table { | |
Sg => "singular form" ; | |
Pl => "plural form" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract Conjunctions = { | |
cat | |
S ; NP ; AP ; Conj ; | |
[NP]{2} ; | |
[AP]{2} ; | |
fun | |
Pred : NP -> AP -> S ; -- the pizza is Italian | |
ConjNP : Conj -> [NP] -> NP ; -- pizza, beer and sandwich |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract TestConj = { | |
-- Same as the hacky version until the list instance | |
flags startcat = MyUtt ; | |
cat | |
MyUtt ; MyCl ; | |
fun | |
testUtt : MyUtt ; | |
testCl : MyCl ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Mini grammar for demo purposes, only has one sentence | |
abstract PeopleThink = { | |
cat | |
S ; | |
fun | |
IWantPeopleToThink : S ; | |
} |
NewerOlder