Additional documentation on type methods is available in the
[library reference](19-library-reference.md#library-reference).
+## <a id="location-information"></a> Location Information
+
+The location of the currently executing script can be obtained using the
+`current_filename` and `current_line` keywords.
+
+Example:
+
+ log("Hello from '" + current_filename + "' in line " + current_line)
+
## <a id="reserved-keywords"></a> Reserved Keywords
These keywords are reserved and must not be used as constants or custom attributes.
template
include
include_recursive
+ ignore_on_error
library
null
true
if
else
in
+ current_filename
+ current_line
You can escape reserved keywords using the `@` character. The following example
tries to set `vars.include` which references a reserved keyword and generates
keywords.push_back("locals");
keywords.push_back("use");
keywords.push_back("ignore_on_error");
+ keywords.push_back("current_filename");
+ keywords.push_back("current_line");
keywords.push_back("apply");
keywords.push_back("to");
keywords.push_back("where");
while return T_WHILE;
throw return T_THROW;
ignore_on_error return T_IGNORE_ON_ERROR;
+current_filename return T_CURRENT_FILENAME;
+current_line return T_CURRENT_LINE;
=\> return T_FOLLOWS;
\<\< return T_SHIFT_LEFT;
\>\> return T_SHIFT_RIGHT;
%token T_LOCALS "locals (T_LOCALS)"
%token T_CONST "const (T_CONST)"
%token T_IGNORE_ON_ERROR "ignore_on_error (T_IGNORE_ON_ERROR)"
+%token T_CURRENT_FILENAME "current_filename (T_CURRENT_FILENAME)"
+%token T_CURRENT_LINE "current_line (T_CURRENT_LINE)"
%token T_USE "use (T_USE)"
%token T_OBJECT "object (T_OBJECT)"
%token T_TEMPLATE "template (T_TEMPLATE)"
{
$$ = new GetScopeExpression(ScopeLocal);
}
+ | T_CURRENT_FILENAME
+ {
+ $$ = MakeLiteral(@$.Path);
+ }
+ | T_CURRENT_LINE
+ {
+ $$ = MakeLiteral(@$.FirstLine);
+ }
| rterm_array
| rterm_scope_require_side_effect
{