Prechádzať zdrojové kódy

Implement GOTO anchors

Bepis 6 rokov pred
rodič
commit
7411be3cd6

+ 14 - 0
NTERA.Engine/Compiler/Parser.cs

@@ -503,6 +503,20 @@ namespace NTERA.Engine.Compiler
 						return node;
 					}
 
+				case Token.GotoLabel:
+
+					if (GetNextToken() != Token.Identifer)
+					{
+						error = new ParserError($"Expected an identifer, got {Enumerator.Current}", CurrentPosition);
+						return null;
+					}
+
+					return new ExecutionNode
+					{
+						Type = "anchor",
+						Anchor = Lexer.Identifier
+					};
+
 				case Token.AtSymbol:
 				case Token.Sharp:
 					while (Enumerator.MoveNext()

+ 3 - 0
NTERA.Engine/Compiler/Token.cs

@@ -13,6 +13,9 @@
 		[LexerCharacter('@')]
 		AtSymbol,
 
+		[LexerCharacter('$')]
+		GotoLabel,
+
 		[LexerKeyword("DIM")]
 		Dim,
 

+ 4 - 0
NTERA.Engine/Runtime/EraRuntime.cs

@@ -315,6 +315,10 @@ namespace NTERA.Engine.Runtime
 
 					return;
 
+				case "anchor":
+					//for now, anchors are explicit types and not attached to ordinary nodes
+					return;
+
 				default:
 					throw new EraRuntimeException($"Unknown node type: '{node.Type}'");
 			}