mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-11 05:49:31 -06:00
fixed some tutorial grammars and updated embedded section (JavaScript and web TODO)
This commit is contained in:
21
examples/tutorial/embedded/TransferLoop.hs
Normal file
21
examples/tutorial/embedded/TransferLoop.hs
Normal file
@@ -0,0 +1,21 @@
|
||||
module Main where
|
||||
|
||||
import PGF
|
||||
import TransferDef (transfer)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
gr <- readPGF "Query.pgf"
|
||||
loop (translate transfer gr)
|
||||
|
||||
loop :: (String -> String) -> IO ()
|
||||
loop trans = do
|
||||
s <- getLine
|
||||
if s == "quit" then putStrLn "bye" else do
|
||||
putStrLn $ trans s
|
||||
loop trans
|
||||
|
||||
translate :: (Tree -> Tree) -> PGF -> String -> String
|
||||
translate tr gr s = case parseAllLang gr (startCat gr) s of
|
||||
(lg,t:_):_ -> linearize gr lg (tr t)
|
||||
_ -> "NO PARSE"
|
||||
Reference in New Issue
Block a user