diff --git a/Global.cpp b/Global.cpp index d8ff733..72f6b8d 100644 --- a/Global.cpp +++ b/Global.cpp @@ -165,7 +165,7 @@ namespace jet { formdata.goeol(); } else - throw coreutils::Exception("expecting closing double quote on vairable name in received CGI data."); + throw coreutils::Exception("expecting closing double quote on variable name in received CGI data."); } else throw coreutils::Exception("expecting name subfield in received CGI data."); } else diff --git a/Global.h b/Global.h index 2dc66d6..bb1f66a 100644 --- a/Global.h +++ b/Global.h @@ -27,6 +27,7 @@ namespace jet { void outputHeaders(); void setupFormData(coreutils::ZString &formdata); void setupFormURLEncoded(coreutils::ZString &formdata); + char *errorCursor = NULL; std::map variables; std::map cgiVariables; diff --git a/Tag.cpp b/Tag.cpp index 9b459f5..ec8a17a 100644 --- a/Tag.cpp +++ b/Tag.cpp @@ -31,6 +31,7 @@ namespace jet { Tag::Tag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, coreutils::ZString splitTagName) : ZString(in), parentOut(parentOut), global(global), parent(parent) { this->splitTagName = splitTagName; + global.errorCursor = in.getCursor(); if(parent && in.ifNext("<")) { name = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_!"); if(in.startsWith(" ") || in.startsWith("/") || in.startsWith(">")) { @@ -196,15 +197,14 @@ namespace jet { in.ifNext("/>"); continue; } else { - out.write(in.charAt(0)); - in.nextChar(); + out.write(in.nextChar()); continue; } - } else if(in.startsWith("$[") || in.startsWith("#[")) { + } else if(in.startsWith("$[") || in.startsWith("#[")) { + global.errorCursor = in.getCursor(); out.write(global.getVariable(in, variables)); } else { - out.write(in.charAt(0)); - in.nextChar(); + out.write(in.nextChar()); } } } diff --git a/__tag.h b/__tag.h index 367b4e6..121319a 100644 --- a/__tag.h +++ b/__tag.h @@ -3,6 +3,8 @@ #include "Tag.h" #include "ZString.h" +#include "MString.h" +#include namespace jet { @@ -10,6 +12,8 @@ namespace jet { public: __tag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent); + + std::map tags; }; diff --git a/jet-2.0.cpp b/jet-2.0.cpp index 59191cb..0da4518 100644 --- a/jet-2.0.cpp +++ b/jet-2.0.cpp @@ -16,16 +16,23 @@ int main(int argc, char **argv, char **envp) { try { coreutils::MString out; + data.reset(); + global.errorCursor = data.getCursor(); jet::__jet *jet = new jet::__jet(data, out, global, NULL); delete jet; global.outputHeaders(); std::cout << out; } catch(coreutils::Exception e) { + data.setCursor(global.errorCursor); + data.moveBackToLineStart(); + std::cout << "-----------------------------" << std::endl; + std::cout << "Error in jet script '" << argv[1] << "' at line " << data.getLineNumberAtCursor() << std::endl; + std::cout << "Error text: " << e.text << std::endl; + std::cout << "-----------------------------" << std::endl; std::cout << data.parsed() << std::endl; std::cout << "******** Error caught: " << e.text << std::endl; std::cout << data.unparsed() << std::endl; - std::cout << "Error caught: " << e.text << std::endl; global.dump(); } diff --git a/tests/testjet.jet b/tests/testjet.jet index c70bf61..e8bfaaf 100755 --- a/tests/testjet.jet +++ b/tests/testjet.jet @@ -10,6 +10,8 @@ $[modified1;$[tohex]] $[complete] + + the unnamed variable value: [$[]] --- $[nonexistant] $[%HOME] @@ -21,7 +23,8 @@ - $[nested] + + $[$nested] 0123456789 lefty=[$[lefty]]