remove yesterday's generatoer, use new generator
This commit is contained in:
@@ -48,9 +48,10 @@ namespace StgSharp.RegularAnalysis.Text
|
||||
* 2. The dispatch chain offers a window to L1, then L2, then L3, then L4. Higher
|
||||
* consumption wins, so a shape spanning a whole region plus a tail is never split by
|
||||
* a smaller generator.
|
||||
* 3. L2, L4 and L5 together are sufficient for correctness. L1 and L3 only flatten what
|
||||
* those would already emit, so an unimplemented one must return -1 cleanly rather
|
||||
* than emit a partial result.
|
||||
* 3. L2, L4, L5 and the required entries of L1 together are sufficient for correctness.
|
||||
* The flattening entries of L1 and all of L3 only improve the shape of what those
|
||||
* would already emit, so an unimplemented one must return -1 cleanly rather than
|
||||
* emit a partial result.
|
||||
* 4. A prefix consumes no IR. L1 to L4 describe what an instruction does, L5 decides
|
||||
* when it runs and who reads the outcome.
|
||||
* 5. Scope follows Prefix.WorkingRegion, not expression nesting.
|
||||
@@ -60,6 +61,10 @@ namespace StgSharp.RegularAnalysis.Text
|
||||
* A region lowers to do { ... } while(false), and POP lowers to break. The goto plus
|
||||
* label scheme used by the .NET generated regex backend is deliberately not adopted.
|
||||
*
|
||||
* A FIND lowers to a candidate retry loop nested inside the region block. That loop is
|
||||
* nearer than the region do block, so a POP inside it needs the __rN_done flag described
|
||||
* in TextRegexSourceGen.GenClass.MultiIR.cs rather than a plain break.
|
||||
*
|
||||
* Generated variable names are owned by SourceGenContext. No generator invents one.
|
||||
*
|
||||
* The per shape checklist this backend is rebuilt against lives in
|
||||
@@ -90,7 +95,6 @@ namespace StgSharp.RegularAnalysis.Text
|
||||
// TODO L0.1 Emit the Match signature from ROS_char and SourceGenContext.InputSpan.
|
||||
// TODO L0.2 Emit region anchor and region result slots, count from RegexInfo.RegionCount.
|
||||
// TODO L0.3 Emit line result slots, only for lines an Observe_Line prefix refers to.
|
||||
// TODO L0.4 Emit the whole pattern guard from RegexInfo.MinPredictLength.
|
||||
// TODO L0.5 Emit the cursor, the step result and any scratch declaration the context collected.
|
||||
//
|
||||
|
||||
@@ -121,6 +125,7 @@ namespace StgSharp.RegularAnalysis.Text
|
||||
{
|
||||
// GenerateRegion(region, sc, match_e, sub_match_list);
|
||||
_ = TryGenerateAltChain(0, region, sc, match_e, sub_match_list);
|
||||
_ = TryGenerateTryBlock(0, region, sc, match_e, sub_match_list);
|
||||
if (end >= ir_sp.Length)
|
||||
{
|
||||
break;
|
||||
@@ -133,6 +138,15 @@ namespace StgSharp.RegularAnalysis.Text
|
||||
_ = se.AppendLine($@"public override MatchResult Match({ROS_char} text)")//
|
||||
.AppendLine(@"{");
|
||||
|
||||
int min_predict_length = info.MinPredictLength;
|
||||
if (min_predict_length > 0) {
|
||||
_ = se.AppendLine($@"if (text.Length < {min_predict_length})")
|
||||
.AppendLine(@"{")
|
||||
.AppendLine(@"return default;")
|
||||
.AppendLine(@"}")
|
||||
.AppendLine();
|
||||
}
|
||||
|
||||
int region_count = info.RegionCount;
|
||||
for (int i = 0; i < region_count; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user