diff --git a/docs/HANDBOOK.md b/docs/HANDBOOK.md
index e68fc92..bd35612 100644
--- a/docs/HANDBOOK.md
+++ b/docs/HANDBOOK.md
@@ -2,8 +2,6 @@
This is a book for my language found [here](https://crosslang.tesseslanguage.com/)
-
-
## Statements and loops
@@ -22,6 +20,25 @@ var myVariable = 42;
myVariable = "I have set the variable to a string";
```
+#### Reflective variables
+
+```js
+var nameOfVariable = "Var 1";
+.[nameOfVariable] = 42; //the variable name in this instance will be Var 1
+Console.WriteLine(.[nameOfVariable]); //prints 42
+
+
+var nameOfVariable2 = "Var 2";
+var nameOfField = "This field has spaces and \n New Lines";
+.[nameOfVariable2] = {
+ .[nameOfField] = "Hello, world"
+};
+
+Console.WriteLine(.[nameOfVariable2].[nameOfField]); //should print Hello, world
+
+```
+
+
#### If statements
The {} are optional if you only need one statement
@@ -579,27 +596,3 @@ myHtml = Hello; //would just be Hello (useful for templating as it
myHtml = ; //allowing you to emit unescaped html from string into html litteral (useful for templating)
```
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/compiler/codegen.cpp b/src/compiler/codegen.cpp
index c4fcc65..9028c08 100644
--- a/src/compiler/codegen.cpp
+++ b/src/compiler/codegen.cpp
@@ -766,18 +766,18 @@ namespace Tesses::CrossLang
if(std::holds_alternative(item))
{
auto tkn = std::get(item);
- if(tkn.nodeName == GetVariableExpression && !tkn.nodes.empty() && std::holds_alternative(tkn.nodes[0]))
+ if(tkn.nodeName == GetVariableExpression && !tkn.nodes.empty())
{
- instructions.push_back(new StringInstruction(GetString(std::get(tkn.nodes[0]))));
+ GenNode(instructions,tkn.nodes[0],scope,contscope,brkscope,contI,brkI);
GenNode(instructions,item,scope,contscope,brkscope,contI,brkI);
instructions.push_back(new SimpleInstruction(APPENDDICT));
}
else if(tkn.nodeName == AssignExpression && tkn.nodes.size()==2 && std::holds_alternative(tkn.nodes[0]))
{
auto myTn = std::get(tkn.nodes[0]);
- if(myTn.nodeName == GetVariableExpression && !myTn.nodes.empty() && std::holds_alternative(myTn.nodes[0]))
+ if(myTn.nodeName == GetVariableExpression && !myTn.nodes.empty())
{
- instructions.push_back(new StringInstruction(GetString(std::get(myTn.nodes[0]))));
+ GenNode(instructions,myTn.nodes[0],scope,contscope,brkscope,contI,brkI);
GenNode(instructions,tkn.nodes[1],scope,contscope,brkscope,contI,brkI);
instructions.push_back(new SimpleInstruction(APPENDDICT));
}
@@ -1098,7 +1098,7 @@ namespace Tesses::CrossLang
}
}
- else if(varNode.nodeName == GetFieldExpression && varNode.nodes.size() == 2 && std::holds_alternative(varNode.nodes[1]))
+ else if(varNode.nodeName == GetFieldExpression && varNode.nodes.size() == 2)
{
GenNode(instructions,varNode.nodes[0],scope,contscope,brkscope,contI,brkI);