Details

    • Sub-task
    • Resolution: Invalid
    • Not Evaluated
    • 4.8.0
    • Qt Script
    • None

    Description

      http://doc.trolltech.com/4.7/qscriptengine.html#canEvaluate
      http://doc.trolltech.com/4.7/qscriptengine.html#checkSyntax

      This API is used to check the syntactical correctness and completeness of a script, without actually evaluating it (i.e. without side-effects).

      From the syntax checking standpoint, a script can be in one of three "states":

      • Syntactically incorrect. The engine would throw a syntax error if the script were passed to evaluate().
      • Syntactically correct.
      • Syntactically incomplete. AKA "premature end of script". E.g. the script ends when

      In order for this API to work as intended, the back-end needs to provide a suitable API.

      • JavaScriptCore provides JSCheckScriptSyntax(), but syntactically incomplete scripts aren't distinguishable from "real" syntax errors.
      • V8 doesn't provide an API for this. One would have to construct a new V8 environment, evaluate the script and check if the return value is a SyntaxError. Incomplete scripts can be detected by checking if the error message is "Unexpected end of input". (This trick can't be used with JSC, since the error message is the generic "Parse error".)

      The use case for detecting incomplete scripts is a line-oriented interactive interpreter that asks for more input until the script is complete, before passing it to evaluate(). See examples/script/qscript in Qt.

      The situation we have currently (Qt 4.7) is that we keep a copy of our old (Qt 4.5) parser, which had the necessary syntax checking capabilities, and use it to implement the syntax checking API only. This is clearly not ideal. We'd like to drop the old parser completely.

      One could argue that it's outside the scope of the QtScript module to provide syntax checking; this should rather be done on the tooling side. Tools like Qt Creator implement their own syntax checking anyway, and attempting an integration with QtScript's syntax checking API doesn't seem worthwhile.

      It's worth investigating whether the needed functionality can be added to JSC or V8.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kenthans Kent Hansen (Inactive)
            kenthans Kent Hansen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes