aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
author lemon<lsof@mailbox.org>2023-05-28 22:35:58 +0200
committer lemon<lsof@mailbox.org>2023-05-28 22:35:58 +0200
commit84824a0ed3a0cf90728078b74ca39778c51e60b9 (patch)
tree1e4f51f90d682974bd09bad72c02934542735354
parent104330a399f405b83328525bb2be55b360109b16 (diff)
cleanup
-rw-r--r--parse.c54
-rw-r--r--parse.h10
2 files changed, 32 insertions, 32 deletions
diff --git a/parse.c b/parse.c
index 0de9346..3da90c0 100644
--- a/parse.c
+++ b/parse.c
@@ -20,27 +20,6 @@ initparser(struct parser *pr, const char *file)
pr->ndat = f->n;
}
-static struct decl *finddecl(struct parser *pr, const char *name);
-
-static bool
-isdecltok(struct parser *pr)
-{
- struct decl *decl;
- struct token tk;
- switch (peek(pr, &tk)) {
- case TKWsigned: case TKWunsigned: case TKWshort: case TKWlong:
- case TKWint: case TKWchar: case TKW_Bool: case TKWauto:
- case TKWstruct: case TKWunion: case TKWenum: case TKWtypedef:
- case TKWextern: case TKWstatic: case TKWinline: case TKW_Noreturn:
- case TKWconst: case TKWvolatile: case TKWvoid: case TKWfloat:
- case TKWdouble:
- return 1;
- case TKIDENT:
- return (decl = finddecl(pr, tk.s)) && decl->scls == SCTYPEDEF;
- }
- return 0;
-}
-
static bool
match(struct parser *pr, struct token *tk, enum toktag t)
{
@@ -81,6 +60,16 @@ enum declkind {
DCASTEXPR,
};
+struct decl {
+ union type ty;
+ uchar scls;
+ uchar qual;
+ ushort align;
+ struct span span;
+ const char *name;
+ int id;
+};
+
struct declstate {
enum declkind kind;
union type base;
@@ -93,6 +82,27 @@ struct declstate {
};
static struct decl pdecl(struct declstate *st, struct parser *pr);
+static struct decl *finddecl(struct parser *pr, const char *name);
+
+static bool
+isdecltok(struct parser *pr)
+{
+ struct decl *decl;
+ struct token tk;
+ switch (peek(pr, &tk)) {
+ case TKWsigned: case TKWunsigned: case TKWshort: case TKWlong:
+ case TKWint: case TKWchar: case TKW_Bool: case TKWauto:
+ case TKWstruct: case TKWunion: case TKWenum: case TKWtypedef:
+ case TKWextern: case TKWstatic: case TKWinline: case TKW_Noreturn:
+ case TKWconst: case TKWvolatile: case TKWvoid: case TKWfloat:
+ case TKWdouble: case TKWregister:
+ return 1;
+ case TKIDENT:
+ return (decl = finddecl(pr, tk.s)) && decl->scls == SCTYPEDEF;
+ }
+ return 0;
+}
+
/*******/
/* ENV */
@@ -673,7 +683,7 @@ Unary:
break;
case TKSTRLIT:
ex = mkexpr(ESTRLIT, tk.span,
- mkarrtype(mktype(TYCHAR), 0, tk.len+1), .s = (uchar *)tk.s);
+ mkarrtype(mktype(TYCHAR), 0, tk.len+1), .s = { (char *)tk.s, tk.len });
break;
case TKIDENT:
decl = finddecl(pr, tk.s);
diff --git a/parse.h b/parse.h
index 2a9b076..dee1115 100644
--- a/parse.h
+++ b/parse.h
@@ -176,16 +176,6 @@ enum storageclass {
SCREGISTER = 1<<5,
};
-struct decl {
- union type ty;
- uchar scls;
- uchar qual;
- ushort align;
- struct span span;
- const char *name;
- int id;
-};
-
enum evalmode {
EVINTCONST,
EVARITH,