Skip to content

Releases: b3b00/csly

Release v3.8.0-alpha1

12 Feb 20:02
3974f0f

Choose a tag to compare

Release v3.8.0-alpha1 Pre-release
Pre-release

Ambiguous grammars

This alpha version is an attempt to allow ambiguous grammars.

CSLY now supports ambiguous grammars via parse forest capture and configurable resolution strategies. By default, behavior is unchanged.

  • Opt-in capture: set ParserConfiguration.CaptureAmbiguities = true to collect all optimal parses for ambiguous points.
  • Parse forest exposure: ParseResult.Forest provides multiple alternative syntax trees; ParseResult.SyntaxTree remains the main tree for backward compatibility.
  • Strategies: AmbiguityResolutionStrategy defines how the parser selects or surfaces alternatives:
    • First: pick the first successful derivation (legacy behavior).
    • All: keep all alternatives in Forest, no automatic visit.
    • ThrowException: raise when ambiguity is detected.
    • Longest: choose the derivation that consumes the most tokens (max end position).

Detection scope: ambiguity is detected when multiple alternatives succeed with the same maximum end position.

Ambiguity resolution strategy may be set in two ways :

  1. programatically by setting the parser.Configuration :

2 properties need to be set :

  1. CpatureAmbiguity : true id ambiguity must be managed, false otherwise
  2. AmbiguityResolutionStrategy : the resolution strategy AmbiguityResolutionStrategy enum.
parser.Configuration.CaptureAmbiguities = true;
parser.Configuration.AmbiguityStrategy = AmbiguityResolutionStrategy.All;

var result = parser.Parse(source);
if (result.IsAmbiguous)
{
    // inspect result.Forest.Trees
}
  1. Using attributes on parser definition :

Available attributes are :

  • [FirstDerivation] : first derivation strategy
  • [AllDerivation] : all derivation strategy
  • [LongestDerivation] : longest derivation strategy
  • [ThrowsErrorOnAmbiguity] : raise exception on ambiguity
 [BroadenTokenWindow]
    [ParserRoot("root")]
     [FirstDerivation]
    // [AllDerivation]
    // [LongestDerivation]
    // [ThrowsErrorOnAmbiguity]
    public class MyGrammar
    {
       // my grammar definition
    }

Release v3.7.7

11 Dec 11:56
ae37d73

Choose a tag to compare

Release v3.7.6

15 Oct 13:56
ec3c2db

Choose a tag to compare

v 3.7.6

Release v3.7.5

29 Aug 16:54
dcb3caf

Choose a tag to compare

v 3.7.5

Release v3.7.5-alpha1

28 Aug 18:34
1827955

Choose a tag to compare

v 3.7.5-alpha1

Release v3.7.4

08 Aug 13:58
36152e1

Choose a tag to compare

v 3.7.4

Release v3.7.3

25 Apr 10:45
ba79388

Choose a tag to compare

Release v3.7.2

24 Apr 11:56
5c461e5

Choose a tag to compare

#559 : remove newtonsoft json dependency. replace with System.Text.Json

Release v3.7.1

15 Apr 18:22
0a6adc2

Choose a tag to compare

Release v3.7.0

14 Apr 07:52
4c3754c

Choose a tag to compare

upgrade to .Net 8.0 : #556