Skip to content

Commit 8707f23

Browse files
committed
Rename BuilderArtifacts to BuilderOutputs.
1 parent 13aba58 commit 8707f23

8 files changed

Lines changed: 76 additions & 73 deletions

File tree

RELEASE_NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#### 7.0.0-preview.3
2+
The following changes were made after 7.0.0-preview.2:
3+
* __Breaking change:__ The type `BuilderArtifacts` was renamed to `BuilderOutputs`.
4+
15
#### 7.0.0-preview.2 - 30-10-2025
26
The following changes were made after 7.0.0-preview.1:
37
* __Breaking change:__ Removed `params` from parameters of type `OperatorScope`.

sample/Farkle.Samples.FSharp/SimpleMaths.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ let mathExpression =
8888
(mkExpr Multiply)
8989
(mkExpr Divide)
9090
(Negate >> MathExpression.Create)
91-
|> _.Build(BuilderArtifacts.SemanticProviderOnChar)
92-
|> _.SemanticProviderOnChar
91+
|> _.BuildSemanticProvider()
9392
int
9493
|> CharParser.withSemanticProvider semanticProvider
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
namespace Farkle.Builder;
99

1010
/// <summary>
11-
/// Represents the possible artifacts that the builder can produce.
11+
/// Represents the possible outputs that the builder can produce.
1212
/// </summary>
1313
/// <seealso cref="BuilderResult{T}"/>
1414
[Flags]
15-
public enum BuilderArtifacts {
15+
public enum BuilderOutputs {
1616
/// <summary>
1717
/// Nothing gets built.
1818
/// </summary>

src/Farkle/Builder/BuilderResult.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ namespace Farkle.Builder;
1212
/// </summary>
1313
/// <typeparam name="T">The type of objects the parser will produce in case of success.</typeparam>
1414
/// <remarks>
15-
/// All properties of this class are nullable and populated based on the <see cref="BuilderArtifacts"/>
15+
/// All properties of this class are nullable and populated based on the <see cref="BuilderOutputs"/>
1616
/// that were requested when building.
1717
/// </remarks>
18-
/// <seealso cref="GrammarBuilderExtensions.Build{T}(IGrammarBuilder{T}, BuilderArtifacts, BuilderOptions?)"/>
19-
/// <seealso cref="GrammarBuilderExtensions.BuildSyntaxCheck(IGrammarBuilder, BuilderArtifacts, BuilderOptions?)"/>
20-
/// <seealso cref="GrammarBuilderExtensions.BuildSyntaxCheck{T}(IGrammarBuilder, BuilderArtifacts, BuilderOptions?)"/>
18+
/// <seealso cref="GrammarBuilderExtensions.Build{T}(IGrammarBuilder{T}, BuilderOutputs, BuilderOptions?)"/>
19+
/// <seealso cref="GrammarBuilderExtensions.BuildSyntaxCheck(IGrammarBuilder, BuilderOutputs, BuilderOptions?)"/>
20+
/// <seealso cref="GrammarBuilderExtensions.BuildSyntaxCheck{T}(IGrammarBuilder, BuilderOutputs, BuilderOptions?)"/>
2121
public sealed class BuilderResult<T>
2222
{
2323
internal BuilderResult() { }

src/Farkle/Builder/GrammarBuild.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,17 @@ private static string ExtractFirstPossibleCharacters(Regex regex)
115115
/// Builds a <see cref="Grammar"/> object from a <see cref="GrammarDefinition"/>.
116116
/// </summary>
117117
/// <param name="grammarDefinition">The grammar definition.</param>
118-
/// <param name="artifacts">The artifacts to build. Only <see cref="BuilderArtifacts.GrammarLrStateMachine"/>
119-
/// and <see cref="BuilderArtifacts.GrammarDfaOnChar"/> are considered.</param>
118+
/// <param name="outputs">The outputs to build. Only <see cref="BuilderOutputs.GrammarLrStateMachine"/>
119+
/// and <see cref="BuilderOutputs.GrammarDfaOnChar"/> are considered.</param>
120120
/// <param name="options">Options to control the building process.</param>
121121
/// <param name="errors">An optional collection to store diagnostics of
122122
/// severity <see cref="DiagnosticSeverity.Error"/>.</param>
123-
public static Grammar Build(GrammarDefinition grammarDefinition, BuilderArtifacts artifacts, BuilderOptions options, ICollection<BuilderDiagnostic>? errors = null)
123+
public static Grammar Build(GrammarDefinition grammarDefinition, BuilderOutputs outputs, BuilderOptions options, ICollection<BuilderDiagnostic>? errors = null)
124124
{
125125
var log = options.Log.WithRedirectErrors(errors);
126126
string grammarName = grammarDefinition.GrammarName;
127127
log.InformationLocalized(nameof(Resources.Builder_BuildingStarted), grammarName);
128-
Grammar grammar = Build(grammarDefinition, artifacts, options, in log);
128+
Grammar grammar = Build(grammarDefinition, outputs, options, in log);
129129
// Get conflicts and log them. Skip the computation if no errors are logged
130130
// (i.e. the log has no listeners at all).
131131
if (log.IsEnabled(DiagnosticSeverity.Error))
@@ -140,7 +140,7 @@ public static Grammar Build(GrammarDefinition grammarDefinition, BuilderArtifact
140140
return grammar;
141141
}
142142

143-
private static Grammar Build(GrammarDefinition grammarDefinition, BuilderArtifacts artifacts, BuilderOptions options, in BuilderLogger log)
143+
private static Grammar Build(GrammarDefinition grammarDefinition, BuilderOutputs outputs, BuilderOptions options, in BuilderLogger log)
144144
{
145145
ref readonly GrammarGlobalOptions globalOptions = ref grammarDefinition.GlobalOptions;
146146
bool autoWhitespace = globalOptions.AutoWhitespace;
@@ -166,7 +166,7 @@ private static Grammar Build(GrammarDefinition grammarDefinition, BuilderArtifac
166166
// Add terminals.
167167
SymbolNameProvider? dfaSymbols = null;
168168
ImmutableArray<Regex>.Builder? regexBuilder = null;
169-
if ((artifacts & BuilderArtifacts.GrammarDfaOnChar) != 0)
169+
if ((outputs & BuilderOutputs.GrammarDfaOnChar) != 0)
170170
{
171171
dfaSymbols = new(grammarDefinition.Terminals.Count);
172172
regexBuilder = ImmutableArray.CreateBuilder<Regex>(grammarDefinition.Terminals.Count);
@@ -211,7 +211,7 @@ private static Grammar Build(GrammarDefinition grammarDefinition, BuilderArtifac
211211
// Add groups.
212212
int groupCount = groups?.Count ?? 0 + grammarDefinition.GlobalOptions.Comments?.Count ?? 0;
213213
List<Regex?>? groupDfaRegexes = null;
214-
if (options.EmitGroupOptimizedDfa && (artifacts & BuilderArtifacts.GrammarDfaOnChar) != 0 && groupCount > 0)
214+
if (options.EmitGroupOptimizedDfa && (outputs & BuilderOutputs.GrammarDfaOnChar) != 0 && groupCount > 0)
215215
{
216216
groupDfaRegexes = new List<Regex?>(groupCount);
217217
}
@@ -325,7 +325,7 @@ private static Grammar Build(GrammarDefinition grammarDefinition, BuilderArtifac
325325
}
326326
}
327327

328-
if ((artifacts & BuilderArtifacts.GrammarLrStateMachine) != 0)
328+
if ((outputs & BuilderOutputs.GrammarLrStateMachine) != 0)
329329
{
330330
var conflictResolver = operatorScope is not null
331331
? new OperatorScopeConflictResolver(operatorScope, operatorSymbolMap!, literalsCaseInsensitive, log)

src/Farkle/Builder/GrammarBuilderExtensions.cs

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -325,50 +325,50 @@ public static IGrammarBuilder<T> MarkForPrecompile<T>(this IGrammarBuilder<T> bu
325325
/// </summary>
326326
/// <typeparam name="T">The type of objects the parser will produce in case of success.</typeparam>
327327
/// <param name="builder">The grammar to build.</param>
328-
/// <param name="artifacts">The set of artifacts to build.</param>
328+
/// <param name="outputs">The set of outputs to build.</param>
329329
/// <param name="options">Used to customize the building process. Optional.</param>
330330
/// <param name="isSyntaxCheck">Whether to use a dummy semantic provider instead of building one.</param>
331-
private static BuilderResult<T> BuildImpl<T>(this IGrammarBuilder builder, BuilderArtifacts artifacts,
331+
private static BuilderResult<T> BuildImpl<T>(this IGrammarBuilder builder, BuilderOutputs outputs,
332332
BuilderOptions? options = null, bool isSyntaxCheck = false)
333333
{
334334
ArgumentNullException.ThrowIfNull(builder);
335335

336336
options ??= BuilderOptions.Default;
337337

338-
// Add dependencies between artifacts.
339-
// The order is important; if an artifact appears in the first parameter,
338+
// Add dependencies between outputs.
339+
// The order is important; if an output appears in the first parameter,
340340
// it cannot appear in the second parameter of a subsequent call.
341-
AddArtifactDependencies(BuilderArtifacts.CharParser,
342-
BuilderArtifacts.SemanticProviderOnChar | BuilderArtifacts.TokenizerOnChar | BuilderArtifacts.GrammarLrStateMachine);
343-
AddArtifactDependencies(BuilderArtifacts.TokenizerOnChar,
344-
BuilderArtifacts.GrammarDfaOnChar);
345-
AddArtifactDependencies(BuilderArtifacts.GrammarLrStateMachine | BuilderArtifacts.GrammarDfaOnChar,
346-
BuilderArtifacts.GrammarSummary);
341+
AddOutputDependencies(BuilderOutputs.CharParser,
342+
BuilderOutputs.SemanticProviderOnChar | BuilderOutputs.TokenizerOnChar | BuilderOutputs.GrammarLrStateMachine);
343+
AddOutputDependencies(BuilderOutputs.TokenizerOnChar,
344+
BuilderOutputs.GrammarDfaOnChar);
345+
AddOutputDependencies(BuilderOutputs.GrammarLrStateMachine | BuilderOutputs.GrammarDfaOnChar,
346+
BuilderOutputs.GrammarSummary);
347347

348348
Grammar? grammar = null;
349349
ISemanticProvider<char, T>? semanticProvider = null;
350350
Tokenizer<char>? tokenizer = null;
351351
CharParser<T>? parser = null;
352352

353-
if (artifacts != BuilderArtifacts.None)
353+
if (outputs != BuilderOutputs.None)
354354
{
355355
GrammarDefinition grammarDefinition = GrammarDefinition.Create(builder, options.Log, options.CancellationToken);
356356

357357
List<BuilderDiagnostic>? errors = null;
358358
// We will collect errors only if we need to report them from a failing parser or tokenizer.
359-
if ((artifacts & (BuilderArtifacts.TokenizerOnChar | BuilderArtifacts.CharParser)) != 0)
359+
if ((outputs & (BuilderOutputs.TokenizerOnChar | BuilderOutputs.CharParser)) != 0)
360360
{
361361
errors = [];
362362
}
363363

364-
if ((artifacts & BuilderArtifacts.GrammarSummary) != 0)
364+
if ((outputs & BuilderOutputs.GrammarSummary) != 0)
365365
{
366-
grammar = GrammarBuild.Build(grammarDefinition, artifacts, options, errors);
366+
grammar = GrammarBuild.Build(grammarDefinition, outputs, options, errors);
367367
}
368368

369369
object? customError = errors is null or [] ? null : new CompositeDiagnostic<BuilderDiagnostic>(errors);
370370

371-
if ((artifacts & BuilderArtifacts.TokenizerOnChar) != 0)
371+
if ((outputs & BuilderOutputs.TokenizerOnChar) != 0)
372372
{
373373
// Custom error is the same for both the parser and the tokenizer, which can
374374
// give confusing messages when a failing tokenizer gets swapped with a
@@ -377,14 +377,14 @@ private static BuilderResult<T> BuildImpl<T>(this IGrammarBuilder builder, Build
377377
tokenizer = Tokenizer.Create<char>(grammar!, false, customError);
378378
}
379379

380-
if ((artifacts & BuilderArtifacts.SemanticProviderOnChar) != 0)
380+
if ((outputs & BuilderOutputs.SemanticProviderOnChar) != 0)
381381
{
382382
semanticProvider = isSyntaxCheck
383383
? SyntaxChecker<char, T>.Instance!
384384
: SemanticProviderBuild.Build<T>(grammarDefinition);
385385
}
386386

387-
if ((artifacts & BuilderArtifacts.CharParser) != 0)
387+
if ((outputs & BuilderOutputs.CharParser) != 0)
388388
{
389389
parser = CharParser.Create(grammar!, tokenizer!, semanticProvider!, customError);
390390
}
@@ -398,38 +398,38 @@ private static BuilderResult<T> BuildImpl<T>(this IGrammarBuilder builder, Build
398398
TokenizerOnChar = tokenizer
399399
};
400400

401-
// Adds dependencies between artifacts. If one of dependents is specified, dependencies will be built as well.
402-
void AddArtifactDependencies(BuilderArtifacts dependents, BuilderArtifacts dependencies)
401+
// Adds dependencies between outputs. If one of dependents is specified, dependencies will be built as well.
402+
void AddOutputDependencies(BuilderOutputs dependents, BuilderOutputs dependencies)
403403
{
404-
if ((artifacts & dependents) != 0)
404+
if ((outputs & dependents) != 0)
405405
{
406-
artifacts |= dependencies;
406+
outputs |= dependencies;
407407
}
408408
}
409409
}
410410

411411
/// <summary>
412-
/// Builds multiple artifacts from the given <see cref="IGrammarBuilder{T}"/>.
412+
/// Builds multiple outputs from the given <see cref="IGrammarBuilder{T}"/>.
413413
/// </summary>
414414
/// <typeparam name="T">The type of objects the parser will produce in case of success.</typeparam>
415415
/// <param name="builder">The grammar to build.</param>
416-
/// <param name="artifacts">The set of artifacts to build.</param>
416+
/// <param name="outputs">The set of outputs to build.</param>
417417
/// <param name="options">Used to customize the building process. Optional.</param>
418418
/// <returns>
419-
/// A <see cref="BuilderResult{T}"/> object with the properties of the requested artifacts populated.
419+
/// A <see cref="BuilderResult{T}"/> object with the properties of the requested outputs populated.
420420
/// </returns>
421421
/// <remarks>
422422
/// <para>
423-
/// The builder will reuse resources to build the requested artifacts where applicable.
423+
/// The builder will reuse resources to build the requested outputs where applicable.
424424
/// </para>
425425
/// <para>
426-
/// Additional artifacts may be built beyond the ones requested, if they are dependencies of the requested
427-
/// artifacts. For example, if <see cref="BuilderArtifacts.CharParser"/> is requested, the builder will also
428-
/// build <see cref="BuilderArtifacts.TokenizerOnChar"/>, <see cref="BuilderArtifacts.SemanticProviderOnChar"/>.
426+
/// Additional outputs may be built beyond the ones requested, if they are dependencies of the requested
427+
/// outputs. For example, if <see cref="BuilderOutputs.CharParser"/> is requested, the builder will also
428+
/// build <see cref="BuilderOutputs.TokenizerOnChar"/>, <see cref="BuilderOutputs.SemanticProviderOnChar"/>.
429429
/// </para>
430430
/// </remarks>
431-
public static BuilderResult<T> Build<T>(this IGrammarBuilder<T> builder, BuilderArtifacts artifacts, BuilderOptions? options = null) =>
432-
builder.BuildImpl<T>(artifacts, options);
431+
public static BuilderResult<T> Build<T>(this IGrammarBuilder<T> builder, BuilderOutputs outputs, BuilderOptions? options = null) =>
432+
builder.BuildImpl<T>(outputs, options);
433433

434434
/// <summary>
435435
/// Creates a <see cref="CharParser{T}"/> from the given <see cref="IGrammarBuilder{T}"/>.
@@ -445,34 +445,34 @@ public static BuilderResult<T> Build<T>(this IGrammarBuilder<T> builder, Builder
445445
/// property to <see cref="IReadOnlyList{BuilderDiagnostic}"/> of type <see cref="BuilderDiagnostic"/>.
446446
/// </returns>
447447
public static CharParser<T> Build<T>(this IGrammarBuilder<T> builder, BuilderOptions? options = null) =>
448-
builder.Build(BuilderArtifacts.CharParser, options).GetCharParserOrThrow();
448+
builder.Build(BuilderOutputs.CharParser, options).GetCharParserOrThrow();
449449

450450
/// <summary>
451-
/// Builds multiple artifacts from the given untyped <see cref="IGrammarBuilder"/>.
451+
/// Builds multiple outputs from the given untyped <see cref="IGrammarBuilder"/>.
452452
/// </summary>
453453
/// <typeparam name="T">The supposed return type of the parser and the semantic provider. Must be a reference type.</typeparam>
454454
/// <param name="builder">The grammar to build.</param>
455-
/// <param name="artifacts">The set of artifacts to build.</param>
455+
/// <param name="outputs">The set of outputs to build.</param>
456456
/// <param name="options">Used to customize the building process. Optional.</param>
457457
/// <returns>
458-
/// A <see cref="BuilderResult{T}"/> object with the properties of the requested artifacts populated.
458+
/// A <see cref="BuilderResult{T}"/> object with the properties of the requested outputs populated.
459459
/// </returns>
460460
/// <remarks>
461461
/// <para>
462-
/// The builder will reuse resources to build the requested artifacts where applicable.
462+
/// The builder will reuse resources to build the requested outputs where applicable.
463463
/// </para>
464464
/// <para>
465-
/// Additional artifacts may be built beyond the ones requested, if they are dependencies of the requested
466-
/// artifacts. For example, if <see cref="BuilderArtifacts.CharParser"/> is requested, the builder will also
467-
/// build <see cref="BuilderArtifacts.TokenizerOnChar"/>, <see cref="BuilderArtifacts.SemanticProviderOnChar"/>.
465+
/// Additional outputs may be built beyond the ones requested, if they are dependencies of the requested
466+
/// outputs. For example, if <see cref="BuilderOutputs.CharParser"/> is requested, the builder will also
467+
/// build <see cref="BuilderOutputs.TokenizerOnChar"/>, <see cref="BuilderOutputs.SemanticProviderOnChar"/>.
468468
/// </para>
469469
/// <para>
470470
/// If requested, the builder will create a syntax-checking parser and semantic provider that will not execute
471471
/// any semantic actions and produce <see langword="null"/> semantic values on success.
472472
/// </para>
473473
/// </remarks>
474-
public static BuilderResult<T?> BuildSyntaxCheck<T>(this IGrammarBuilder builder, BuilderArtifacts artifacts, BuilderOptions? options = null) where T : class? =>
475-
builder.BuildImpl<T?>(artifacts, options, isSyntaxCheck: true);
474+
public static BuilderResult<T?> BuildSyntaxCheck<T>(this IGrammarBuilder builder, BuilderOutputs outputs, BuilderOptions? options = null) where T : class? =>
475+
builder.BuildImpl<T?>(outputs, options, isSyntaxCheck: true);
476476

477477
/// <summary>
478478
/// Creates a syntax-checking <see cref="CharParser{T}"/> from the given <see cref="IGrammarBuilder{T}"/>.
@@ -491,15 +491,15 @@ public static CharParser<T> Build<T>(this IGrammarBuilder<T> builder, BuilderOpt
491491
/// property to <see cref="IReadOnlyList{BuilderDiagnostic}"/> of type <see cref="BuilderDiagnostic"/>.
492492
/// </remarks>
493493
public static CharParser<T?> BuildSyntaxCheck<T>(this IGrammarBuilder builder, BuilderOptions? options = null) where T : class? =>
494-
builder.BuildSyntaxCheck<T>(BuilderArtifacts.CharParser, options).GetCharParserOrThrow();
494+
builder.BuildSyntaxCheck<T>(BuilderOutputs.CharParser, options).GetCharParserOrThrow();
495495

496496
/// <inheritdoc cref="BuildSyntaxCheck{T}(IGrammarBuilder, BuilderOptions?)"/>
497497
public static CharParser<object?> BuildSyntaxCheck(this IGrammarBuilder builder, BuilderOptions? options = null) =>
498498
builder.BuildSyntaxCheck<object>(options);
499499

500-
/// <inheritdoc cref="BuildSyntaxCheck{T}(IGrammarBuilder, BuilderArtifacts, BuilderOptions?)"/>
501-
public static BuilderResult<object?> BuildSyntaxCheck(this IGrammarBuilder builder, BuilderArtifacts artifacts, BuilderOptions? options = null) =>
502-
builder.BuildSyntaxCheck<object>(artifacts, options);
500+
/// <inheritdoc cref="BuildSyntaxCheck{T}(IGrammarBuilder, BuilderOutputs, BuilderOptions?)"/>
501+
public static BuilderResult<object?> BuildSyntaxCheck(this IGrammarBuilder builder, BuilderOutputs outputs, BuilderOptions? options = null) =>
502+
builder.BuildSyntaxCheck<object>(outputs, options);
503503

504504
/// <summary>
505505
/// Obsolete. Use <see cref="BuildSyntaxCheck(IGrammarBuilder, BuilderOptions?)"/> instead.
@@ -519,7 +519,7 @@ public static CharParser<T> Build<T>(this IGrammarBuilder<T> builder, BuilderOpt
519519
/// <param name="builder">The grammar to build.</param>
520520
/// <remarks>
521521
/// By not building a whole grammar, some expensive steps are skipped, and
522-
/// by using this function instead of <see cref="Build{T}(IGrammarBuilder{T}, BuilderArtifacts, BuilderOptions?)"/>,
522+
/// by using this function instead of <see cref="Build{T}(IGrammarBuilder{T}, BuilderOutputs, BuilderOptions?)"/>,
523523
/// most of the grammar building code can be trimmed away. This function is
524524
/// useful only in some very limited scenarios, such as having many grammar
525525
/// builders with an identical grammar but different semantic providers.

0 commit comments

Comments
 (0)