private static NcParser GetSqlParser() { var assembly = Assembly.GetExecutingAssembly(); return(NcParser.LoadFromAssembly(assembly, "Nccc.Tests.SQL.sql.grammer", settings => { settings.CaseSensitive = false; })); }
public void TestSample() { var src = Assembly.GetExecutingAssembly().ReadString("Nccc.Tests.Json.sample.json"); var parser = NcParser.LoadFromAssembly(Assembly.GetExecutingAssembly(), "Nccc.Tests.Json.json.grammer"); var parseResult = parser.Parse(src); Console.WriteLine(parseResult.ToSExp().ToPrettyString()); Assert.IsTrue(parseResult.IsSuccess()); }
public void TestError() { var expectMessage = "哈哈"; var src = "[1,2,3"; var parser = NcParser.LoadFromAssembly(Assembly.GetExecutingAssembly(), "Nccc.Tests.Json.json.grammer", settings => { settings.Locale.Language = "zh-cn"; settings.Locale.Set("zh-cn", new Dictionary <string, string> { { "expect", expectMessage } }); }); var parseResult = parser.Parse(src); Console.WriteLine(parseResult.ToSExp().ToPrettyString()); Assert.IsFalse(parseResult.IsSuccess()); Assert.IsTrue(parseResult.Message.Contains(expectMessage)); }