Aria

A low-level systems programming language
git clone git://git.m21c.me/Aria.git
Log | Files | Refs | LICENSE

commit d4b065fb260a57895304cec9b9e5b7eb3e6423a5
parent 57e454b408baa58afa805b79fc34a9771630c4d2
Author: m21c <ho*******@gmail.com>
Date:   Wed, 16 Apr 2025 17:01:17 +0200

added multi-line comments

Diffstat:
Mcompiler.c | 32++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+), 0 deletions(-)

diff --git a/compiler.c b/compiler.c @@ -1552,10 +1552,12 @@ skipwhite: } if (source->currloc.column) { + /* just skip whitespace */ while (isspace(ch)) ch = nextchar(source); } else { + /* skip whitespace and calculate indentation */ source->lastindent = 0; while (isspace(ch)) { if (ch == '\t') { @@ -1582,11 +1584,41 @@ skipwhite: if (hasnewline) { goto skipwhite; } else { + /* defer reading new line to next call of gettok() + * and return LINEDELIM */ hasnewline = true; return source->tok.kind = LINEDELIM; } } + /* c-syle block comment with nesting allowed */ + if (ch == '/' && peeknextchar(source) == '*') { + int nest = 1; + + nextchar(source); + ch = nextchar(source); + + for (;nest; ch = nextchar(source)) { + if (!ch) { + if (!mygetline(source)) + return source->tok.kind = 0; + + source->currloc.column = 0; /* is this needed? */ + ch = peekchar(source); + } + + if (ch == '*' && peeknextchar(source) == '/') { + nextchar(source); + --nest; + } else if (ch == '/' && peeknextchar(source) == '*') { + nextchar(source); + ++nest; + } + } + + goto skipwhite; + } + hasnewline = false; /* identifier or keyword */