symbol.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. /*
  2. * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
  3. * Released under the terms of the GNU GPL v2.0.
  4. */
  5. #include <ctype.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <sys/utsname.h>
  9. #define LKC_DIRECT_LINK
  10. #include "lkc.h"
  11. struct symbol symbol_yes = {
  12. .name = "y",
  13. .curr = { "y", yes },
  14. .flags = SYMBOL_YES|SYMBOL_VALID,
  15. }, symbol_mod = {
  16. .name = "m",
  17. .curr = { "m", mod },
  18. .flags = SYMBOL_MOD|SYMBOL_VALID,
  19. }, symbol_no = {
  20. .name = "n",
  21. .curr = { "n", no },
  22. .flags = SYMBOL_NO|SYMBOL_VALID,
  23. }, symbol_empty = {
  24. .name = "",
  25. .curr = { "", no },
  26. .flags = SYMBOL_VALID,
  27. };
  28. int sym_change_count;
  29. struct symbol *modules_sym;
  30. tristate modules_val;
  31. void sym_add_default(struct symbol *sym, const char *def)
  32. {
  33. struct property *prop = prop_alloc(P_DEFAULT, sym);
  34. prop->expr = expr_alloc_symbol(sym_lookup(def, 1));
  35. }
  36. void sym_init(void)
  37. {
  38. struct symbol *sym;
  39. char *p;
  40. static bool inited = false;
  41. if (inited)
  42. return;
  43. inited = true;
  44. sym = sym_lookup("VERSION", 0);
  45. sym->type = S_STRING;
  46. sym->flags |= SYMBOL_AUTO;
  47. p = getenv("VERSION");
  48. if (p)
  49. sym_add_default(sym, p);
  50. sym = sym_lookup("TARGET_ARCH", 0);
  51. sym->type = S_STRING;
  52. sym->flags |= SYMBOL_AUTO;
  53. p = getenv("TARGET_ARCH");
  54. if (p)
  55. sym_add_default(sym, p);
  56. }
  57. enum symbol_type sym_get_type(struct symbol *sym)
  58. {
  59. enum symbol_type type = sym->type;
  60. if (type == S_TRISTATE) {
  61. if (sym_is_choice_value(sym) && sym->visible == yes)
  62. type = S_BOOLEAN;
  63. else if (modules_val == no)
  64. type = S_BOOLEAN;
  65. }
  66. return type;
  67. }
  68. const char *sym_type_name(enum symbol_type type)
  69. {
  70. switch (type) {
  71. case S_BOOLEAN:
  72. return "boolean";
  73. case S_TRISTATE:
  74. return "tristate";
  75. case S_INT:
  76. return "integer";
  77. case S_HEX:
  78. return "hex";
  79. case S_STRING:
  80. return "string";
  81. case S_UNKNOWN:
  82. return "unknown";
  83. case S_OTHER:
  84. break;
  85. }
  86. return "???";
  87. }
  88. struct property *sym_get_choice_prop(struct symbol *sym)
  89. {
  90. struct property *prop;
  91. for_all_choices(sym, prop)
  92. return prop;
  93. return NULL;
  94. }
  95. struct property *sym_get_default_prop(struct symbol *sym)
  96. {
  97. struct property *prop;
  98. for_all_defaults(sym, prop) {
  99. prop->visible.tri = expr_calc_value(prop->visible.expr);
  100. if (prop->visible.tri != no)
  101. return prop;
  102. }
  103. return NULL;
  104. }
  105. struct property *sym_get_range_prop(struct symbol *sym)
  106. {
  107. struct property *prop;
  108. for_all_properties(sym, prop, P_RANGE) {
  109. prop->visible.tri = expr_calc_value(prop->visible.expr);
  110. if (prop->visible.tri != no)
  111. return prop;
  112. }
  113. return NULL;
  114. }
  115. static void sym_calc_visibility(struct symbol *sym)
  116. {
  117. struct property *prop;
  118. tristate tri;
  119. /* any prompt visible? */
  120. tri = no;
  121. for_all_prompts(sym, prop) {
  122. prop->visible.tri = expr_calc_value(prop->visible.expr);
  123. tri = E_OR(tri, prop->visible.tri);
  124. }
  125. if (tri == mod && (sym->type != S_TRISTATE || modules_val == no))
  126. tri = yes;
  127. if (sym->visible != tri) {
  128. sym->visible = tri;
  129. sym_set_changed(sym);
  130. }
  131. if (sym_is_choice_value(sym))
  132. return;
  133. tri = no;
  134. if (sym->rev_dep.expr)
  135. tri = expr_calc_value(sym->rev_dep.expr);
  136. if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
  137. tri = yes;
  138. if (sym->rev_dep.tri != tri) {
  139. sym->rev_dep.tri = tri;
  140. sym_set_changed(sym);
  141. }
  142. }
  143. static struct symbol *sym_calc_choice(struct symbol *sym)
  144. {
  145. struct symbol *def_sym;
  146. struct property *prop;
  147. struct expr *e;
  148. /* is the user choice visible? */
  149. def_sym = sym->user.val;
  150. if (def_sym) {
  151. sym_calc_visibility(def_sym);
  152. if (def_sym->visible != no)
  153. return def_sym;
  154. }
  155. /* any of the defaults visible? */
  156. for_all_defaults(sym, prop) {
  157. prop->visible.tri = expr_calc_value(prop->visible.expr);
  158. if (prop->visible.tri == no)
  159. continue;
  160. def_sym = prop_get_symbol(prop);
  161. sym_calc_visibility(def_sym);
  162. if (def_sym->visible != no)
  163. return def_sym;
  164. }
  165. /* just get the first visible value */
  166. prop = sym_get_choice_prop(sym);
  167. for (e = prop->expr; e; e = e->left.expr) {
  168. def_sym = e->right.sym;
  169. sym_calc_visibility(def_sym);
  170. if (def_sym->visible != no)
  171. return def_sym;
  172. }
  173. /* no choice? reset tristate value */
  174. sym->curr.tri = no;
  175. return NULL;
  176. }
  177. void sym_calc_value(struct symbol *sym)
  178. {
  179. struct symbol_value newval, oldval;
  180. struct property *prop;
  181. struct expr *e;
  182. if (!sym)
  183. return;
  184. if (sym->flags & SYMBOL_VALID)
  185. return;
  186. sym->flags |= SYMBOL_VALID;
  187. oldval = sym->curr;
  188. switch (sym->type) {
  189. case S_INT:
  190. case S_HEX:
  191. case S_STRING:
  192. newval = symbol_empty.curr;
  193. break;
  194. case S_BOOLEAN:
  195. case S_TRISTATE:
  196. newval = symbol_no.curr;
  197. break;
  198. default:
  199. sym->curr.val = sym->name;
  200. sym->curr.tri = no;
  201. return;
  202. }
  203. if (!sym_is_choice_value(sym))
  204. sym->flags &= ~SYMBOL_WRITE;
  205. sym_calc_visibility(sym);
  206. /* set default if recursively called */
  207. sym->curr = newval;
  208. switch (sym_get_type(sym)) {
  209. case S_BOOLEAN:
  210. case S_TRISTATE:
  211. if (sym_is_choice_value(sym) && sym->visible == yes) {
  212. prop = sym_get_choice_prop(sym);
  213. newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
  214. } else if (E_OR(sym->visible, sym->rev_dep.tri) != no) {
  215. sym->flags |= SYMBOL_WRITE;
  216. if (sym_has_value(sym))
  217. newval.tri = sym->user.tri;
  218. else if (!sym_is_choice(sym)) {
  219. prop = sym_get_default_prop(sym);
  220. if (prop)
  221. newval.tri = expr_calc_value(prop->expr);
  222. }
  223. newval.tri = E_OR(E_AND(newval.tri, sym->visible), sym->rev_dep.tri);
  224. } else if (!sym_is_choice(sym)) {
  225. prop = sym_get_default_prop(sym);
  226. if (prop) {
  227. sym->flags |= SYMBOL_WRITE;
  228. newval.tri = expr_calc_value(prop->expr);
  229. }
  230. }
  231. if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
  232. newval.tri = yes;
  233. break;
  234. case S_STRING:
  235. case S_HEX:
  236. case S_INT:
  237. if (sym->visible != no) {
  238. sym->flags |= SYMBOL_WRITE;
  239. if (sym_has_value(sym)) {
  240. newval.val = sym->user.val;
  241. break;
  242. }
  243. }
  244. prop = sym_get_default_prop(sym);
  245. if (prop) {
  246. struct symbol *ds = prop_get_symbol(prop);
  247. if (ds) {
  248. sym->flags |= SYMBOL_WRITE;
  249. sym_calc_value(ds);
  250. newval.val = ds->curr.val;
  251. }
  252. }
  253. break;
  254. default:
  255. ;
  256. }
  257. sym->curr = newval;
  258. if (sym_is_choice(sym) && newval.tri == yes)
  259. sym->curr.val = sym_calc_choice(sym);
  260. if (memcmp(&oldval, &sym->curr, sizeof(oldval)))
  261. sym_set_changed(sym);
  262. if (modules_sym == sym)
  263. modules_val = modules_sym->curr.tri;
  264. if (sym_is_choice(sym)) {
  265. int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
  266. prop = sym_get_choice_prop(sym);
  267. for (e = prop->expr; e; e = e->left.expr) {
  268. e->right.sym->flags |= flags;
  269. if (flags & SYMBOL_CHANGED)
  270. sym_set_changed(e->right.sym);
  271. }
  272. }
  273. }
  274. void sym_clear_all_valid(void)
  275. {
  276. struct symbol *sym;
  277. int i;
  278. for_all_symbols(i, sym)
  279. sym->flags &= ~SYMBOL_VALID;
  280. sym_change_count++;
  281. if (modules_sym)
  282. sym_calc_value(modules_sym);
  283. }
  284. void sym_set_changed(struct symbol *sym)
  285. {
  286. struct property *prop;
  287. sym->flags |= SYMBOL_CHANGED;
  288. for (prop = sym->prop; prop; prop = prop->next) {
  289. if (prop->menu)
  290. prop->menu->flags |= MENU_CHANGED;
  291. }
  292. }
  293. void sym_set_all_changed(void)
  294. {
  295. struct symbol *sym;
  296. int i;
  297. for_all_symbols(i, sym)
  298. sym_set_changed(sym);
  299. }
  300. bool sym_tristate_within_range(struct symbol *sym, tristate val)
  301. {
  302. int type = sym_get_type(sym);
  303. if (sym->visible == no)
  304. return false;
  305. if (type != S_BOOLEAN && type != S_TRISTATE)
  306. return false;
  307. if (type == S_BOOLEAN && val == mod)
  308. return false;
  309. if (sym->visible <= sym->rev_dep.tri)
  310. return false;
  311. if (sym_is_choice_value(sym) && sym->visible == yes)
  312. return val == yes;
  313. return val >= sym->rev_dep.tri && val <= sym->visible;
  314. }
  315. bool sym_set_tristate_value(struct symbol *sym, tristate val)
  316. {
  317. tristate oldval = sym_get_tristate_value(sym);
  318. if (oldval != val && !sym_tristate_within_range(sym, val))
  319. return false;
  320. if (sym->flags & SYMBOL_NEW) {
  321. sym->flags &= ~SYMBOL_NEW;
  322. sym_set_changed(sym);
  323. }
  324. if (sym_is_choice_value(sym) && val == yes) {
  325. struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
  326. cs->user.val = sym;
  327. cs->flags &= ~SYMBOL_NEW;
  328. }
  329. sym->user.tri = val;
  330. if (oldval != val) {
  331. sym_clear_all_valid();
  332. if (sym == modules_sym)
  333. sym_set_all_changed();
  334. }
  335. return true;
  336. }
  337. tristate sym_toggle_tristate_value(struct symbol *sym)
  338. {
  339. tristate oldval, newval;
  340. oldval = newval = sym_get_tristate_value(sym);
  341. do {
  342. switch (newval) {
  343. case no:
  344. newval = mod;
  345. break;
  346. case mod:
  347. newval = yes;
  348. break;
  349. case yes:
  350. newval = no;
  351. break;
  352. }
  353. if (sym_set_tristate_value(sym, newval))
  354. break;
  355. } while (oldval != newval);
  356. return newval;
  357. }
  358. bool sym_string_valid(struct symbol *sym, const char *str)
  359. {
  360. char ch;
  361. switch (sym->type) {
  362. case S_STRING:
  363. return true;
  364. case S_INT:
  365. ch = *str++;
  366. if (ch == '-')
  367. ch = *str++;
  368. if (!isdigit(ch))
  369. return false;
  370. if (ch == '0' && *str != 0)
  371. return false;
  372. while ((ch = *str++)) {
  373. if (!isdigit(ch))
  374. return false;
  375. }
  376. return true;
  377. case S_HEX:
  378. if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
  379. str += 2;
  380. ch = *str++;
  381. do {
  382. if (!isxdigit(ch))
  383. return false;
  384. } while ((ch = *str++));
  385. return true;
  386. case S_BOOLEAN:
  387. case S_TRISTATE:
  388. switch (str[0]) {
  389. case 'y': case 'Y':
  390. case 'm': case 'M':
  391. case 'n': case 'N':
  392. return true;
  393. }
  394. return false;
  395. default:
  396. return false;
  397. }
  398. }
  399. bool sym_string_within_range(struct symbol *sym, const char *str)
  400. {
  401. struct property *prop;
  402. int val;
  403. switch (sym->type) {
  404. case S_STRING:
  405. return sym_string_valid(sym, str);
  406. case S_INT:
  407. if (!sym_string_valid(sym, str))
  408. return false;
  409. prop = sym_get_range_prop(sym);
  410. if (!prop)
  411. return true;
  412. val = strtol(str, NULL, 10);
  413. return val >= strtol(prop->expr->left.sym->name, NULL, 10) &&
  414. val <= strtol(prop->expr->right.sym->name, NULL, 10);
  415. case S_HEX:
  416. if (!sym_string_valid(sym, str))
  417. return false;
  418. prop = sym_get_range_prop(sym);
  419. if (!prop)
  420. return true;
  421. val = strtol(str, NULL, 16);
  422. return val >= strtol(prop->expr->left.sym->name, NULL, 16) &&
  423. val <= strtol(prop->expr->right.sym->name, NULL, 16);
  424. case S_BOOLEAN:
  425. case S_TRISTATE:
  426. switch (str[0]) {
  427. case 'y': case 'Y':
  428. return sym_tristate_within_range(sym, yes);
  429. case 'm': case 'M':
  430. return sym_tristate_within_range(sym, mod);
  431. case 'n': case 'N':
  432. return sym_tristate_within_range(sym, no);
  433. }
  434. return false;
  435. default:
  436. return false;
  437. }
  438. }
  439. bool sym_set_string_value(struct symbol *sym, const char *newval)
  440. {
  441. const char *oldval;
  442. char *val;
  443. int size;
  444. switch (sym->type) {
  445. case S_BOOLEAN:
  446. case S_TRISTATE:
  447. switch (newval[0]) {
  448. case 'y': case 'Y':
  449. return sym_set_tristate_value(sym, yes);
  450. case 'm': case 'M':
  451. return sym_set_tristate_value(sym, mod);
  452. case 'n': case 'N':
  453. return sym_set_tristate_value(sym, no);
  454. }
  455. return false;
  456. default:
  457. ;
  458. }
  459. if (!sym_string_within_range(sym, newval))
  460. return false;
  461. if (sym->flags & SYMBOL_NEW) {
  462. sym->flags &= ~SYMBOL_NEW;
  463. sym_set_changed(sym);
  464. }
  465. oldval = sym->user.val;
  466. size = strlen(newval) + 1;
  467. if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
  468. size += 2;
  469. sym->user.val = val = malloc(size);
  470. *val++ = '0';
  471. *val++ = 'x';
  472. } else if (!oldval || strcmp(oldval, newval))
  473. sym->user.val = val = malloc(size);
  474. else
  475. return true;
  476. strcpy(val, newval);
  477. free((void *)oldval);
  478. sym_clear_all_valid();
  479. return true;
  480. }
  481. const char *sym_get_string_value(struct symbol *sym)
  482. {
  483. tristate val;
  484. switch (sym->type) {
  485. case S_BOOLEAN:
  486. case S_TRISTATE:
  487. val = sym_get_tristate_value(sym);
  488. switch (val) {
  489. case no:
  490. return "n";
  491. case mod:
  492. return "m";
  493. case yes:
  494. return "y";
  495. }
  496. break;
  497. default:
  498. ;
  499. }
  500. return (const char *)sym->curr.val;
  501. }
  502. bool sym_is_changable(struct symbol *sym)
  503. {
  504. return sym->visible > sym->rev_dep.tri;
  505. }
  506. struct symbol *sym_lookup(const char *name, int isconst)
  507. {
  508. struct symbol *symbol;
  509. const char *ptr;
  510. char *new_name;
  511. int hash = 0;
  512. if (name) {
  513. if (name[0] && !name[1]) {
  514. switch (name[0]) {
  515. case 'y': return &symbol_yes;
  516. case 'm': return &symbol_mod;
  517. case 'n': return &symbol_no;
  518. }
  519. }
  520. for (ptr = name; *ptr; ptr++)
  521. hash += *ptr;
  522. hash &= 0xff;
  523. for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
  524. if (!strcmp(symbol->name, name)) {
  525. if ((isconst && symbol->flags & SYMBOL_CONST) ||
  526. (!isconst && !(symbol->flags & SYMBOL_CONST)))
  527. return symbol;
  528. }
  529. }
  530. new_name = strdup(name);
  531. } else {
  532. new_name = NULL;
  533. hash = 256;
  534. }
  535. symbol = malloc(sizeof(*symbol));
  536. memset(symbol, 0, sizeof(*symbol));
  537. symbol->name = new_name;
  538. symbol->type = S_UNKNOWN;
  539. symbol->flags = SYMBOL_NEW;
  540. if (isconst)
  541. symbol->flags |= SYMBOL_CONST;
  542. symbol->next = symbol_hash[hash];
  543. symbol_hash[hash] = symbol;
  544. return symbol;
  545. }
  546. struct symbol *sym_find(const char *name)
  547. {
  548. struct symbol *symbol = NULL;
  549. const char *ptr;
  550. int hash = 0;
  551. if (!name)
  552. return NULL;
  553. if (name[0] && !name[1]) {
  554. switch (name[0]) {
  555. case 'y': return &symbol_yes;
  556. case 'm': return &symbol_mod;
  557. case 'n': return &symbol_no;
  558. }
  559. }
  560. for (ptr = name; *ptr; ptr++)
  561. hash += *ptr;
  562. hash &= 0xff;
  563. for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
  564. if (!strcmp(symbol->name, name) &&
  565. !(symbol->flags & SYMBOL_CONST))
  566. break;
  567. }
  568. return symbol;
  569. }
  570. struct symbol *sym_check_deps(struct symbol *sym);
  571. static struct symbol *sym_check_expr_deps(struct expr *e)
  572. {
  573. struct symbol *sym;
  574. if (!e)
  575. return NULL;
  576. switch (e->type) {
  577. case E_OR:
  578. case E_AND:
  579. sym = sym_check_expr_deps(e->left.expr);
  580. if (sym)
  581. return sym;
  582. return sym_check_expr_deps(e->right.expr);
  583. case E_NOT:
  584. return sym_check_expr_deps(e->left.expr);
  585. case E_EQUAL:
  586. case E_UNEQUAL:
  587. sym = sym_check_deps(e->left.sym);
  588. if (sym)
  589. return sym;
  590. return sym_check_deps(e->right.sym);
  591. case E_SYMBOL:
  592. return sym_check_deps(e->left.sym);
  593. default:
  594. break;
  595. }
  596. printf("Oops! How to check %d?\n", e->type);
  597. return NULL;
  598. }
  599. struct symbol *sym_check_deps(struct symbol *sym)
  600. {
  601. struct symbol *sym2;
  602. struct property *prop;
  603. if (sym->flags & SYMBOL_CHECK_DONE)
  604. return NULL;
  605. if (sym->flags & SYMBOL_CHECK) {
  606. printf("Warning! Found recursive dependency: %s", sym->name);
  607. return sym;
  608. }
  609. sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
  610. sym2 = sym_check_expr_deps(sym->rev_dep.expr);
  611. if (sym2)
  612. goto out;
  613. for (prop = sym->prop; prop; prop = prop->next) {
  614. if (prop->type == P_CHOICE || prop->type == P_SELECT)
  615. continue;
  616. sym2 = sym_check_expr_deps(prop->visible.expr);
  617. if (sym2)
  618. goto out;
  619. if (prop->type != P_DEFAULT || sym_is_choice(sym))
  620. continue;
  621. sym2 = sym_check_expr_deps(prop->expr);
  622. if (sym2)
  623. goto out;
  624. }
  625. out:
  626. if (sym2)
  627. printf(" %s", sym->name);
  628. sym->flags &= ~SYMBOL_CHECK;
  629. return sym2;
  630. }
  631. struct property *prop_alloc(enum prop_type type, struct symbol *sym)
  632. {
  633. struct property *prop;
  634. struct property **propp;
  635. prop = malloc(sizeof(*prop));
  636. memset(prop, 0, sizeof(*prop));
  637. prop->type = type;
  638. prop->sym = sym;
  639. prop->file = current_file;
  640. prop->lineno = zconf_lineno();
  641. /* append property to the prop list of symbol */
  642. if (sym) {
  643. for (propp = &sym->prop; *propp; propp = &(*propp)->next)
  644. ;
  645. *propp = prop;
  646. }
  647. return prop;
  648. }
  649. struct symbol *prop_get_symbol(struct property *prop)
  650. {
  651. if (prop->expr && (prop->expr->type == E_SYMBOL ||
  652. prop->expr->type == E_CHOICE))
  653. return prop->expr->left.sym;
  654. return NULL;
  655. }
  656. const char *prop_get_type_name(enum prop_type type)
  657. {
  658. switch (type) {
  659. case P_PROMPT:
  660. return "prompt";
  661. case P_COMMENT:
  662. return "comment";
  663. case P_MENU:
  664. return "menu";
  665. case P_DEFAULT:
  666. return "default";
  667. case P_CHOICE:
  668. return "choice";
  669. case P_SELECT:
  670. return "select";
  671. case P_RANGE:
  672. return "range";
  673. case P_UNKNOWN:
  674. break;
  675. }
  676. return "unknown";
  677. }