blob: 5abd7e2024c48e5d6da16bcc6a6f16ba4c3cea1a (
plain)
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
|
%{
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
/*
* POSIX iconv charmap grammar.
*/
#include <wchar.h>
#include <stdio.h>
#include <limits.h>
#include "charmap.h"
%}
%union {
char *token;
int num;
char mbs[MB_LEN_MAX + 2]; /* NB: [0] is length! */
}
%token T_CODE_SET
%token T_MB_CUR_MAX
%token T_MB_CUR_MIN
%token T_COM_CHAR
%token T_ESC_CHAR
%token T_LT
%token T_GT
%token T_NL
%token T_SEMI
%token T_COMMA
%token T_ELLIPSIS
%token T_RPAREN
%token T_LPAREN
%token T_QUOTE
%token T_NULL
%token T_END
%token T_CHARMAP
%token T_WIDTH
%token T_WIDTH_DEFAULT
%token <mbs> T_CHAR
%token <token> T_NAME
%token <num> T_NUMBER
%token <token> T_SYMBOL
%%
goal : setting_list charmap
| charmap
;
string : T_QUOTE charlist T_QUOTE
| T_QUOTE T_QUOTE
;
charlist : charlist T_CHAR
| T_CHAR
;
setting_list : setting_list setting
| setting
;
setting : T_COM_CHAR T_CHAR T_NL
{
com_char = $2[1];
}
| T_ESC_CHAR T_CHAR T_NL
{
esc_char = $2[1];
}
| T_MB_CUR_MAX T_NUMBER T_NL
{
mb_cur_max = $2;
}
| T_MB_CUR_MIN T_NUMBER T_NL
{
mb_cur_min = $2;
}
| T_CODE_SET T_NAME T_NL
{
/* ignore */
}
| T_CODE_SET string T_NL
{
/* ignore */
}
;
charmap : T_CHARMAP T_NL charmap_list T_END T_CHARMAP T_NL
charmap_list : charmap_list charmap_entry
| charmap_entry
;
charmap_entry : T_SYMBOL T_CHAR
{
add_charmap($1, $2);
scan_to_eol();
}
| T_SYMBOL T_ELLIPSIS T_SYMBOL T_CHAR
{
add_charmap_range($1, $3, $4);
scan_to_eol();
}
| T_NL
;
|