Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse: error.UnexpectedToken when parsing document markers #32

Open
perillo opened this issue Nov 21, 2023 · 0 comments
Open

parse: error.UnexpectedToken when parsing document markers #32

perillo opened this issue Nov 21, 2023 · 0 comments

Comments

@perillo
Copy link
Contributor

perillo commented Nov 21, 2023

This example is from https://yaml.org/spec/1.2.2/#document-markers, example 9.2 "Document Markers":

%YAML 1.2
---
Document
... # Suffix

This is the output:

debug(tokenizer): Tokenizer.Token{ .id = Tokenizer.Token.Id.literal, .start = 0, .end = 5 }
debug(tokenizer):     | %YAML
debug(tokenizer): Tokenizer.Token{ .id = Tokenizer.Token.Id.space, .start = 5, .end = 6 }
debug(tokenizer):     |  
debug(tokenizer): Tokenizer.Token{ .id = Tokenizer.Token.Id.literal, .start = 6, .end = 9 }
debug(tokenizer):     | 1.2
debug(tokenizer): Tokenizer.Token{ .id = Tokenizer.Token.Id.new_line, .start = 9, .end = 10 }
debug(tokenizer):     | 

debug(tokenizer): Tokenizer.Token{ .id = Tokenizer.Token.Id.doc_start, .start = 10, .end = 13 }
debug(tokenizer):     | ---
debug(tokenizer): Tokenizer.Token{ .id = Tokenizer.Token.Id.new_line, .start = 13, .end = 14 }
debug(tokenizer):     | 

debug(tokenizer): Tokenizer.Token{ .id = Tokenizer.Token.Id.literal, .start = 14, .end = 22 }
debug(tokenizer):     | Document
debug(tokenizer): Tokenizer.Token{ .id = Tokenizer.Token.Id.new_line, .start = 22, .end = 23 }
debug(tokenizer):     | 

debug(tokenizer): Tokenizer.Token{ .id = Tokenizer.Token.Id.doc_end, .start = 23, .end = 26 }
debug(tokenizer):     | ...
debug(tokenizer): Tokenizer.Token{ .id = Tokenizer.Token.Id.space, .start = 26, .end = 27 }
debug(tokenizer):     |  
debug(tokenizer): Tokenizer.Token{ .id = Tokenizer.Token.Id.comment, .start = 27, .end = 35 }
debug(tokenizer):     | # Suffix
debug(tokenizer): Tokenizer.Token{ .id = Tokenizer.Token.Id.new_line, .start = 35, .end = 36 }
debug(tokenizer):     | 

debug(tokenizer): Tokenizer.Token{ .id = Tokenizer.Token.Id.eof, .start = 36, .end = 36 }
debug(tokenizer):     | 
debug(parse): eatCommentsAndSpace
debug(parse):   (token 'literal')
debug(parse): eatCommentsAndSpace
debug(parse):   (token 'literal')
debug(parse): (main) next literal@0
debug(parse): (doc) begin literal@0
debug(parse): eatToken('doc_start')
debug(parse): eatCommentsAndSpace
debug(parse):   (token 'literal')
debug(parse):   (not found)
debug(parse): eatCommentsAndSpace
debug(parse):   (token 'literal')
debug(parse):   next literal@0
debug(parse): eatToken('map_value_ind')
debug(parse): eatCommentsAndSpace
debug(parse):   (token 'space')
debug(parse):   (token 'literal')
debug(parse):   (not found)
debug(parse): eatCommentsAndSpace
debug(parse):   (token 'literal')
debug(parse): (leaf) %YAML 1.2
debug(parse): eatToken('doc_end')
debug(parse): eatCommentsAndSpace
debug(parse):   (token 'new_line')
debug(parse):   (token 'doc_start')
debug(parse):   (not found)
debug(parse): eatToken('doc_start')
debug(parse): eatCommentsAndSpace
debug(parse):   (token 'doc_start')
debug(parse):   (found at 4)
error: UnexpectedToken
/home/manlio/src/contrib/zig/github.com/perillo/zig-yaml/src/parse.zig:412:36: 0x244b6e in doc (yaml)
                if (!explicit_doc) return error.UnexpectedToken;
                                   ^
/home/manlio/src/contrib/zig/github.com/perillo/zig-yaml/src/parse.zig:325:33: 0x2429b3 in parse (yaml)
                    const doc = try parser.doc();
                                ^
/home/manlio/src/contrib/zig/github.com/perillo/zig-yaml/src/yaml.zig:308:9: 0x245058 in load (yaml)
        try tree.parse(source);
        ^
/home/manlio/src/contrib/zig/github.com/perillo/zig-yaml/examples/yaml.zig:95:18: 0x248505 in main (yaml)
    var parsed = try yaml.Yaml.load(allocator, source);
@perillo perillo changed the title Document markers not parsed correctly parse: error.UnexpectedToken when parsing document markers Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant