// // Copyright (c) 2011-2019 Canonical Ltd// Copyright (c) 2006-2010 Kirill Simonov// // Permission is hereby granted, free of charge, to any person obtaining a copy of// this software and associated documentation files (the "Software"), to deal in// the Software without restriction, including without limitation the rights to// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies// of the Software, and to permit persons to whom the Software is furnished to do// so, subject to the following conditions:// // The above copyright notice and this permission notice shall be included in all// copies or substantial portions of the Software.// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE// SOFTWARE.package yamlconst (// The size of the input raw buffer. input_raw_buffer_size = 512// The size of the input buffer. // It should be possible to decode the whole raw buffer. input_buffer_size = input_raw_buffer_size * 3// The size of the output buffer. output_buffer_size = 128// The size of the output raw buffer. // It should be possible to encode the whole output buffer. output_raw_buffer_size = (output_buffer_size*2 + 2)// The size of other stacks and queues. initial_stack_size = 16 initial_queue_size = 16 initial_string_size = 16)// Check if the character at the specified position is an alphabetical// character, a digit, '_', or '-'.func is_alpha( []byte, int) bool {return [] >= '0' && [] <= '9' || [] >= 'A' && [] <= 'Z' || [] >= 'a' && [] <= 'z' || [] == '_' || [] == '-'}// Check if the character at the specified position is a digit.func is_digit( []byte, int) bool {return [] >= '0' && [] <= '9'}// Get the value of a digit.func as_digit( []byte, int) int {returnint([]) - '0'}// Check if the character at the specified position is a hex-digit.func is_hex( []byte, int) bool {return [] >= '0' && [] <= '9' || [] >= 'A' && [] <= 'F' || [] >= 'a' && [] <= 'f'}// Get the value of a hex-digit.func as_hex( []byte, int) int { := []if >= 'A' && <= 'F' {returnint() - 'A' + 10 }if >= 'a' && <= 'f' {returnint() - 'a' + 10 }returnint() - '0'}// Check if the character is ASCII.func is_ascii( []byte, int) bool {return [] <= 0x7F}// Check if the character at the start of the buffer can be printed unescaped.func is_printable( []byte, int) bool {return (([] == 0x0A) || // . == #x0A ([] >= 0x20 && [] <= 0x7E) || // #x20 <= . <= #x7E ([] == 0xC2 && [+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF ([] > 0xC2 && [] < 0xED) || ([] == 0xED && [+1] < 0xA0) || ([] == 0xEE) || ([] == 0xEF && // #xE000 <= . <= #xFFFD !([+1] == 0xBB && [+2] == 0xBF) && // && . != #xFEFF !([+1] == 0xBF && ([+2] == 0xBE || [+2] == 0xBF))))}// Check if the character at the specified position is NUL.func is_z( []byte, int) bool {return [] == 0x00}// Check if the beginning of the buffer is a BOM.func is_bom( []byte, int) bool {return [0] == 0xEF && [1] == 0xBB && [2] == 0xBF}// Check if the character at the specified position is space.func is_space( []byte, int) bool {return [] == ' '}// Check if the character at the specified position is tab.func is_tab( []byte, int) bool {return [] == '\t'}// Check if the character at the specified position is blank (space or tab).func is_blank( []byte, int) bool {//return is_space(b, i) || is_tab(b, i)return [] == ' ' || [] == '\t'}// Check if the character at the specified position is a line break.func is_break( []byte, int) bool {return ([] == '\r' || // CR (#xD) [] == '\n' || // LF (#xA) [] == 0xC2 && [+1] == 0x85 || // NEL (#x85) [] == 0xE2 && [+1] == 0x80 && [+2] == 0xA8 || // LS (#x2028) [] == 0xE2 && [+1] == 0x80 && [+2] == 0xA9) // PS (#x2029)}func is_crlf( []byte, int) bool {return [] == '\r' && [+1] == '\n'}// Check if the character is a line break or NUL.func is_breakz( []byte, int) bool {//return is_break(b, i) || is_z(b, i)return (// is_break: [] == '\r' || // CR (#xD) [] == '\n' || // LF (#xA) [] == 0xC2 && [+1] == 0x85 || // NEL (#x85) [] == 0xE2 && [+1] == 0x80 && [+2] == 0xA8 || // LS (#x2028) [] == 0xE2 && [+1] == 0x80 && [+2] == 0xA9 || // PS (#x2029)// is_z: [] == 0)}// Check if the character is a line break, space, or NUL.func is_spacez( []byte, int) bool {//return is_space(b, i) || is_breakz(b, i)return (// is_space: [] == ' ' ||// is_breakz: [] == '\r' || // CR (#xD) [] == '\n' || // LF (#xA) [] == 0xC2 && [+1] == 0x85 || // NEL (#x85) [] == 0xE2 && [+1] == 0x80 && [+2] == 0xA8 || // LS (#x2028) [] == 0xE2 && [+1] == 0x80 && [+2] == 0xA9 || // PS (#x2029) [] == 0)}// Check if the character is a line break, space, tab, or NUL.func is_blankz( []byte, int) bool {//return is_blank(b, i) || is_breakz(b, i)return (// is_blank: [] == ' ' || [] == '\t' ||// is_breakz: [] == '\r' || // CR (#xD) [] == '\n' || // LF (#xA) [] == 0xC2 && [+1] == 0x85 || // NEL (#x85) [] == 0xE2 && [+1] == 0x80 && [+2] == 0xA8 || // LS (#x2028) [] == 0xE2 && [+1] == 0x80 && [+2] == 0xA9 || // PS (#x2029) [] == 0)}// Determine the width of the character.func width( byte) int {// Don't replace these by a switch without first // confirming that it is being inlined.if &0x80 == 0x00 {return1 }if &0xE0 == 0xC0 {return2 }if &0xF0 == 0xE0 {return3 }if &0xF8 == 0xF0 {return4 }return0}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.