mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 09:17:35 +02:00
Issue #256 - Remove shift instruction
This commit is contained in:
parent
5947c859df
commit
09b6472ce0
1 changed files with 21 additions and 17 deletions
38
runtime.c
38
runtime.c
|
@ -6874,20 +6874,24 @@ void Cyc_io_read_token(void *data, object cont, object port)
|
||||||
// Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
|
// Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
|
||||||
// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
|
// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
|
||||||
static const uint8_t utf8d[] = {
|
static const uint8_t utf8d[] = {
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 00..1f
|
// The first part of the table maps bytes to character classes that
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 20..3f
|
// to reduce the size of the transition table and create bitmasks.
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 40..5f
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 60..7f
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, // 80..9f
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, // a0..bf
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // c0..df
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
|
||||||
0xa,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x4,0x3,0x3, // e0..ef
|
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||||
0xb,0x6,0x6,0x6,0x5,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8, // f0..ff
|
8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
||||||
0x0,0x1,0x2,0x3,0x5,0x8,0x7,0x1,0x1,0x1,0x4,0x6,0x1,0x1,0x1,0x1, // s0..s0
|
10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,1, // s1..s2
|
|
||||||
1,2,1,1,1,1,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1, // s3..s4
|
// The second part is a transition table that maps a combination
|
||||||
1,2,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,3,1,1,1,1,1,1, // s5..s6
|
// of a state of the automaton and a character class to a state.
|
||||||
1,3,1,1,1,1,1,3,1,3,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // s7..s8
|
0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12,
|
||||||
|
12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,
|
||||||
|
12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
|
||||||
|
12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
|
||||||
|
12,36,12,12,12,12,12,12,12,12,12,12,
|
||||||
};
|
};
|
||||||
|
|
||||||
//uint32_t inline
|
//uint32_t inline
|
||||||
|
@ -6898,7 +6902,7 @@ uint32_t Cyc_utf8_decode(uint32_t* state, uint32_t* codep, uint32_t byte) {
|
||||||
(byte & 0x3fu) | (*codep << 6) :
|
(byte & 0x3fu) | (*codep << 6) :
|
||||||
(0xff >> type) & (byte);
|
(0xff >> type) & (byte);
|
||||||
|
|
||||||
*state = utf8d[256 + *state*16 + type];
|
*state = utf8d[256 + *state + type];
|
||||||
return *state;
|
return *state;
|
||||||
}
|
}
|
||||||
// END Bjoern Hoehrmann
|
// END Bjoern Hoehrmann
|
||||||
|
@ -6955,7 +6959,7 @@ uint32_t Cyc_utf8_validate_stream(uint32_t *state, char *str, size_t len) {
|
||||||
// We don't care about the codepoint, so this is
|
// We don't care about the codepoint, so this is
|
||||||
// a simplified version of the decode function.
|
// a simplified version of the decode function.
|
||||||
type = utf8d[(uint8_t)str[i]];
|
type = utf8d[(uint8_t)str[i]];
|
||||||
*state = utf8d[256 + (*state) * 16 + type];
|
*state = utf8d[256 + (*state) + type];
|
||||||
|
|
||||||
if (*state == CYC_UTF8_REJECT)
|
if (*state == CYC_UTF8_REJECT)
|
||||||
break;
|
break;
|
||||||
|
@ -6975,7 +6979,7 @@ uint32_t Cyc_utf8_validate(char *str, size_t len) {
|
||||||
// We don't care about the codepoint, so this is
|
// We don't care about the codepoint, so this is
|
||||||
// a simplified version of the decode function.
|
// a simplified version of the decode function.
|
||||||
type = utf8d[(uint8_t)str[i]];
|
type = utf8d[(uint8_t)str[i]];
|
||||||
state = utf8d[256 + (state) * 16 + type];
|
state = utf8d[256 + (state) + type];
|
||||||
|
|
||||||
if (state == CYC_UTF8_REJECT)
|
if (state == CYC_UTF8_REJECT)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue