~ubuntu-branches/ubuntu/trusty/happy/trusty-proposed

« back to all changes in this revision

Viewing changes to examples/glr/nlp/English.y

  • Committer: Bazaar Package Importer
  • Author(s): Ian Lynagh (wibble)
  • Date: 2006-10-26 22:52:14 UTC
  • mfrom: (1.2.2 upstream) (3.1.1 dapper)
  • Revision ID: james.westby@ubuntu.com-20061026225214-6jmf0n3ykkc9elyw
Tags: 1.16~rc2-1
* New upstream (release candidate) version.
* Removed happy/ prefixes from various paths in debian/rules and
  debian/docs.
* doc/configure generated by autoconf is in the Debian diff.
* Build using cabal:
  * Various debian/rules changes.
  * Create debian/get_version.hs for extracting the version from the cabal
    file.
  * Requires ghc6 >= 6.4.2.
  * No longer tries to detect platform. Closes: #340325, #332979.
  * Removed autotool-dev build-dep.
* Add 'XSLTPROC_OPTS = --nonet' to doc/config.mk.in.
* Remove src/Parser.ly and src/AttrGrammarParser.ly before cleaning so
  the generated files don't get cleaned.
* Set Standards-Version to 3.7.2 (no changes needed).
* Removed PS and DVI stanzas from debian/doc-base as we don't build
  the documentation those ways.
* Removed content-free postinst and prerm.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{
 
2
-- only list imports here
 
3
import Char
 
4
}
 
5
 
 
6
%tokentype { Token }
 
7
 
 
8
%lexer { lexer } { TokenEOF }
 
9
 
 
10
%token
 
11
        det             { Det $$ }
 
12
        prep            { Prep $$ }
 
13
        noun            { Noun $$ }
 
14
        transvb         { Verb Trans $$ }
 
15
        intransvb       { Verb Intrans $$ }
 
16
 
 
17
%%
 
18
 
 
19
 
20
 : NP VP {}
 
21
 
 
22
NP
 
23
 : det noun {}
 
24
 | NP PP {}
 
25
 
 
26
PP 
 
27
 : prep NP {}
 
28
 
 
29
VP
 
30
 : transvb NP {}
 
31
 | intransvb  {}
 
32
 | VP PP      {}
 
33
 
 
34
{
 
35
 
 
36
data Token
 
37
        = TokenEOF
 
38
        | Noun String
 
39
        | Verb Arity String 
 
40
        | Prep String
 
41
        | Det String
 
42
  deriving (Show,Eq,Ord)
 
43
 
 
44
data Arity = Trans | Intrans deriving (Show,Eq,Ord)
 
45
 
 
46
lexer :: String -> [[Token]]
 
47
lexer = map lex_word . words
 
48
 
 
49
-- simple lexicon
 
50
-- (no claims to accuracy)
 
51
 
 
52
lex_word w@"the"       = [Det w]
 
53
lex_word w@"a"         = [Det w]
 
54
lex_word w@"some"      = [Det w]
 
55
lex_word w@"in"        = [Prep w]
 
56
lex_word w@"with"      = [Prep w]
 
57
lex_word w@"park"      = [Verb Trans w, Noun w]
 
58
lex_word w@"man"       = [Verb Trans w, Noun w]
 
59
lex_word w@"saw"       = [Verb Trans w, Verb Intrans w, Noun w]
 
60
lex_word w@"run"       = [Verb Trans w, Verb Intrans w, Noun w]
 
61
lex_word w@"race"      = [Verb Trans w, Verb Intrans w, Noun w]
 
62
lex_word w@"telescope" = [Verb Trans w, Verb Intrans w, Noun w]
 
63
lex_word w = error $ "Not know: " ++ show w
 
64
}