regex ir emitter is working
This commit is contained in:
@@ -40,13 +40,13 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
Search_Seq = 0,
|
||||
Search_Set = 1,
|
||||
SearchChar = 2,
|
||||
Jump = 3,
|
||||
ConfigFail = 3,
|
||||
Condition = 4,
|
||||
Try = 5,
|
||||
Pop = 6,
|
||||
Count = 7,
|
||||
Count_Seq = 8,
|
||||
Count_Set = 9
|
||||
Count = 6,
|
||||
Count_Seq = 7,
|
||||
Count_Set = 8,
|
||||
Pop = 10
|
||||
|
||||
}
|
||||
|
||||
@@ -55,30 +55,16 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
|
||||
internal abstract RegexIRCommand Command { get; }
|
||||
|
||||
internal abstract void Execute();
|
||||
|
||||
}
|
||||
|
||||
internal sealed class RegexPopIR(
|
||||
bool isSuccess
|
||||
) : RegexIR
|
||||
{
|
||||
|
||||
public bool IsSuccess { get; } = isSuccess;
|
||||
|
||||
internal override RegexIRCommand Command => RegexIRCommand.Pop;
|
||||
|
||||
internal override void Execute()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
internal abstract string AsCommand(
|
||||
int lineNum
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for a certain string pattern or charset from current position.
|
||||
/// </summary>
|
||||
internal sealed class RegexSearchSeqIR(
|
||||
internal sealed class RegexMatchSeqIR(
|
||||
string pattern
|
||||
) : RegexIR
|
||||
{
|
||||
@@ -87,9 +73,11 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
|
||||
internal override RegexIRCommand Command => RegexIRCommand.Search_Seq;
|
||||
|
||||
internal override void Execute()
|
||||
internal override string AsCommand(
|
||||
int lineNum
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return $"[{lineNum}]\t SEARCH_SEQ \"{(string.IsNullOrEmpty(Pattern) ? "<EPSILON>" : Pattern)}\"";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -103,31 +91,35 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
|
||||
internal override RegexIRCommand Command => RegexIRCommand.Search_Set;
|
||||
|
||||
internal override void Execute()
|
||||
internal override string AsCommand(
|
||||
int lineNum
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return $"[{lineNum}]\t SEARCH_SET \"{Charset}\"";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// JUMP to a certain instruction index.
|
||||
/// Configures the failure jump of current position. The failMod ranges 0-2
|
||||
/// </summary>
|
||||
/// <param name="target">
|
||||
///
|
||||
/// </param>
|
||||
internal sealed class RegexJumpIR(
|
||||
int target
|
||||
internal sealed class RegexConfigFailIR(
|
||||
int failMod
|
||||
) : RegexIR
|
||||
{
|
||||
|
||||
public int TargetIndex { get; } = target;
|
||||
public int FailMod { get; } = failMod & 0x3;
|
||||
|
||||
internal override RegexIRCommand Command => RegexIRCommand.Jump;
|
||||
internal override RegexIRCommand Command => RegexIRCommand.ConfigFail;
|
||||
|
||||
internal override void Execute()
|
||||
internal override string AsCommand(
|
||||
int lineNum
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return $"[{lineNum}]\t CONFIG_FAIL {FailMod}";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -144,9 +136,11 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
|
||||
internal override RegexIRCommand Command => RegexIRCommand.Condition;
|
||||
|
||||
internal override void Execute()
|
||||
internal override string AsCommand(
|
||||
int lineNum
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return $"[{lineNum}]\t CONDITION SUCCESS: {SuccessCase} FAIL: {FailCase}";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -169,9 +163,11 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
|
||||
internal override RegexIRCommand Command { get; } = RegexIRCommand.Count;
|
||||
|
||||
internal override void Execute()
|
||||
internal override string AsCommand(
|
||||
int lineNum
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return $"[{lineNum}]\t COUNT {(IsGreedy ? "GREEDY" : "NON_GREEDY")} MIN: {Min} MAX: {Max} OPERATION: {OperationIndex}";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -194,9 +190,11 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
|
||||
internal override RegexIRCommand Command { get; } = RegexIRCommand.Count_Seq;
|
||||
|
||||
internal override void Execute()
|
||||
internal override string AsCommand(
|
||||
int lineNum
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return $"[{lineNum}]\t COUNT_SEQ {(IsGreedy ? "GREEDY" : "NON_GREEDY")} MIN: {Min} MAX: {Max} SEQ: \"{Sequence}\"";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -219,9 +217,11 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
|
||||
internal override RegexIRCommand Command => RegexIRCommand.Count_Set;
|
||||
|
||||
internal override void Execute()
|
||||
internal override string AsCommand(
|
||||
int lineNum
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return $"[{lineNum}]\t COUNT_SET {(IsGreedy ? "GREEDY" : "NON_GREEDY")} MIN: {Min} MAX: {Max} SET: \"{CharSet}\"";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -235,9 +235,29 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
|
||||
internal override RegexIRCommand Command => RegexIRCommand.Try;
|
||||
|
||||
internal override void Execute()
|
||||
internal override string AsCommand(
|
||||
int lineNum
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return $"[{lineNum}]\t TRY {CountOfCommand}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal sealed class RegexPopIR(
|
||||
bool isSuccess
|
||||
) : RegexIR
|
||||
{
|
||||
|
||||
public bool IsSuccess { get; } = isSuccess;
|
||||
|
||||
internal override RegexIRCommand Command => RegexIRCommand.Try;
|
||||
|
||||
internal override string AsCommand(
|
||||
int lineNum
|
||||
)
|
||||
{
|
||||
return $"[{lineNum}]\t POP {(IsSuccess ? "SUCCESS" : "FAIL")}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user