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

Display context and mark out error tokens #145

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

Conversation

aliclark
Copy link

@aliclark aliclark commented Aug 20, 2020

This PR adds a graphical representation of the last few lines before and error and highlighting of the error token from underneath, intended to make it easier to understand which part of the print out was cause of the error.

Some examples (using Moo with Nearley):

Before:

Error: Syntax error at line 4 col 1:

  
  ^

After:

Error: Syntax error at line 4 col 1:

     1	
     2	
     3	new of self with iterable:
     4	
      	^       

Before:

Error: Syntax error at line 6 col 5:

  note:
      ^

After:

Error: Syntax error at line 6 col 5:

     2	use software,
     3	    category
     4	
     5	
     6	note:`This is the main software`
      	    ~                           

Before:

Error: Syntax error at line 35 col 11:

  square of x
            ^

After:

Error: Syntax error at line 35 col 11:

    31	        otherwise:
    32	            result 'stopped'
    33	
    34	
    35	square of x:
      	          ~ 

Before:

Error: Syntax error at line 11 col 30:

  	for each number in infinity, 
                               ^

After:

Error: Syntax error at line 11 col 30:

     7	        collect self + 1 + number
     8	
     9	
    10	numbersLessThan self:
    11	    for each number in infinity, with extent: self,
      	\tab                            ~                  

@aliclark
Copy link
Author

@tjvr @nathan any chance for this change to get merged?

I could create a scoped package otherwise but would prefer not to

@tjvr
Copy link
Collaborator

tjvr commented Sep 28, 2020

I think I would prefer to merge #129, sorry!

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

Successfully merging this pull request may close these issues.

None yet

2 participants