mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 00:55:11 +01:00
Have tokens include explicit link bits
This commit is contained in:
1 parent
cb37a56997
commit
d1c928a1ed
11 files changed
+533
-388
No files matched your search
@@ -17,22 +17,52 @@
|
||||
// ---------------- Tokens
|
||||
|
||||
typedef struct {
|
||||
// The repr is divided as:
|
||||
// - Bits 63 .. 40 (24 bits) is the major value.
|
||||
// - Bits 39 .. 16 (24 bits) is the minor value.
|
||||
// The repr's 64 bits are divided as:
|
||||
//
|
||||
// +-----+-------------+-------+-------------+-----+-----+-----------+
|
||||
// | 1 | 21 | 3 | 21 | 1 | 1 | 16 |
|
||||
// +-----+-------------+-------+-------------+-----+-----+-----------+
|
||||
// [..................value..................] LP LN length
|
||||
// [..0..|.value_major.|.....value_minor.....]
|
||||
// [..0..|.........VBC.........|.....VBD.....]
|
||||
//
|
||||
// The broad divisions are:
|
||||
// - Bits 63 .. 18 (46 bits) is the value.
|
||||
// - Bits 17 .. 16 ( 2 bits) is LP and LN (link_prev and link_next).
|
||||
// - Bits 15 .. 0 (16 bits) is the length.
|
||||
//
|
||||
// The major value is a [Base38](doc/note/base38-and-fourcc.md) value. If
|
||||
// zero (special cased for Wuffs' built-in "base" package) then the minor
|
||||
// value is further sub-divided:
|
||||
// - Bits 39 .. 37 ( 3 bits) is the value_base_category.
|
||||
// - Bits 36 .. 16 (21 bits) is the value_base_detail.
|
||||
// The value bits can be sub-divided in multiple ways:
|
||||
// - Bits 63 .. 63 ( 1 bits) is reserved (a zero bit).
|
||||
// - Bits 62 .. 42 (21 bits) is the value_major.
|
||||
// - Bits 41 .. 18 (24 bits) is the value_minor.
|
||||
// - Bits 62 .. 39 (24 bits) is the VBC (value_base_category).
|
||||
// - Bits 38 .. 18 (21 bits) is the VBD (value_base_detail).
|
||||
//
|
||||
// In particular, at 21 bits, the value_base_detail can hold every valid
|
||||
// Unicode code point.
|
||||
// The value_major is a 21-bit [Base38](doc/note/base38-and-fourcc.md) value.
|
||||
// If all of its bits are zero (special cased for Wuffs' built-in "base"
|
||||
// package) then the value_minor is further sub-divided:
|
||||
// - Bits 41 .. 39 ( 3 bits) is the VBC (value_base_category).
|
||||
// - Bits 38 .. 18 (21 bits) is the VBD (value_base_detail).
|
||||
//
|
||||
// If the major value is non-zero then the minor value has whatever arbitrary
|
||||
// meaning the tokenizer's package assigns to it.
|
||||
// The high 46 bits (bits 63 .. 18) only have VBC and VBD semantics when the
|
||||
// high 22 bits (the value_major) are all zero. An equivalent test is that
|
||||
// the high 25 bits (the notional VBC) has a numerical value less than 8.
|
||||
//
|
||||
// At 21 bits, the VBD can hold every valid Unicode code point.
|
||||
//
|
||||
// If value_major is non-zero then value_minor has whatever arbitrary meaning
|
||||
// the tokenizer's package assigns to it.
|
||||
//
|
||||
// Multiple consecutive tokens can form a larger conceptual unit. For
|
||||
// example, an "abc\tz" string is a single higher level concept but at the
|
||||
// lower level, it could consist of multiple tokens: the quotes '"', the
|
||||
// ASCII texts "abc" and "z" and the backslash-escaped tab '\t'. The LP and
|
||||
// LN (link_prev and link_next) bits denote tokens that are part of a
|
||||
// multi-token chain:
|
||||
// - LP means that this token is not the first (there is a previous token).
|
||||
// - LN means that this token is not the last (there is a next token).
|
||||
//
|
||||
// In particular, a stand-alone token will have both link bits set to zero.
|
||||
uint64_t repr;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -41,6 +71,8 @@ typedef struct {
|
||||
inline uint64_t value_minor() const;
|
||||
inline uint64_t value_base_category() const;
|
||||
inline uint64_t value_base_detail() const;
|
||||
inline bool link_prev() const;
|
||||
inline bool link_next() const;
|
||||
inline uint64_t length() const;
|
||||
#endif // __cplusplus
|
||||
|
||||
@@ -55,20 +87,25 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE__MASK 0xFFFFFFFFFFFF
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MAJOR__MASK 0xFFFFFF
|
||||
#define WUFFS_BASE__TOKEN__VALUE__MASK 0x3FFFFFFFFFFF
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MAJOR__MASK 0x3FFFFF
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MINOR__MASK 0xFFFFFF
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__MASK 0x7FFFFFF
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__MASK 0x1FFFFFF
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__MASK 0x1FFFFF
|
||||
#define WUFFS_BASE__TOKEN__LINK__MASK 0x3
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__MASK 0xFFFF
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE__SHIFT 16
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT 40
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT 16
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT 37
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT 16
|
||||
#define WUFFS_BASE__TOKEN__VALUE__SHIFT 18
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT 42
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT 18
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT 39
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT 18
|
||||
#define WUFFS_BASE__TOKEN__LINK__SHIFT 16
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__SHIFT 0
|
||||
|
||||
#define WUFFS_BASE__TOKEN__LINK_PREV 0x20000
|
||||
#define WUFFS_BASE__TOKEN__LINK_NEXT 0x10000
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBC__FILLER 0
|
||||
@@ -77,41 +114,19 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
#define WUFFS_BASE__TOKEN__VBC__NUMBER 3
|
||||
#define WUFFS_BASE__TOKEN__VBC__STRUCTURE 4
|
||||
|
||||
// --------
|
||||
// --------
|
||||
|
||||
// INCOMPLETE means that this token combines with the following token.
|
||||
//
|
||||
// For example, tokenizing a comment that is longer than the source buffer can
|
||||
// result in multiple VBC__FILLER tokens. All but the last one is INCOMPLETE.
|
||||
//
|
||||
// By convention, whitespace is not marked incomplete. Two whitespace tokens of
|
||||
// length 30 are equivalent to one whitespace token of length 60.
|
||||
//
|
||||
// Bits 0x2, 0x4 and 0x8 are reserved for flags that are common between
|
||||
// VBD_FILLER and VBD_STRING.
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__INCOMPLETE 0x00001
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__END_OF_CONSECUTIVE_COMMENTS 0x00010
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_LINE 0x00020
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_BLOCK 0x00040
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_LINE 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_BLOCK 0x00002
|
||||
|
||||
// --------
|
||||
|
||||
// INCOMPLETE means that this token combines with the following token.
|
||||
//
|
||||
// For example, tokenizing a string that is longer than the source buffer can
|
||||
// result in multiple VBC__STRING tokens. All but the last one is INCOMPLETE.
|
||||
//
|
||||
// Bits 0x2, 0x4 and 0x8 are reserved for flags that are common between
|
||||
// VBD_FILLER and VBD_STRING.
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__INCOMPLETE 0x00001
|
||||
|
||||
// "DEFINITELY_FOO" means that the source bytes (and also the destination
|
||||
// bytes, assuming 1_DST_1_SRC_COPY) are in the FOO format. Definitely means
|
||||
// that the lack of the bit is conservative: it is valid for all-ASCII strings
|
||||
// to have neither DEFINITELY_ASCII or DEFINITELY_UTF_8 bits set.
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_ASCII 0x00010
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_UTF_8 0x00020
|
||||
// "DEFINITELY_FOO" means that the destination bytes (and also the source
|
||||
// bytes, for 1_DST_1_SRC_COPY) are in the FOO format. Definitely means that
|
||||
// the lack of the bit is conservative: it is valid for all-ASCII strings to
|
||||
// have neither DEFINITELY_UTF_8 or DEFINITELY_ASCII bits set.
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_UTF_8 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_ASCII 0x00002
|
||||
|
||||
// "CONVERT_D_DST_S_SRC" means that multiples of S source bytes (possibly
|
||||
// padded) produces multiples of D destination bytes. For example,
|
||||
@@ -121,21 +136,13 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
// When src is the empty string, multiple conversion algorithms are applicable
|
||||
// (so these bits are not necessarily mutually exclusive), all producing the
|
||||
// same empty dst string.
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_0_DST_1_SRC_DROP 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_1_SRC_COPY 0x00200
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_2_SRC_HEXADECIMAL 0x00400
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_4_SRC_BACKSLASH_X 0x00800
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_STD 0x01000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_URL 0x02000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_4_DST_5_SRC_ASCII_85 0x04000
|
||||
|
||||
// --------
|
||||
|
||||
// UNICODE_CODE_POINT tokens have no room in their VBD for an INCOMPLETE bit.
|
||||
// All 21 bits are used to hold the Unicode code point. Such tokens preserve
|
||||
// the INCOMPLETEness of the previous token (if a FILLER or STRING).
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__UNICODE_CODE_POINT__MAX_INCL 0x10FFFF
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_0_DST_1_SRC_DROP 0x00010
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_1_SRC_COPY 0x00020
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_2_SRC_HEXADECIMAL 0x00040
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_4_SRC_BACKSLASH_X 0x00080
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_STD 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_URL 0x00200
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_4_DST_5_SRC_ASCII_85 0x00400
|
||||
|
||||
// --------
|
||||
|
||||
@@ -201,6 +208,16 @@ wuffs_base__token__value_base_detail(const wuffs_base__token* t) {
|
||||
WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__MASK;
|
||||
}
|
||||
|
||||
static inline bool //
|
||||
wuffs_base__token__link_prev(const wuffs_base__token* t) {
|
||||
return t->repr & WUFFS_BASE__TOKEN__LINK_PREV;
|
||||
}
|
||||
|
||||
static inline bool //
|
||||
wuffs_base__token__link_next(const wuffs_base__token* t) {
|
||||
return t->repr & WUFFS_BASE__TOKEN__LINK_NEXT;
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
wuffs_base__token__length(const wuffs_base__token* t) {
|
||||
return (t->repr >> WUFFS_BASE__TOKEN__LENGTH__SHIFT) &
|
||||
@@ -234,6 +251,16 @@ wuffs_base__token::value_base_detail() const {
|
||||
return wuffs_base__token__value_base_detail(this);
|
||||
}
|
||||
|
||||
inline bool //
|
||||
wuffs_base__token::link_prev() const {
|
||||
return wuffs_base__token__link_prev(this);
|
||||
}
|
||||
|
||||
inline bool //
|
||||
wuffs_base__token::link_next() const {
|
||||
return wuffs_base__token__link_next(this);
|
||||
}
|
||||
|
||||
inline uint64_t //
|
||||
wuffs_base__token::length() const {
|
||||
return wuffs_base__token__length(this);
|
||||
|
||||
@@ -325,11 +325,27 @@ func (g *gen) writeBuiltinIOWriter(b *buffer, recv *a.Expr, method t.ID, args []
|
||||
func (g *gen) writeBuiltinTokenWriter(b *buffer, recv *a.Expr, method t.ID, args []*a.Node, depth uint32) error {
|
||||
if method == t.IDWriteFastToken {
|
||||
b.printf("*iop_a_dst++ = wuffs_base__make_token((((uint64_t)(")
|
||||
if err := g.writeExpr(b, args[0].AsArg().Value(), depth); err != nil {
|
||||
|
||||
if cv := args[0].AsArg().Value().ConstValue(); (cv == nil) || (cv.Sign() != 0) {
|
||||
if err := g.writeExpr(b, args[0].AsArg().Value(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes(")) << WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT) | (((uint64_t)(")
|
||||
}
|
||||
|
||||
if err := g.writeExpr(b, args[1].AsArg().Value(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes(")) << WUFFS_BASE__TOKEN__VALUE__SHIFT) | (((uint64_t)(")
|
||||
if err := g.writeExpr(b, args[1].AsArg().Value(), depth); err != nil {
|
||||
b.writes(")) << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) | (((uint64_t)(")
|
||||
|
||||
if cv := args[2].AsArg().Value().ConstValue(); (cv == nil) || (cv.Sign() != 0) {
|
||||
if err := g.writeExpr(b, args[2].AsArg().Value(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes(")) << WUFFS_BASE__TOKEN__LINK__SHIFT) | (((uint64_t)(")
|
||||
}
|
||||
|
||||
if err := g.writeExpr(b, args[3].AsArg().Value(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes(")) << WUFFS_BASE__TOKEN__LENGTH__SHIFT))")
|
||||
@@ -699,7 +715,7 @@ func (g *gen) writeBuiltinQuestionCall(b *buffer, n *a.Expr, depth uint32) error
|
||||
if err := g.writeExpr(b, n.Args()[0].AsArg().Value(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes(")) << WUFFS_BASE__TOKEN__VALUE__SHIFT) | (((uint64_t)(")
|
||||
b.writes(")) << WUFFS_BASE__TOKEN__VLL__SHIFT) | (((uint64_t)(")
|
||||
if err := g.writeExpr(b, n.Args()[1].AsArg().Value(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+10
-10
@@ -308,26 +308,26 @@ const baseTokenPrivateH = "" +
|
||||
""
|
||||
|
||||
const baseTokenPublicH = "" +
|
||||
"// ---------------- Tokens\n\ntypedef struct {\n // The repr is divided as:\n // - Bits 63 .. 40 (24 bits) is the major value.\n // - Bits 39 .. 16 (24 bits) is the minor value.\n // - Bits 15 .. 0 (16 bits) is the length.\n //\n // The major value is a [Base38](doc/note/base38-and-fourcc.md) value. If\n // zero (special cased for Wuffs' built-in \"base\" package) then the minor\n // value is further sub-divided:\n // - Bits 39 .. 37 ( 3 bits) is the value_base_category.\n // - Bits 36 .. 16 (21 bits) is the value_base_detail.\n //\n // In particular, at 21 bits, the value_base_detail can hold every valid\n // Unicode code point.\n //\n // If the major value is non-zero then the minor value has whatever arbitrary\n // meaning the tokenizer's package assigns to it.\n uint64_t repr;\n\n#ifdef __cplusplus\n inline uint64_t value() const;\n inline uint64_t value_major() const;\n inline uint64_t value_minor() const;\n inline uint64_t value_base_category() const;\n inline uint64_t value_base_detail() const;\n inlin" +
|
||||
"e uint64_t length() const;\n#endif // __cplusplus\n\n} wuffs_base__token;\n\nstatic inline wuffs_base__token //\nwuffs_base__make_token(uint64_t repr) {\n wuffs_base__token ret;\n ret.repr = repr;\n return ret;\n}\n\n " +
|
||||
"// ---------------- Tokens\n\ntypedef struct {\n // The repr's 64 bits are divided as:\n //\n // +-----+-------------+-------+-------------+-----+-----+-----------+\n // | 1 | 21 | 3 | 21 | 1 | 1 | 16 |\n // +-----+-------------+-------+-------------+-----+-----+-----------+\n // [..................value..................] LP LN length\n // [..0..|.value_major.|.....value_minor.....]\n // [..0..|.........VBC.........|.....VBD.....]\n //\n // The broad divisions are:\n // - Bits 63 .. 18 (46 bits) is the value.\n // - Bits 17 .. 16 ( 2 bits) is LP and LN (link_prev and link_next).\n // - Bits 15 .. 0 (16 bits) is the length.\n //\n // The value bits can be sub-divided in multiple ways:\n // - Bits 63 .. 63 ( 1 bits) is reserved (a zero bit).\n // - Bits 62 .. 42 (21 bits) is the value_major.\n // - Bits 41 .. 18 (24 bits) is the value_minor.\n // - Bits 62 .. 39 (24 bits) is the VBC (value_base_category).\n // - Bits 38 .. 18 (21 bits) is the VBD (value_base_de" +
|
||||
"tail).\n //\n // The value_major is a 21-bit [Base38](doc/note/base38-and-fourcc.md) value.\n // If all of its bits are zero (special cased for Wuffs' built-in \"base\"\n // package) then the value_minor is further sub-divided:\n // - Bits 41 .. 39 ( 3 bits) is the VBC (value_base_category).\n // - Bits 38 .. 18 (21 bits) is the VBD (value_base_detail).\n //\n // The high 46 bits (bits 63 .. 18) only have VBC and VBD semantics when the\n // high 22 bits (the value_major) are all zero. An equivalent test is that\n // the high 25 bits (the notional VBC) has a numerical value less than 8.\n //\n // At 21 bits, the VBD can hold every valid Unicode code point.\n //\n // If value_major is non-zero then value_minor has whatever arbitrary meaning\n // the tokenizer's package assigns to it.\n //\n // Multiple consecutive tokens can form a larger conceptual unit. For\n // example, an \"abc\\tz\" string is a single higher level concept but at the\n // lower level, it could consist of multiple tokens: the quotes '\"', the\n " +
|
||||
"// ASCII texts \"abc\" and \"z\" and the backslash-escaped tab '\\t'. The LP and\n // LN (link_prev and link_next) bits denote tokens that are part of a\n // multi-token chain:\n // - LP means that this token is not the first (there is a previous token).\n // - LN means that this token is not the last (there is a next token).\n //\n // In particular, a stand-alone token will have both link bits set to zero.\n uint64_t repr;\n\n#ifdef __cplusplus\n inline uint64_t value() const;\n inline uint64_t value_major() const;\n inline uint64_t value_minor() const;\n inline uint64_t value_base_category() const;\n inline uint64_t value_base_detail() const;\n inline bool link_prev() const;\n inline bool link_next() const;\n inline uint64_t length() const;\n#endif // __cplusplus\n\n} wuffs_base__token;\n\nstatic inline wuffs_base__token //\nwuffs_base__make_token(uint64_t repr) {\n wuffs_base__token ret;\n ret.repr = repr;\n return ret;\n}\n\n " +
|
||||
"" +
|
||||
"// --------\n\n#define WUFFS_BASE__TOKEN__VALUE__MASK 0xFFFFFFFFFFFF\n#define WUFFS_BASE__TOKEN__VALUE_MAJOR__MASK 0xFFFFFF\n#define WUFFS_BASE__TOKEN__VALUE_MINOR__MASK 0xFFFFFF\n#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__MASK 0x7FFFFFF\n#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__MASK 0x1FFFFF\n#define WUFFS_BASE__TOKEN__LENGTH__MASK 0xFFFF\n\n#define WUFFS_BASE__TOKEN__VALUE__SHIFT 16\n#define WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT 40\n#define WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT 16\n#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT 37\n#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT 16\n#define WUFFS_BASE__TOKEN__LENGTH__SHIFT 0\n\n " +
|
||||
"// --------\n\n#define WUFFS_BASE__TOKEN__VALUE__MASK 0x3FFFFFFFFFFF\n#define WUFFS_BASE__TOKEN__VALUE_MAJOR__MASK 0x3FFFFF\n#define WUFFS_BASE__TOKEN__VALUE_MINOR__MASK 0xFFFFFF\n#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__MASK 0x1FFFFFF\n#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__MASK 0x1FFFFF\n#define WUFFS_BASE__TOKEN__LINK__MASK 0x3\n#define WUFFS_BASE__TOKEN__LENGTH__MASK 0xFFFF\n\n#define WUFFS_BASE__TOKEN__VALUE__SHIFT 18\n#define WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT 42\n#define WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT 18\n#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT 39\n#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT 18\n#define WUFFS_BASE__TOKEN__LINK__SHIFT 16\n#define WUFFS_BASE__TOKEN__LENGTH__SHIFT 0\n\n#define WUFFS_BASE__TOKEN__LINK_PREV 0x20000\n#define WUFFS_BASE__TOKEN__LINK_NEXT 0x10000\n\n " +
|
||||
"" +
|
||||
"// --------\n\n#define WUFFS_BASE__TOKEN__VBC__FILLER 0\n#define WUFFS_BASE__TOKEN__VBC__STRING 1\n#define WUFFS_BASE__TOKEN__VBC__UNICODE_CODE_POINT 2\n#define WUFFS_BASE__TOKEN__VBC__NUMBER 3\n#define WUFFS_BASE__TOKEN__VBC__STRUCTURE 4\n\n" +
|
||||
"// --------\n\n#define WUFFS_BASE__TOKEN__VBC__FILLER 0\n#define WUFFS_BASE__TOKEN__VBC__STRING 1\n#define WUFFS_BASE__TOKEN__VBC__UNICODE_CODE_POINT 2\n#define WUFFS_BASE__TOKEN__VBC__NUMBER 3\n#define WUFFS_BASE__TOKEN__VBC__STRUCTURE 4\n\n " +
|
||||
"" +
|
||||
"// --------\n\n// INCOMPLETE means that this token combines with the following token.\n//\n// For example, tokenizing a comment that is longer than the source buffer can\n// result in multiple VBC__FILLER tokens. All but the last one is INCOMPLETE.\n//\n// By convention, whitespace is not marked incomplete. Two whitespace tokens of\n// length 30 are equivalent to one whitespace token of length 60.\n//\n// Bits 0x2, 0x4 and 0x8 are reserved for flags that are common between\n// VBD_FILLER and VBD_STRING.\n#define WUFFS_BASE__TOKEN__VBD__FILLER__INCOMPLETE 0x00001\n\n#define WUFFS_BASE__TOKEN__VBD__FILLER__END_OF_CONSECUTIVE_COMMENTS 0x00010\n#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_LINE 0x00020\n#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_BLOCK 0x00040\n\n" +
|
||||
"// --------\n\n#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_LINE 0x00001\n#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_BLOCK 0x00002\n\n" +
|
||||
"" +
|
||||
"// --------\n\n// INCOMPLETE means that this token combines with the following token.\n//\n// For example, tokenizing a string that is longer than the source buffer can\n// result in multiple VBC__STRING tokens. All but the last one is INCOMPLETE.\n//\n// Bits 0x2, 0x4 and 0x8 are reserved for flags that are common between\n// VBD_FILLER and VBD_STRING.\n#define WUFFS_BASE__TOKEN__VBD__STRING__INCOMPLETE 0x00001\n\n// \"DEFINITELY_FOO\" means that the source bytes (and also the destination\n// bytes, assuming 1_DST_1_SRC_COPY) are in the FOO format. Definitely means\n// that the lack of the bit is conservative: it is valid for all-ASCII strings\n// to have neither DEFINITELY_ASCII or DEFINITELY_UTF_8 bits set.\n#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_ASCII 0x00010\n#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_UTF_8 0x00020\n\n// \"CONVERT_D_DST_S_SRC\" means that multiples of S source bytes (possibly\n// padded) produces multiples of D destination bytes. For example,\n// CONVERT_1_DST_4_SRC_BACKSLASH_X means a sourc" +
|
||||
"e like \"\\\\x23\\\\x67\\\\xAB\", where\n// 12 src bytes encode 3 dst bytes.\n//\n// When src is the empty string, multiple conversion algorithms are applicable\n// (so these bits are not necessarily mutually exclusive), all producing the\n// same empty dst string.\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_0_DST_1_SRC_DROP 0x00100\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_1_SRC_COPY 0x00200\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_2_SRC_HEXADECIMAL 0x00400\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_4_SRC_BACKSLASH_X 0x00800\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_STD 0x01000\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_URL 0x02000\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_4_DST_5_SRC_ASCII_85 0x04000\n\n " +
|
||||
"" +
|
||||
"// --------\n\n // UNICODE_CODE_POINT tokens have no room in their VBD for an INCOMPLETE bit.\n // All 21 bits are used to hold the Unicode code point. Such tokens preserve\n // the INCOMPLETEness of the previous token (if a FILLER or STRING).\n\n#define WUFFS_BASE__TOKEN__VBD__UNICODE_CODE_POINT__MAX_INCL 0x10FFFF\n\n " +
|
||||
"// --------\n\n// \"DEFINITELY_FOO\" means that the destination bytes (and also the source\n// bytes, for 1_DST_1_SRC_COPY) are in the FOO format. Definitely means that\n// the lack of the bit is conservative: it is valid for all-ASCII strings to\n// have neither DEFINITELY_UTF_8 or DEFINITELY_ASCII bits set.\n#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_UTF_8 0x00001\n#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_ASCII 0x00002\n\n// \"CONVERT_D_DST_S_SRC\" means that multiples of S source bytes (possibly\n// padded) produces multiples of D destination bytes. For example,\n// CONVERT_1_DST_4_SRC_BACKSLASH_X means a source like \"\\\\x23\\\\x67\\\\xAB\", where\n// 12 src bytes encode 3 dst bytes.\n//\n// When src is the empty string, multiple conversion algorithms are applicable\n// (so these bits are not necessarily mutually exclusive), all producing the\n// same empty dst string.\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_0_DST_1_SRC_DROP 0x00010\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_1_SRC_COPY 0x00020\n#" +
|
||||
"define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_2_SRC_HEXADECIMAL 0x00040\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_4_SRC_BACKSLASH_X 0x00080\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_STD 0x00100\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_URL 0x00200\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_4_DST_5_SRC_ASCII_85 0x00400\n\n " +
|
||||
"" +
|
||||
"// --------\n\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__LITERAL 0x00001\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__LITERAL__UNDEFINED 0x00101\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__LITERAL__NULL 0x00201\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__LITERAL__FALSE 0x00401\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__LITERAL__TRUE 0x00801\n\n// For a source string of \"123\" or \"0x9A\", it is valid for a tokenizer to\n// return any one of:\n// - WUFFS_BASE__TOKEN__VBD__NUMBER__FLOATING_POINT.\n// - WUFFS_BASE__TOKEN__VBD__NUMBER__INTEGER_SIGNED.\n// - WUFFS_BASE__TOKEN__VBD__NUMBER__INTEGER_UNSIGNED.\n//\n// For a source string of \"+123\" or \"-0x9A\", only the first two are valid.\n//\n// For a source string of \"123.\", only the first one is valid.\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__FLOATING_POINT 0x00002\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__INTEGER_SIGNED 0x00004\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__INTEGER_UNSIGNED 0x00008\n\n " +
|
||||
"" +
|
||||
"// --------\n\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__PUSH 0x00001\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__POP 0x00002\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_NONE 0x00010\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_LIST 0x00020\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_DICT 0x00040\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_NONE 0x01000\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_LIST 0x02000\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_DICT 0x04000\n\n" +
|
||||
"" +
|
||||
"// --------\n\nstatic inline uint64_t //\nwuffs_base__token__value(const wuffs_base__token* t) {\n return (t->repr >> WUFFS_BASE__TOKEN__VALUE__SHIFT) &\n WUFFS_BASE__TOKEN__VALUE__MASK;\n}\n\nstatic inline uint64_t //\nwuffs_base__token__value_major(const wuffs_base__token* t) {\n return (t->repr >> WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT) &\n WUFFS_BASE__TOKEN__VALUE_MAJOR__MASK;\n}\n\nstatic inline uint64_t //\nwuffs_base__token__value_minor(const wuffs_base__token* t) {\n return (t->repr >> WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) &\n WUFFS_BASE__TOKEN__VALUE_MINOR__MASK;\n}\n\nstatic inline uint64_t //\nwuffs_base__token__value_base_category(const wuffs_base__token* t) {\n return (t->repr >> WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT) &\n WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__MASK;\n}\n\nstatic inline uint64_t //\nwuffs_base__token__value_base_detail(const wuffs_base__token* t) {\n return (t->repr >> WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT) &\n WUFFS_BASE__TOKEN__VALUE_BASE_DETA" +
|
||||
"IL__MASK;\n}\n\nstatic inline uint64_t //\nwuffs_base__token__length(const wuffs_base__token* t) {\n return (t->repr >> WUFFS_BASE__TOKEN__LENGTH__SHIFT) &\n WUFFS_BASE__TOKEN__LENGTH__MASK;\n}\n\n#ifdef __cplusplus\n\ninline uint64_t //\nwuffs_base__token::value() const {\n return wuffs_base__token__value(this);\n}\n\ninline uint64_t //\nwuffs_base__token::value_major() const {\n return wuffs_base__token__value_major(this);\n}\n\ninline uint64_t //\nwuffs_base__token::value_minor() const {\n return wuffs_base__token__value_minor(this);\n}\n\ninline uint64_t //\nwuffs_base__token::value_base_category() const {\n return wuffs_base__token__value_base_category(this);\n}\n\ninline uint64_t //\nwuffs_base__token::value_base_detail() const {\n return wuffs_base__token__value_base_detail(this);\n}\n\ninline uint64_t //\nwuffs_base__token::length() const {\n return wuffs_base__token__length(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"IL__MASK;\n}\n\nstatic inline bool //\nwuffs_base__token__link_prev(const wuffs_base__token* t) {\n return t->repr & WUFFS_BASE__TOKEN__LINK_PREV;\n}\n\nstatic inline bool //\nwuffs_base__token__link_next(const wuffs_base__token* t) {\n return t->repr & WUFFS_BASE__TOKEN__LINK_NEXT;\n}\n\nstatic inline uint64_t //\nwuffs_base__token__length(const wuffs_base__token* t) {\n return (t->repr >> WUFFS_BASE__TOKEN__LENGTH__SHIFT) &\n WUFFS_BASE__TOKEN__LENGTH__MASK;\n}\n\n#ifdef __cplusplus\n\ninline uint64_t //\nwuffs_base__token::value() const {\n return wuffs_base__token__value(this);\n}\n\ninline uint64_t //\nwuffs_base__token::value_major() const {\n return wuffs_base__token__value_major(this);\n}\n\ninline uint64_t //\nwuffs_base__token::value_minor() const {\n return wuffs_base__token__value_minor(this);\n}\n\ninline uint64_t //\nwuffs_base__token::value_base_category() const {\n return wuffs_base__token__value_base_category(this);\n}\n\ninline uint64_t //\nwuffs_base__token::value_base_detail() const {\n return wuffs_base__to" +
|
||||
"ken__value_base_detail(this);\n}\n\ninline bool //\nwuffs_base__token::link_prev() const {\n return wuffs_base__token__link_prev(this);\n}\n\ninline bool //\nwuffs_base__token::link_next() const {\n return wuffs_base__token__link_next(this);\n}\n\ninline uint64_t //\nwuffs_base__token::length() const {\n return wuffs_base__token__length(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"" +
|
||||
"// --------\n\ntypedef WUFFS_BASE__SLICE(wuffs_base__token) wuffs_base__slice_token;\n\nstatic inline wuffs_base__slice_token //\nwuffs_base__make_slice_token(wuffs_base__token* ptr, size_t len) {\n wuffs_base__slice_token ret;\n ret.ptr = ptr;\n ret.len = len;\n return ret;\n}\n\n" +
|
||||
"" +
|
||||
|
||||
Reference in new issue
Block a user