Skip to content

Commit

Permalink
Rename extensions to experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
Ygg01 committed Oct 24, 2023
1 parent 9524f98 commit 21367b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions Linguini.Bundle/Builder/LinguiniBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ private class StepBuilder : IReadyStep, ILocaleStep, IResourceStep
private Func<string, string>? _transformFunc;
private readonly Dictionary<string, ExternalFunction> _functions = new();
private bool _concurrent;
private readonly bool _enableExtensions;
private readonly bool _enableExperimental;

internal StepBuilder(bool enableExtensions = false)
internal StepBuilder(bool isExperimental = false)
{
_culture = System.Globalization.CultureInfo.CurrentCulture;
_enableExtensions = enableExtensions;
_enableExperimental = isExperimental;
}

public IReadyStep SetUseIsolating(bool isIsolating)
Expand Down Expand Up @@ -130,7 +130,7 @@ public FluentBundle UncheckedBuild()
Locales = _locales,
UseIsolating = _useIsolating,
UseConcurrent = _concurrent,
EnableExtensions = _enableExtensions,
EnableExtensions = _enableExperimental,
};
var bundle = FluentBundle.MakeUnchecked(concurrent);
bundle.Culture = _culture;
Expand Down Expand Up @@ -190,14 +190,14 @@ public IResourceStep CultureInfo(CultureInfo culture)

public IReadyStep AddResource(string unparsed)
{
var resource = new LinguiniParser(unparsed, _enableExtensions).Parse();
var resource = new LinguiniParser(unparsed, _enableExperimental).Parse();
_resources.Add(resource);
return this;
}

public IReadyStep AddResource(TextReader unparsed)
{
var resource = new LinguiniParser(unparsed, _enableExtensions).Parse();
var resource = new LinguiniParser(unparsed, _enableExperimental).Parse();
_resources.Add(resource);
return this;
}
Expand All @@ -206,7 +206,7 @@ public IReadyStep AddResources(params TextReader[] unparsedStreamList)
{
foreach (var unparsed in unparsedStreamList)
{
var parsed = new LinguiniParser(unparsed, _enableExtensions).Parse();
var parsed = new LinguiniParser(unparsed, _enableExperimental).Parse();
_resources.Add(parsed);
}

Expand All @@ -217,7 +217,7 @@ public IReadyStep AddResources(IEnumerable<string> unparsedResources)
{
foreach (var unparsed in unparsedResources)
{
var parsed = new LinguiniParser(unparsed, _enableExtensions).Parse();
var parsed = new LinguiniParser(unparsed, _enableExperimental).Parse();
_resources.Add(parsed);
}

Expand All @@ -228,7 +228,7 @@ public IReadyStep AddResources(params string[] unparsedResourceArray)
{
foreach (var unparsed in unparsedResourceArray)
{
var parsed = new LinguiniParser(unparsed, _enableExtensions).Parse();
var parsed = new LinguiniParser(unparsed, _enableExperimental).Parse();
_resources.Add(parsed);
}

Expand All @@ -239,7 +239,7 @@ public IReadyStep AddResources(IEnumerable<TextReader> unparsedStream)
{
foreach (var unparsed in unparsedStream)
{
var parsed = new LinguiniParser(unparsed, _enableExtensions).Parse();
var parsed = new LinguiniParser(unparsed, _enableExperimental).Parse();
_resources.Add(parsed);
}

Expand Down
20 changes: 10 additions & 10 deletions Linguini.Syntax/Parser/LinguiniParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ namespace Linguini.Syntax.Parser
public class LinguiniParser
{
private readonly ZeroCopyReader _reader;
private readonly bool _enableExtensions;
private readonly bool _enableExperimental;
private const string CR = "\n";

/// <summary>
/// Set input to <c>string</c>
/// </summary>
/// <param name="input">Input to be parsed</param>
/// <param name="enableExtensions">Using non-standard Fluent extensions</param>
public LinguiniParser(string input, bool enableExtensions = false)
/// <param name="enableExperimental">Using non-standard Fluent extensions</param>
public LinguiniParser(string input, bool enableExperimental = false)
{
_reader = new ZeroCopyReader(input);
_enableExtensions = enableExtensions;
_enableExperimental = enableExperimental;
}

/// <summary>
/// Set input to <c>TextReader</c>
/// </summary>
/// <param name="input">TextReader to be parsed to Fluent AST.</param>
/// <param name="enableExtensions">Using non-standard Fluent extensions</param>
public LinguiniParser(TextReader input, bool enableExtensions = false)
/// <param name="enableExperimental">Using non-standard Fluent extensions</param>
public LinguiniParser(TextReader input, bool enableExperimental = false)
{
using (input)
{
_reader = new ZeroCopyReader(input.ReadToEnd());
_enableExtensions = enableExtensions;
_enableExperimental = enableExperimental;
}
}

Expand Down Expand Up @@ -462,7 +462,7 @@ private bool TryGetPattern(out Pattern? pattern, out ParseError? error)
elements.Add(new Placeable(exp));
textElementRole = TextElementPosition.Continuation;
}
else if (_enableExtensions && '-' == _reader.PeekChar() && textElementRole != TextElementPosition.LineStart)
else if (_enableExperimental && '-' == _reader.PeekChar() && textElementRole != TextElementPosition.LineStart)
{
_reader.Position += 1;
if (_reader.TryPeekChar(out var c) && c.IsAsciiAlphabetic())
Expand Down Expand Up @@ -870,7 +870,7 @@ private bool TryGetExpression([NotNullWhen(true)] out IExpression? retVal, out P
&& inlineExpression is not NumberLiteral
&& inlineExpression is not VariableReference
&& inlineExpression is not FunctionReference
&& (!_enableExtensions || inlineExpression is not DynamicReference))
&& (!_enableExperimental || inlineExpression is not DynamicReference))
{
retVal = null;
error = ParseError.ExpectedSimpleExpressionAsSelector(_reader.Position, _reader.Row);
Expand Down Expand Up @@ -1129,7 +1129,7 @@ private bool TryGetInlineExpression(bool onlyLiteral, [NotNullWhen(true)] out II
return false;
}
}
if (_enableExtensions && '$' == peekChr && _reader.PeekChar(1) == '$')
if (_enableExperimental && '$' == peekChr && _reader.PeekChar(1) == '$')
{
_reader.Position += 3;
return TryGetDynamicReference(out expr, out error);
Expand Down

0 comments on commit 21367b4

Please sign in to comment.