Releases: b3b00/csly
Releases · b3b00/csly
Release v3.8.0-alpha1
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:
AmbiguityResolutionStrategydefines 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 :
- programatically by setting the parser.Configuration :
2 properties need to be set :
- CpatureAmbiguity : true id ambiguity must be managed, false otherwise
- AmbiguityResolutionStrategy : the resolution strategy
AmbiguityResolutionStrategyenum.
parser.Configuration.CaptureAmbiguities = true;
parser.Configuration.AmbiguityStrategy = AmbiguityResolutionStrategy.All;
var result = parser.Parse(source);
if (result.IsAmbiguous)
{
// inspect result.Forest.Trees
}
- 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
Release v3.7.6
v 3.7.6
Release v3.7.5
v 3.7.5
Release v3.7.5-alpha1
v 3.7.5-alpha1
Release v3.7.4
v 3.7.4
Release v3.7.3
Release v3.7.2
#559 : remove newtonsoft json dependency. replace with System.Text.Json
Release v3.7.1
v3.7.1
Release v3.7.0
upgrade to .Net 8.0 : #556