1 %{ 2 /* 3 * This file and its contents are supplied under the terms of the 4 * Common Development and Distribution License ("CDDL"), version 1.0. 5 * You may only use this file in accordance with the terms of version 6 * 1.0 of the CDDL. 7 * 8 * A full copy of the text of the CDDL should have accompanied this 9 * source. A copy of the CDDL is also available via the Internet at 10 * http://www.illumos.org/license/CDDL. 11 */ 12 13 /* 14 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 15 */ 16 17 /* 18 * POSIX iconv charmap grammar. 19 */ 20 21 #include <wchar.h> 22 #include <stdio.h> 23 #include <limits.h> 24 #include "charmap.h" 25 26 extern int yylex(void); 27 28 %} 29 %union { 30 char *token; 31 int num; 32 char mbs[MB_LEN_MAX + 2]; /* NB: [0] is length! */ 33 } 34 35 %token T_CODE_SET 36 %token T_MB_CUR_MAX 37 %token T_MB_CUR_MIN 38 %token T_COM_CHAR 39 %token T_ESC_CHAR 40 %token T_LT 41 %token T_GT 42 %token T_NL 43 %token T_SEMI 44 %token T_COMMA 45 %token T_ELLIPSIS 46 %token T_RPAREN 47 %token T_LPAREN 48 %token T_QUOTE 49 %token T_NULL 50 %token T_END 51 %token T_CHARMAP 52 %token T_WIDTH 53 %token T_WIDTH_DEFAULT 54 %token <mbs> T_CHAR 55 %token <token> T_NAME 56 %token <num> T_NUMBER 57 %token <token> T_SYMBOL 58 59 %% 60 61 goal : setting_list charmap 62 | charmap 63 ; 64 65 string : T_QUOTE charlist T_QUOTE 66 | T_QUOTE T_QUOTE 67 ; 68 69 charlist : charlist T_CHAR 70 | T_CHAR 71 ; 72 73 setting_list : setting_list setting 74 | setting 75 ; 76 77 setting : T_COM_CHAR T_CHAR T_NL 78 { 79 com_char = $2[1]; 80 } 81 | T_ESC_CHAR T_CHAR T_NL 82 { 83 esc_char = $2[1]; 84 } 85 | T_MB_CUR_MAX T_NUMBER T_NL 86 { 87 mb_cur_max = $2; 88 } 89 | T_MB_CUR_MIN T_NUMBER T_NL 90 { 91 mb_cur_min = $2; 92 } 93 | T_CODE_SET T_NAME T_NL 94 { 95 /* ignore */ 96 } 97 | T_CODE_SET string T_NL 98 { 99 /* ignore */ 100 } 101 ; 102 103 charmap : T_CHARMAP T_NL charmap_list T_END T_CHARMAP T_NL 104 105 charmap_list : charmap_list charmap_entry 106 | charmap_entry 107 ; 108 109 charmap_entry : T_SYMBOL T_CHAR 110 { 111 add_charmap($1, $2); 112 scan_to_eol(); 113 } 114 | T_SYMBOL T_ELLIPSIS T_SYMBOL T_CHAR 115 { 116 add_charmap_range($1, $3, $4); 117 scan_to_eol(); 118 } 119 | T_NL 120 ; 121