• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision3877 (tree)
Time2018-09-19 00:55:20
Authormagicant

Log Message

Simplify parse_while function

Change Summary

Incremental Difference

--- yash/branches/token_based_parser/parser.c (revision 3876)
+++ yash/branches/token_based_parser/parser.c (revision 3877)
@@ -617,7 +617,7 @@
617617 __attribute__((nonnull,malloc,warn_unused_result));
618618 static command_T *parse_for(parsestate_T *ps)
619619 __attribute__((nonnull,malloc,warn_unused_result));
620-static command_T *parse_while(parsestate_T *ps, bool whltype)
620+static command_T *parse_while(parsestate_T *ps)
621621 __attribute__((nonnull,malloc,warn_unused_result));
622622 static command_T *parse_case(parsestate_T *ps)
623623 __attribute__((nonnull,malloc,warn_unused_result));
@@ -2346,10 +2346,8 @@
23462346 result = parse_function(ps);
23472347 break;
23482348 case TT_WHILE:
2349- result = parse_while(ps, true);
2350- break;
23512349 case TT_UNTIL:
2352- result = parse_while(ps, false);
2350+ result = parse_while(ps);
23532351 break;
23542352 case TT_CASE:
23552353 result = parse_case(ps);
@@ -2530,15 +2528,16 @@
25302528 }
25312529
25322530 /* Parses a while/until command.
2533- * `whltype' must be true for the while command and false for the until command.
25342531 * The current token must be the starting "while" or "until". Never returns
25352532 * NULL. */
2536-command_T *parse_while(parsestate_T *ps, bool whltype)
2533+command_T *parse_while(parsestate_T *ps)
25372534 {
2538- if (whltype)
2539- assert(ps->tokentype == TT_WHILE);
2540- else
2541- assert(ps->tokentype == TT_UNTIL);
2535+ bool whltype;
2536+ switch (ps->tokentype) {
2537+ case TT_WHILE: whltype = true; break;
2538+ case TT_UNTIL: whltype = false; break;
2539+ default: assert(false);
2540+ }
25422541 next_token(ps);
25432542
25442543 command_T *result = xmalloc(sizeof *result);
Show on old repository browser