Syntax error reporting for packages

26 views
Skip to first unread message

Greg Spurrier

unread,
Apr 26, 2015, 6:28:38 PM4/26/15
to qil...@googlegroups.com
I'm finding Shen's package mechanism to be frustrating to work with when I am editing a file and accidentally introduce a syntax error. Consider this simple file, foo.shen:

(package foo
  []

\\ Here is a function. It is a good one.
(define f
  X -> X)

\\ Here is another function. It has a syntax error
(define f-oops
  X -> [X)

)

This is what I see when I attempt to load it:

Shen, copyright (C) 2010-2015 Mark Tarver
running under Common Lisp, implementation: SBCL
port 1.8 ported by Mark Tarver


(0-) (load "foo.shen")
read error here:

 (package foo
  []

\\ Here is a function. It is a
 

(1-) 

In this trivial example, it's easy to find the error by inspection. But, with a large file with many functions, I have no choice but to look at the differences between my edited version and the last good version that I checked into source control. This is an extremely frustrating error reporting/correcting cycle for the Shen programmer to endure.

I suppose the reporting here is because the top-level package form failed to parse. It would be extremely value, however, to instead show the parse error on the failed second function definition rather than backtracking all the way back to the top. What would it take for Shen-YACC to be able to support that?

In a similar vein, has anyone have any examples of tracking line numbers when parsing a file with Shen-YACC for the purpose of error reporting? I have some vague ideas of how I might tackle it, but they are ugly and I'm hoping it's an already-solved problem.

Thanks,
Greg

Mark Tarver

unread,
Apr 26, 2015, 7:37:22 PM4/26/15
to qil...@googlegroups.com
I'd make two practical suggestions.

1.  Don't package up your code until you know it works.

2.  Don't make extensive changes in working code and then try to load it and then try to figure out where the problems are when it does not load.  Make small local changes and then load it.  If it fails, you'll know where to look.  Use a bracket balancing editor of course.

Mark  

--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.
To post to this group, send email to qil...@googlegroups.com.
Visit this group at http://groups.google.com/group/qilang.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages