~ubuntu-branches/ubuntu/breezy/malaga/breezy

« back to all changes in this revision

Viewing changes to grammars/numeral/numeral.mor

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Bushnell, BSG
  • Date: 2005-01-10 11:52:04 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050110115204-hpgncw5pb0m1t8i6
Tags: 6.13-5
debian/control (malaga-doc Recommends): Suggest gv as a
postscript-viewer instead of ghostview.  (Closes: #289701).

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
#------------------------------------------------------------------------------
7
7
 
8
 
combi_rule dash_to_ones ($start, $next, $surface):
 
8
combi_rule dash_to_ones( $state, $link, $surface ):
9
9
# Read a "-" in front of "one", ..., "nine".
10
 
  ? $surface = "-";
11
 
  result $start, rules ones;
 
10
  require $surface = "-";
 
11
  result $state, rules ones;
12
12
end dash_to_ones;
13
13
 
14
14
#------------------------------------------------------------------------------
15
15
 
16
 
combi_rule blank_to_ones_or_tens ($start, $next, $surface):
 
16
combi_rule blank_to_ones_or_tens( $state, $link, $surface ):
17
17
# Read a blank in front of "one", ..., "ninety".
18
 
  ? $surface = " ";
19
 
  result $start, rules ones, tens;
 
18
  require $surface = " ";
 
19
  result $state, rules ones, tens;
20
20
end blank_to_ones_or_tens;
21
21
 
22
22
#------------------------------------------------------------------------------
23
23
 
24
 
combi_rule ones ($start, $next):
 
24
combi_rule ones( $state, $link ):
25
25
# Read "one", "two", ..., "nineteen"
26
 
  ? ones in $next;
27
 
  if tens in $next then
28
 
    ? $start.tens = 0;
29
 
    $start.tens := $next.tens;
 
26
  require ones in $link;
 
27
  if tens in $link then
 
28
    require $state.tens = 0;
 
29
    $state.tens := $link.tens;
30
30
  end if;
31
 
  $start.ones := $next.ones;
32
 
  result $start, rules blank_to_thousand, blank_to_hundred, finish;
 
31
  $state.ones := $link.ones;
 
32
  result $state, rules blank_to_thousand, blank_to_hundred, finish;
33
33
end combi_rule;
34
34
 
35
35
#------------------------------------------------------------------------------
36
36
 
37
 
combi_rule tens ($start, $next):
 
37
combi_rule tens( $state, $link ):
38
38
# Read "twenty", ..., "ninety".
39
 
  ? $start.tens = 0;
40
 
  ? tens in $next and not ones in $next;
41
 
  $start.tens := $next.tens;
42
 
  result $start, rules dash_to_ones, blank_to_thousand, finish;
 
39
  require $state.tens = 0;
 
40
  require tens in $link and not ones in $link;
 
41
  $state.tens := $link.tens;
 
42
  result $state, rules dash_to_ones, blank_to_thousand, finish;
43
43
end combi_rule;
44
44
 
45
45
#------------------------------------------------------------------------------
46
46
 
47
 
combi_rule blank_to_hundred ($start, $next, $surface):
 
47
combi_rule blank_to_hundred( $state, $link, $surface ):
48
48
# Read a blank in front of "hundred".
49
 
  ? $surface = " ";
50
 
  result $start, rules hundred;
 
49
  require $surface = " ";
 
50
  result $state, rules hundred;
51
51
end blank_to_hundred;
52
52
 
53
53
#------------------------------------------------------------------------------
54
54
 
55
 
combi_rule hundred ($start, $next, $surface):
 
55
combi_rule hundred( $state, $link, $surface ):
56
56
# Read "hundred".
57
 
  ? $surface = "hundred";
58
 
  ? $start.hundreds = 0 and $start.tens = 0;
59
 
  if $start.ones = 0 then
60
 
    $start :=+ [ones: 1];
 
57
  require $surface = "hundred";
 
58
  require $state.hundreds = 0 and $state.tens = 0;
 
59
  if $state.ones = 0 then
 
60
    $state :=+ [ones: 1];
61
61
  end if;
62
 
  $start :=+ [hundreds: $start.ones, ones: 0];
63
 
  result $start, rules blank_to_ones_or_tens, blank_to_thousand, finish;
 
62
  $state :=+ [hundreds: $state.ones, ones: 0];
 
63
  result $state, rules blank_to_ones_or_tens, blank_to_thousand, finish;
64
64
end combi_rule;
65
65
 
66
66
#------------------------------------------------------------------------------
67
67
 
68
 
combi_rule blank_to_thousand ($start, $next, $surface):
 
68
combi_rule blank_to_thousand( $state, $link, $surface ):
69
69
# Read a blank in front of "thousand".
70
 
  ? $surface = " ";
71
 
  result $start, rules thousand;
 
70
  require $surface = " ";
 
71
  result $state, rules thousand;
72
72
end blank_to_thousand;
73
73
 
74
74
#------------------------------------------------------------------------------
75
75
 
76
 
combi_rule thousand ($start, $next, $surface):
 
76
combi_rule thousand( $state, $link, $surface ):
77
77
# Read "thousand".
78
 
  ? $surface = "thousand";
79
 
  ? $start.thousands = 0;
80
 
  if $start.ones = 0 and $start.tens = 0 and $start.hundreds = 0 then
81
 
    $start :=+ [ones: 1];
 
78
  require $surface = "thousand";
 
79
  require $state.thousands = 0;
 
80
  if $state.ones = 0 and $state.tens = 0 and $state.hundreds = 0 then
 
81
    $state :=+ [ones: 1];
82
82
  end if;
83
83
  define $result := [ones: 0, tens: 0, hundreds: 0,
84
 
                     thousands: ($start.hundreds * 100 + $start.tens * 10
85
 
                                 + $start.ones)];
 
84
                     thousands: ($state.hundreds * 100 + $state.tens * 10
 
85
                                 + $state.ones)];
86
86
  result $result, rules blank_to_ones_or_tens, finish;
87
87
end combi_rule;
88
88
 
89
89
#------------------------------------------------------------------------------
90
90
 
91
 
end_rule finish ($start):
92
 
  result ($start.thousands * 1000
93
 
          + $start.hundreds * 100
94
 
          + $start.tens * 10
95
 
          + $start.ones), accept;
 
91
end_rule finish( $state ):
 
92
  result ($state.thousands * 1000
 
93
          + $state.hundreds * 100
 
94
          + $state.tens * 10
 
95
          + $state.ones), accept;
96
96
end finish;
97
97
 
98
98
# end of file =================================================================