public override FmtToken Format(FmtToken directives) => FmtToken.Concat( directives, "{", FmtToken.Block(Fields.Select(f => FmtToken.Concat(f.Format(), ","))) .WithIntegerTokenMap(), "}" ).WithTokenNames(null, "", "core", "");
public override FmtToken Format(FmtToken directives) => FmtToken.Concat( Implements.Length > 0 ? FmtToken.Concat(" implements ", FmtToken.Concat(Implements.Select(f => FmtToken.Concat(f, " "))).WithIntegerTokenMap()) : "", directives, "{", FmtToken.Block(Fields.Select(f => FmtToken.Concat(f, ","))) .WithIntegerTokenMap(), "}" ) .WithTokenNames("core.implements", null, "", "core.fields", "");
public FmtToken Format(string rootType) { if (Entities.Length >= 0 && Types.Any(t => t.Name == rootType)) { throw new InvalidOperationException($"Type with name '{rootType}' already exists in the schema so it can't be root type."); } return(FmtToken.Block( FmtToken.Block(Types).WithIntegerTokenMap(), Entities.Length == 0 && rootType != null ? "" : FmtToken.Concat("type ", rootType, "{", FmtToken.Block(Entities).WithIntegerTokenMap(), "}") ) .WithTokenNames( "types", "entities" )); }