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

Make errors more readable #89

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Commits on Jul 3, 2024

  1. feat: Add additional fields to token.Token struct

    Add `Filename` and `Line` in preparation to enhance error reporting.
    The extra fields should be suited to provide consise error reporting when an error occurs.
    
    Signed-off-by: Gekko Wrld <[email protected]>
    gekkowrld committed Jul 3, 2024
    Configuration menu
    Copy the full SHA
    16060bb View commit details
    Browse the repository at this point in the history

Commits on Jul 4, 2024

  1. chore: Convert parser errors to 'Syntax Error'

    The parser doesn't emit its own errors, it relies on 'errd' package to do so.
    This makes it easier to format the error messages in a uniform parsable form.
    
    Instead of:
    	Mstari 1: Tumeshindwa kuparse HARAMU
    Its:
    	Kosa la kisintaksia: h.nr:1:4
    	Tumeshindwa kuparse '#'
    
    This gives the user the hint where the problem is and what caused the problem.
    
    Parser errors doesn't exit after display.
    
    Signed-off-by: Gekko Wrld <[email protected]>
    gekkowrld committed Jul 4, 2024
    Configuration menu
    Copy the full SHA
    4e2aa13 View commit details
    Browse the repository at this point in the history

Commits on Jul 5, 2024

  1. fix: Count column and lines better

    Previuos implementation counted the rows and columns inconsistently.
    This fix will enable counting to be consistent and better.
    
    - Use strings.Builder in `readString` function instead of naive string concatenation
    	This reduces memory allocation and deallocation being done by go making the program efficient.
    
    Signed-off-by: Gekko Wrld <[email protected]>
    gekkowrld committed Jul 5, 2024
    Configuration menu
    Copy the full SHA
    f192a1f View commit details
    Browse the repository at this point in the history

Commits on Jul 6, 2024

  1. chore: Add context line

    The line in which the error occured in is now displayed along with the error.
    This makes it easier to see what went wrong at a glance without opening the file to confirm.
    A caret is placed at the start of the error token to help the user know where they can start fixing from.
    
    Signed-off-by: Gekko Wrld <[email protected]>
    gekkowrld committed Jul 6, 2024
    Configuration menu
    Copy the full SHA
    2f0fe5b View commit details
    Browse the repository at this point in the history