diff options
author | ache <ache@FreeBSD.org> | 1996-10-16 03:12:22 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1996-10-16 03:12:22 +0000 |
commit | f5b4e8c2abd5160b9d821a234962354728748f49 (patch) | |
tree | 981a086d32426b26e3940c73565d5662776f9294 /usr.bin/colldef | |
parent | 0b67136d65d40b2d2dda49a4e9a837e5ff5b59d3 (diff) | |
download | FreeBSD-src-f5b4e8c2abd5160b9d821a234962354728748f49.zip FreeBSD-src-f5b4e8c2abd5160b9d821a234962354728748f49.tar.gz |
Simplify and improve parser.
Clarify manpage.
Diffstat (limited to 'usr.bin/colldef')
-rw-r--r-- | usr.bin/colldef/colldef.1 | 40 | ||||
-rw-r--r-- | usr.bin/colldef/parse.y | 227 | ||||
-rw-r--r-- | usr.bin/colldef/scan.l | 15 |
3 files changed, 38 insertions, 244 deletions
diff --git a/usr.bin/colldef/colldef.1 b/usr.bin/colldef/colldef.1 index 4c44cf7..d7e7998 100644 --- a/usr.bin/colldef/colldef.1 +++ b/usr.bin/colldef/colldef.1 @@ -124,11 +124,7 @@ representation, and can be only one character in length. .Pp Symbol names cannot be specified in .Ar substitute -fields. Symbol names also cannot be combined with -any other representation, such as, <c>h, c<h>, -<c>\ex68, or <c><h>. Symbol names can be used with -primary and secondary ordering as in the following -example. +fields. .Pp The .Ar charmap @@ -153,14 +149,15 @@ statement is optional. .Ar order order_list .Pp .Ar order_list -is a list of symbols, separated by semi colons, that defines the collating sequence. The +is a list of symbols, separated by semi colons, that defines the +collating sequence. The special symbol .Ar ... specifies, in a short-hand form, symbols that are sequential in machine code order. .Pp -A symbol can be up to two characters in length and +An order list element can be represented in any one of the following ways: .Bl -bullet @@ -208,18 +205,33 @@ Symbols .Ar \er , .Ar \ev are permitted in its usual C-language meaning +.It +The symbol range (for example, +.Ar a;...;z ) +.It +Comma-separated symbols, ranges and chains enclosed in parenthesis (for example +.Ar \&( +.Ar sym1 , +.Ar sym2 , +.Ar ... +.Ar \&) ) +are assigned the +same primary ordering but different secondary +ordering. +.It +Comma-separated symbols, ranges and chains enclosed in curly brackets (for example +.Ar \&{ +.Ar sym1 , +.Ar sym2 , +.Ar ... +.Ar \&} ) +are assigned the same primary ordering only. .El .Pp The backslash character .Ar \e is used for continuation. In this case, no characters are permitted -after the backslash character. And as a quotation mark. -.Pp -Symbols enclosed in parentheses are assigned the -same primary ordering but different secondary -ordering. Symbols enclosed in curly brackets are -assigned only the same primary ordering -and different secondary ordering. +after the backslash character. .Sh EXIT STATUS .Ar colldef exits with the following values: diff --git a/usr.bin/colldef/parse.y b/usr.bin/colldef/parse.y index 55067c5..5823689 100644 --- a/usr.bin/colldef/parse.y +++ b/usr.bin/colldef/parse.y @@ -61,7 +61,6 @@ char *out_file = "LC_COLLATE"; } %token SUBSTITUTE WITH ORDER RANGE %token <str> STRING -%token <str> NAME %token <str> CHAIN %token <str> DEFN %token <ch> CHAR @@ -117,17 +116,6 @@ item : CHAR { __collate_char_pri_table[$1].prim = prim_pri++; } strcpy(__collate_chain_pri_table[chain_index].str, $1); __collate_chain_pri_table[chain_index++].prim = prim_pri++; } - | NAME { - u_int i; - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $1) == 0) - goto findi; - yyerror("Name <%s> not defined", $1); - findi: - - __collate_char_pri_table[i].prim = prim_pri++; -} | CHAR RANGE CHAR { u_int i; @@ -137,68 +125,6 @@ item : CHAR { __collate_char_pri_table[$1].prim = prim_pri++; } for (i = $1; i <= $3; i++) __collate_char_pri_table[(u_char)i].prim = prim_pri++; } - | NAME RANGE CHAR { - u_int i, c1; - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $1) == 0) { - c1 = i; - goto find1; - } - yyerror("Name <%s> not defined", $1); - find1: - - if ($3 <= c1) - yyerror("Illegal range 0x%02x -- 0x%02x", - c1, $3); - - for (i = c1; i <= $3; i++) - __collate_char_pri_table[(u_char)i].prim = prim_pri++; -} - | CHAR RANGE NAME { - u_int i, c3; - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $3) == 0) { - c3 = i; - goto find3; - } - yyerror("Name <%s> not defined", $3); - find3: - - if (c3 <= $1) - yyerror("Illegal range 0x%02x -- 0x%02x", - $1, c3); - - for (i = $1; i <= c3; i++) - __collate_char_pri_table[(u_char)i].prim = prim_pri++; -} - | NAME RANGE NAME { - u_int i, c1, c3; - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $1) == 0) { - c1 = i; - goto find21; - } - yyerror("Name <%s> not defined", $1); - find21: - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $3) == 0) { - c3 = i; - goto find23; - } - yyerror("Name <%s> not defined", $3); - find23: - - if (c3 <= c1) - yyerror("Illegal range 0x%02x -- 0x%02x", - c1, c3); - - for (i = c1; i <= c3; i++) - __collate_char_pri_table[(u_char)i].prim = prim_pri++; -} | '{' prim_order_list '}' { prim_pri++; } @@ -226,79 +152,6 @@ prim_sub_item : CHAR { for (i = $1; i <= $3; i++) __collate_char_pri_table[(u_char)i].prim = prim_pri; } - | NAME RANGE CHAR { - u_int i, c1; - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $1) == 0) { - c1 = i; - goto findpsi1; - } - yyerror("Name <%s> not defined", $1); - findpsi1: - - if ($3 <= c1) - yyerror("Illegal range 0x%02x -- 0x%02x", - c1, $3); - - for (i = c1; i <= $3; i++) - __collate_char_pri_table[(u_char)i].prim = prim_pri; -} - | CHAR RANGE NAME { - u_int i, c3; - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $3) == 0) { - c3 = i; - goto findpsi3; - } - yyerror("Name <%s> not defined", $3); - findpsi3: - - if (c3 <= $1) - yyerror("Illegal range 0x%02x -- 0x%02x", - $1, c3); - - for (i = $1; i <= c3; i++) - __collate_char_pri_table[(u_char)i].prim = prim_pri; -} - | NAME RANGE NAME { - u_int i, c1, c3; - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $1) == 0) { - c1 = i; - goto findpsi21; - } - yyerror("Name <%s> not defined", $1); - findpsi21: - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $3) == 0) { - c3 = i; - goto findpsi23; - } - yyerror("Name <%s> not defined", $3); - findpsi23: - - if (c3 <= c1) - yyerror("Illegal range 0x%02x -- 0x%02x", - c1, c3); - - for (i = c1; i <= c3; i++) - __collate_char_pri_table[(u_char)i].prim = prim_pri; -} - | NAME { - u_int i; - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $1) == 0) - goto findpsi; - yyerror("Name <%s> not defined", $1); - findpsi: - - __collate_char_pri_table[i].prim = prim_pri; -} | CHAIN { if (chain_index >= TABLE_SIZE - 1) yyerror("__collate_chain_pri_table overflow"); @@ -322,86 +175,6 @@ sec_sub_item : CHAR { __collate_char_pri_table[(u_char)i].sec = sec_pri++; } } - | NAME RANGE CHAR { - u_int i, c1; - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $1) == 0) { - c1 = i; - goto findssi1; - } - yyerror("Name <%s> not defined", $1); - findssi1: - - if ($3 <= c1) - yyerror("Illegal range 0x%02x -- 0x%02x", - c1, $3); - - for (i = c1; i <= $3; i++) { - __collate_char_pri_table[(u_char)i].prim = prim_pri; - __collate_char_pri_table[(u_char)i].sec = sec_pri++; - } -} - | CHAR RANGE NAME { - u_int i, c3; - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $3) == 0) { - c3 = i; - goto findssi3; - } - yyerror("Name <%s> not defined", $3); - findssi3: - - if (c3 <= $1) - yyerror("Illegal range 0x%02x -- 0x%02x", - $1, c3); - - for (i = $1; i <= c3; i++) { - __collate_char_pri_table[(u_char)i].prim = prim_pri; - __collate_char_pri_table[(u_char)i].sec = sec_pri++; - } -} - | NAME RANGE NAME { - u_int i, c1, c3; - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $1) == 0) { - c1 = i; - goto findssi21; - } - yyerror("Name <%s> not defined", $1); - findssi21: - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $3) == 0) { - c3 = i; - goto findssi23; - } - yyerror("Name <%s> not defined", $3); - findssi23: - - if (c3 <= c1) - yyerror("Illegal range 0x%02x -- 0x%02x", - c1, c3); - - for (i = c1; i <= c3; i++) { - __collate_char_pri_table[(u_char)i].prim = prim_pri; - __collate_char_pri_table[(u_char)i].sec = sec_pri++; - } -} - | NAME { - u_int i; - - for (i = 0; i <= UCHAR_MAX; i++) - if (strcmp(charmap_table[i], $1) == 0) - goto findssi; - yyerror("Name <%s> not defined", $1); - findssi: - - __collate_char_pri_table[i].prim = prim_pri; - __collate_char_pri_table[i].sec = sec_pri++; -} | CHAIN { if (chain_index >= TABLE_SIZE - 1) yyerror("__collate_chain_pri_table overflow"); diff --git a/usr.bin/colldef/scan.l b/usr.bin/colldef/scan.l index 6a7d0cf..d8c1116 100644 --- a/usr.bin/colldef/scan.l +++ b/usr.bin/colldef/scan.l @@ -41,6 +41,7 @@ int line_no = 1, save_no; u_char buf[STR_LEN], *ptr; FILE *map_fp; extern char map_name[]; +extern u_char charmap_table[UCHAR_MAX + 1][STR_LEN]; YY_BUFFER_STATE main_buf, map_buf; #ifdef FLEX_DEBUG YYSTYPE yylval; @@ -137,13 +138,21 @@ YYSTYPE yylval; *ptr++ = '"'; } <name>\> { + u_int i; + if (ptr == buf) - errx(EX_UNAVAILABLE, "name expected near line %u", + errx(EX_UNAVAILABLE, "non-empty name expected near line %u", line_no); *ptr = '\0'; - strcpy(yylval.str, buf); + for (i = 0; i <= UCHAR_MAX; i++) + if (strcmp(charmap_table[i], buf) == 0) + goto findit; + errx(EX_UNAVAILABLE, "name <%s> not 'charmap'-defined near line %u", + buf, line_no); + findit: + yylval.ch = i; BEGIN(INITIAL); - return NAME; + return CHAR; } <string>\" { *ptr = '\0'; |