Skip to content

Commit fb1c9f5

Browse files
committed
Updates
1 parent 1e433c5 commit fb1c9f5

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

Docs/FexElementsRef.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,11 @@ A PreOp is efficient as it will execute only once while trying several *lookahea
432432
|`GlobalPreOp(Action<Ctx> preOp)`|Global setting to automatically attach to all operators.|
433433
|`PreOp(Action<Ctx> preOp)`| Use directly after an operator to attach/override a PreOp|
434434

435-
See the Expression example which uses a SetPreOp to skip all spaces before the *tokens*
435+
See the Expression example which uses a GlobalPreOp to skip all spaces before the *tokens*
436436

437-
> **Note** The preOp action may be null if no PreOp should be executed.
437+
> **Notes:**
438+
> - The preOp action may be null if no PreOp should be executed.
439+
> - The above mechanism could then be used to *switch off* the GlobalPreOp for selected Op's.
438440
439441
[(toc)](#id-toc)
440442

FexSampleSet/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ void ExpressionREPL() {
248248

249249
var primary = fex.Seq(s => s.RefName("primary")
250250
.OneOf(o => o
251-
.Seq(e => e.Ch('(').Ref("expr").Ch(')').OnFail(") expected"))
251+
.Seq(e => e.Ch('(').Fex(expr).Ch(')').OnFail(") expected"))
252252
.Seq(s => s.NumDecimal(n => numStack.Push(n)))
253253
.Seq(s => s.Ch('a').Act(c => numStack.Push(ans))) // a is previous answer
254254
));
@@ -260,6 +260,7 @@ void ExpressionREPL() {
260260
Console.Write("> ");
261261
var line = Console.ReadLine();
262262
if (string.IsNullOrEmpty(line)) return false;
263+
//Console.WriteLine($"Line:{line}");
263264
c.SetSource(line);
264265

265266
if (exprEval.Run(scn)) {

Psw.FlowExpressions/FexScannerExt.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static FexBuilder<T> IsString<T>(this FexBuilder<T> exp, string matchStri
116116
/// <param name="comp">Comparison type (default = StringComparison.InvariantCultureIgnoreCase)</param>
117117
/// <returns>True and matching string is logged as a Value, else false</returns>
118118
public static FexBuilder<T> IsAnyString<T>(this FexBuilder<T> exp, IEnumerable<string> matchStrings, bool advanceIndex = true, StringComparison comp = StringComparison.InvariantCultureIgnoreCase) where T : FexScanner
119-
=> exp.Op((c, v) => v.SetValue(c.IsAnyString(matchStrings, advanceIndex, comp), c.Token));
119+
=> exp.Op((c, v) => v.SetValue(c.IsAnyString(matchStrings, advanceIndex, comp), c.Match));
120120

121121
/// <summary>
122122
/// Check if text at Index equals any string in matchString and optionally advance Index if it matches.<br/>
@@ -126,7 +126,7 @@ public static FexBuilder<T> IsAnyString<T>(this FexBuilder<T> exp, IEnumerable<s
126126
/// <param name="comp">Comparison type (default = StringComparison.InvariantCultureIgnoreCase)</param>
127127
/// <returns>True and matching string is logged as a Value, else false</returns>
128128
public static FexBuilder<T> IsAnyString<T>(this FexBuilder<T> exp, string matchStrings, bool advanceIndex = true, StringComparison comp = StringComparison.InvariantCultureIgnoreCase) where T : FexScanner
129-
=> exp.Op((c, v) => v.SetValue(c.IsAnyString(matchStrings, advanceIndex, comp), c.Token));
129+
=> exp.Op((c, v) => v.SetValue(c.IsAnyString(matchStrings, advanceIndex, comp), c.Match));
130130

131131
// Skip Operations ====================================================
132132

@@ -195,7 +195,7 @@ public static FexBuilder<T> SkipToStr<T>(this FexBuilder<T> exp, string str, boo
195195
/// False: Not found or Eos. Index unchanged
196196
/// </returns>
197197
public static FexBuilder<T> SkipToAnyStr<T>(this FexBuilder<T> exp, IEnumerable<string> matchStrings, bool skipOver = false, StringComparison comp = StringComparison.InvariantCultureIgnoreCase) where T : FexScanner
198-
=> exp.Op((c, v) => v.SetValue(c.SkipToAnyStr(matchStrings, skipOver, comp), c.Token));
198+
=> exp.Op((c, v) => v.SetValue(c.SkipToAnyStr(matchStrings, skipOver, comp), c.Match));
199199

200200
/// <summary>
201201
/// Skip up to first occurrence of any string in delimited matchStrings and optionally skip over the matching string.<br/>
@@ -209,7 +209,7 @@ public static FexBuilder<T> SkipToAnyStr<T>(this FexBuilder<T> exp, IEnumerable<
209209
/// False: Not found or Eos. Index unchanged
210210
/// </returns>
211211
public static FexBuilder<T> SkipToAnyStr<T>(this FexBuilder<T> exp, string matchStrings, bool skipOver = false, StringComparison comp = StringComparison.InvariantCultureIgnoreCase) where T : FexScanner
212-
=> exp.Op((c, v) => v.SetValue(c.SkipToAnyStr(matchStrings, skipOver, comp), c.Token));
212+
=> exp.Op((c, v) => v.SetValue(c.SkipToAnyStr(matchStrings, skipOver, comp), c.Match));
213213

214214
/// <summary>
215215
/// Skip to Eol or Eos (last line)<br/>

Psw.FlowExpressions/FlowExpression.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected FexElement<T> _Prod(FexElement<T> prod, Action<FexBuilder<T>> build)
4949
/// <summary>
5050
/// Define an optional set of sequences where one of them may pass
5151
/// </summary>
52-
public FexElement<T> OptOneOf(Action<FexBuilder<T>> buildFex) => Opt(o => OneOf(buildFex));
52+
public FexElement<T> OptOneOf(Action<FexBuilder<T>> buildFex) => Opt(o => o.OneOf(buildFex));
5353

5454
/// <summary>
5555
/// Inverse of OneOf, where it fails if any sequence passes<br />
@@ -83,6 +83,6 @@ protected FexElement<T> _Prod(FexElement<T> prod, Action<FexBuilder<T>> build)
8383
/// <summary>
8484
/// Repeat a OneOf construct repMin up to repMax times (-1 for any reps > repMin) (see documentation for details)
8585
/// </summary>
86-
public FexElement<T> RepOneOf(int repMin, int repMax, Action<FexBuilder<T>> buildFex) => Rep(repMin, repMax, r => OneOf(buildFex));
86+
public FexElement<T> RepOneOf(int repMin, int repMax, Action<FexBuilder<T>> buildFex) => Rep(repMin, repMax, r => r.OneOf(buildFex));
8787
}
8888
}

Psw.FlowExpressions/Psw.FlowExpressions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</ItemGroup>
2424

2525
<ItemGroup>
26-
<PackageReference Include="Psw.Scanners" Version="1.0.0" />
26+
<PackageReference Include="Psw.Scanners" Version="1.0.1" />
2727
</ItemGroup>
2828

2929
</Project>

0 commit comments

Comments
 (0)