Squirrel

The programming language
Welcome to Squirrel Sign in | Join | Help
in Search

syntax error message not clear (Squirrel 3.0)

Last post 07-03-2009, 12:43 AM by fagiano. 1 replies.
Sort Posts: Previous Next
  •  05-22-2009, 3:19 PM 3266

    syntax error message not clear (Squirrel 3.0)

    Hi, assuming I have two Squirrel source files

    s1.sq:

     x = =


    s2.sq:

    dofile("s1.sq");



    so if I run

    sq_interp s1.sq

    output:
    ./s1.sq line = (1) column = (6) : error expression expected

    Fine; there is a syntax error.

    But if I run

    sq_interp s2.sq

    output:

    AN ERROR HAS OCCURED [expression expected]

    CALLSTACK
    *FUNCTION [main()] ./s2.sq line [2]

    LOCALS
    [vargv] ARRAY
    [this] TABLE


    It does not really indicate where the syntax error occurs;
    this can be annoying when a lot of library routines are included via dofile()

    What is funny is that if a run time error like an undefined variable occurs in the included file, clear messages are shown telling where (in the included file) the error occurs.  But this is not true for syntax errors.

    Can this be improved?
    Thanks

  •  07-03-2009, 12:43 AM 3348 in reply to 3266

    Re: syntax error message not clear (Squirrel 3.0)

    Look at the raiseerror parameter

    From the sqstd documentation

    dofile(path, [raiseerror]);

    compiles a squirrel script or loads a precompiled one and executes it. returns the value returned by the script or null if no value is returned. if the optional parameter 'raiseerror' is true, the compiler error handler is invoked in case of a syntax error. If raiseerror is omitted or set to false, the compiler error handler is not ivoked. When squirrel is compiled in unicode mode the function can handle different character ecodings, UTF8 with and without prefix and UCS-2 prefixed(both big endian an little endian). If the source stream is not prefixed UTF8 ecoding is used as default.

    Alberto

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems