C bootstrap (phases 0-9):
cmd/wwc, cmd/6c, cmd/6a, cmd/6l, cmd/ww, rt, lib/*.
ww-side self-host (phase 10):
selfhost/cmd/wwc — ww-cgen frontend; bootstrap fixed point.
selfhost/cmd/6a — assembler; byte-identical to C 6a (test 991).
selfhost/cmd/6l — linker w/ archive (.a) support; byte-identical
to C 6l (test 992).
selfhost/cmd/ww — driver (build/run/version); byte-identical to
C ww (test 993).
make test: 15/15. make bootstrap: ww2.s == ww3.s, ww2.o == ww3.o,
ww2 == ww3 byte-identical, with the full ww-tooled chain.
32 lines
796 B
C
32 lines
796 B
C
/*
|
|
* lex.c — character-level helpers for 6a's line-oriented parser.
|
|
* The parser itself lives in parse.c; here we keep the tokenisers
|
|
* for identifiers and numbers so parse.c stays focused on syntax.
|
|
*/
|
|
#include "a.h"
|
|
#include <ctype.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
int
|
|
a_isidstart(int c)
|
|
{
|
|
return c == '_' || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
|
|
}
|
|
|
|
int
|
|
a_isidcont(int c)
|
|
{
|
|
return a_isidstart(c) || (c >= '0' && c <= '9') || c == '.';
|
|
}
|
|
|
|
i64
|
|
a_parsenum(const char *s, char **end)
|
|
{
|
|
/* Let strtoll handle the sign itself: hand-stripping '-' then
|
|
* negating the result fails for LLONG_MIN because the positive
|
|
* magnitude (2^63) doesn't fit in long long, strtoll clamps to
|
|
* LLONG_MAX, and the negation lands one short. */
|
|
return (i64)strtoll(s, end, 0);
|
|
}
|