mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-27 04:50:28 +00:00
Add chibicc
This program popped up on Hacker News recently. It's the only modern compiler I've ever seen that doesn't have dependencies and is easily modified. So I added all of the missing GNU extensions I like to use which means it might be possible soon to build on non-Linux and have third party not vendor gcc binaries.
This commit is contained in:
parent
e44a0cf6f8
commit
8da931a7f6
298 changed files with 19493 additions and 11950 deletions
|
@ -68,7 +68,7 @@
|
|||
#include "libc/time/time.h"
|
||||
#include "libc/unicode/unicode.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "tool/build/lib/address.h"
|
||||
#include "tool/build/lib/breakpoint.h"
|
||||
|
@ -277,8 +277,9 @@ static struct sigaction oldsig[4];
|
|||
static void SetupDraw(void);
|
||||
static void Redraw(void);
|
||||
|
||||
static char *FormatDouble(char *b, double x) {
|
||||
return g_fmt(b, x);
|
||||
static char *FormatDouble(char buf[32], long double x) {
|
||||
g_xfmt_p(buf, &x, 15, 32, 0);
|
||||
return buf;
|
||||
}
|
||||
|
||||
static int64_t SignExtend(uint64_t x, char b) {
|
||||
|
@ -2463,7 +2464,7 @@ static void HandleBreakpointFlag(const char *s) {
|
|||
PushBreakpoint(&breakpoints, &b);
|
||||
}
|
||||
|
||||
static noreturn void PrintUsage(int rc, FILE *f) {
|
||||
static wontreturn void PrintUsage(int rc, FILE *f) {
|
||||
fprintf(f, "SYNOPSIS\n\n %s%s", program_invocation_name, USAGE);
|
||||
exit(rc);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ TOOL_BUILD_DIRECTDEPS = \
|
|||
LIBC_X \
|
||||
TOOL_BUILD_LIB \
|
||||
THIRD_PARTY_COMPILER_RT \
|
||||
THIRD_PARTY_DTOA \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_GETOPT \
|
||||
THIRD_PARTY_XED \
|
||||
THIRD_PARTY_ZLIB \
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/tinymath/emodl.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
|
||||
#define INT intmax_t
|
||||
|
@ -162,7 +162,7 @@ INT Popcnt(INT x) {
|
|||
char *Repr(struct Value x) {
|
||||
static char buf[64];
|
||||
if (x.t == kFloat) {
|
||||
g_fmt(buf, x.f);
|
||||
g_xfmt_p(buf, &x.f, 16, sizeof(buf), 0);
|
||||
} else {
|
||||
sprintf(buf, "%jd", x.i);
|
||||
}
|
||||
|
@ -256,36 +256,47 @@ void Pushf(FLOAT f) {
|
|||
void OpDrop(void) {
|
||||
Pop();
|
||||
}
|
||||
|
||||
void OpDup(void) {
|
||||
Push(Push(Pop()));
|
||||
}
|
||||
|
||||
void OpExit(void) {
|
||||
exit(Popi());
|
||||
}
|
||||
|
||||
void OpSrand(void) {
|
||||
srand(Popi());
|
||||
}
|
||||
|
||||
void OpEmit(void) {
|
||||
fputwc(Popi(), stdout);
|
||||
}
|
||||
|
||||
void OpCr(void) {
|
||||
Cr(stdout);
|
||||
}
|
||||
|
||||
void OpPrint(void) {
|
||||
printf("%s ", Repr(Pop()));
|
||||
}
|
||||
|
||||
void OpComment(void) {
|
||||
comment = true;
|
||||
}
|
||||
|
||||
void Glue0f(FLOAT fn(void)) {
|
||||
Pushf(fn());
|
||||
}
|
||||
|
||||
void Glue0i(INT fn(void)) {
|
||||
Pushi(fn());
|
||||
}
|
||||
|
||||
void Glue1f(FLOAT fn(FLOAT)) {
|
||||
Pushf(fn(Popf()));
|
||||
}
|
||||
|
||||
void Glue1i(INT fn(INT)) {
|
||||
Pushi(fn(Popi()));
|
||||
}
|
||||
|
@ -562,12 +573,16 @@ void GotoStartOfLine(void) {
|
|||
|
||||
void GotoEndOfLine(void) {
|
||||
}
|
||||
|
||||
void GotoPrevLine(void) {
|
||||
}
|
||||
|
||||
void GotoNextLine(void) {
|
||||
}
|
||||
|
||||
void GotoPrevChar(void) {
|
||||
}
|
||||
|
||||
void GotoNextChar(void) {
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ nan isnormal ! assert
|
|||
0 0 / dup isnan assert signbit assert # is this right?
|
||||
1 0 / dup isinf assert signbit ! assert # is this right?
|
||||
nan nan != assert # is this right?
|
||||
-nan -nan != assert # is this right?
|
||||
# -nan -nan != assert # is this right?
|
||||
inf inf = assert # is this right?
|
||||
-inf -inf = assert # is this right?
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "libc/sysv/consts/ex.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
|
||||
#define USAGE \
|
||||
|
@ -60,7 +60,7 @@ static struct Flags {
|
|||
.H = 255,
|
||||
};
|
||||
|
||||
static noreturn void PrintUsage(int rc, FILE *f) {
|
||||
static wontreturn void PrintUsage(int rc, FILE *f) {
|
||||
fprintf(f, "Usage: %s%s", program_invocation_name, USAGE);
|
||||
exit(rc);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "third_party/stb/stb_image.h"
|
||||
#include "third_party/xed/x86.h"
|
||||
|
@ -69,7 +69,7 @@ static struct Flags {
|
|||
.p = 1,
|
||||
};
|
||||
|
||||
static noreturn void PrintUsage(int rc, FILE *f) {
|
||||
static wontreturn void PrintUsage(int rc, FILE *f) {
|
||||
fprintf(f, "Usage: %s%s", program_invocation_name, USAGE);
|
||||
exit(rc);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ struct Machine {
|
|||
uint8_t *p;
|
||||
} real;
|
||||
uint64_t cr3;
|
||||
uint8_t xmm[16][16] aligned(16);
|
||||
uint8_t xmm[16][16];
|
||||
uint8_t es[8];
|
||||
uint8_t ds[8];
|
||||
uint8_t fs[8];
|
||||
|
@ -165,7 +165,7 @@ struct Machine {
|
|||
uint8_t icache[1024][40];
|
||||
void (*onbinbase)(struct Machine *);
|
||||
void (*onlongbranch)(struct Machine *);
|
||||
} aligned(64);
|
||||
} forcealign(64);
|
||||
|
||||
struct Machine *NewMachine(void) nodiscard;
|
||||
void FreeMachine(struct Machine *);
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
(!IsModeDbg() && __SSE3__ + 0 && \
|
||||
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 408)
|
||||
|
||||
typedef int int_v _Vector_size(16) aligned(16);
|
||||
typedef long long_v _Vector_size(16) aligned(16);
|
||||
typedef int int_v _Vector_size(16) forcealign(16);
|
||||
typedef long long_v _Vector_size(16) forcealign(16);
|
||||
|
||||
static float_v Addps(struct Machine *m, float_v x, float_v y) {
|
||||
return x + y;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
typedef float float_v _Vector_size(16) aligned(16);
|
||||
typedef double double_v _Vector_size(16) aligned(16);
|
||||
typedef float float_v _Vector_size(16) forcealign(16);
|
||||
typedef double double_v _Vector_size(16) forcealign(16);
|
||||
|
||||
void OpUnpcklpsd(struct Machine *, uint32_t);
|
||||
void OpUnpckhpsd(struct Machine *, uint32_t);
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
void OpUd(struct Machine *, uint32_t) noreturn;
|
||||
void HaltMachine(struct Machine *, int) noreturn;
|
||||
void ThrowDivideError(struct Machine *) noreturn;
|
||||
void ThrowSegmentationFault(struct Machine *, int64_t) noreturn;
|
||||
void ThrowProtectionFault(struct Machine *) noreturn;
|
||||
void OpHlt(struct Machine *, uint32_t) noreturn;
|
||||
void OpUd(struct Machine *, uint32_t) wontreturn;
|
||||
void HaltMachine(struct Machine *, int) wontreturn;
|
||||
void ThrowDivideError(struct Machine *) wontreturn;
|
||||
void ThrowSegmentationFault(struct Machine *, int64_t) wontreturn;
|
||||
void ThrowProtectionFault(struct Machine *) wontreturn;
|
||||
void OpHlt(struct Machine *, uint32_t) wontreturn;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
struct stat st_;
|
||||
size_t extractedsize;
|
||||
|
||||
noreturn void usage(char *argv[], FILE *f, int rc) {
|
||||
wontreturn void usage(char *argv[], FILE *f, int rc) {
|
||||
fprintf(f, "%s: %s [-o %s] [-s %s] %s\n", "Usage", argv[0], "PATH", "SYMBOL",
|
||||
"FILE");
|
||||
exit(rc);
|
||||
|
|
|
@ -210,7 +210,7 @@ bool ShouldSkipSource(const char *src) {
|
|||
return false;
|
||||
}
|
||||
|
||||
noreturn void OnMissingFile(const char *list, const char *src) {
|
||||
wontreturn void OnMissingFile(const char *list, const char *src) {
|
||||
DCHECK_EQ(ENOENT, errno, "%s", src);
|
||||
/*
|
||||
* This code helps GNU Make automatically fix itself when we
|
||||
|
|
|
@ -118,7 +118,7 @@ forceinline pureconst size_t GreatestTwoDivisor(size_t x) {
|
|||
return x & (~x + 1);
|
||||
}
|
||||
|
||||
noreturn void ShowUsage(FILE *f, int rc) {
|
||||
wontreturn void ShowUsage(FILE *f, int rc) {
|
||||
fprintf(f, "Usage: %s RUNITD PROGRAM HOSTNAME[:RUNITDPORT[:SSHPORT]]...\n",
|
||||
program_invocation_name);
|
||||
exit(rc);
|
||||
|
|
|
@ -121,7 +121,7 @@ void OnChildTerminated(int sig) {
|
|||
g_childterm = true;
|
||||
}
|
||||
|
||||
noreturn void ShowUsage(FILE *f, int rc) {
|
||||
wontreturn void ShowUsage(FILE *f, int rc) {
|
||||
fprintf(f, "%s: %s %s\n", "Usage", program_invocation_name,
|
||||
"[-d] [-r] [-l LISTENIP] [-p PORT] [-t TIMEOUTMS]");
|
||||
exit(rc);
|
||||
|
|
|
@ -75,7 +75,7 @@ const char kNoCompressExts[][8] = {".gz", ".xz", ".jpg", ".png",
|
|||
".gif", ".zip", ".bz2", ".mpg",
|
||||
".mp4", ".lz4", ".webp", ".mpeg"};
|
||||
|
||||
noreturn void PrintUsage(int rc, FILE *f) {
|
||||
wontreturn void PrintUsage(int rc, FILE *f) {
|
||||
fprintf(f, "%s%s%s\n", "Usage: ", program_invocation_name,
|
||||
" [-o FILE] [-s SYMBOL] [-y YOINK] [FILE...]\n");
|
||||
exit(rc);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/bswap.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/conv/conv.h"
|
||||
|
@ -37,6 +38,7 @@
|
|||
#include "libc/x/x.h"
|
||||
#include "o/tool/calc/calc.c.inc"
|
||||
#include "o/tool/calc/calc.h.inc"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "tool/calc/calc.h"
|
||||
|
||||
/**
|
||||
|
@ -51,28 +53,28 @@ static int g_column;
|
|||
static const char *g_file;
|
||||
static yyParser g_parser[1];
|
||||
|
||||
noreturn static void Error(const char *msg) {
|
||||
wontreturn static void Error(const char *msg) {
|
||||
fprintf(stderr, "%s:%d:%d: %s\n", g_file, g_line, g_column, msg);
|
||||
longjmp(jb, 1);
|
||||
}
|
||||
|
||||
noreturn static void SyntaxError(void) {
|
||||
wontreturn static void SyntaxError(void) {
|
||||
Error("SYNTAX ERROR");
|
||||
}
|
||||
|
||||
noreturn static void LexError(void) {
|
||||
wontreturn static void LexError(void) {
|
||||
Error("LEX ERROR");
|
||||
}
|
||||
|
||||
noreturn static void MissingArgumentError(void) {
|
||||
wontreturn static void MissingArgumentError(void) {
|
||||
Error("MISSING ARGUMENT");
|
||||
}
|
||||
|
||||
noreturn static void MissingFunctionError(void) {
|
||||
wontreturn static void MissingFunctionError(void) {
|
||||
Error("MISSING FUNCTION");
|
||||
}
|
||||
|
||||
noreturn static void SyscallError(const char *name) {
|
||||
wontreturn static void SyscallError(const char *name) {
|
||||
fprintf(stderr, "ERROR: %s[%s]: %d\n", name, g_file, errno);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -395,6 +397,21 @@ static long double FnFpclassify(struct Numbers *a) {
|
|||
return fpclassify(a->x);
|
||||
}
|
||||
|
||||
static long double FnBswap16(struct Numbers *a) {
|
||||
if (!a) MissingArgumentError();
|
||||
return bswap_16((uint16_t)a->x);
|
||||
}
|
||||
|
||||
static long double FnBswap32(struct Numbers *a) {
|
||||
if (!a) MissingArgumentError();
|
||||
return bswap_32((uint32_t)a->x);
|
||||
}
|
||||
|
||||
static long double FnBswap64(struct Numbers *a) {
|
||||
if (!a) MissingArgumentError();
|
||||
return bswap_64((uint64_t)a->x);
|
||||
}
|
||||
|
||||
static long double FnBsr(struct Numbers *a) {
|
||||
if (!a) MissingArgumentError();
|
||||
return bsr(a->x);
|
||||
|
@ -611,9 +628,9 @@ static long double FnHex(struct Numbers *a) {
|
|||
}
|
||||
|
||||
static void PrintNumber(long double x) {
|
||||
char b[32];
|
||||
g_fmt(b, x);
|
||||
fputs(b, stdout);
|
||||
char buf[32];
|
||||
g_xfmt_p(buf, &x, 15, sizeof(buf), 0);
|
||||
fputs(buf, stdout);
|
||||
}
|
||||
|
||||
static void Print(struct Numbers *a) {
|
||||
|
@ -648,6 +665,9 @@ static const struct Fn {
|
|||
{"bsfl", FnBsfl},
|
||||
{"bsr", FnBsr},
|
||||
{"bsrl", FnBsrl},
|
||||
{"bswap16", FnBswap16},
|
||||
{"bswap32", FnBswap32},
|
||||
{"bswap64", FnBswap64},
|
||||
{"cbrt", FnCbrt},
|
||||
{"ceil", FnCeil},
|
||||
{"copysign", FnCopysign},
|
||||
|
|
|
@ -13,7 +13,7 @@ struct Numbers {
|
|||
long double x;
|
||||
};
|
||||
|
||||
static void SyntaxError(void) noreturn;
|
||||
static void SyntaxError(void) wontreturn;
|
||||
static long double ParseNumber(struct Token);
|
||||
static void NumbersFree(struct Numbers *);
|
||||
static struct Numbers *NumbersAppend(struct Numbers *, long double);
|
||||
|
|
|
@ -41,7 +41,7 @@ TOOL_CALC_DIRECTDEPS = \
|
|||
LIBC_TINYMATH \
|
||||
LIBC_X \
|
||||
THIRD_PARTY_COMPILER_RT \
|
||||
THIRD_PARTY_DTOA
|
||||
THIRD_PARTY_GDTOA
|
||||
|
||||
TOOL_CALC_DEPS := \
|
||||
$(call uniq,$(foreach x,$(TOOL_CALC_DIRECTDEPS),$($(x))))
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "tool/calc/calc.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/math.h"
|
||||
|
|
193
tool/cc/c11.l
193
tool/cc/c11.l
|
@ -1,193 +0,0 @@
|
|||
/* http://www.quut.com/c/ANSI-C-grammar-l-2011.html */
|
||||
|
||||
%e 1019
|
||||
%p 2807
|
||||
%n 371
|
||||
%k 284
|
||||
%a 1213
|
||||
%o 1117
|
||||
|
||||
O [0-7]
|
||||
D [0-9]
|
||||
NZ [1-9]
|
||||
L [a-zA-Z_]
|
||||
A [a-zA-Z_0-9]
|
||||
H [a-fA-F0-9]
|
||||
HP (0[xX])
|
||||
E ([Ee][+-]?{D}+)
|
||||
P ([Pp][+-]?{D}+)
|
||||
FS (f|F|l|L)
|
||||
IS (((u|U)(l|L|ll|LL)?)|((l|L|ll|LL)(u|U)?))
|
||||
CP (u|U|L)
|
||||
SP (u8|u|U|L)
|
||||
ES (\\(['"\?\\abfnrtv]|[0-7]{1,3}|x[a-fA-F0-9]+))
|
||||
WS [ \t\v\n\f]
|
||||
|
||||
%{
|
||||
#include <stdio.h>
|
||||
#include "y.tab.h"
|
||||
|
||||
extern void yyerror(const char *); /* prints grammar violation message */
|
||||
|
||||
extern int sym_type(const char *); /* returns type from symbol table */
|
||||
|
||||
#define sym_type(identifier) IDENTIFIER /* with no symbol table, fake it */
|
||||
|
||||
static void comment(void);
|
||||
static int check_type(void);
|
||||
%}
|
||||
|
||||
%%
|
||||
"/*" { comment(); }
|
||||
"//".* { /* consume //-comment */ }
|
||||
|
||||
"auto" { return(AUTO); }
|
||||
"break" { return(BREAK); }
|
||||
"case" { return(CASE); }
|
||||
"char" { return(CHAR); }
|
||||
"const" { return(CONST); }
|
||||
"continue" { return(CONTINUE); }
|
||||
"default" { return(DEFAULT); }
|
||||
"do" { return(DO); }
|
||||
"double" { return(DOUBLE); }
|
||||
"else" { return(ELSE); }
|
||||
"enum" { return(ENUM); }
|
||||
"extern" { return(EXTERN); }
|
||||
"float" { return(FLOAT); }
|
||||
"for" { return(FOR); }
|
||||
"goto" { return(GOTO); }
|
||||
"if" { return(IF); }
|
||||
"inline" { return(INLINE); }
|
||||
"int" { return(INT); }
|
||||
"long" { return(LONG); }
|
||||
"register" { return(REGISTER); }
|
||||
"restrict" { return(RESTRICT); }
|
||||
"return" { return(RETURN); }
|
||||
"short" { return(SHORT); }
|
||||
"signed" { return(SIGNED); }
|
||||
"sizeof" { return(SIZEOF); }
|
||||
"static" { return(STATIC); }
|
||||
"struct" { return(STRUCT); }
|
||||
"switch" { return(SWITCH); }
|
||||
"typedef" { return(TYPEDEF); }
|
||||
"union" { return(UNION); }
|
||||
"unsigned" { return(UNSIGNED); }
|
||||
"void" { return(VOID); }
|
||||
"volatile" { return(VOLATILE); }
|
||||
"while" { return(WHILE); }
|
||||
"_Alignas" { return ALIGNAS; }
|
||||
"_Alignof" { return ALIGNOF; }
|
||||
"_Atomic" { return ATOMIC; }
|
||||
"_Bool" { return BOOL; }
|
||||
"_Complex" { return COMPLEX; }
|
||||
"_Generic" { return GENERIC; }
|
||||
"_Imaginary" { return IMAGINARY; }
|
||||
"_Noreturn" { return NORETURN; }
|
||||
"_Static_assert" { return STATIC_ASSERT; }
|
||||
"_Thread_local" { return THREAD_LOCAL; }
|
||||
"__func__" { return FUNC_NAME; }
|
||||
|
||||
{L}{A}* { return check_type(); }
|
||||
|
||||
{HP}{H}+{IS}? { return I_CONSTANT; }
|
||||
{NZ}{D}*{IS}? { return I_CONSTANT; }
|
||||
"0"{O}*{IS}? { return I_CONSTANT; }
|
||||
{CP}?"'"([^'\\\n]|{ES})+"'" { return I_CONSTANT; }
|
||||
|
||||
{D}+{E}{FS}? { return F_CONSTANT; }
|
||||
{D}*"."{D}+{E}?{FS}? { return F_CONSTANT; }
|
||||
{D}+"."{E}?{FS}? { return F_CONSTANT; }
|
||||
{HP}{H}+{P}{FS}? { return F_CONSTANT; }
|
||||
{HP}{H}*"."{H}+{P}{FS}? { return F_CONSTANT; }
|
||||
{HP}{H}+"."{P}{FS}? { return F_CONSTANT; }
|
||||
|
||||
({SP}?\"([^"\\\n]|{ES})*\"{WS}*)+ { return STRING_LITERAL; }
|
||||
|
||||
"..." { return ELLIPSIS; }
|
||||
">>=" { return RIGHT_ASSIGN; }
|
||||
"<<=" { return LEFT_ASSIGN; }
|
||||
"+=" { return ADD_ASSIGN; }
|
||||
"-=" { return SUB_ASSIGN; }
|
||||
"*=" { return MUL_ASSIGN; }
|
||||
"/=" { return DIV_ASSIGN; }
|
||||
"%=" { return MOD_ASSIGN; }
|
||||
"&=" { return AND_ASSIGN; }
|
||||
"^=" { return XOR_ASSIGN; }
|
||||
"|=" { return OR_ASSIGN; }
|
||||
">>" { return RIGHT_OP; }
|
||||
"<<" { return LEFT_OP; }
|
||||
"++" { return INC_OP; }
|
||||
"--" { return DEC_OP; }
|
||||
"->" { return PTR_OP; }
|
||||
"&&" { return AND_OP; }
|
||||
"||" { return OR_OP; }
|
||||
"<=" { return LE_OP; }
|
||||
">=" { return GE_OP; }
|
||||
"==" { return EQ_OP; }
|
||||
"!=" { return NE_OP; }
|
||||
";" { return ';'; }
|
||||
("{"|"<%") { return '{'; }
|
||||
("}"|"%>") { return '}'; }
|
||||
"," { return ','; }
|
||||
":" { return ':'; }
|
||||
"=" { return '='; }
|
||||
"(" { return '('; }
|
||||
")" { return ')'; }
|
||||
("["|"<:") { return '['; }
|
||||
("]"|":>") { return ']'; }
|
||||
"." { return '.'; }
|
||||
"&" { return '&'; }
|
||||
"!" { return '!'; }
|
||||
"~" { return '~'; }
|
||||
"-" { return '-'; }
|
||||
"+" { return '+'; }
|
||||
"*" { return '*'; }
|
||||
"/" { return '/'; }
|
||||
"%" { return '%'; }
|
||||
"<" { return '<'; }
|
||||
">" { return '>'; }
|
||||
"^" { return '^'; }
|
||||
"|" { return '|'; }
|
||||
"?" { return '?'; }
|
||||
|
||||
{WS}+ { /* whitespace separates tokens */ }
|
||||
. { /* discard bad characters */ }
|
||||
|
||||
%%
|
||||
|
||||
int yywrap(void) /* called at end of input */
|
||||
{
|
||||
return 1; /* terminate now */
|
||||
}
|
||||
|
||||
static void comment(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
while ((c = input()) != 0)
|
||||
if (c == '*')
|
||||
{
|
||||
while ((c = input()) == '*')
|
||||
;
|
||||
|
||||
if (c == '/')
|
||||
return;
|
||||
|
||||
if (c == 0)
|
||||
break;
|
||||
}
|
||||
yyerror("unterminated comment");
|
||||
}
|
||||
|
||||
static int check_type(void)
|
||||
{
|
||||
switch (sym_type(yytext))
|
||||
{
|
||||
case TYPEDEF_NAME: /* previously defined */
|
||||
return TYPEDEF_NAME;
|
||||
case ENUMERATION_CONSTANT: /* previously defined */
|
||||
return ENUMERATION_CONSTANT;
|
||||
default: /* includes undefined */
|
||||
return IDENTIFIER;
|
||||
}
|
||||
}
|
535
tool/cc/c11.y
535
tool/cc/c11.y
|
@ -1,535 +0,0 @@
|
|||
/* http://www.quut.com/c/ANSI-C-grammar-y-2011.html */
|
||||
|
||||
%token IDENTIFIER I_CONSTANT F_CONSTANT STRING_LITERAL FUNC_NAME SIZEOF
|
||||
%token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP
|
||||
%token AND_OP OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN
|
||||
%token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN
|
||||
%token XOR_ASSIGN OR_ASSIGN
|
||||
%token TYPEDEF_NAME ENUMERATION_CONSTANT
|
||||
|
||||
%token TYPEDEF EXTERN STATIC AUTO REGISTER INLINE
|
||||
%token CONST RESTRICT VOLATILE
|
||||
%token BOOL CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE VOID
|
||||
%token COMPLEX IMAGINARY
|
||||
%token STRUCT UNION ENUM ELLIPSIS
|
||||
|
||||
%token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
|
||||
|
||||
%token ALIGNAS ALIGNOF ATOMIC GENERIC NORETURN STATIC_ASSERT THREAD_LOCAL
|
||||
|
||||
%start translation_unit
|
||||
%%
|
||||
|
||||
primary_expression
|
||||
: IDENTIFIER
|
||||
| constant
|
||||
| string
|
||||
| '(' expression ')'
|
||||
| generic_selection
|
||||
;
|
||||
|
||||
constant
|
||||
: I_CONSTANT /* includes character_constant */
|
||||
| F_CONSTANT
|
||||
| ENUMERATION_CONSTANT /* after it has been defined as such */
|
||||
;
|
||||
|
||||
enumeration_constant /* before it has been defined as such */
|
||||
: IDENTIFIER
|
||||
;
|
||||
|
||||
string
|
||||
: STRING_LITERAL
|
||||
| FUNC_NAME
|
||||
;
|
||||
|
||||
generic_selection
|
||||
: GENERIC '(' assignment_expression ',' generic_assoc_list ')'
|
||||
;
|
||||
|
||||
generic_assoc_list
|
||||
: generic_association
|
||||
| generic_assoc_list ',' generic_association
|
||||
;
|
||||
|
||||
generic_association
|
||||
: type_name ':' assignment_expression
|
||||
| DEFAULT ':' assignment_expression
|
||||
;
|
||||
|
||||
postfix_expression
|
||||
: primary_expression
|
||||
| postfix_expression '[' expression ']'
|
||||
| postfix_expression '(' ')'
|
||||
| postfix_expression '(' argument_expression_list ')'
|
||||
| postfix_expression '.' IDENTIFIER
|
||||
| postfix_expression PTR_OP IDENTIFIER
|
||||
| postfix_expression INC_OP
|
||||
| postfix_expression DEC_OP
|
||||
| '(' type_name ')' '{' initializer_list '}'
|
||||
| '(' type_name ')' '{' initializer_list ',' '}'
|
||||
;
|
||||
|
||||
argument_expression_list
|
||||
: assignment_expression
|
||||
| argument_expression_list ',' assignment_expression
|
||||
;
|
||||
|
||||
unary_expression
|
||||
: postfix_expression
|
||||
| INC_OP unary_expression
|
||||
| DEC_OP unary_expression
|
||||
| unary_operator cast_expression
|
||||
| SIZEOF unary_expression
|
||||
| SIZEOF '(' type_name ')'
|
||||
| ALIGNOF '(' type_name ')'
|
||||
;
|
||||
|
||||
unary_operator
|
||||
: '&'
|
||||
| '*'
|
||||
| '+'
|
||||
| '-'
|
||||
| '~'
|
||||
| '!'
|
||||
;
|
||||
|
||||
cast_expression
|
||||
: unary_expression
|
||||
| '(' type_name ')' cast_expression
|
||||
;
|
||||
|
||||
multiplicative_expression
|
||||
: cast_expression
|
||||
| multiplicative_expression '*' cast_expression
|
||||
| multiplicative_expression '/' cast_expression
|
||||
| multiplicative_expression '%' cast_expression
|
||||
;
|
||||
|
||||
additive_expression
|
||||
: multiplicative_expression
|
||||
| additive_expression '+' multiplicative_expression
|
||||
| additive_expression '-' multiplicative_expression
|
||||
;
|
||||
|
||||
shift_expression
|
||||
: additive_expression
|
||||
| shift_expression LEFT_OP additive_expression
|
||||
| shift_expression RIGHT_OP additive_expression
|
||||
;
|
||||
|
||||
relational_expression
|
||||
: shift_expression
|
||||
| relational_expression '<' shift_expression
|
||||
| relational_expression '>' shift_expression
|
||||
| relational_expression LE_OP shift_expression
|
||||
| relational_expression GE_OP shift_expression
|
||||
;
|
||||
|
||||
equality_expression
|
||||
: relational_expression
|
||||
| equality_expression EQ_OP relational_expression
|
||||
| equality_expression NE_OP relational_expression
|
||||
;
|
||||
|
||||
and_expression
|
||||
: equality_expression
|
||||
| and_expression '&' equality_expression
|
||||
;
|
||||
|
||||
exclusive_or_expression
|
||||
: and_expression
|
||||
| exclusive_or_expression '^' and_expression
|
||||
;
|
||||
|
||||
inclusive_or_expression
|
||||
: exclusive_or_expression
|
||||
| inclusive_or_expression '|' exclusive_or_expression
|
||||
;
|
||||
|
||||
logical_and_expression
|
||||
: inclusive_or_expression
|
||||
| logical_and_expression AND_OP inclusive_or_expression
|
||||
;
|
||||
|
||||
logical_or_expression
|
||||
: logical_and_expression
|
||||
| logical_or_expression OR_OP logical_and_expression
|
||||
;
|
||||
|
||||
conditional_expression
|
||||
: logical_or_expression
|
||||
| logical_or_expression '?' expression ':' conditional_expression
|
||||
;
|
||||
|
||||
assignment_expression
|
||||
: conditional_expression
|
||||
| unary_expression assignment_operator assignment_expression
|
||||
;
|
||||
|
||||
assignment_operator
|
||||
: '='
|
||||
| MUL_ASSIGN
|
||||
| DIV_ASSIGN
|
||||
| MOD_ASSIGN
|
||||
| ADD_ASSIGN
|
||||
| SUB_ASSIGN
|
||||
| LEFT_ASSIGN
|
||||
| RIGHT_ASSIGN
|
||||
| AND_ASSIGN
|
||||
| XOR_ASSIGN
|
||||
| OR_ASSIGN
|
||||
;
|
||||
|
||||
expression
|
||||
: assignment_expression
|
||||
| expression ',' assignment_expression
|
||||
;
|
||||
|
||||
constant_expression
|
||||
: conditional_expression /* with constraints */
|
||||
;
|
||||
|
||||
declaration
|
||||
: declaration_specifiers ';'
|
||||
| declaration_specifiers init_declarator_list ';'
|
||||
| static_assert_declaration
|
||||
;
|
||||
|
||||
declaration_specifiers
|
||||
: storage_class_specifier declaration_specifiers
|
||||
| storage_class_specifier
|
||||
| type_specifier declaration_specifiers
|
||||
| type_specifier
|
||||
| type_qualifier declaration_specifiers
|
||||
| type_qualifier
|
||||
| function_specifier declaration_specifiers
|
||||
| function_specifier
|
||||
| alignment_specifier declaration_specifiers
|
||||
| alignment_specifier
|
||||
;
|
||||
|
||||
init_declarator_list
|
||||
: init_declarator
|
||||
| init_declarator_list ',' init_declarator
|
||||
;
|
||||
|
||||
init_declarator
|
||||
: declarator '=' initializer
|
||||
| declarator
|
||||
;
|
||||
|
||||
storage_class_specifier
|
||||
: TYPEDEF /* identifiers must be flagged as TYPEDEF_NAME */
|
||||
| EXTERN
|
||||
| STATIC
|
||||
| THREAD_LOCAL
|
||||
| AUTO
|
||||
| REGISTER
|
||||
;
|
||||
|
||||
type_specifier
|
||||
: VOID
|
||||
| CHAR
|
||||
| SHORT
|
||||
| INT
|
||||
| LONG
|
||||
| FLOAT
|
||||
| DOUBLE
|
||||
| SIGNED
|
||||
| UNSIGNED
|
||||
| BOOL
|
||||
| COMPLEX
|
||||
| IMAGINARY /* non-mandated extension */
|
||||
| atomic_type_specifier
|
||||
| struct_or_union_specifier
|
||||
| enum_specifier
|
||||
| TYPEDEF_NAME /* after it has been defined as such */
|
||||
;
|
||||
|
||||
struct_or_union_specifier
|
||||
: struct_or_union '{' struct_declaration_list '}'
|
||||
| struct_or_union IDENTIFIER '{' struct_declaration_list '}'
|
||||
| struct_or_union IDENTIFIER
|
||||
;
|
||||
|
||||
struct_or_union
|
||||
: STRUCT
|
||||
| UNION
|
||||
;
|
||||
|
||||
struct_declaration_list
|
||||
: struct_declaration
|
||||
| struct_declaration_list struct_declaration
|
||||
;
|
||||
|
||||
struct_declaration
|
||||
: specifier_qualifier_list ';' /* for anonymous struct/union */
|
||||
| specifier_qualifier_list struct_declarator_list ';'
|
||||
| static_assert_declaration
|
||||
;
|
||||
|
||||
specifier_qualifier_list
|
||||
: type_specifier specifier_qualifier_list
|
||||
| type_specifier
|
||||
| type_qualifier specifier_qualifier_list
|
||||
| type_qualifier
|
||||
;
|
||||
|
||||
struct_declarator_list
|
||||
: struct_declarator
|
||||
| struct_declarator_list ',' struct_declarator
|
||||
;
|
||||
|
||||
struct_declarator
|
||||
: ':' constant_expression
|
||||
| declarator ':' constant_expression
|
||||
| declarator
|
||||
;
|
||||
|
||||
enum_specifier
|
||||
: ENUM '{' enumerator_list '}'
|
||||
| ENUM '{' enumerator_list ',' '}'
|
||||
| ENUM IDENTIFIER '{' enumerator_list '}'
|
||||
| ENUM IDENTIFIER '{' enumerator_list ',' '}'
|
||||
| ENUM IDENTIFIER
|
||||
;
|
||||
|
||||
enumerator_list
|
||||
: enumerator
|
||||
| enumerator_list ',' enumerator
|
||||
;
|
||||
|
||||
enumerator /* identifiers must be flagged as ENUMERATION_CONSTANT */
|
||||
: enumeration_constant '=' constant_expression
|
||||
| enumeration_constant
|
||||
;
|
||||
|
||||
atomic_type_specifier
|
||||
: ATOMIC '(' type_name ')'
|
||||
;
|
||||
|
||||
type_qualifier
|
||||
: CONST
|
||||
| RESTRICT
|
||||
| VOLATILE
|
||||
| ATOMIC
|
||||
;
|
||||
|
||||
function_specifier
|
||||
: INLINE
|
||||
| NORETURN
|
||||
;
|
||||
|
||||
alignment_specifier
|
||||
: ALIGNAS '(' type_name ')'
|
||||
| ALIGNAS '(' constant_expression ')'
|
||||
;
|
||||
|
||||
declarator
|
||||
: pointer direct_declarator
|
||||
| direct_declarator
|
||||
;
|
||||
|
||||
direct_declarator
|
||||
: IDENTIFIER
|
||||
| '(' declarator ')'
|
||||
| direct_declarator '[' ']'
|
||||
| direct_declarator '[' '*' ']'
|
||||
| direct_declarator '[' STATIC type_qualifier_list assignment_expression ']'
|
||||
| direct_declarator '[' STATIC assignment_expression ']'
|
||||
| direct_declarator '[' type_qualifier_list '*' ']'
|
||||
| direct_declarator '[' type_qualifier_list STATIC assignment_expression ']'
|
||||
| direct_declarator '[' type_qualifier_list assignment_expression ']'
|
||||
| direct_declarator '[' type_qualifier_list ']'
|
||||
| direct_declarator '[' assignment_expression ']'
|
||||
| direct_declarator '(' parameter_type_list ')'
|
||||
| direct_declarator '(' ')'
|
||||
| direct_declarator '(' identifier_list ')'
|
||||
;
|
||||
|
||||
pointer
|
||||
: '*' type_qualifier_list pointer
|
||||
| '*' type_qualifier_list
|
||||
| '*' pointer
|
||||
| '*'
|
||||
;
|
||||
|
||||
type_qualifier_list
|
||||
: type_qualifier
|
||||
| type_qualifier_list type_qualifier
|
||||
;
|
||||
|
||||
|
||||
parameter_type_list
|
||||
: parameter_list ',' ELLIPSIS
|
||||
| parameter_list
|
||||
;
|
||||
|
||||
parameter_list
|
||||
: parameter_declaration
|
||||
| parameter_list ',' parameter_declaration
|
||||
;
|
||||
|
||||
parameter_declaration
|
||||
: declaration_specifiers declarator
|
||||
| declaration_specifiers abstract_declarator
|
||||
| declaration_specifiers
|
||||
;
|
||||
|
||||
identifier_list
|
||||
: IDENTIFIER
|
||||
| identifier_list ',' IDENTIFIER
|
||||
;
|
||||
|
||||
type_name
|
||||
: specifier_qualifier_list abstract_declarator
|
||||
| specifier_qualifier_list
|
||||
;
|
||||
|
||||
abstract_declarator
|
||||
: pointer direct_abstract_declarator
|
||||
| pointer
|
||||
| direct_abstract_declarator
|
||||
;
|
||||
|
||||
direct_abstract_declarator
|
||||
: '(' abstract_declarator ')'
|
||||
| '[' ']'
|
||||
| '[' '*' ']'
|
||||
| '[' STATIC type_qualifier_list assignment_expression ']'
|
||||
| '[' STATIC assignment_expression ']'
|
||||
| '[' type_qualifier_list STATIC assignment_expression ']'
|
||||
| '[' type_qualifier_list assignment_expression ']'
|
||||
| '[' type_qualifier_list ']'
|
||||
| '[' assignment_expression ']'
|
||||
| direct_abstract_declarator '[' ']'
|
||||
| direct_abstract_declarator '[' '*' ']'
|
||||
| direct_abstract_declarator '[' STATIC type_qualifier_list assignment_expression ']'
|
||||
| direct_abstract_declarator '[' STATIC assignment_expression ']'
|
||||
| direct_abstract_declarator '[' type_qualifier_list assignment_expression ']'
|
||||
| direct_abstract_declarator '[' type_qualifier_list STATIC assignment_expression ']'
|
||||
| direct_abstract_declarator '[' type_qualifier_list ']'
|
||||
| direct_abstract_declarator '[' assignment_expression ']'
|
||||
| '(' ')'
|
||||
| '(' parameter_type_list ')'
|
||||
| direct_abstract_declarator '(' ')'
|
||||
| direct_abstract_declarator '(' parameter_type_list ')'
|
||||
;
|
||||
|
||||
initializer
|
||||
: '{' initializer_list '}'
|
||||
| '{' initializer_list ',' '}'
|
||||
| assignment_expression
|
||||
;
|
||||
|
||||
initializer_list
|
||||
: designation initializer
|
||||
| initializer
|
||||
| initializer_list ',' designation initializer
|
||||
| initializer_list ',' initializer
|
||||
;
|
||||
|
||||
designation
|
||||
: designator_list '='
|
||||
;
|
||||
|
||||
designator_list
|
||||
: designator
|
||||
| designator_list designator
|
||||
;
|
||||
|
||||
designator
|
||||
: '[' constant_expression ']'
|
||||
| '.' IDENTIFIER
|
||||
;
|
||||
|
||||
static_assert_declaration
|
||||
: STATIC_ASSERT '(' constant_expression ',' STRING_LITERAL ')' ';'
|
||||
;
|
||||
|
||||
statement
|
||||
: labeled_statement
|
||||
| compound_statement
|
||||
| expression_statement
|
||||
| selection_statement
|
||||
| iteration_statement
|
||||
| jump_statement
|
||||
;
|
||||
|
||||
labeled_statement
|
||||
: IDENTIFIER ':' statement
|
||||
| CASE constant_expression ':' statement
|
||||
| DEFAULT ':' statement
|
||||
;
|
||||
|
||||
compound_statement
|
||||
: '{' '}'
|
||||
| '{' block_item_list '}'
|
||||
;
|
||||
|
||||
block_item_list
|
||||
: block_item
|
||||
| block_item_list block_item
|
||||
;
|
||||
|
||||
block_item
|
||||
: declaration
|
||||
| statement
|
||||
;
|
||||
|
||||
expression_statement
|
||||
: ';'
|
||||
| expression ';'
|
||||
;
|
||||
|
||||
selection_statement
|
||||
: IF '(' expression ')' statement ELSE statement
|
||||
| IF '(' expression ')' statement
|
||||
| SWITCH '(' expression ')' statement
|
||||
;
|
||||
|
||||
iteration_statement
|
||||
: WHILE '(' expression ')' statement
|
||||
| DO statement WHILE '(' expression ')' ';'
|
||||
| FOR '(' expression_statement expression_statement ')' statement
|
||||
| FOR '(' expression_statement expression_statement expression ')' statement
|
||||
| FOR '(' declaration expression_statement ')' statement
|
||||
| FOR '(' declaration expression_statement expression ')' statement
|
||||
;
|
||||
|
||||
jump_statement
|
||||
: GOTO IDENTIFIER ';'
|
||||
| CONTINUE ';'
|
||||
| BREAK ';'
|
||||
| RETURN ';'
|
||||
| RETURN expression ';'
|
||||
;
|
||||
|
||||
translation_unit
|
||||
: external_declaration
|
||||
| translation_unit external_declaration
|
||||
;
|
||||
|
||||
external_declaration
|
||||
: function_definition
|
||||
| declaration
|
||||
;
|
||||
|
||||
function_definition
|
||||
: declaration_specifiers declarator declaration_list compound_statement
|
||||
| declaration_specifiers declarator compound_statement
|
||||
;
|
||||
|
||||
declaration_list
|
||||
: declaration
|
||||
| declaration_list declaration
|
||||
;
|
||||
|
||||
%%
|
||||
#include <stdio.h>
|
||||
|
||||
void yyerror(const char *s) {
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "*** %s\n", s);
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
|
||||
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
|
||||
|
||||
PKGS += TOOL_CC
|
||||
|
||||
o/$(MODE)/tool/cc/c11.c: tool/cc/c11.l o/$(MODE)/third_party/lex/lex.com.dbg
|
||||
@mkdir -p $(dir $@)
|
||||
o/$(MODE)/third_party/lex/lex.com.dbg -o $@ $<
|
||||
|
||||
.PHONY: o/$(MODE)/tool/cc
|
||||
o/$(MODE)/tool/cc:
|
|
@ -41,7 +41,7 @@ TOOL_DECODE_DIRECTDEPS = \
|
|||
LIBC_UNICODE \
|
||||
LIBC_X \
|
||||
TOOL_DECODE_LIB \
|
||||
THIRD_PARTY_DTOA \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_GETOPT \
|
||||
THIRD_PARTY_XED
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ static uint32_t bit, maxbit;
|
|||
static struct BitaBuilder *bitset;
|
||||
static char *line, *tok, *s1, *category, *g_inpath, *g_outpath;
|
||||
|
||||
noreturn void ShowUsage(FILE *f, int rc) {
|
||||
wontreturn void ShowUsage(FILE *f, int rc) {
|
||||
fprintf(f, "Usage: %s [-o OUTPUT] [INPUT]\n", "Usage",
|
||||
program_invocation_name);
|
||||
exit(rc);
|
||||
|
|
|
@ -35,7 +35,7 @@ static size_t linecap, i, x, y;
|
|||
static struct BitaBuilder *bitset;
|
||||
static char *g_inpath, *g_outpath;
|
||||
|
||||
noreturn void ShowUsage(FILE *f, int rc) {
|
||||
wontreturn void ShowUsage(FILE *f, int rc) {
|
||||
fprintf(f, "Usage: %s [-o OUTPUT] [INPUT]\n", "Usage",
|
||||
program_invocation_name);
|
||||
exit(rc);
|
||||
|
|
|
@ -42,7 +42,7 @@ const struct IdName kXedModeNames[] = {
|
|||
enum XedMachineMode g_mode;
|
||||
struct XedDecodedInst g_xedd;
|
||||
|
||||
noreturn void ShowUsage(int rc, FILE *f) {
|
||||
wontreturn void ShowUsage(int rc, FILE *f) {
|
||||
size_t i;
|
||||
fputs("Usage: ", f);
|
||||
fputs(program_invocation_name, f);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
|
||||
const char kConfig[] = "\
|
||||
/* FPU Control Word (x87) Exception Masks\n\
|
||||
|
@ -73,7 +73,8 @@ void PrintRegister(long double x) {
|
|||
memcpy(buf, &x, sizeof(x));
|
||||
memcpy(&lo, &buf[0], sizeof(lo));
|
||||
memcpy(&hi, &buf[8], sizeof(hi));
|
||||
printf("/\t%016lb%064lb %s\n", hi, lo, g_fmt(buf, x));
|
||||
g_xfmt_p(buf, &x, 15, 32, 0);
|
||||
printf("/\t%016lb%064lb %s\n", hi, lo, buf);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
|
|
@ -168,7 +168,7 @@
|
|||
"hasatleast"
|
||||
"nodebuginfo"
|
||||
"frownedupon"
|
||||
"noreturn"
|
||||
"wontreturn"
|
||||
"initarray"
|
||||
"mayalias"
|
||||
"noinstrument"
|
||||
|
@ -190,7 +190,7 @@
|
|||
"thatispacked"
|
||||
"strlenesque"
|
||||
"textwindows"
|
||||
"aligned"
|
||||
"forcealign"
|
||||
"typeof"
|
||||
"textreal"
|
||||
"autotype"
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
"__LINE__"
|
||||
"__DATE__"))
|
||||
|
||||
(defconst cosmo-cpp-constants-chibicc
|
||||
'("__cosmo__"
|
||||
"__chibicc__"))
|
||||
|
||||
(defconst cosmo-cpp-constants-gcc-412
|
||||
'("__BASE_FILE__"
|
||||
"__CHAR_BIT__"
|
||||
|
@ -21,6 +25,8 @@
|
|||
"__SHRT_MAX__"
|
||||
"__DBL_MIN__"
|
||||
"__DBL_MAX__"
|
||||
"__LDBL_MIN__"
|
||||
"__LDBL_MAX__"
|
||||
"__FLT_MIN__"
|
||||
"__FLT_MAX__"
|
||||
"__WCHAR_MAX__"
|
||||
|
@ -156,6 +162,7 @@
|
|||
(append cosmo-cpp-constants-c11
|
||||
cosmo-cpp-constants-gcc-92
|
||||
cosmo-cpp-constants-gcc-412
|
||||
cosmo-cpp-constants-chibicc
|
||||
cosmo-cpp-constants-cosmopolitan))
|
||||
|
||||
(defconst cosmo-cpp-constants-regex
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
;; M-3 C-c C-c Compile w/ MODE=rel
|
||||
;; M-4 C-c C-c Compile w/ MODE=dbg
|
||||
;; M-5 C-c C-c Compile w/ MODE=""
|
||||
;; M-9 C-c C-c Compile w/ chibicc
|
||||
|
||||
(defun cosmo-intest (&optional file-name)
|
||||
(let (path root pkg)
|
||||
|
@ -155,7 +156,15 @@
|
|||
((cosmo-intest) "dbg")
|
||||
(t "")))
|
||||
|
||||
(defun cosmo--compile-command (this root kind mode)
|
||||
(defun cosmo--make-suffix (arg)
|
||||
(cond ((eq arg 9) ".chibicc")
|
||||
(t "")))
|
||||
|
||||
(defun cosmo--make-objdump-flags (arg)
|
||||
(cond ((eq arg 9) "-x")
|
||||
(t "")))
|
||||
|
||||
(defun cosmo--compile-command (this root kind mode suffix objdumpflags)
|
||||
(let* ((ext (file-name-extension this)) ;; e.g. "c"
|
||||
(dir (file-name-directory this)) ;; e.g. "/home/jart/daisy/libc/"
|
||||
(dots (file-relative-name root dir)) ;; e.g. "../"
|
||||
|
@ -170,20 +179,21 @@
|
|||
(directory-file-name
|
||||
(file-name-directory
|
||||
(file-relative-name this root)))))
|
||||
((cosmo-contains "_test." (buffer-file-name))
|
||||
((and (equal suffix "")
|
||||
(cosmo-contains "_test." (buffer-file-name)))
|
||||
(format "m=%s; make -j8 -O MODE=$m %s"
|
||||
mode runs))
|
||||
((file-exists-p (format "%s" buddy))
|
||||
((and (equal suffix "")
|
||||
(file-exists-p (format "%s" buddy)))
|
||||
(format (cosmo-join
|
||||
" && "
|
||||
'("m=%s; n=%s; make -j8 -O o/$m/%s.o MODE=$m SILENT=0"
|
||||
"make -j8 -O MODE=$m %s"
|
||||
'("m=%s; n=%s; make -j8 -O o/$m/$n%s.o MODE=$m SILENT=0"
|
||||
;; "bloat o/$m/%s.o | head"
|
||||
;; "nm -C --size o/$m/%s.o | sort -r"
|
||||
"echo"
|
||||
"size -A o/$m/$n.o | grep '^[.T]' | grep -v 'debug\\|command.line\\|stack' | sort -rnk2"
|
||||
"objdump -wzCd o/$m/$n.o"))
|
||||
mode name name buns))
|
||||
"objdump %s -wzCd o/$m/$n%s.o"))
|
||||
mode name suffix objdumpflags suffix))
|
||||
((eq kind 'run)
|
||||
(format
|
||||
(cosmo-join
|
||||
|
@ -199,13 +209,13 @@
|
|||
(format
|
||||
(cosmo-join
|
||||
" && "
|
||||
`("m=%s; f=o/$m/%s.o"
|
||||
`("m=%s; f=o/$m/%s%s.o"
|
||||
,(concat "make -j8 -O $f MODE=$m SILENT=0")
|
||||
;; "nm -C --size $f | sort -r"
|
||||
"echo"
|
||||
"size -A $f | grep '^[.T]' | grep -v 'debug\\|command.line\\|stack' | sort -rnk2"
|
||||
"objdump -wzCd $f"))
|
||||
mode name)))))
|
||||
"objdump %s -wzCd $f"))
|
||||
mode name suffix objdumpflags)))))
|
||||
|
||||
(defun cosmo-compile (arg)
|
||||
(interactive "P")
|
||||
|
@ -213,9 +223,11 @@
|
|||
(root (locate-dominating-file this "Makefile")))
|
||||
(when root
|
||||
(let* ((mode (cosmo--make-mode arg))
|
||||
(suffix (cosmo--make-suffix arg))
|
||||
(objdumpflags (cosmo--make-objdump-flags arg))
|
||||
(compilation-scroll-output nil)
|
||||
(default-directory root)
|
||||
(compile-command (cosmo--compile-command this root nil mode)))
|
||||
(compile-command (cosmo--compile-command this root nil mode suffix objdumpflags)))
|
||||
(compile compile-command)))))
|
||||
|
||||
(defun cosmo-compile-hook ()
|
||||
|
@ -554,7 +566,7 @@
|
|||
(format "./%s" file))))
|
||||
((memq major-mode '(c-mode c++-mode asm-mode fortran-mode))
|
||||
(let* ((mode (cosmo--make-mode arg))
|
||||
(compile-command (cosmo--compile-command this root 'run mode)))
|
||||
(compile-command (cosmo--compile-command this root 'run mode "" "")))
|
||||
(compile compile-command)))
|
||||
((eq major-mode 'sh-mode)
|
||||
(compile (format "sh %s" file)))
|
||||
|
@ -590,7 +602,7 @@
|
|||
(next (file-name-sans-extension name))
|
||||
(exec (format "o/%s/%s.com.dbg" mode next))
|
||||
(default-directory root)
|
||||
(compile-command (cosmo--compile-command this root nil mode)))
|
||||
(compile-command (cosmo--compile-command this root nil mode "" "")))
|
||||
(compile compile-command)
|
||||
(gdb (format "gdb -q -nh -i=mi %s -ex run" exec))))))
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@ cosmo_kws = frozenset([
|
|||
"nointerpose",
|
||||
"nooptimize",
|
||||
"noprune",
|
||||
"noreturn",
|
||||
"wontreturn",
|
||||
"nosideeffect",
|
||||
"nothrow",
|
||||
"nothrow",
|
||||
|
@ -411,7 +411,7 @@ cosmo_kws = frozenset([
|
|||
"nointerpose",
|
||||
"nooptimize",
|
||||
"noprune",
|
||||
"noreturn",
|
||||
"wontreturn",
|
||||
"nosideeffect",
|
||||
"nothrow",
|
||||
"nothrow",
|
||||
|
|
|
@ -100,7 +100,7 @@ nodiscard char *DescribeSocket(struct Socket *s) {
|
|||
gc(DescribeAddress(&s->addr)));
|
||||
}
|
||||
|
||||
noreturn void ShowUsageAndExit(bool iserror) {
|
||||
wontreturn void ShowUsageAndExit(bool iserror) {
|
||||
FILE *f = iserror ? stderr : stdout;
|
||||
int rc = iserror ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
fprintf(f, "%s: %s %s\n", "Usage", g_argv[0], "PROTOCOL:ADDR:PORT...");
|
||||
|
|
|
@ -372,7 +372,7 @@ static const char *GetContentType(const char *path, size_t n) {
|
|||
}
|
||||
}
|
||||
|
||||
static noreturn void PrintUsage(FILE *f, int rc) {
|
||||
static wontreturn void PrintUsage(FILE *f, int rc) {
|
||||
fprintf(f, "SYNOPSIS\n\n %s%s", program_invocation_name, USAGE);
|
||||
exit(rc);
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ static const char *GetContentType(const char *path, size_t n) {
|
|||
}
|
||||
}
|
||||
|
||||
static noreturn void PrintUsage(FILE *f, int rc) {
|
||||
static wontreturn void PrintUsage(FILE *f, int rc) {
|
||||
fprintf(f, "SYNOPSIS\n\n %s%s", program_invocation_name, USAGE);
|
||||
exit(rc);
|
||||
}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "tool/tags/keywords.inc"
|
||||
#include "tool/tags/tags.h"
|
||||
|
||||
/**
|
||||
* Returns small number for HTTP header, or -1 if not found.
|
||||
*/
|
||||
int GetKeyword(const char *str, size_t len) {
|
||||
const struct KeywordSlot *slot;
|
||||
if ((slot = LookupKeyword(str, len))) {
|
||||
return slot->code;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
|
@ -1,161 +0,0 @@
|
|||
%{
|
||||
#include "libc/str/str.h"
|
||||
#include "tool/tags/tags.h"
|
||||
#include "o/tool/tags/tags.h.inc"
|
||||
%}
|
||||
%compare-strncmp
|
||||
%language=ANSI-C
|
||||
%readonly-tables
|
||||
%struct-type
|
||||
%define lookup-function-name LookupKeyword
|
||||
struct KeywordSlot { char *name; int code; };
|
||||
%%
|
||||
auto, TK_AUTO
|
||||
break, TK_BREAK
|
||||
case, TK_CASE
|
||||
char, TK_CHAR
|
||||
const, TK_CONST
|
||||
continue, TK_CONTINUE
|
||||
default, TK_DEFAULT
|
||||
do, TK_DO
|
||||
double, TK_DOUBLE
|
||||
else, TK_ELSE
|
||||
enum, TK_ENUM
|
||||
extern, TK_EXTERN
|
||||
float, TK_FLOAT
|
||||
for, TK_FOR
|
||||
goto, TK_GOTO
|
||||
if, TK_IF
|
||||
inline, TK_INLINE
|
||||
int, TK_INT
|
||||
long, TK_LONG
|
||||
register, TK_REGISTER
|
||||
restrict, TK_RESTRICT
|
||||
return, TK_RETURN
|
||||
short, TK_SHORT
|
||||
signed, TK_SIGNED
|
||||
sizeof, TK_SIZEOF
|
||||
static, TK_STATIC
|
||||
struct, TK_STRUCT
|
||||
switch, TK_SWITCH
|
||||
typedef, TK_TYPEDEF
|
||||
union, TK_UNION
|
||||
unsigned, TK_UNSIGNED
|
||||
void, TK_VOID
|
||||
volatile, TK_VOLATILE
|
||||
while, TK_WHILE
|
||||
_Alignas, TK_ALIGNAS
|
||||
_Alignof, TK_ALIGNOF
|
||||
_Atomic, TK_ATOMIC
|
||||
_Bool, TK_BOOL
|
||||
_Complex, TK_COMPLEX
|
||||
_Generic, TK_GENERIC
|
||||
_Imaginary, TK_IMAGINARY
|
||||
_Noreturn, TK_NORETURN
|
||||
_Static_assert, TK_STATIC_ASSERT
|
||||
_Thread_local, TK_THREAD_LOCAL
|
||||
elif, TK_ELIF
|
||||
endif, TK_ENDIF
|
||||
ifdef, TK_IFDEF
|
||||
ifndef, TK_IFNDEF
|
||||
define, TK_DEFINE
|
||||
undef, TK_UNDEF
|
||||
include, TK_INCLUDE
|
||||
line, TK_LINE
|
||||
error, TK_ERROR
|
||||
pragma, TK_PRAGMA
|
||||
asm, TK_ASM
|
||||
__attribute__, TK_ATTRIBUTE
|
||||
__restrict__, TK_RESTRICT
|
||||
__typeof__, TK_TYPEOF
|
||||
__typeof, TK_TYPEOF
|
||||
__inline, TK_INLINE
|
||||
__const__, TK_CONST
|
||||
__label__, TK_LABEL
|
||||
__noinline__, TK_LABEL
|
||||
__force_align_arg_pointer__, TK_FORCE_ALIGN_ARG_POINTER
|
||||
__always_inline__, TK_ALWAYS_INLINE
|
||||
__gnu_inline__, TK_GNU_INLINE
|
||||
__alignof__, TK_ALIGNOF
|
||||
__asm__, TK_ASM
|
||||
__auto_type, TK_AUTO_TYPE
|
||||
__byte__, TK_BYTE
|
||||
__complex__, TK_COMPLEX
|
||||
__imag__, TK_IMAG
|
||||
__may_alias__, TK_MAY_ALIAS
|
||||
__noreturn__, TK_NORETURN
|
||||
__packed__, TK_PACKED
|
||||
__pointer__, TK_POINTER
|
||||
__printf__, TK_PRINTF
|
||||
__real__, TK_REAL
|
||||
__scanf__, TK_SCANF
|
||||
__strfmon__, TK_STRFMON
|
||||
__strftime__, TK_STRFTIME
|
||||
__strong__, TK_STRONG
|
||||
__target__, TK_TARGET
|
||||
__transparent_union__, TK_TRANSPARENT_UNION
|
||||
__volatile__, TK_VOLATILE
|
||||
__word__, TK_WORD
|
||||
__alias__, TK_ALIAS
|
||||
__aligned__, TK_ALIGNED
|
||||
__alloc_align__, TK_ALLOC_ALIGN
|
||||
__alloc_size__, TK_ALLOC_SIZE
|
||||
__artificial__, TK_ARTIFICIAL
|
||||
__assume_aligned__, TK_ASSUME_ALIGNED
|
||||
__cold__, TK_COLD
|
||||
__constructor__, TK_CONSTRUCTOR
|
||||
__destructor__, TK_DESTRUCTOR
|
||||
__copy__, TK_COPY
|
||||
__deprecated__, TK_DEPRECATED
|
||||
__error__, TK_ERROR
|
||||
__warning__, TK_WARNING
|
||||
__externally_visible__, TK_EXTERNALLY_VISIBLE
|
||||
__flatten__, TK_FLATTEN
|
||||
__format__, TK_FORMAT
|
||||
__gnu_format__, TK_GNU_FORMAT
|
||||
__gnu_printf__, TK_GNU_PRINTF
|
||||
__gnu_scanf__, TK_GNU_SCANF
|
||||
__format_arg__, TK_FORMAT_ARG
|
||||
__hot__, TK_HOT
|
||||
__ifunc__, TK_IFUNC
|
||||
__interrupt__, TK_INTERRUPT
|
||||
__interrupt_handler__, TK_INTERRUPT_HANDLER
|
||||
__no_caller_saved_registers__, TK_NO_CALLER_SAVED_REGISTERS
|
||||
__leaf__, TK_LEAF
|
||||
__malloc__, TK_MALLOC
|
||||
__no_icf__, TK_NO_ICF
|
||||
__no_instrument_function__, TK_NO_INSTRUMENT_FUNCTION
|
||||
__no_profile_instrument_function__, TK_NO_PROFILE_INSTRUMENT_FUNCTION
|
||||
__no_reorder__, TK_NO_REORDER
|
||||
__no_sanitize__, TK_NO_SANITIZE
|
||||
__no_sanitize_address__, TK_NO_SANITIZE_ADDRESS
|
||||
__no_address_safety_analysis__, TK_NO_ADDRESS_SAFETY_ANALYSIS
|
||||
__no_sanitize_thread__, TK_NO_SANITIZE_THREAD
|
||||
__no_sanitize_undefined__, TK_NO_SANITIZE_UNDEFINED
|
||||
__no_split_stack__, TK_NO_SPLIT_STACK
|
||||
__no_stack_limit__, TK_NO_STACK_LIMIT
|
||||
__noclone__, TK_NOCLONE
|
||||
__noipa__, TK_NOIPA
|
||||
__nonnull__, TK_NONNULL
|
||||
__noplt__, TK_NOPLT
|
||||
__nothrow__, TK_NOTHROW
|
||||
__optimize__, TK_OPTIMIZE
|
||||
__pure__, TK_PURE
|
||||
__patchable_function_entry__, TK_PATCHABLE_FUNCTION_ENTRY
|
||||
__returns_nonnull__, TK_RETURNS_NONNULL
|
||||
__returns_twice__, TK_RETURNS_TWICE
|
||||
__section__, TK_SECTION
|
||||
__sentinel__, TK_SENTINEL
|
||||
__simd__, TK_SIMD
|
||||
__target_clones__, TK_TARGET_CLONES
|
||||
__unused__, TK_UNUSED
|
||||
__used__, TK_USED
|
||||
__visibility__, TK_VISIBILITY
|
||||
__warn_unused_result__, TK_WARN_UNUSED_RESULT
|
||||
__params_nonnull__, TK_PARAMS_NONNULL
|
||||
__weak__, TK_WEAK
|
||||
__vector_size__, TK_VECTOR_SIZE
|
||||
__ms_abi__, TK_MS_ABI
|
||||
__mode__, TK_MODE
|
||||
__optnone__, TK_OPTNONE
|
||||
__nodebug__, TK_NODEBUG
|
|
@ -1,516 +0,0 @@
|
|||
/* ANSI-C code produced by gperf version 3.1 */
|
||||
/* Command-line: gperf keywords.gperf */
|
||||
/* Computed positions: -k'1-3,5,8' */
|
||||
|
||||
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
|
||||
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
|
||||
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
|
||||
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
|
||||
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
|
||||
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
|
||||
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
|
||||
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
|
||||
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
|
||||
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
|
||||
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
|
||||
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
|
||||
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
|
||||
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
|
||||
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
|
||||
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
|
||||
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
|
||||
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
|
||||
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
|
||||
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
|
||||
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
|
||||
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
||||
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
|
||||
/* The character set is not based on ISO-646. */
|
||||
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
|
||||
#endif
|
||||
|
||||
#line 1 "keywords.gperf"
|
||||
|
||||
#include "libc/str/str.h"
|
||||
#include "tool/tags/tags.h"
|
||||
#include "o/tool/tags/tags.h.inc"
|
||||
#line 11 "keywords.gperf"
|
||||
struct KeywordSlot { char *name; int code; };
|
||||
|
||||
#define TOTAL_KEYWORDS 149
|
||||
#define MIN_WORD_LENGTH 2
|
||||
#define MAX_WORD_LENGTH 34
|
||||
#define MIN_HASH_VALUE 15
|
||||
#define MAX_HASH_VALUE 485
|
||||
/* maximum key range = 471, duplicates = 0 */
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
inline
|
||||
#endif
|
||||
#endif
|
||||
static unsigned int
|
||||
hash (register const char *str, register size_t len)
|
||||
{
|
||||
static const unsigned short asso_values[] =
|
||||
{
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 0, 5, 5, 486, 486,
|
||||
486, 5, 486, 0, 486, 486, 486, 486, 0, 486,
|
||||
486, 486, 486, 5, 0, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 45, 0, 40, 120, 160,
|
||||
80, 60, 0, 130, 0, 55, 15, 486, 175, 20,
|
||||
10, 0, 5, 70, 125, 10, 40, 0, 40, 145,
|
||||
20, 20, 0, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486, 486, 486, 486,
|
||||
486, 486, 486, 486, 486, 486, 486
|
||||
};
|
||||
register unsigned int hval = len;
|
||||
|
||||
switch (hval)
|
||||
{
|
||||
default:
|
||||
hval += asso_values[(unsigned char)str[7]+1];
|
||||
/*FALLTHROUGH*/
|
||||
case 7:
|
||||
case 6:
|
||||
case 5:
|
||||
hval += asso_values[(unsigned char)str[4]+1];
|
||||
/*FALLTHROUGH*/
|
||||
case 4:
|
||||
case 3:
|
||||
hval += asso_values[(unsigned char)str[2]];
|
||||
/*FALLTHROUGH*/
|
||||
case 2:
|
||||
hval += asso_values[(unsigned char)str[1]];
|
||||
/*FALLTHROUGH*/
|
||||
case 1:
|
||||
hval += asso_values[(unsigned char)str[0]];
|
||||
break;
|
||||
}
|
||||
return hval;
|
||||
}
|
||||
|
||||
const struct KeywordSlot *
|
||||
LookupKeyword (register const char *str, register size_t len)
|
||||
{
|
||||
static const struct KeywordSlot wordlist[] =
|
||||
{
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""},
|
||||
#line 35 "keywords.gperf"
|
||||
{"short", TK_SHORT},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""},
|
||||
#line 28 "keywords.gperf"
|
||||
{"if", TK_IF},
|
||||
#line 56 "keywords.gperf"
|
||||
{"_Thread_local", TK_THREAD_LOCAL},
|
||||
{""}, {""}, {""}, {""}, {""},
|
||||
#line 54 "keywords.gperf"
|
||||
{"_Noreturn", TK_NORETURN},
|
||||
{""}, {""}, {""}, {""}, {""},
|
||||
#line 42 "keywords.gperf"
|
||||
{"union", TK_UNION},
|
||||
#line 60 "keywords.gperf"
|
||||
{"ifndef", TK_IFNDEF},
|
||||
{""},
|
||||
#line 67 "keywords.gperf"
|
||||
{"asm", TK_ASM},
|
||||
#line 23 "keywords.gperf"
|
||||
{"enum", TK_ENUM},
|
||||
#line 50 "keywords.gperf"
|
||||
{"_Bool", TK_BOOL},
|
||||
#line 37 "keywords.gperf"
|
||||
{"sizeof", TK_SIZEOF},
|
||||
{""}, {""}, {""}, {""}, {""},
|
||||
#line 20 "keywords.gperf"
|
||||
{"do", TK_DO},
|
||||
{""},
|
||||
#line 13 "keywords.gperf"
|
||||
{"auto", TK_AUTO},
|
||||
{""}, {""}, {""},
|
||||
#line 43 "keywords.gperf"
|
||||
{"unsigned", TK_UNSIGNED},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
#line 119 "keywords.gperf"
|
||||
{"__hot__", TK_HOT},
|
||||
#line 152 "keywords.gperf"
|
||||
{"__used__", TK_USED},
|
||||
#line 44 "keywords.gperf"
|
||||
{"void", TK_VOID},
|
||||
{""},
|
||||
#line 160 "keywords.gperf"
|
||||
{"__optnone__", TK_OPTNONE},
|
||||
#line 49 "keywords.gperf"
|
||||
{"_Atomic", TK_ATOMIC},
|
||||
{""},
|
||||
#line 55 "keywords.gperf"
|
||||
{"_Static_assert", TK_STATIC_ASSERT},
|
||||
{""},
|
||||
#line 21 "keywords.gperf"
|
||||
{"double", TK_DOUBLE},
|
||||
{""},
|
||||
#line 30 "keywords.gperf"
|
||||
{"int", TK_INT},
|
||||
{""},
|
||||
#line 114 "keywords.gperf"
|
||||
{"__format__", TK_FORMAT},
|
||||
#line 38 "keywords.gperf"
|
||||
{"static", TK_STATIC},
|
||||
#line 148 "keywords.gperf"
|
||||
{"__sentinel__", TK_SENTINEL},
|
||||
#line 143 "keywords.gperf"
|
||||
{"__pure__", TK_PURE},
|
||||
#line 118 "keywords.gperf"
|
||||
{"__format_arg__", TK_FORMAT_ARG},
|
||||
#line 130 "keywords.gperf"
|
||||
{"__no_sanitize__", TK_NO_SANITIZE},
|
||||
#line 141 "keywords.gperf"
|
||||
{"__nothrow__", TK_NOTHROW},
|
||||
#line 142 "keywords.gperf"
|
||||
{"__optimize__", TK_OPTIMIZE},
|
||||
#line 149 "keywords.gperf"
|
||||
{"__simd__", TK_SIMD},
|
||||
#line 129 "keywords.gperf"
|
||||
{"__no_reorder__", TK_NO_REORDER},
|
||||
#line 94 "keywords.gperf"
|
||||
{"__strong__", TK_STRONG},
|
||||
#line 88 "keywords.gperf"
|
||||
{"__pointer__", TK_POINTER},
|
||||
#line 133 "keywords.gperf"
|
||||
{"__no_sanitize_thread__", TK_NO_SANITIZE_THREAD},
|
||||
#line 131 "keywords.gperf"
|
||||
{"__no_sanitize_address__", TK_NO_SANITIZE_ADDRESS},
|
||||
#line 138 "keywords.gperf"
|
||||
{"__noipa__", TK_NOIPA},
|
||||
#line 134 "keywords.gperf"
|
||||
{"__no_sanitize_undefined__", TK_NO_SANITIZE_UNDEFINED},
|
||||
#line 92 "keywords.gperf"
|
||||
{"__strfmon__", TK_STRFMON},
|
||||
#line 76 "keywords.gperf"
|
||||
{"__force_align_arg_pointer__", TK_FORCE_ALIGN_ARG_POINTER},
|
||||
#line 26 "keywords.gperf"
|
||||
{"for", TK_FOR},
|
||||
{""}, {""},
|
||||
#line 139 "keywords.gperf"
|
||||
{"__nonnull__", TK_NONNULL},
|
||||
#line 41 "keywords.gperf"
|
||||
{"typedef", TK_TYPEDEF},
|
||||
{""}, {""},
|
||||
#line 158 "keywords.gperf"
|
||||
{"__ms_abi__", TK_MS_ABI},
|
||||
#line 24 "keywords.gperf"
|
||||
{"extern", TK_EXTERN},
|
||||
#line 93 "keywords.gperf"
|
||||
{"__strftime__", TK_STRFTIME},
|
||||
#line 135 "keywords.gperf"
|
||||
{"__no_split_stack__", TK_NO_SPLIT_STACK},
|
||||
#line 128 "keywords.gperf"
|
||||
{"__no_profile_instrument_function__", TK_NO_PROFILE_INSTRUMENT_FUNCTION},
|
||||
{""},
|
||||
#line 81 "keywords.gperf"
|
||||
{"__auto_type", TK_AUTO_TYPE},
|
||||
#line 75 "keywords.gperf"
|
||||
{"__noinline__", TK_LABEL},
|
||||
#line 85 "keywords.gperf"
|
||||
{"__may_alias__", TK_MAY_ALIAS},
|
||||
{""}, {""},
|
||||
#line 61 "keywords.gperf"
|
||||
{"define", TK_DEFINE},
|
||||
#line 80 "keywords.gperf"
|
||||
{"__asm__", TK_ASM},
|
||||
#line 51 "keywords.gperf"
|
||||
{"_Complex", TK_COMPLEX},
|
||||
#line 123 "keywords.gperf"
|
||||
{"__no_caller_saved_registers__", TK_NO_CALLER_SAVED_REGISTERS},
|
||||
#line 95 "keywords.gperf"
|
||||
{"__target__", TK_TARGET},
|
||||
{""}, {""}, {""},
|
||||
#line 99 "keywords.gperf"
|
||||
{"__alias__", TK_ALIAS},
|
||||
{""},
|
||||
#line 100 "keywords.gperf"
|
||||
{"__aligned__", TK_ALIGNED},
|
||||
#line 150 "keywords.gperf"
|
||||
{"__target_clones__", TK_TARGET_CLONES},
|
||||
{""},
|
||||
#line 103 "keywords.gperf"
|
||||
{"__artificial__", TK_ARTIFICIAL},
|
||||
{""},
|
||||
#line 79 "keywords.gperf"
|
||||
{"__alignof__", TK_ALIGNOF},
|
||||
#line 86 "keywords.gperf"
|
||||
{"__noreturn__", TK_NORETURN},
|
||||
#line 155 "keywords.gperf"
|
||||
{"__params_nonnull__", TK_PARAMS_NONNULL},
|
||||
#line 102 "keywords.gperf"
|
||||
{"__alloc_size__", TK_ALLOC_SIZE},
|
||||
#line 101 "keywords.gperf"
|
||||
{"__alloc_align__", TK_ALLOC_ALIGN},
|
||||
#line 127 "keywords.gperf"
|
||||
{"__no_instrument_function__", TK_NO_INSTRUMENT_FUNCTION},
|
||||
{""},
|
||||
#line 121 "keywords.gperf"
|
||||
{"__interrupt__", TK_INTERRUPT},
|
||||
#line 110 "keywords.gperf"
|
||||
{"__error__", TK_ERROR},
|
||||
{""}, {""},
|
||||
#line 112 "keywords.gperf"
|
||||
{"__externally_visible__", TK_EXTERNALLY_VISIBLE},
|
||||
#line 72 "keywords.gperf"
|
||||
{"__inline", TK_INLINE},
|
||||
#line 27 "keywords.gperf"
|
||||
{"goto", TK_GOTO},
|
||||
#line 17 "keywords.gperf"
|
||||
{"const", TK_CONST},
|
||||
#line 122 "keywords.gperf"
|
||||
{"__interrupt_handler__", TK_INTERRUPT_HANDLER},
|
||||
#line 97 "keywords.gperf"
|
||||
{"__volatile__", TK_VOLATILE},
|
||||
#line 159 "keywords.gperf"
|
||||
{"__mode__", TK_MODE},
|
||||
#line 140 "keywords.gperf"
|
||||
{"__noplt__", TK_NOPLT},
|
||||
#line 25 "keywords.gperf"
|
||||
{"float", TK_FLOAT},
|
||||
{""}, {""}, {""}, {""}, {""},
|
||||
#line 66 "keywords.gperf"
|
||||
{"pragma", TK_PRAGMA},
|
||||
#line 19 "keywords.gperf"
|
||||
{"default", TK_DEFAULT},
|
||||
#line 104 "keywords.gperf"
|
||||
{"__assume_aligned__", TK_ASSUME_ALIGNED},
|
||||
#line 31 "keywords.gperf"
|
||||
{"long", TK_LONG},
|
||||
#line 132 "keywords.gperf"
|
||||
{"__no_address_safety_analysis__", TK_NO_ADDRESS_SAFETY_ANALYSIS},
|
||||
#line 137 "keywords.gperf"
|
||||
{"__noclone__", TK_NOCLONE},
|
||||
{""},
|
||||
#line 18 "keywords.gperf"
|
||||
{"continue", TK_CONTINUE},
|
||||
#line 120 "keywords.gperf"
|
||||
{"__ifunc__", TK_IFUNC},
|
||||
#line 53 "keywords.gperf"
|
||||
{"_Imaginary", TK_IMAGINARY},
|
||||
#line 147 "keywords.gperf"
|
||||
{"__section__", TK_SECTION},
|
||||
{""},
|
||||
#line 52 "keywords.gperf"
|
||||
{"_Generic", TK_GENERIC},
|
||||
#line 153 "keywords.gperf"
|
||||
{"__visibility__", TK_VISIBILITY},
|
||||
#line 151 "keywords.gperf"
|
||||
{"__unused__", TK_UNUSED},
|
||||
#line 36 "keywords.gperf"
|
||||
{"signed", TK_SIGNED},
|
||||
{""}, {""},
|
||||
#line 16 "keywords.gperf"
|
||||
{"char", TK_CHAR},
|
||||
#line 46 "keywords.gperf"
|
||||
{"while", TK_WHILE},
|
||||
{""},
|
||||
#line 77 "keywords.gperf"
|
||||
{"__always_inline__", TK_ALWAYS_INLINE},
|
||||
{""}, {""}, {""},
|
||||
#line 161 "keywords.gperf"
|
||||
{"__nodebug__", TK_NODEBUG},
|
||||
{""},
|
||||
#line 33 "keywords.gperf"
|
||||
{"restrict", TK_RESTRICT},
|
||||
#line 15 "keywords.gperf"
|
||||
{"case", TK_CASE},
|
||||
{""}, {""}, {""},
|
||||
#line 82 "keywords.gperf"
|
||||
{"__byte__", TK_BYTE},
|
||||
{""},
|
||||
#line 125 "keywords.gperf"
|
||||
{"__malloc__", TK_MALLOC},
|
||||
#line 113 "keywords.gperf"
|
||||
{"__flatten__", TK_FLATTEN},
|
||||
{""},
|
||||
#line 45 "keywords.gperf"
|
||||
{"volatile", TK_VOLATILE},
|
||||
{""},
|
||||
#line 62 "keywords.gperf"
|
||||
{"undef", TK_UNDEF},
|
||||
{""}, {""}, {""},
|
||||
#line 91 "keywords.gperf"
|
||||
{"__scanf__", TK_SCANF},
|
||||
{""}, {""},
|
||||
#line 146 "keywords.gperf"
|
||||
{"__returns_twice__", TK_RETURNS_TWICE},
|
||||
{""},
|
||||
#line 145 "keywords.gperf"
|
||||
{"__returns_nonnull__", TK_RETURNS_NONNULL},
|
||||
#line 157 "keywords.gperf"
|
||||
{"__vector_size__", TK_VECTOR_SIZE},
|
||||
{""}, {""},
|
||||
#line 136 "keywords.gperf"
|
||||
{"__no_stack_limit__", TK_NO_STACK_LIMIT},
|
||||
{""},
|
||||
#line 126 "keywords.gperf"
|
||||
{"__no_icf__", TK_NO_ICF},
|
||||
#line 34 "keywords.gperf"
|
||||
{"return", TK_RETURN},
|
||||
{""},
|
||||
#line 144 "keywords.gperf"
|
||||
{"__patchable_function_entry__", TK_PATCHABLE_FUNCTION_ENTRY},
|
||||
#line 64 "keywords.gperf"
|
||||
{"line", TK_LINE},
|
||||
#line 87 "keywords.gperf"
|
||||
{"__packed__", TK_PACKED},
|
||||
#line 29 "keywords.gperf"
|
||||
{"inline", TK_INLINE},
|
||||
{""}, {""},
|
||||
#line 22 "keywords.gperf"
|
||||
{"else", TK_ELSE},
|
||||
#line 89 "keywords.gperf"
|
||||
{"__printf__", TK_PRINTF},
|
||||
{""}, {""},
|
||||
#line 98 "keywords.gperf"
|
||||
{"__word__", TK_WORD},
|
||||
{""}, {""},
|
||||
#line 111 "keywords.gperf"
|
||||
{"__warning__", TK_WARNING},
|
||||
{""}, {""},
|
||||
#line 73 "keywords.gperf"
|
||||
{"__const__", TK_CONST},
|
||||
{""},
|
||||
#line 39 "keywords.gperf"
|
||||
{"struct", TK_STRUCT},
|
||||
{""}, {""},
|
||||
#line 107 "keywords.gperf"
|
||||
{"__destructor__", TK_DESTRUCTOR},
|
||||
{""}, {""}, {""},
|
||||
#line 47 "keywords.gperf"
|
||||
{"_Alignas", TK_ALIGNAS},
|
||||
{""},
|
||||
#line 59 "keywords.gperf"
|
||||
{"ifdef", TK_IFDEF},
|
||||
#line 83 "keywords.gperf"
|
||||
{"__complex__", TK_COMPLEX},
|
||||
#line 63 "keywords.gperf"
|
||||
{"include", TK_INCLUDE},
|
||||
#line 84 "keywords.gperf"
|
||||
{"__imag__", TK_IMAG},
|
||||
#line 78 "keywords.gperf"
|
||||
{"__gnu_inline__", TK_GNU_INLINE},
|
||||
#line 106 "keywords.gperf"
|
||||
{"__constructor__", TK_CONSTRUCTOR},
|
||||
{""}, {""},
|
||||
#line 105 "keywords.gperf"
|
||||
{"__cold__", TK_COLD},
|
||||
#line 115 "keywords.gperf"
|
||||
{"__gnu_format__", TK_GNU_FORMAT},
|
||||
{""}, {""},
|
||||
#line 69 "keywords.gperf"
|
||||
{"__restrict__", TK_RESTRICT},
|
||||
{""},
|
||||
#line 116 "keywords.gperf"
|
||||
{"__gnu_printf__", TK_GNU_PRINTF},
|
||||
#line 58 "keywords.gperf"
|
||||
{"endif", TK_ENDIF},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
#line 57 "keywords.gperf"
|
||||
{"elif", TK_ELIF},
|
||||
{""},
|
||||
#line 40 "keywords.gperf"
|
||||
{"switch", TK_SWITCH},
|
||||
{""}, {""}, {""}, {""}, {""}, {""},
|
||||
#line 68 "keywords.gperf"
|
||||
{"__attribute__", TK_ATTRIBUTE},
|
||||
{""}, {""}, {""},
|
||||
#line 154 "keywords.gperf"
|
||||
{"__warn_unused_result__", TK_WARN_UNUSED_RESULT},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
#line 65 "keywords.gperf"
|
||||
{"error", TK_ERROR},
|
||||
{""}, {""},
|
||||
#line 108 "keywords.gperf"
|
||||
{"__copy__", TK_COPY},
|
||||
{""}, {""}, {""}, {""}, {""},
|
||||
#line 109 "keywords.gperf"
|
||||
{"__deprecated__", TK_DEPRECATED},
|
||||
{""}, {""}, {""},
|
||||
#line 71 "keywords.gperf"
|
||||
{"__typeof", TK_TYPEOF},
|
||||
{""},
|
||||
#line 70 "keywords.gperf"
|
||||
{"__typeof__", TK_TYPEOF},
|
||||
#line 96 "keywords.gperf"
|
||||
{"__transparent_union__", TK_TRANSPARENT_UNION},
|
||||
{""},
|
||||
#line 90 "keywords.gperf"
|
||||
{"__real__", TK_REAL},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
#line 117 "keywords.gperf"
|
||||
{"__gnu_scanf__", TK_GNU_SCANF},
|
||||
{""}, {""}, {""}, {""},
|
||||
#line 48 "keywords.gperf"
|
||||
{"_Alignof", TK_ALIGNOF},
|
||||
{""}, {""}, {""}, {""},
|
||||
#line 156 "keywords.gperf"
|
||||
{"__weak__", TK_WEAK},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
#line 32 "keywords.gperf"
|
||||
{"register", TK_REGISTER},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""},
|
||||
#line 124 "keywords.gperf"
|
||||
{"__leaf__", TK_LEAF},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""},
|
||||
#line 74 "keywords.gperf"
|
||||
{"__label__", TK_LABEL},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""},
|
||||
#line 14 "keywords.gperf"
|
||||
{"break", TK_BREAK}
|
||||
};
|
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||
{
|
||||
register unsigned int key = hash (str, len);
|
||||
|
||||
if (key <= MAX_HASH_VALUE)
|
||||
{
|
||||
register const char *s = wordlist[key].name;
|
||||
|
||||
if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
|
||||
return &wordlist[key];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
343
tool/tags/tags.c
343
tool/tags/tags.c
|
@ -1,343 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/conv/conv.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/bsf.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "o/tool/tags/tags.c.inc"
|
||||
#include "o/tool/tags/tags.h.inc"
|
||||
#include "tool/tags/tags.h"
|
||||
|
||||
static jmp_buf jb;
|
||||
static int g_line;
|
||||
static int g_column;
|
||||
static const char *g_file;
|
||||
static yyParser g_parser[1];
|
||||
|
||||
noreturn static void Error(const char *msg) {
|
||||
fprintf(stderr, "%s:%d:%d: %s\n", g_file, g_line, g_column, msg);
|
||||
longjmp(jb, 1);
|
||||
}
|
||||
|
||||
noreturn static void SyntaxError(void) {
|
||||
Error("SYNTAX ERROR");
|
||||
}
|
||||
|
||||
noreturn static void LexError(void) {
|
||||
Error("LEX ERROR");
|
||||
}
|
||||
|
||||
noreturn static void MissingArgumentError(void) {
|
||||
Error("MISSING ARGUMENT");
|
||||
}
|
||||
|
||||
noreturn static void MissingFunctionError(void) {
|
||||
Error("MISSING FUNCTION");
|
||||
}
|
||||
|
||||
noreturn static void SyscallError(const char *name) {
|
||||
fprintf(stderr, "ERROR: %s[%s]: %d\n", name, g_file, errno);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void ExprsFree(struct Exprs *n) {
|
||||
if (n) {
|
||||
ExprsFree(n->n);
|
||||
free(n);
|
||||
}
|
||||
}
|
||||
|
||||
static struct Exprs *ExprsAppend(struct Exprs *n, long double x) {
|
||||
struct Exprs *a;
|
||||
a = malloc(sizeof(struct Exprs));
|
||||
a->n = n;
|
||||
a->x = x;
|
||||
return a;
|
||||
}
|
||||
|
||||
static long double ParseExpr(struct Token t) {
|
||||
char *ep;
|
||||
ep = t.s + t.n;
|
||||
if (t.s[0] == '0') {
|
||||
return strtoumax(t.s, &ep, 0);
|
||||
} else {
|
||||
return strtod(t.s, &ep);
|
||||
}
|
||||
}
|
||||
|
||||
static long double CallFunction(struct Token fn, struct Exprs *args) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void Tokenize(const char *s, size_t size) {
|
||||
int kw;
|
||||
size_t n;
|
||||
char *se;
|
||||
for (se = s + size; s < se; s += n, ++g_column) {
|
||||
n = 1;
|
||||
switch (*s & 0xff) {
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\v':
|
||||
case '\r':
|
||||
case 0x0C:
|
||||
break;
|
||||
case '\n':
|
||||
++g_line;
|
||||
g_column = 0;
|
||||
break;
|
||||
case 'A' ... 'Z':
|
||||
case 'a' ... 'z':
|
||||
n = strspn(s, "$"
|
||||
"0123456789"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz");
|
||||
if ((kw = GetKeyword(s, n)) != -1) {
|
||||
Parse(g_parser, kw, (struct Token){s, n});
|
||||
} else {
|
||||
Parse(g_parser, TK_SYMBOL, (struct Token){s, n});
|
||||
}
|
||||
break;
|
||||
case '0':
|
||||
n = strspn(s, "xXbB0123456789abcdefABCDEF");
|
||||
Parse(g_parser, TK_I_CONSTANT, (struct Token){s, n});
|
||||
n += strspn(s + n, "LUlu");
|
||||
break;
|
||||
case '1' ... '9':
|
||||
n = strspn(s, "0123456789.");
|
||||
if (s[n] == 'e' || s[n] == 'E') {
|
||||
++n;
|
||||
if (s[n] == '+' || s[n] == '-') ++n;
|
||||
n += strspn(s + n, "0123456789");
|
||||
}
|
||||
Parse(g_parser, memchr(s, '.', n) ? TK_F_CONSTANT : TK_I_CONSTANT,
|
||||
(struct Token){s, n});
|
||||
n += strspn(s + n, "LUlu");
|
||||
break;
|
||||
case ';':
|
||||
Parse(g_parser, TK_SEMI, (struct Token){0, 0});
|
||||
break;
|
||||
case '(':
|
||||
Parse(g_parser, TK_LP, (struct Token){0, 0});
|
||||
break;
|
||||
case ')':
|
||||
Parse(g_parser, TK_RP, (struct Token){0, 0});
|
||||
break;
|
||||
case '[':
|
||||
Parse(g_parser, TK_LSB, (struct Token){0, 0});
|
||||
break;
|
||||
case ']':
|
||||
Parse(g_parser, TK_RSB, (struct Token){0, 0});
|
||||
break;
|
||||
case '{':
|
||||
Parse(g_parser, TK_LCB, (struct Token){0, 0});
|
||||
break;
|
||||
case '}':
|
||||
Parse(g_parser, TK_RCB, (struct Token){0, 0});
|
||||
break;
|
||||
case '?':
|
||||
Parse(g_parser, TK_QUESTION, (struct Token){0, 0});
|
||||
break;
|
||||
case ':':
|
||||
Parse(g_parser, TK_COLON, (struct Token){0, 0});
|
||||
break;
|
||||
case ',':
|
||||
Parse(g_parser, TK_COMMA, (struct Token){0, 0});
|
||||
break;
|
||||
case '^':
|
||||
if (s[1] == '=') {
|
||||
Parse(g_parser, TK_XOR_ASSIGN, (struct Token){0, 0});
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_XOR, (struct Token){0, 0});
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
if (s[1] == '=') {
|
||||
Parse(g_parser, TK_REM_ASSIGN, (struct Token){0, 0});
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_REM, (struct Token){0, 0});
|
||||
}
|
||||
break;
|
||||
case '.':
|
||||
Parse(g_parser, TK_DOT, (struct Token){0, 0});
|
||||
break;
|
||||
case '+':
|
||||
if (s[1] == '=') {
|
||||
Parse(g_parser, TK_ADD_ASSIGN, (struct Token){0, 0});
|
||||
++n;
|
||||
} else if (s[1] == '+') {
|
||||
Parse(g_parser, TK_INC, (struct Token){0, 0});
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_ADD, (struct Token){0, 0});
|
||||
}
|
||||
break;
|
||||
case '-':
|
||||
if (s[1] == '=') {
|
||||
Parse(g_parser, TK_SUB_ASSIGN, (struct Token){0, 0});
|
||||
++n;
|
||||
} else if (s[1] == '-') {
|
||||
Parse(g_parser, TK_DEC, (struct Token){0, 0});
|
||||
++n;
|
||||
} else if (s[1] == '>') {
|
||||
Parse(g_parser, TK_ARROW, (struct Token){0, 0});
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_SUB, (struct Token){0, 0});
|
||||
}
|
||||
break;
|
||||
case '~':
|
||||
Parse(g_parser, TK_TILDE, (struct Token){0, 0});
|
||||
break;
|
||||
case '/':
|
||||
if (s[1] == '=') {
|
||||
Parse(g_parser, TK_DIV_ASSIGN, (struct Token){0, 0});
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_DIV, (struct Token){0, 0});
|
||||
}
|
||||
break;
|
||||
case '*':
|
||||
if (s[1] == '=') {
|
||||
Parse(g_parser, TK_MUL_ASSIGN, (struct Token){0, 0});
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_STAR, (struct Token){0, 0});
|
||||
}
|
||||
break;
|
||||
case '|':
|
||||
if (s[1] == '|') {
|
||||
Parse(g_parser, TK_OR_LOGICAL, (struct Token){0, 0});
|
||||
++n;
|
||||
} else if (s[1] == '=') {
|
||||
Parse(g_parser, TK_OR_ASSIGN, (struct Token){0, 0});
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_OR, (struct Token){0, 0});
|
||||
}
|
||||
break;
|
||||
case '&':
|
||||
if (s[1] == '&') {
|
||||
Parse(g_parser, TK_AND_LOGICAL, (struct Token){0, 0});
|
||||
++n;
|
||||
} else if (s[1] == '=') {
|
||||
Parse(g_parser, TK_AND_ASSIGN, (struct Token){0, 0});
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_AND, (struct Token){0, 0});
|
||||
}
|
||||
break;
|
||||
case '!':
|
||||
if (s[1] == '=') {
|
||||
Parse(g_parser, TK_NOTEQUAL, (struct Token){0, 0});
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_EXCLAIM, (struct Token){0, 0});
|
||||
}
|
||||
break;
|
||||
case '=':
|
||||
if (s[1] == '=') {
|
||||
Parse(g_parser, TK_EQUAL, (struct Token){0, 0});
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_EQ, (struct Token){0, 0});
|
||||
}
|
||||
break;
|
||||
case '>':
|
||||
if (s[1] == '=') {
|
||||
Parse(g_parser, TK_GE, (struct Token){0, 0});
|
||||
++n;
|
||||
} else if (s[1] == '>') {
|
||||
if (s[2] == '=') {
|
||||
Parse(g_parser, TK_SHR_ASSIGN, (struct Token){0, 0});
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_SHR, (struct Token){0, 0});
|
||||
}
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_GT, (struct Token){0, 0});
|
||||
}
|
||||
break;
|
||||
case '<':
|
||||
if (s[1] == '=') {
|
||||
Parse(g_parser, TK_LE, (struct Token){0, 0});
|
||||
++n;
|
||||
} else if (s[1] == '<') {
|
||||
if (s[2] == '=') {
|
||||
Parse(g_parser, TK_SHL_ASSIGN, (struct Token){0, 0});
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_SHL, (struct Token){0, 0});
|
||||
}
|
||||
++n;
|
||||
} else {
|
||||
Parse(g_parser, TK_LT, (struct Token){0, 0});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LexError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i;
|
||||
int ec;
|
||||
int fd;
|
||||
size_t n;
|
||||
char *buf;
|
||||
ssize_t rc;
|
||||
size_t bufcap;
|
||||
bufcap = BIGPAGESIZE;
|
||||
buf = malloc(bufcap);
|
||||
if (!(ec = setjmp(jb))) {
|
||||
for (i = 1; i < argc; ++i) {
|
||||
g_file = argv[i];
|
||||
g_line = 0;
|
||||
g_column = 0;
|
||||
n = 0; /* wut */
|
||||
if ((fd = open(g_file, O_RDONLY)) == -1) SyscallError("open");
|
||||
ParseInit(g_parser);
|
||||
for (;;) {
|
||||
if ((rc = read(fd, buf, bufcap)) == -1) SyscallError("read");
|
||||
if (!(n = rc)) break;
|
||||
Tokenize(buf, n);
|
||||
}
|
||||
close(fd);
|
||||
Parse(g_parser, 0, (struct Token){0, 0});
|
||||
ParseFinalize(g_parser);
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
return ec;
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_TAGS_TAGS_H_
|
||||
#define COSMOPOLITAN_TOOL_TAGS_TAGS_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct Token {
|
||||
const char *s;
|
||||
size_t n;
|
||||
};
|
||||
|
||||
struct Exprs {
|
||||
struct Exprs *n;
|
||||
long double x;
|
||||
};
|
||||
|
||||
static void SyntaxError(void) noreturn;
|
||||
static long double ParseExpr(struct Token);
|
||||
static void ExprsFree(struct Exprs *);
|
||||
static struct Exprs *ExprsAppend(struct Exprs *, long double);
|
||||
static long double CallFunction(struct Token, struct Exprs *);
|
||||
int GetKeyword(const char *, size_t);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_TAGS_TAGS_H_ */
|
|
@ -1,74 +0,0 @@
|
|||
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
|
||||
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
|
||||
|
||||
PKGS += TOOL_TAGS
|
||||
|
||||
TOOL_TAGS = $(TOOL_LIB_A_DEPS) $(TOOL_LIB_A)
|
||||
TOOL_TAGS_A = o/$(MODE)/tool/tags/tags.a
|
||||
TOOL_TAGS_FILES := $(wildcard tool/tags/*)
|
||||
TOOL_TAGS_COMS = $(TOOL_TAGS_OBJS:%.o=%.com)
|
||||
TOOL_TAGS_SRCS = $(filter %.c,$(TOOL_TAGS_FILES))
|
||||
TOOL_TAGS_HDRS = $(filter %.h,$(TOOL_TAGS_FILES))
|
||||
|
||||
TOOL_TAGS_OBJS = \
|
||||
$(TOOL_TAGS_SRCS:%=o/$(MODE)/%.zip.o) \
|
||||
$(TOOL_TAGS_SRCS:%.c=o/$(MODE)/%.o)
|
||||
|
||||
TOOL_TAGS_COMS = \
|
||||
$(TOOL_TAGS_SRCS:%.c=o/$(MODE)/%.com)
|
||||
|
||||
TOOL_TAGS_BINS = \
|
||||
$(TOOL_TAGS_COMS) \
|
||||
$(TOOL_TAGS_COMS:%=%.dbg)
|
||||
|
||||
TOOL_TAGS_CHECKS = \
|
||||
$(TOOL_TAGS_HDRS:%=o/$(MODE)/%.ok)
|
||||
|
||||
TOOL_TAGS_DIRECTDEPS = \
|
||||
LIBC_BITS \
|
||||
LIBC_CALLS \
|
||||
LIBC_CONV \
|
||||
LIBC_LOG \
|
||||
LIBC_FMT \
|
||||
LIBC_MEM \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_STDIO \
|
||||
LIBC_STUBS \
|
||||
LIBC_STR \
|
||||
LIBC_SYSV \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_X \
|
||||
THIRD_PARTY_COMPILER_RT \
|
||||
THIRD_PARTY_DTOA
|
||||
|
||||
TOOL_TAGS_DEPS := \
|
||||
$(call uniq,$(foreach x,$(TOOL_TAGS_DIRECTDEPS),$($(x))))
|
||||
|
||||
$(TOOL_TAGS_A): \
|
||||
tool/tags/ \
|
||||
$(TOOL_TAGS_A).pkg \
|
||||
$(TOOL_TAGS_OBJS)
|
||||
|
||||
$(TOOL_TAGS_A).pkg: \
|
||||
$(TOOL_TAGS_OBJS) \
|
||||
$(foreach x,$(TOOL_TAGS_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
o/tool/tags/tags.h.inc: o/tool/tags/tags.c.inc
|
||||
o/tool/tags/tags.c.inc: \
|
||||
tool/tags/tags.y \
|
||||
$(THIRD_PARTY_LEMON)
|
||||
@$(LEMON) -l -d$(@D) $<
|
||||
|
||||
o/$(MODE)/tool/tags/%.com.dbg: \
|
||||
$(TOOL_TAGS_DEPS) \
|
||||
$(TOOL_TAGS_A) \
|
||||
o/$(MODE)/tool/tags/%.o \
|
||||
$(TOOL_TAGS_A).pkg \
|
||||
$(CRT) \
|
||||
$(APE)
|
||||
@$(APELINK)
|
||||
|
||||
.PHONY: o/$(MODE)/tool/tags
|
||||
o/$(MODE)/tool/tags:
|
||||
# TODO: Why isn't tags.h.inc being generated?
|
436
tool/tags/tags.y
436
tool/tags/tags.y
|
@ -1,436 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
%include {
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "tool/tags/tags.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/math.h"
|
||||
}
|
||||
|
||||
/**
|
||||
* C parser.
|
||||
*
|
||||
* “The grammar of C seems remarkably well-behaved. It is almost
|
||||
* LALR(1). More precisely, the automaton built for C by an LALR(1)
|
||||
* parser generator exhibits only two conflicts: (1) a shift/reduce
|
||||
* conflict caused by dangling else ambiguity and (2) a shift/reduce
|
||||
* conflict caused by the _Atomic( ambiguity. In both cases, the
|
||||
* desired behavior can be obtained by instructing the parser to
|
||||
* prefer shifting.” Quoth Jacques-Henri Jourdan & François Pottier
|
||||
*
|
||||
*/
|
||||
|
||||
%token_prefix TK_
|
||||
%token_type {struct Token}
|
||||
%default_type {struct Token}
|
||||
%syntax_error { SyntaxError(); }
|
||||
|
||||
%token AUTO BREAK CASE CHAR CONST CONTINUE DEFAULT DO DOUBLE ELSE ENUM EXTERN.
|
||||
%token FLOAT FOR GOTO IF INLINE INT LONG REGISTER RESTRICT RETURN SHORT SIGNED.
|
||||
%token SIZEOF STATIC STRUCT SWITCH TYPEDEF UNION UNSIGNED VOID VOLATILE WHILE.
|
||||
%token ALIGNAS ALIGNOF ATOMIC BOOL COMPLEX GENERIC IMAGINARY NORETURN INCLUDE.
|
||||
%token STATIC_ASSERT THREAD_LOCAL ELIF ENDIF IFDEF IFNDEF DEFINE UNDEF PRAGMA.
|
||||
%token LINE ERROR SYMBOL ATTRIBUTE RESTRICT TYPEOF TYPEOF INLINE CONST LABEL.
|
||||
%token FORCE_ALIGN_ARG_POINTER ALWAYS_INLINE GNU_INLINE ALIGNOF ASM AUTO_TYPE.
|
||||
%token BYTE COMPLEX IMAG MAY_ALIAS NORETURN PACKED POINTER PRINTF REAL SCANF.
|
||||
%token STRFMON STRFTIME STRONG TARGET TRANSPARENT_UNION VOLATILE WORD ALIAS.
|
||||
%token ALIGNED ALLOC_ALIGN ALLOC_SIZE ARTIFICIAL ASSUME_ALIGNED COLD.
|
||||
%token CONSTRUCTOR DESTRUCTOR COPY DEPRECATED ERROR WARNING EXTERNALLY_VISIBLE.
|
||||
%token FLATTEN FORMAT GNU_FORMAT GNU_PRINTF GNU_SCANF FORMAT_ARG HOT IFUNC.
|
||||
%token INTERRUPT INTERRUPT_HANDLER NO_CALLER_SAVED_REGISTERS LEAF MALLOC NO_ICF.
|
||||
%token NO_INSTRUMENT_FUNCTION NO_PROFILE_INSTRUMENT_FUNCTION NO_REORDER.
|
||||
%token NO_SANITIZE NO_SANITIZE_ADDRESS NO_ADDRESS_SAFETY_ANALYSIS.
|
||||
%token NO_SANITIZE_THREAD NO_SANITIZE_UNDEFINED NO_SPLIT_STACK NO_STACK_LIMIT.
|
||||
%token NOCLONE NOIPA NONNULL NOPLT NOTHROW OPTIMIZE PURE.
|
||||
%token PATCHABLE_FUNCTION_ENTRY RETURNS_NONNULL RETURNS_TWICE SECTION SENTINEL.
|
||||
%token SIMD TARGET_CLONES UNUSED USED VISIBILITY WARN_UNUSED_RESULT.
|
||||
%token PARAMS_NONNULL WEAK VECTOR_SIZE MS_ABI MODE OPTNONE NODEBUG.
|
||||
|
||||
%left IF.
|
||||
%left ELSE.
|
||||
%right COMMA.
|
||||
%right EQ ADD_ASSIGN SUB_ASSIGN MUL_ASSIGN DIV_ASSIGN REM_ASSIGN.
|
||||
%right SHL_ASSIGN SHR_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN.
|
||||
%right QUESTION COLON.
|
||||
%left OR_LOGICAL.
|
||||
%left AND_LOGICAL.
|
||||
%left OR.
|
||||
%left XOR.
|
||||
%left AND.
|
||||
%left EQUAL NOTEQUAL.
|
||||
%left LT LE GT GE.
|
||||
%left SHL SHR.
|
||||
%left ADD SUB.
|
||||
%left STAR DIV REM.
|
||||
%right TILDE EXCLAIM INC DEC AMP SIZEOF ALIGNOF.
|
||||
%left DOT ARROW LP RP RSB LSB.
|
||||
|
||||
program ::= translation_unit.
|
||||
|
||||
translation_unit ::= external_declaration.
|
||||
translation_unit ::= translation_unit external_declaration.
|
||||
|
||||
external_declaration ::= function_definition.
|
||||
external_declaration ::= declaration.
|
||||
|
||||
function_definition ::= declaration_specifiers declarator declaration_list compound_statement.
|
||||
function_definition ::= declaration_specifiers declarator compound_statement.
|
||||
|
||||
declaration_list ::= declaration.
|
||||
declaration_list ::= declaration_list declaration.
|
||||
|
||||
jump_statement ::= GOTO IDENTIFIER SEMI.
|
||||
jump_statement ::= CONTINUE SEMI.
|
||||
jump_statement ::= BREAK SEMI.
|
||||
jump_statement ::= RETURN SEMI.
|
||||
jump_statement ::= RETURN expression SEMI.
|
||||
|
||||
iteration_statement ::= WHILE LP expression RP statement.
|
||||
iteration_statement ::= DO statement WHILE LP expression RP SEMI.
|
||||
iteration_statement ::= FOR LP expression_statement expression_statement RP statement.
|
||||
iteration_statement ::= FOR LP expression_statement expression_statement expression RP statement.
|
||||
iteration_statement ::= FOR LP declaration expression_statement RP statement.
|
||||
iteration_statement ::= FOR LP declaration expression_statement expression RP statement.
|
||||
|
||||
selection_statement ::= IF LP expression RP statement ELSE statement.
|
||||
selection_statement ::= IF LP expression RP statement.
|
||||
selection_statement ::= SWITCH LP expression RP statement.
|
||||
|
||||
expression_statement ::= SEMI.
|
||||
expression_statement ::= expression SEMI.
|
||||
|
||||
block_item ::= declaration.
|
||||
block_item ::= statement.
|
||||
|
||||
block_item_list ::= block_item.
|
||||
block_item_list ::= block_item_list block_item.
|
||||
|
||||
compound_statement ::= LCB RCB.
|
||||
compound_statement ::= LCB block_item_list RCB.
|
||||
|
||||
labeled_statement ::= IDENTIFIER COLON statement.
|
||||
labeled_statement ::= CASE constant_expression COLON statement.
|
||||
labeled_statement ::= DEFAULT COLON statement.
|
||||
|
||||
statement ::= labeled_statement.
|
||||
statement ::= compound_statement.
|
||||
statement ::= expression_statement.
|
||||
statement ::= selection_statement.
|
||||
statement ::= iteration_statement.
|
||||
statement ::= jump_statement.
|
||||
|
||||
static_assert_declaration ::= STATIC_ASSERT LP constant_expression COMMA STRING_LITERAL RP SEMI.
|
||||
|
||||
designator ::= LSB constant_expression RSB.
|
||||
designator ::= DOT IDENTIFIER.
|
||||
|
||||
designator_list ::= designator.
|
||||
designator_list ::= designator_list designator.
|
||||
|
||||
designation ::= designator_list EQ.
|
||||
|
||||
initializer_list ::= designation initializer.
|
||||
initializer_list ::= initializer.
|
||||
initializer_list ::= initializer_list COMMA designation initializer.
|
||||
initializer_list ::= initializer_list COMMA initializer.
|
||||
|
||||
initializer ::= LCB initializer_list RCB.
|
||||
initializer ::= LCB initializer_list COMMA RCB.
|
||||
initializer ::= assignment_expression.
|
||||
|
||||
direct_abstract_declarator ::= LP abstract_declarator RP.
|
||||
direct_abstract_declarator ::= LSB RSB.
|
||||
direct_abstract_declarator ::= LSB STAR RSB.
|
||||
direct_abstract_declarator ::= LSB STATIC type_qualifier_list assignment_expression RSB.
|
||||
direct_abstract_declarator ::= LSB STATIC assignment_expression RSB.
|
||||
direct_abstract_declarator ::= LSB type_qualifier_list STATIC assignment_expression RSB.
|
||||
direct_abstract_declarator ::= LSB type_qualifier_list assignment_expression RSB.
|
||||
direct_abstract_declarator ::= LSB type_qualifier_list RSB.
|
||||
direct_abstract_declarator ::= LSB assignment_expression RSB.
|
||||
direct_abstract_declarator ::= direct_abstract_declarator LSB RSB.
|
||||
direct_abstract_declarator ::= direct_abstract_declarator LSB STAR RSB.
|
||||
direct_abstract_declarator ::= direct_abstract_declarator LSB STATIC type_qualifier_list assignment_expression RSB.
|
||||
direct_abstract_declarator ::= direct_abstract_declarator LSB STATIC assignment_expression RSB.
|
||||
direct_abstract_declarator ::= direct_abstract_declarator LSB type_qualifier_list assignment_expression RSB.
|
||||
direct_abstract_declarator ::= direct_abstract_declarator LSB type_qualifier_list STATIC assignment_expression RSB.
|
||||
direct_abstract_declarator ::= direct_abstract_declarator LSB type_qualifier_list RSB.
|
||||
direct_abstract_declarator ::= direct_abstract_declarator LSB assignment_expression RSB.
|
||||
direct_abstract_declarator ::= LP RP.
|
||||
direct_abstract_declarator ::= LP parameter_type_list RP.
|
||||
direct_abstract_declarator ::= direct_abstract_declarator LP RP.
|
||||
direct_abstract_declarator ::= direct_abstract_declarator LP parameter_type_list RP.
|
||||
|
||||
abstract_declarator ::= pointer direct_abstract_declarator.
|
||||
abstract_declarator ::= pointer.
|
||||
abstract_declarator ::= direct_abstract_declarator.
|
||||
|
||||
type_name ::= specifier_qualifier_list abstract_declarator.
|
||||
type_name ::= specifier_qualifier_list.
|
||||
|
||||
primary_expression ::= IDENTIFIER.
|
||||
primary_expression ::= constant.
|
||||
primary_expression ::= string.
|
||||
primary_expression ::= LP expression RP.
|
||||
primary_expression ::= generic_selection.
|
||||
|
||||
constant ::= I_CONSTANT.
|
||||
constant ::= F_CONSTANT.
|
||||
constant ::= ENUMERATION_CONSTANT.
|
||||
|
||||
enumeration_constant ::= IDENTIFIER.
|
||||
|
||||
string ::= STRING_LITERAL.
|
||||
string ::= FUNC_NAME.
|
||||
|
||||
generic_selection ::= GENERIC LP assignment_expression COMMA generic_assoc_list RP.
|
||||
|
||||
generic_assoc_list ::= generic_association.
|
||||
generic_assoc_list ::= generic_assoc_list COMMA generic_association.
|
||||
|
||||
generic_association ::= type_name COLON assignment_expression.
|
||||
generic_association ::= DEFAULT COLON assignment_expression.
|
||||
|
||||
postfix_expression ::= primary_expression.
|
||||
postfix_expression ::= postfix_expression LSB expression RSB.
|
||||
postfix_expression ::= postfix_expression LP RP.
|
||||
postfix_expression ::= postfix_expression LP argument_expression_list RP.
|
||||
postfix_expression ::= postfix_expression DOT IDENTIFIER.
|
||||
postfix_expression ::= postfix_expression ARROW IDENTIFIER.
|
||||
postfix_expression ::= postfix_expression INC.
|
||||
postfix_expression ::= postfix_expression DEC.
|
||||
postfix_expression ::= LP type_name RP LCB initializer_list RCB.
|
||||
postfix_expression ::= LP type_name RP LCB initializer_list COMMA RCB.
|
||||
|
||||
argument_expression_list ::= assignment_expression.
|
||||
argument_expression_list ::= argument_expression_list COMMA assignment_expression.
|
||||
|
||||
unary_expression ::= postfix_expression.
|
||||
unary_expression ::= INC unary_expression.
|
||||
unary_expression ::= DEC unary_expression.
|
||||
unary_expression ::= unary_operator cast_expression.
|
||||
unary_expression ::= SIZEOF unary_expression.
|
||||
unary_expression ::= SIZEOF LP type_name RP.
|
||||
unary_expression ::= ALIGNOF LP type_name RP.
|
||||
|
||||
unary_operator ::= AMP.
|
||||
unary_operator ::= STAR.
|
||||
unary_operator ::= ADD.
|
||||
unary_operator ::= SUB.
|
||||
unary_operator ::= TILDE.
|
||||
unary_operator ::= EXCLAIM.
|
||||
|
||||
cast_expression ::= unary_expression.
|
||||
cast_expression ::= LP type_name RP cast_expression.
|
||||
|
||||
multiplicative_expression ::= cast_expression.
|
||||
multiplicative_expression ::= multiplicative_expression STAR cast_expression.
|
||||
multiplicative_expression ::= multiplicative_expression DIV cast_expression.
|
||||
multiplicative_expression ::= multiplicative_expression REM cast_expression.
|
||||
|
||||
additive_expression ::= multiplicative_expression.
|
||||
additive_expression ::= additive_expression ADD multiplicative_expression.
|
||||
additive_expression ::= additive_expression SUB multiplicative_expression.
|
||||
|
||||
shift_expression ::= additive_expression.
|
||||
shift_expression ::= shift_expression SHL additive_expression.
|
||||
shift_expression ::= shift_expression SHR additive_expression.
|
||||
|
||||
relational_expression ::= shift_expression.
|
||||
relational_expression ::= relational_expression LT shift_expression.
|
||||
relational_expression ::= relational_expression GT shift_expression.
|
||||
relational_expression ::= relational_expression LE shift_expression.
|
||||
relational_expression ::= relational_expression GE shift_expression.
|
||||
|
||||
equality_expression ::= relational_expression.
|
||||
equality_expression ::= equality_expression EQUAL relational_expression.
|
||||
equality_expression ::= equality_expression NOTEQUAL relational_expression.
|
||||
|
||||
and_expression ::= equality_expression.
|
||||
and_expression ::= and_expression AMP equality_expression.
|
||||
|
||||
exclusive_or_expression ::= and_expression.
|
||||
exclusive_or_expression ::= exclusive_or_expression XOR and_expression.
|
||||
inclusive_or_expression ::= exclusive_or_expression.
|
||||
inclusive_or_expression ::= inclusive_or_expression OR exclusive_or_expression.
|
||||
|
||||
logical_and_expression ::= inclusive_or_expression.
|
||||
logical_and_expression ::= logical_and_expression AND_LOGICAL inclusive_or_expression.
|
||||
|
||||
logical_or_expression ::= logical_and_expression.
|
||||
logical_or_expression ::= logical_or_expression OR_LOGICAL logical_and_expression.
|
||||
|
||||
conditional_expression ::= logical_or_expression.
|
||||
conditional_expression ::= logical_or_expression QUESTION expression COLON conditional_expression.
|
||||
|
||||
assignment_expression ::= conditional_expression.
|
||||
assignment_expression ::= unary_expression assignment_operator assignment_expression.
|
||||
|
||||
assignment_operator ::= EQ.
|
||||
assignment_operator ::= MUL_ASSIGN.
|
||||
assignment_operator ::= DIV_ASSIGN.
|
||||
assignment_operator ::= REM_ASSIGN.
|
||||
assignment_operator ::= ADD_ASSIGN.
|
||||
assignment_operator ::= SUB_ASSIGN.
|
||||
assignment_operator ::= SHL_ASSIGN.
|
||||
assignment_operator ::= SHR_ASSIGN.
|
||||
assignment_operator ::= AND_ASSIGN.
|
||||
assignment_operator ::= XOR_ASSIGN.
|
||||
assignment_operator ::= OR_ASSIGN.
|
||||
|
||||
expression ::= assignment_expression.
|
||||
expression ::= expression COMMA assignment_expression.
|
||||
|
||||
constant_expression ::= conditional_expression. /* with constraints */
|
||||
|
||||
declaration ::= declaration_specifiers SEMI.
|
||||
declaration ::= declaration_specifiers init_declarator_list SEMI.
|
||||
declaration ::= static_assert_declaration.
|
||||
|
||||
declaration_specifiers ::= storage_class_specifier declaration_specifiers.
|
||||
declaration_specifiers ::= storage_class_specifier.
|
||||
declaration_specifiers ::= type_specifier declaration_specifiers.
|
||||
declaration_specifiers ::= type_specifier.
|
||||
declaration_specifiers ::= type_qualifier declaration_specifiers.
|
||||
declaration_specifiers ::= type_qualifier.
|
||||
declaration_specifiers ::= function_specifier declaration_specifiers.
|
||||
declaration_specifiers ::= function_specifier.
|
||||
declaration_specifiers ::= alignment_specifier declaration_specifiers.
|
||||
declaration_specifiers ::= alignment_specifier.
|
||||
|
||||
init_declarator_list ::= init_declarator.
|
||||
init_declarator_list ::= init_declarator_list COMMA init_declarator.
|
||||
|
||||
init_declarator ::= declarator EQ initializer.
|
||||
init_declarator ::= declarator.
|
||||
|
||||
storage_class_specifier ::= TYPEDEF. /* identifiers must be flagged as TYPEDEF_NAME */
|
||||
storage_class_specifier ::= EXTERN.
|
||||
storage_class_specifier ::= STATIC.
|
||||
storage_class_specifier ::= THREAD_LOCAL.
|
||||
storage_class_specifier ::= AUTO.
|
||||
storage_class_specifier ::= REGISTER.
|
||||
|
||||
type_specifier ::= VOID.
|
||||
type_specifier ::= CHAR.
|
||||
type_specifier ::= SHORT.
|
||||
type_specifier ::= INT.
|
||||
type_specifier ::= LONG.
|
||||
type_specifier ::= FLOAT.
|
||||
type_specifier ::= DOUBLE.
|
||||
type_specifier ::= SIGNED.
|
||||
type_specifier ::= UNSIGNED.
|
||||
type_specifier ::= BOOL.
|
||||
type_specifier ::= COMPLEX.
|
||||
type_specifier ::= IMAGINARY. /* non-mandated extension */
|
||||
type_specifier ::= struct_or_union_specifier.
|
||||
type_specifier ::= enum_specifier.
|
||||
type_specifier ::= TYPEDEF_NAME. /* after it has been defined as such */
|
||||
|
||||
struct_or_union_specifier ::= struct_or_union LCB struct_declaration_list RCB.
|
||||
struct_or_union_specifier ::= struct_or_union IDENTIFIER LCB struct_declaration_list RCB.
|
||||
struct_or_union_specifier ::= struct_or_union IDENTIFIER.
|
||||
|
||||
struct_or_union ::= STRUCT.
|
||||
struct_or_union ::= UNION.
|
||||
|
||||
struct_declaration_list ::= struct_declaration.
|
||||
struct_declaration_list ::= struct_declaration_list struct_declaration.
|
||||
|
||||
struct_declaration ::= specifier_qualifier_list SEMI. /* for anonymous struct/union */
|
||||
struct_declaration ::= specifier_qualifier_list struct_declarator_list SEMI.
|
||||
struct_declaration ::= static_assert_declaration.
|
||||
|
||||
specifier_qualifier_list ::= type_specifier specifier_qualifier_list.
|
||||
specifier_qualifier_list ::= type_specifier.
|
||||
specifier_qualifier_list ::= type_qualifier specifier_qualifier_list.
|
||||
specifier_qualifier_list ::= type_qualifier.
|
||||
|
||||
struct_declarator_list ::= struct_declarator.
|
||||
struct_declarator_list ::= struct_declarator_list COMMA struct_declarator.
|
||||
|
||||
struct_declarator ::= COLON constant_expression.
|
||||
struct_declarator ::= declarator COLON constant_expression.
|
||||
struct_declarator ::= declarator.
|
||||
|
||||
enum_specifier ::= ENUM LCB enumerator_list RCB.
|
||||
enum_specifier ::= ENUM LCB enumerator_list COMMA RCB.
|
||||
enum_specifier ::= ENUM IDENTIFIER LCB enumerator_list RCB.
|
||||
enum_specifier ::= ENUM IDENTIFIER LCB enumerator_list COMMA RCB.
|
||||
enum_specifier ::= ENUM IDENTIFIER.
|
||||
|
||||
enumerator_list ::= enumerator.
|
||||
enumerator_list ::= enumerator_list COMMA enumerator.
|
||||
|
||||
enumerator ::= enumeration_constant EQ constant_expression.
|
||||
enumerator ::= enumeration_constant.
|
||||
|
||||
type_qualifier ::= CONST.
|
||||
type_qualifier ::= RESTRICT.
|
||||
type_qualifier ::= VOLATILE.
|
||||
type_qualifier ::= ATOMIC.
|
||||
|
||||
function_specifier ::= INLINE.
|
||||
function_specifier ::= NORETURN.
|
||||
|
||||
alignment_specifier ::= ALIGNAS LP type_name RP.
|
||||
alignment_specifier ::= ALIGNAS LP constant_expression RP.
|
||||
|
||||
declarator ::= pointer direct_declarator.
|
||||
declarator ::= direct_declarator.
|
||||
|
||||
direct_declarator ::= IDENTIFIER.
|
||||
direct_declarator ::= LP declarator RP.
|
||||
direct_declarator ::= direct_declarator LSB RSB.
|
||||
direct_declarator ::= direct_declarator LSB STAR RSB.
|
||||
direct_declarator ::= direct_declarator LSB STATIC type_qualifier_list assignment_expression RSB.
|
||||
direct_declarator ::= direct_declarator LSB STATIC assignment_expression RSB.
|
||||
direct_declarator ::= direct_declarator LSB type_qualifier_list STAR RSB.
|
||||
direct_declarator ::= direct_declarator LSB type_qualifier_list STATIC assignment_expression RSB.
|
||||
direct_declarator ::= direct_declarator LSB type_qualifier_list assignment_expression RSB.
|
||||
direct_declarator ::= direct_declarator LSB type_qualifier_list RSB.
|
||||
direct_declarator ::= direct_declarator LSB assignment_expression RSB.
|
||||
direct_declarator ::= direct_declarator LP parameter_type_list RP.
|
||||
direct_declarator ::= direct_declarator LP RP.
|
||||
direct_declarator ::= direct_declarator LP identifier_list RP.
|
||||
|
||||
pointer ::= STAR type_qualifier_list pointer.
|
||||
pointer ::= STAR type_qualifier_list.
|
||||
pointer ::= STAR pointer.
|
||||
pointer ::= STAR.
|
||||
|
||||
type_qualifier_list ::= type_qualifier.
|
||||
type_qualifier_list ::= type_qualifier_list type_qualifier.
|
||||
|
||||
parameter_type_list ::= parameter_list COMMA ELLIPSIS.
|
||||
parameter_type_list ::= parameter_list.
|
||||
|
||||
parameter_list ::= parameter_declaration.
|
||||
parameter_list ::= parameter_list COMMA parameter_declaration.
|
||||
|
||||
parameter_declaration ::= declaration_specifiers declarator.
|
||||
parameter_declaration ::= declaration_specifiers abstract_declarator.
|
||||
parameter_declaration ::= declaration_specifiers.
|
||||
|
||||
identifier_list ::= IDENTIFIER.
|
||||
identifier_list ::= identifier_list COMMA IDENTIFIER.
|
|
@ -8,6 +8,4 @@ o/$(MODE)/tool: \
|
|||
o/$(MODE)/tool/decode \
|
||||
o/$(MODE)/tool/hash \
|
||||
o/$(MODE)/tool/net \
|
||||
o/$(MODE)/tool/tags \
|
||||
o/$(MODE)/tool/viz \
|
||||
o/$(MODE)/tool/cc
|
||||
o/$(MODE)/tool/viz
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
int ispipe_;
|
||||
int newlines_;
|
||||
|
||||
noreturn void ShowUsage(FILE *f, int rc) {
|
||||
wontreturn void ShowUsage(FILE *f, int rc) {
|
||||
fputs(program_invocation_name, f);
|
||||
fputs(": [-p] [-n] [FILE...]\n", f);
|
||||
exit(rc);
|
||||
|
|
|
@ -398,8 +398,8 @@ static struct Cell derasterize(unsigned char block[CN][YS * XS]) {
|
|||
static char *RenderImage(char *v, unsigned yn, unsigned xn,
|
||||
const unsigned char srgb[yn][YS][xn][XS][CN]) {
|
||||
unsigned y, x, i, j, k;
|
||||
unsigned char copy[YS][XS][CN] aligned(32);
|
||||
unsigned char block[CN][YS * XS] aligned(32);
|
||||
unsigned char copy[YS][XS][CN] forcealign(32);
|
||||
unsigned char block[CN][YS * XS] forcealign(32);
|
||||
DCHECK_ALIGNED(32, v);
|
||||
DCHECK_ALIGNED(32, srgb);
|
||||
for (y = 0; y < yn; ++y) {
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
|
||||
void double2int(const char *s) {
|
||||
double b64;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
int column_;
|
||||
|
||||
noreturn void usage(int rc, FILE *f) {
|
||||
wontreturn void usage(int rc, FILE *f) {
|
||||
fputs("Usage: ", f);
|
||||
fputs(program_invocation_name, f);
|
||||
fputs(" [-w COLS] [FILE...]\n", f);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "libc/sysv/consts/ex.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "tool/viz/lib/formatstringtable.h"
|
||||
|
||||
|
@ -59,7 +59,7 @@ struct Range r1_ = {LONG_MIN, LONG_MAX};
|
|||
struct Range r2_ = {0, 1};
|
||||
StringTableFormatter *formatter_ = FormatStringTableAsCode;
|
||||
|
||||
static noreturn void PrintUsage(int rc, FILE *f) {
|
||||
static wontreturn void PrintUsage(int rc, FILE *f) {
|
||||
fprintf(f, "Usage: %s%s", program_invocation_name, "\
|
||||
[FLAGS] [FILE]\n\
|
||||
\n\
|
||||
|
@ -95,8 +95,8 @@ static bool StringEquals(const char *a, const char *b) {
|
|||
return strcasecmp(a, b) == 0;
|
||||
}
|
||||
|
||||
static noreturn void ShowInvalidArg(const char *name, const char *s,
|
||||
const char *type) {
|
||||
static wontreturn void ShowInvalidArg(const char *name, const char *s,
|
||||
const char *type) {
|
||||
fprintf(stderr, "error: invalid %s %s: %s\n", type, name, s);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
static FILE *fi_, *fo_;
|
||||
static char *inpath_, *outpath_;
|
||||
|
||||
noreturn void usage(int rc, FILE *f) {
|
||||
wontreturn void usage(int rc, FILE *f) {
|
||||
fprintf(f, "%s%s%s\n", "Usage: ", program_invocation_name,
|
||||
" [-o FILE] [FILE...]\n");
|
||||
exit(rc);
|
||||
|
|
|
@ -19,10 +19,12 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/conv/conv.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "tool/viz/lib/formatstringtable.h"
|
||||
#include "tool/viz/lib/stringbuilder.h"
|
||||
|
||||
|
@ -34,7 +36,9 @@ void *ConvertMatrixToStringTable(long yn, long xn, char *T[yn][xn],
|
|||
assert(yn && xn && !T[0][0]);
|
||||
for (y = 0; y < yn; ++y) {
|
||||
for (x = 0; x < xn; ++x) {
|
||||
T[y][x] = xdtoa(RoundDecimalPlaces(M[y][x], digs, rounder));
|
||||
T[y][x] = xmalloc(40);
|
||||
T[y][x][0] = '\0';
|
||||
g_dfmt_p(T[y][x], &M[y][x], digs, 40, 0);
|
||||
}
|
||||
}
|
||||
return T;
|
||||
|
|
|
@ -48,7 +48,7 @@ TOOL_VIZ_LIB_A_DIRECTDEPS = \
|
|||
LIBC_STR \
|
||||
LIBC_X \
|
||||
THIRD_PARTY_AVIR \
|
||||
THIRD_PARTY_DTOA \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_DLMALLOC
|
||||
|
||||
TOOL_VIZ_LIB_A_DEPS := \
|
||||
|
|
|
@ -668,7 +668,7 @@ static int Write(const char *s) {
|
|||
return write(out, s, strlen(s));
|
||||
}
|
||||
|
||||
static noreturn void PrintUsage(int rc) {
|
||||
static wontreturn void PrintUsage(int rc) {
|
||||
Write("SYNOPSIS\n\n ");
|
||||
Write(program_invocation_name);
|
||||
Write(USAGE);
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "libc/x/x.h"
|
||||
#include "third_party/avir/lanczos1b.h"
|
||||
#include "third_party/avir/lanczos1f.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "third_party/stb/stb_image.h"
|
||||
#include "tool/viz/lib/bilinearscale.h"
|
||||
|
|
|
@ -241,7 +241,7 @@ static void Setup(void) {
|
|||
sigaction(SIGWINCH, &(struct sigaction){.sa_sigaction = OnSigWinch}, NULL);
|
||||
}
|
||||
|
||||
static noreturn void FailPath(const char *s, int rc) {
|
||||
static wontreturn void FailPath(const char *s, int rc) {
|
||||
Write("error: ");
|
||||
Write(s);
|
||||
Write(": ");
|
||||
|
@ -861,7 +861,7 @@ static void MemZoom(void) {
|
|||
} while (!(action & INTERRUPTED));
|
||||
}
|
||||
|
||||
static noreturn void PrintUsage(int rc) {
|
||||
static wontreturn void PrintUsage(int rc) {
|
||||
Write("SYNOPSIS\n\n ");
|
||||
Write(program_invocation_name);
|
||||
Write(USAGE);
|
||||
|
|
|
@ -69,7 +69,7 @@ static struct Flags {
|
|||
enum TtyQuantizationAlgorithm quant;
|
||||
} g_flags;
|
||||
|
||||
static noreturn void PrintUsage(int rc, FILE *f) {
|
||||
static wontreturn void PrintUsage(int rc, FILE *f) {
|
||||
fprintf(f, "Usage: %s%s", program_invocation_name, "\
|
||||
[FLAGS] [PATH]\n\
|
||||
\n\
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/ex.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i;
|
||||
|
|
|
@ -298,9 +298,9 @@ static struct Graphic graphic_[2], *g1_, *g2_;
|
|||
static bool yes_, stats_, dither_, ttymode_, istango_;
|
||||
static long double deadline_, dura_, skip_, starttime_;
|
||||
static long double decode_start_, f1_start_, f2_start_;
|
||||
static bool fullclear_, historyclear_, tuned_, yonly_, gotvideo_;
|
||||
static int16_t pcm_[PLM_AUDIO_SAMPLES_PER_FRAME * 2 / 8][8];
|
||||
static int16_t pcmscale_[PLM_AUDIO_SAMPLES_PER_FRAME * 2 / 8][8];
|
||||
static int16_t pcm_[PLM_AUDIO_SAMPLES_PER_FRAME * 2 / 8][8] aligned(PAGESIZE);
|
||||
static bool fullclear_, historyclear_, tuned_, yonly_, gotvideo_;
|
||||
static int homerow_, lastrow_, playfd_, infd_, outfd_, nullfd_, speakerfails_;
|
||||
static char host_[DNS_NAME_MAX + 1], port_[8], path_[PATH_MAX], status_[7][200],
|
||||
logpath_[PATH_MAX], fifopath_[PATH_MAX], chansstr_[16], sratestr_[16];
|
||||
|
|
|
@ -54,7 +54,7 @@ static size_t linecap_;
|
|||
static char *outpath_, *line_;
|
||||
static bool rawmode_, background_, emphasis_, cleanup_;
|
||||
|
||||
noreturn void usage(int rc, FILE *f) {
|
||||
wontreturn void usage(int rc, FILE *f) {
|
||||
fprintf(f, kUsage, program_invocation_name);
|
||||
exit(rc);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ static struct Lines lines_;
|
|||
static size_t mincol_, col_, maxcol_, linecap_;
|
||||
static char *inpath_, *outpath_, *delim_, *line_;
|
||||
|
||||
noreturn void usage(int rc, FILE *f) {
|
||||
wontreturn void usage(int rc, FILE *f) {
|
||||
fprintf(f, "%s%s%s\n", "Usage: ", program_invocation_name,
|
||||
" [-c] [-m MINCOL] [-M MAXCOL] [-F DELIM] [-o FILE] [FILE...]\n"
|
||||
"\n"
|
||||
|
|
|
@ -54,7 +54,7 @@ TOOL_VIZ_DIRECTDEPS = \
|
|||
THIRD_PARTY_GETOPT \
|
||||
THIRD_PARTY_AVIR \
|
||||
THIRD_PARTY_DLMALLOC \
|
||||
THIRD_PARTY_DTOA \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_STB \
|
||||
THIRD_PARTY_XED \
|
||||
THIRD_PARTY_ZLIB
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue