scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit aaf9dd81207b3944018233ca15f6befa871aaf0f
parent 167690b43dd4a0f6279bd9e8dd6f4aa84a3ca375
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 27 Jul 2015 10:56:43 +0200

Add #elif

The implemetation of elif is really easy, it is a #else chained
with a #if.

Diffstat:
Mcc1/cc1.h | 1+
Mcc1/cpp.c | 8++++++++
Mcc1/symbol.c | 1+
3 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -214,6 +214,7 @@ enum tokens { PRAGMA, ERROR, IFDEF, + ELIF, IFNDEF, UNDEF, ENDIF, diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -522,6 +522,13 @@ elseclause(void) } static void +elif(void) +{ + elseclause(); + ifclause(0, 0); +} + +static void undef(void) { Symbol *sym; @@ -549,6 +556,7 @@ cpp(void) {LINE, line}, {IFDEF, ifdef}, {IF, cppif}, + {ELIF, elif}, {IFNDEF, ifndef}, {ELSE, elseclause}, {ENDIF, endif}, diff --git a/cc1/symbol.c b/cc1/symbol.c @@ -263,6 +263,7 @@ ikeywords(void) {"line", LINE, LINE}, {"ifdef", IFDEF, IFDEF}, {"if", IF, IF}, + {"elif", ELIF, ELIF}, {"else", ELSE, ELSE}, {"ifndef", IFNDEF, IFNDEF}, {"endif", ENDIF, ENDIF},