public void Can_resolve_references(String source) { var parser = new CapnpParser(source); var module = parser.Parse(); module = parser.ProcessParsedSource(module, null); }
public void Can_parse_schema_capnp() { var schemaFile = @"..\..\..\Tests\Schema\schema.capnp"; var schemaContent = File.ReadAllText(schemaFile); var parser = new CapnpParser(schemaContent); var module = parser.Parse(); module = parser.ProcessParsedSource(module, s => { if (s == "/capnp/c++.capnp") { return(@" @0xbdf87d7bb8304e81; $namespace(""capnp::annotations""); annotation namespace(file): Text; annotation name(field, enumerant, struct, enum, interface, method, param, group, union): Text; "); } throw new Exception("don't understand schema.capnp import " + s); }); Trace.WriteLine(module.ToString()); }
private CapnpType _ResolveImport(CapnpImport import) { if (_GetImportContents == null) throw new Exception("import attempted but no way to resolve it"); var source = _GetImportContents(import.File); var importedType = import.Type; var importParser = new CapnpParser(source); var parsedSource = importParser.Parse(); parsedSource = importParser.ProcessParsedSource(parsedSource, _GetImportContents); // No type specified, so return the module for later perusal. if (importedType == null) return parsedSource; if (importedType is CapnpReference) { var @ref = (CapnpReference)importedType; return parsedSource.ResolveFullName(@ref.FullName); } else Debug.Assert(false); return importedType; }
public void Can_do_me_some_parsing(String source) { var parser = new CapnpParser(source); var result = parser.Parse(); Trace.WriteLine(result); }
public void Can_handle_entire_capnp_syntax() { var source = File.ReadAllText("..\\..\\Parser\\FullSyntax.capnp"); var p = new CapnpParser(source); var m = p.Parse(); m = p.ProcessParsedSource(m, null); }
public void Fail_at_bad_input(String badSource) { try { var parser = new CapnpParser(badSource); var result = parser.Parse(); Assert.True(false); } catch (Xunit.Sdk.AssertException) { throw; } catch (Exception e) { // OK, for now Trace.WriteLine(e.Message); } }
public void Detect_bad_syntax(String source) { var p = new CapnpParser(source); try { p.ProcessParsedSource(p.Parse(), null); Assert.True(false); } catch { // todo: filter on exception later // OK // throw; } }
public void Can_resolve_imports(String source, String[] imports) { Func <String, String> getImport = s => { for (var i = 0; i < imports.Length; i++) { if (imports[i] == s) { return(imports[i + 1]); } } throw new Exception("could not find " + s); }; var parser = new CapnpParser(source); var phase1 = parser.Parse(); var phase2 = parser.ProcessParsedSource(phase1, getImport); }
public void Can_parse_capnp_test_file(String capnpFile) { var source = File.ReadAllText(capnpFile); var p = new CapnpParser(source); var m = p.Parse(); m = p.ProcessParsedSource(m, s => { if (s == "c++.capnp" || s == "/capnp/c++.capnp") { return(@" @0xbdf87d7bb8304e81; $namespace(""capnp::annotations""); annotation namespace(file): Text; annotation name(field, enumerant, struct, enum, interface, method, param, group, union): Text; "); } throw new Exception("don't understand schema.capnp import " + s); }); }
public void Can_resolve_imports(String source, String[] imports) { Func<String, String> getImport = s => { for (var i = 0; i < imports.Length; i++) if (imports[i] == s) return imports[i + 1]; throw new Exception("could not find " + s); }; var parser = new CapnpParser(source); var phase1 = parser.Parse(); var phase2 = parser.ProcessParsedSource(phase1, getImport); }
public void Can_parse_schema_capnp() { var schemaFile = @"..\..\..\Tests\Schema\schema.capnp"; var schemaContent = File.ReadAllText(schemaFile); var parser = new CapnpParser(schemaContent); var module = parser.Parse(); module = parser.ProcessParsedSource(module, s => { if (s == "/capnp/c++.capnp") return @" @0xbdf87d7bb8304e81; $namespace(""capnp::annotations""); annotation namespace(file): Text; annotation name(field, enumerant, struct, enum, interface, method, param, group, union): Text; "; throw new Exception("don't understand schema.capnp import " + s); }); Trace.WriteLine(module.ToString()); }
public void Can_parse_capnp_test_file(String capnpFile) { var source = File.ReadAllText(capnpFile); var p = new CapnpParser(source); var m = p.Parse(); m = p.ProcessParsedSource(m, s => { if (s == "c++.capnp" || s == "/capnp/c++.capnp") return @" @0xbdf87d7bb8304e81; $namespace(""capnp::annotations""); annotation namespace(file): Text; annotation name(field, enumerant, struct, enum, interface, method, param, group, union): Text; "; throw new Exception("don't understand schema.capnp import " + s); }); }