Unknown identifier : xxx

Top  Previous  Next

Messages > Unknown identifier : xxx

 

The message "Unknown identifier : xxx" is caused by an error of the interpreter. A variable was used, which had not been declared before or the scope, where it was declared is left.

This message also can appear as a consequence of another previous error.

 

EXAMPLE

 

The assignment

 

s = "Hallo";

 

can't be used, without preceding declaration of s:

 

str s;

s = "Hallo";

 

or combined to one instruction:

 

str s = "Hallo";

 

 

For the interpreter invisible export code

 

The error message appears, if the declaration wrongly was set into the brackets for export code "{_" and "_}:

 

{_str sComment;_}

 

while the variable is used in the interpreter code:

 

(

Comment[sComment] 

)+

 

If interpretable is activated in the project options Parameter and "{{...}}"

sComment will be seen by the interpreter, but isn't declared.

 

 

 

 

Hidden Scopes

 

A variable exists as long as its scope exists. A scope is the whole text of a production/token or the section included into the braces '{' and '}' or defined indirectly by alternatives.

For example in the text of the production:

 

if( xi == 1 )

{

str s = "one";

out << s;

}

s = "two" // error

 

the string s doesn't exist any longer after the closing '}'. So nothing can be assigned to it there.

 

Attention: Alternatives define scopes, which are not visible directly.

 

Example

 

The following production causes the error message "Unknown identifier: s", although the string s seems to be correctly declared:

 

{{str s; }}

"a"

| "b"

print[s]

 

But by the alternatives hidden scopes are introduced:

 

{{str s; }}

"a"

 

and

 

"b"

print[s]

 

have their owns scopes respectively. This becomes clear in the syntax tree of the production:

 

HiddenScope

 

The semantic action, which declares the string, is executed immediately before the recognition of "a" and is not preceding the whole alternative. To achieve this, the alternatives must be enclosed into parenthesis:

 

{{str s; }}

(

"a"

| "b"

print[s]

)

 

Now the syntax tree looks as:

 

HiddenScope2

 

The declaration now precedes all alternatives and the variable s can be accessed in the whole production.

 



This page belongs to the TextTransformer Documentation

Home  Content  German