public string Execute() { var sb = new StringBuilder(); sb.AppendLine($".intel_syntax noprefix"); sb.AppendLine($" mov rax, 0"); sb.AppendLine($" call main"); sb.AppendLine($" ret"); var tokenList = TokenList.Tokenize(SourceCode); var nodeMap = NodeMap.Create(tokenList); var generator = new Generator(); // Nodesは関数ごとに存在する foreach (var node in nodeMap.Nodes) { if (node.Kind != NodeKind.Function) { throw new Exception($"Invalid Node:{node}"); } generator.Generate(sb, node); } return(sb.ToString()); }
public static NodeMap Create(TokenList tokenList) { var nodeMap = new NodeMap(); nodeMap.TokenList = tokenList; nodeMap.Analyze(); return(nodeMap); }