소스 검색

Implement GOTO anchors

Bepis 6 년 전
부모
커밋
7411be3cd6
3개의 변경된 파일21개의 추가작업 그리고 0개의 파일을 삭제
  1. 14 0
      NTERA.Engine/Compiler/Parser.cs
  2. 3 0
      NTERA.Engine/Compiler/Token.cs
  3. 4 0
      NTERA.Engine/Runtime/EraRuntime.cs

+ 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}'");
 			}