fromSource static method
Implementation
static Safety<RootCitrusSyntax> fromSource(String source) {
final log = Log(classLocation: RootCitrusSyntax, functionLocation: 'fromSource');
// 1.
final scanner = StringScanner<DerivationCitrusSyntax>.fromString(source);
final stringScannerCompileResult = scanner.compile(LeafCitrusSyntax.result);
log.add(stringScannerCompileResult);
// 1. より LeafCitrusSyntaxExceptionA は起こりえないので throw out.
if (stringScannerCompileResult is! Success<SyntaxScanner<DerivationCitrusSyntax, DerivationCitrusSyntax>, LeafCitrusSyntaxExceptionA>) Result.panic(CitrusSyntaxErrorA(), log);
final compileUnits = [
CompileUnit([
ListSyntaxVerify(ListOfIdentifierable.fromIterable),
ListSyntaxVerify(ListOfOperatable.fromIterable),
ListSyntaxVerify(ListOfWhiteSpace.fromIterable),
]),
CompileUnit([
OneLengthSyntaxVerify(Identifier.result),
OneLengthSyntaxVerify(Operator.result),
]),
CompileUnit([
TwoLengthSyntaxVerify(BlockType.new),
FiveLengthSyntaxVerify(InExpression.new),
OperatorExpressionVerify(),
ThreeLengthSyntaxVerify(PeriodExpression.new),
]),
CompileUnit([
ThreeLengthSyntaxVerify(EndBlock.new),
ThreeLengthSyntaxVerify(CurlyBind.new),
FiveLengthSyntaxVerify(StartBlock.new),
]),
CompileUnit([
TrunkSyntaxVerify(BlockSandwich.fromIterable),
]),
];
final syntaxCompileResult = stringScannerCompileResult.wrapped.compile(compileUnits);
final derivationSyntaxListResult = CitrusSyntaxList(syntaxCompileResult.wrapped);
final result = RootCitrusSyntax(derivationSyntaxListResult);
return Safety(result, log);
}