1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/* GNU gettext - internationalization aids
Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
This file was written by Peter Miller <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
%{
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include "po-lex.h"
#include "po-gram.h"
#include "error.h"
#include "system.h"
#include <libintl.h>
#include "po.h"
#define _(str) gettext (str)
%}
%token COMMENT
%token DOMAIN
%token JUNK
%token MSGID
%token MSGSTR
%token NAME
%token NUMBER
%token STRING
%union
{
char *string;
long number;
lex_pos_ty pos;
}
%type <string> STRING COMMENT string_list
%type <number> NUMBER
%type <pos> msgid msgstr
%right MSGSTR
%%
msgfmt
: /* empty */
| msgfmt comment
| msgfmt domain
| msgfmt message
| msgfmt error
;
domain
: DOMAIN STRING
{
po_callback_domain ($2);
}
;
message
: msgid string_list msgstr string_list
{
po_callback_message ($2, &$1, $4, &$3);
}
| msgid string_list
{
gram_error_at_line (&$1, _("missing `msgstr' section"));
free ($2);
}
;
msgid
: MSGID
{
$$ = gram_pos;
}
;
msgstr
: MSGSTR
{
$$ = gram_pos;
}
;
string_list
: STRING
{
$$ = $1;
}
| string_list STRING
{
size_t len1;
size_t len2;
len1 = strlen ($1);
len2 = strlen ($2);
$$ = (char *) xmalloc (len1 + len2 + 1);
stpcpy (stpcpy ($$, $1), $2);
free ($1);
free ($2);
}
;
comment
: COMMENT
{
po_callback_comment ($1);
}
;
|