Created
April 30, 2020 18:44
-
-
Save MadaraUchiha/397dae94a15b6fe1692bd7be082f1f40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<Instruction> Transpiler(IEnumerable<Instruction> codes) | |
{ | |
var state = TranspilerState.Initial; | |
foreach (var code of codes) | |
{ | |
switch (state) | |
{ | |
case TranspilerState.Initial: | |
if (SomeCondition(code)) | |
{ | |
state = TranspilerState.HitPattern; | |
} | |
break; | |
case TranspilerState.HitPattern: | |
return yield whatever; | |
return yield whatever; | |
return yield code; | |
state = TranspilerState.Done; | |
break; | |
case TranspilerState.Done: | |
yield return code; | |
break; | |
default | |
throw new Exception("Invalid state"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment