regex interpreter now can build partial correct AST (i forget groups), but in bad shape. building an optimizer.
This commit is contained in:
@@ -47,7 +47,7 @@ namespace StgSharp.RegularAnalysis.Abstraction
|
||||
|
||||
public CompileStack()
|
||||
{
|
||||
_depthMarks.Push(new DepthMark(0, 0));
|
||||
_depthMarks.Push(new DepthMark(0, 0, 0));
|
||||
}
|
||||
|
||||
public int OperandInDepthCount
|
||||
@@ -59,7 +59,7 @@ namespace StgSharp.RegularAnalysis.Abstraction
|
||||
public int OperatorInDepthCount
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _operands.Count - _depthMarks.Peek().OperandPos;
|
||||
get => _operators.Count - _depthMarks.Peek().OperandPos;
|
||||
}
|
||||
|
||||
public int Depth
|
||||
@@ -108,6 +108,20 @@ namespace StgSharp.RegularAnalysis.Abstraction
|
||||
return false;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool TryPeekOperator(
|
||||
out TNode op
|
||||
)
|
||||
{
|
||||
if (OperatorInDepthCount > 0)
|
||||
{
|
||||
op = _operators.Peek();
|
||||
return true;
|
||||
}
|
||||
op = TNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region operand
|
||||
@@ -117,7 +131,7 @@ namespace StgSharp.RegularAnalysis.Abstraction
|
||||
)
|
||||
{
|
||||
if (OperatorInDepthCount > 0) {
|
||||
return _operators.Pop();
|
||||
return _operands.Pop();
|
||||
}
|
||||
return TNode.Empty;
|
||||
}
|
||||
@@ -127,7 +141,7 @@ namespace StgSharp.RegularAnalysis.Abstraction
|
||||
TNode operatorNode
|
||||
)
|
||||
{
|
||||
_operators.Push(operatorNode);
|
||||
_operands.Push(operatorNode);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -144,6 +158,20 @@ namespace StgSharp.RegularAnalysis.Abstraction
|
||||
return false;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool TryPeekOperand(
|
||||
out TNode op
|
||||
)
|
||||
{
|
||||
if (OperandInDepthCount > 0)
|
||||
{
|
||||
op = _operands.Peek();
|
||||
return true;
|
||||
}
|
||||
op = TNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region depth
|
||||
|
||||
Reference in New Issue
Block a user