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

Add "extended errors" #299

Merged
merged 1 commit into from
Nov 15, 2021
Merged

Add "extended errors" #299

merged 1 commit into from
Nov 15, 2021

Commits on Nov 15, 2021

  1. Add "extended errors"

    The lexer and parser now always return a ParseError; the Error() method
    is mostly unchanged:
    
    	toml: line 1 (last key "x.key"): newlines not allowed within inline tables
    
    This adds an ErrorWithLocation() method, which will add some context
    where the error occurred, similar to e.g. clang or the Rust compiler:
    
    	toml: error: newlines not allowed within inline tables
    
    	At line 1, column 18:
    
    	      1 | x = [{ key = 42 #
    				   ^
    
    And the ErrorWithUsage() also adds some usage guidance (not always
    present):
    
    	toml: error: newlines not allowed within inline tables
    
    	At line 1, column 16:
    
    	      1 | x = [{ key = 42
    				 ^
    	Error help:
    
    		Inline tables must always be on a single line:
    
    		    table = {key = 42, second = 43}
    
    		It is invalid to split them over multiple lines like so:
    
    		    # INVALID
    		    table = {
    			key    = 42,
    			second = 43
    		    }
    
    		Use regular for this:
    
    		    [table]
    		    key    = 42
    		    second = 43
    
    The line/column information should now also always be correct, and a
    number of error message have been tweaked a bit.
    
    Fixes #201
    Fixes #217
    arp242 committed Nov 15, 2021
    Configuration menu
    Copy the full SHA
    774ffd8 View commit details
    Browse the repository at this point in the history