Aria

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

commit 502db9d50f65a31aecda5116fc65e803689c488f
parent 042c933eb160930b2971aa46316764aef44923cf
Author: m21c  <ho*******@gmail.com>
Date:   Thu,  2 Feb 2023 02:17:07 +0100

added SECTION to comments + fix: typos in err-msgs

Diffstat:
Mcompiler.c | 67+++++++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 39 insertions(+), 28 deletions(-)

diff --git a/compiler.c b/compiler.c @@ -11,7 +11,8 @@ typedef unsigned char uchar; typedef unsigned int uint; -/* - forward declarations - */ + +/* SECTION: - forward declarations - */ typedef struct Node Node; @@ -27,7 +28,9 @@ struct Env Env; -/* - node kind table - */ + + +/* SECTION: - node kind table - */ #define SENDOFFILE "end-of-file" #define SINVALID "invalide token" @@ -195,7 +198,7 @@ struct Env Env; -/* - type kind table - */ +/* SECTION: - type kind table - */ #define TYPETAB \ /* tag , size , align*/ \ @@ -261,7 +264,7 @@ struct Env Env; -/* - enumerations & constants - */ +/* SECTION: - enumerations & constants - */ typedef enum Flags { @@ -375,7 +378,9 @@ enum Qualifier { -/* - type definitions - */ + + +/* SECTION: - type definitions - */ typedef struct SrcLoc { @@ -500,13 +505,14 @@ struct Source { -/* - global-vars - */ + +/* SECTION: - global-vars - */ Source testsource; -/* - look-up tables - */ +/* SECTION: - look-up tables - */ #define defaultloc {0, 1, "<builtin>"} @@ -568,7 +574,7 @@ const uint8_t opinfo[] = { -/* - utility functions - */ +/* SECTION: - utility functions - */ #define lengthof(array) ((int) sizeof(array) / (int) sizeof(*(array))) @@ -626,7 +632,7 @@ mystrcasecmp(const char *str1, const char *str2) -/* - pre-lexer - */ +/* SECTION: - pre-lexer - */ static void tryprompt(Source *source, const char ch); @@ -710,7 +716,7 @@ advance: -/* - keyword map - */ +/* SECTION: - keyword map - */ #define KEYWORD_MAP_SIZE 128 const char *keywordkeys[KEYWORD_MAP_SIZE]; @@ -771,7 +777,7 @@ getkeyword(const char *str, int n) -/* - string map - */ +/* SECTION: - string map - */ typedef struct StringEntry { @@ -896,7 +902,7 @@ getstringkey(StringMap *map, const char *str, int n) -/* - error reporting - */ +/* SECTION: - error reporting - */ static int warn(SrcLoc *loc, const char *fmt, ...) @@ -940,7 +946,7 @@ error(SrcLoc *loc, const char *fmt, ...) -/* - lexer - */ +/* SECTION: - lexer - */ #define nextindent(source, indent) \ ((indent) + (source)->tabwidth - ((indent) % (source)->tabwidth)) @@ -1479,7 +1485,7 @@ getunarysuffix(Source *source) } -/* - ast-node - */ +/* SECTION: - ast-node */ Node *poolednodes; Node nodebuf[4096]; @@ -1560,7 +1566,7 @@ deletenode(Node *node) -/* - type-strcut - */ +/* SECTION: - type-struct - */ Type typebuf[4096]; int typetop; @@ -1579,7 +1585,11 @@ maketype(SrcLoc *loc, Type *orig, Type *target) -/* - environment - */ +/* SECTION: - annotation - */ + + + +/* SECTION: - environment - */ Env envbuf[4096]; int envtop; @@ -1773,7 +1783,7 @@ deleteenv(Env *env) -/* - declaration - */ +/* SECTION: - declaration - */ Decl declbuf[4096]; int decltop; @@ -1895,7 +1905,7 @@ defertypedeclaration(Source *source, int key) -/* - parser - */ +/* SECTION: - parser - */ #define getkind(source) \ ((source)->tok.kind) @@ -2939,7 +2949,7 @@ exprlist(Source *source, bool isparam, Type *paramtype) -/* - type-checking & folding - */ +/* SECTION: - type-checking & folding - */ static bool isinttype(Type *ty) @@ -3385,7 +3395,7 @@ typecheck(Env *env, Node *expr) case OPLUS: case OMINUS: /* reporton(!isarithtype(lhs->type), - &lhs->loc, "expression is not of arithmentic type"); + &lhs->loc, "expression is not of arithmetic type"); */ expr->lhs = conv(lhs); @@ -3402,7 +3412,7 @@ typecheck(Env *env, Node *expr) case OLNOT: reporton(!isarithtype(lhs->type), - &lhs->loc, "expression is not of arithmentic type"); + &lhs->loc, "expression is not of arithmetic type"); expr->type = primitive(TBOOL); expr->lhs = conv(lhs); /* cannot be wrap(expr->type, lhs) */ @@ -3423,7 +3433,7 @@ typecheck(Env *env, Node *expr) case OMUL: case ODIV: case OMOD: case OADD: case OSUB: reporton(!isarithtype(lhs->type) || !isarithtype(rhs->type), - &expr->loc, "expression is not of arithmentic type"); + &expr->loc, "expression is not of arithmetic type"); /* usual arithmetic conversion */ if (lhs->type->kind < rhs->type->kind) @@ -3462,7 +3472,7 @@ typecheck(Env *env, Node *expr) case OLET: case OLEQ: case OGRT: case OGEQ: reporton(!isarithtype(lhs->type) || !isarithtype(rhs->type), - &expr->loc, "expression is not of arithmentic type"); + &expr->loc, "expression is not of arithmetic type"); expr->lhs = conv(lhs); expr->rhs = conv(rhs); @@ -3471,7 +3481,7 @@ typecheck(Env *env, Node *expr) case OLAND: case OLOR: reporton(!isarithtype(lhs->type) || !isarithtype(rhs->type), - &expr->loc, "expression is not of arithmentic type"); + &expr->loc, "expression is not of arithmetic type"); expr->type = primitive(TBOOL); expr->lhs = wrap(expr->type, lhs); @@ -3481,7 +3491,7 @@ typecheck(Env *env, Node *expr) case OMULA: case ODIVA: case OMODA: case OADDA: case OSUBA: reporton(!isarithtype(lhs->type) || !isarithtype(rhs->type), - &expr->loc, "expression is not of arithmentic type"); + &expr->loc, "expression is not of arithmetic type"); goto joinassign; case OLSHA: case ORSHA: case OARSHA: @@ -3871,7 +3881,8 @@ foldexpr(Env *env, Node *expr) -/* - print ast - */ + +/* SECTION: - print ast - */ static void promptenvpath(Env* currenv) @@ -4681,7 +4692,7 @@ printexpr(FILE *out, Node *expr, int indent) -/* - init source - */ +/* SECTION: - init source - */ static void initsource(Source *source, const char *filename, FILE *file) @@ -4700,7 +4711,7 @@ initsource(Source *source, const char *filename, FILE *file) -/* - main-routine - */ +/* SECTION: - main-routine - */ const char * isolatecommand(char **string)