Top  Previous  Next

Scripts > Class elements and c++ instructions > Interpreted C++ instructions > Container > vector > Stack


There isn't a general stack container class of his own in the TextTransformer interpreter. Stacks can nevertheless be realized easily.


At first there are two special stacks for text-scopes and indentations. A stack also arises from productions called recursively automatically (see below). 


In other cases a vector can be used as a stack. A new value can be pushed on the stack with push_back, then the value can be accessed by back and finally it can be removed again by pop_back.


vint v;


for(int i = 1; i <= 3; i++)





out << v.back();




// result: 321



E.g. a Stack arises automatically, when the text : "( ( ( 1 ) ) )", is parsed with the following start rule:



StackItem(int xi)


{{ int i = xi + 1; }}



{{ out << i << endl; }}





For every new instance of stack a local variables i is created: i is pushed on the stack.  When the stack production is left, the variable is destoyed: i is popped from the stack.




This page belongs to the TextTransformer Documentation

Home  Content  German