:: style procedure declarations; remove old parsing code

This commit is contained in:
Ginger Bill
2017-06-28 23:47:06 +01:00
parent 4f28e9e1fb
commit 94afcec757
32 changed files with 956 additions and 1557 deletions
+11 -11
View File
@@ -58,7 +58,7 @@ accept_sizes := [256]u8{
0x34, 0x04, 0x04, 0x04, 0x44, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, // 0xf0-0xff
};
proc encode_rune(r: rune) -> ([4]u8, int) {
encode_rune :: proc(r: rune) -> ([4]u8, int) {
buf: [4]u8;
i := u32(r);
mask: u8 : 0x3f;
@@ -92,8 +92,8 @@ proc encode_rune(r: rune) -> ([4]u8, int) {
return buf, 4;
}
proc decode_rune(s: string) -> (rune, int) #inline { return decode_rune([]u8(s)); }
proc decode_rune(s: []u8) -> (rune, int) {
decode_rune :: proc(s: string) -> (rune, int) #inline { return decode_rune([]u8(s)); }
decode_rune :: proc(s: []u8) -> (rune, int) {
n := len(s);
if n < 1 {
return RUNE_ERROR, 0;
@@ -132,8 +132,8 @@ proc decode_rune(s: []u8) -> (rune, int) {
proc decode_last_rune(s: string) -> (rune, int) #inline { return decode_last_rune([]u8(s)); }
proc decode_last_rune(s: []u8) -> (rune, int) {
decode_last_rune :: proc(s: string) -> (rune, int) #inline { return decode_last_rune([]u8(s)); }
decode_last_rune :: proc(s: []u8) -> (rune, int) {
r: rune;
size: int;
start, end, limit: int;
@@ -171,7 +171,7 @@ proc decode_last_rune(s: []u8) -> (rune, int) {
proc valid_rune(r: rune) -> bool {
valid_rune :: proc(r: rune) -> bool {
if r < 0 {
return false;
} else if SURROGATE_MIN <= r && r <= SURROGATE_MAX {
@@ -182,7 +182,7 @@ proc valid_rune(r: rune) -> bool {
return true;
}
proc valid_string(s: string) -> bool {
valid_string :: proc(s: string) -> bool {
n := len(s);
for i := 0; i < n; {
si := s[i];
@@ -215,10 +215,10 @@ proc valid_string(s: string) -> bool {
return true;
}
proc rune_start(b: u8) -> bool #inline { return b&0xc0 != 0x80; }
rune_start :: proc(b: u8) -> bool #inline { return b&0xc0 != 0x80; }
proc rune_count(s: string) -> int #inline { return rune_count([]u8(s)); }
proc rune_count(s: []u8) -> int {
rune_count :: proc(s: string) -> int #inline { return rune_count([]u8(s)); }
rune_count :: proc(s: []u8) -> int {
count := 0;
n := len(s);
@@ -257,7 +257,7 @@ proc rune_count(s: []u8) -> int {
}
proc rune_size(r: rune) -> int {
rune_size :: proc(r: rune) -> int {
match {
case r < 0: return -1;
case r <= 1<<7 - 1: return 1;