(parser *yaml_parser_t, token *yaml_token_t, typ yaml_token_type_t)
| 1896 | } |
| 1897 | |
| 1898 | func yaml_parser_scan_anchor(parser *yaml_parser_t, token *yaml_token_t, typ yaml_token_type_t) bool { |
| 1899 | var s []byte |
| 1900 | |
| 1901 | // Eat the indicator character. |
| 1902 | start_mark := parser.mark |
| 1903 | skip(parser) |
| 1904 | |
| 1905 | // Consume the value. |
| 1906 | if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { |
| 1907 | return false |
| 1908 | } |
| 1909 | |
| 1910 | for is_alpha(parser.buffer, parser.buffer_pos) { |
| 1911 | s = read(parser, s) |
| 1912 | if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { |
| 1913 | return false |
| 1914 | } |
| 1915 | } |
| 1916 | |
| 1917 | end_mark := parser.mark |
| 1918 | |
| 1919 | /* |
| 1920 | * Check if length of the anchor is greater than 0 and it is followed by |
| 1921 | * a whitespace character or one of the indicators: |
| 1922 | * |
| 1923 | * '?', ':', ',', ']', '}', '%', '@', '`'. |
| 1924 | */ |
| 1925 | |
| 1926 | if len(s) == 0 || |
| 1927 | !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '?' || |
| 1928 | parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == ',' || |
| 1929 | parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '}' || |
| 1930 | parser.buffer[parser.buffer_pos] == '%' || parser.buffer[parser.buffer_pos] == '@' || |
| 1931 | parser.buffer[parser.buffer_pos] == '`') { |
| 1932 | context := "while scanning an alias" |
| 1933 | if typ == yaml_ANCHOR_TOKEN { |
| 1934 | context = "while scanning an anchor" |
| 1935 | } |
| 1936 | yaml_parser_set_scanner_error(parser, context, start_mark, |
| 1937 | "did not find expected alphabetic or numeric character") |
| 1938 | return false |
| 1939 | } |
| 1940 | |
| 1941 | // Create a token. |
| 1942 | *token = yaml_token_t{ |
| 1943 | typ: typ, |
| 1944 | start_mark: start_mark, |
| 1945 | end_mark: end_mark, |
| 1946 | value: s, |
| 1947 | } |
| 1948 | |
| 1949 | return true |
| 1950 | } |
| 1951 | |
| 1952 | /* |
| 1953 | * Scan a TAG token. |
no test coverage detected