From 6492ec3098fae844d8265d94a33f86426965c8c6 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Tue, 19 May 2020 12:17:43 -0700 Subject: chore: small restructure associated to lex layout --- sys/cmd/cc/lex.c | 76 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'sys/cmd/cc') diff --git a/sys/cmd/cc/lex.c b/sys/cmd/cc/lex.c index 03aba4b..c1ee6a4 100644 --- a/sys/cmd/cc/lex.c +++ b/sys/cmd/cc/lex.c @@ -192,7 +192,7 @@ oct: #define CASE1(stmt1, kind1) \ case stmt1: \ tok.kind = kind1; \ - break; + goto Return #define CASE2(stmt1, kind1, b1, kind2) \ case stmt1: \ @@ -202,7 +202,7 @@ oct: tok.kind = kind2; \ else \ ungetbyte(lx); \ - break; + goto Return #define CASE3(stmt1, kind1, b1, kind2, b2, kind3) \ case stmt1: \ @@ -214,7 +214,7 @@ oct: tok.kind = kind3; \ else \ ungetbyte(lx); \ - break; + goto Return #define CASE4(stmt1, kind1, b1, kind2, b2, kind3, b3, type4) \ case stmt1: \ @@ -228,7 +228,7 @@ oct: tok.kind = type4; \ else \ ungetbyte(lx); \ - break; + goto Return Token @@ -299,7 +299,7 @@ Dispatch: } tok.kind = Alit | Vchar; tok.val.c = v; - break; + goto Return; case '"': s = strĀ·makecap("", 0, 8); @@ -339,7 +339,7 @@ Dispatch: } } ungetbyte(lx); - break; + goto Return; case '<': tok.kind = Alt; @@ -356,7 +356,7 @@ Dispatch: tok.kind = Alteq; else ungetbyte(lx); - break; + goto Return; case '>': tok.kind = Agt; @@ -373,7 +373,7 @@ Dispatch: tok.kind = Agteq; else ungetbyte(lx); - break; + goto Return; case '/': tok.kind = Adiv; @@ -405,7 +405,7 @@ Dispatch: goto Dispatch; } else ungetbyte(lx); - break; + goto Return; case '#': if (domacro(lx)) { @@ -420,36 +420,28 @@ Dispatch: if (lx->io) goto GetByte; tok.kind = Aeof; - return tok; - - CASE1('(', Alparen) - CASE1(')', Arparen) - CASE1('{', Albrace) - CASE1('}', Arbrace) - CASE1('[', Albrakt) - CASE1(']', Arbrakt) - CASE1(',', Acomma) - CASE1('?', Aqmark) - CASE1(';', Asemi) - CASE1('~', Aneg) - CASE1(':', Acolon) - CASE2('^', Axor, '=', Axorasn) - CASE2('!', Anot, '=', Aneq) - CASE2('*', Astar,'=', Amulasn) - CASE2('=', Aasn, '=', Aeq) - CASE2('%', Amod, '=', Amodasn) - CASE3('+', Aadd, '=', Aaddasn, '+', Ainc) - CASE3('&', Aand, '=', Aandasn, '&', Aandand) - CASE3('|', Aor, '=', Aorasn, '|', Aoror) - CASE4('-', Asub, '=', Asubasn, '-', Adec, '>', Aarrow) - - default: - tok.kind = Anil; - errorat(lx->pos, "invalid token, crashing"); - abort(); - } + goto Return; - goto Return; + CASE1('(', Alparen); + CASE1(')', Arparen); + CASE1('{', Albrace); + CASE1('}', Arbrace); + CASE1('[', Albrakt); + CASE1(']', Arbrakt); + CASE1(',', Acomma); + CASE1('?', Aqmark); + CASE1(';', Asemi); + CASE1('~', Aneg); + CASE1(':', Acolon); + CASE2('^', Axor, '=', Axorasn); + CASE2('!', Anot, '=', Aneq); + CASE2('*', Astar,'=', Amulasn); + CASE2('=', Aasn, '=', Aeq); + CASE2('%', Amod, '=', Amodasn); + CASE3('+', Aadd, '=', Aaddasn, '+', Ainc); + CASE3('&', Aand, '=', Aandasn, '&', Aandand); + CASE3('|', Aor, '=', Aorasn, '|', Aoror); + CASE4('-', Asub, '=', Asubasn, '-', Adec, '>', Aarrow); Tnum: e = lx->buf + arrlen(lx->buf); @@ -611,6 +603,14 @@ Dispatch: pushio(lx, io); goto GetByte; } + goto Return; + + + default: + tok.kind = Anil; + errorat(lx->pos, "invalid token, crashing"); + abort(); + } Return: lx->b = lx->buf; -- cgit v1.2.1