From a683b2d07b5c49230008d5ef37427bb29515ba6c Mon Sep 17 00:00:00 2001 From: Anthony VEREZ Date: Fri, 17 Nov 2023 02:30:42 -0500 Subject: [PATCH 1/7] Update host-applications.rst --- doc/host-applications.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/host-applications.rst b/doc/host-applications.rst index 0169072d9..6b3201f64 100644 --- a/doc/host-applications.rst +++ b/doc/host-applications.rst @@ -62,7 +62,7 @@ invocation of ``spicyc`` and can remove e.g., unused code. Since we generate output files with multiple invocations, optimizations could lead to incomplete code. -We also need ``spicyc`` to get generate some additional additional +We also need ``spicyc`` to generate some additional "linker" code implementing internal plumbing necessary for cross-module functionality. That's what ``-l`` (aka ``--output-linker``) does:: @@ -94,10 +94,11 @@ signatures: ``parse1`` The simplest form of parsing function receives a stream of input data, along with an optional view into the stream to limit the - region to parse if desired. ``parse``` will internally instantiate - an instance of the unit's ``struct``, and then feed the unit's - parser with the data stream. However, it won't provide access to - what's being parsed as it doesn't pass back the ``struct``. + region to parse if desired and an optional context. + ``parse1`` will internally instantiate an instance of the unit's + ``struct``, and then feed the unit's parser with the data stream. + However, it won't provide access to what's being parsed as it + doesn't pass back the ``struct``. ``parse2`` The second form takes a pre-instantiated instance of the unit's From 4b16683cd9d1a1597945dbe6f31a2b34049f04dc Mon Sep 17 00:00:00 2001 From: Anthony VEREZ Date: Fri, 17 Nov 2023 07:36:54 +0000 Subject: [PATCH 2/7] doc: Update my-http-excerpt.h --- doc/examples/my-http-excerpt.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/examples/my-http-excerpt.h b/doc/examples/my-http-excerpt.h index fa732c017..861c754ab 100644 --- a/doc/examples/my-http-excerpt.h +++ b/doc/examples/my-http-excerpt.h @@ -1,15 +1,15 @@ [...] namespace __hlt::MyHTTP { - struct RequestLine : hilti::rt::trait::isStruct, hilti::rt::Controllable { - std::optional method{}; - std::optional uri{}; - std::optional> version{}; + struct RequestLine : ::hilti::rt::trait::isStruct, ::hilti::rt::Controllable { + std::optional<::hilti::rt::Bytes> method{}; + std::optional<::hilti::rt::Bytes> uri{}; + std::optional<::hilti::rt::ValueReference> version{}; [...] }; - struct Version : hilti::rt::trait::isStruct, hilti::rt::Controllable { - std::optional number{}; + struct Version : ::hilti::rt::trait::isStruct, ::hilti::rt::Controllable { + std::optional<::hilti::rt::Bytes> number{}; [...] }; @@ -17,9 +17,9 @@ namespace __hlt::MyHTTP { } namespace hlt::MyHTTP::RequestLine { - extern auto parse1(hilti::rt::ValueReference& data, const std::optional& cur) -> hilti::rt::Resumable; - extern auto parse2(hilti::rt::ValueReference<__hlt::MyHTTP::RequestLine>& unit, hilti::rt::ValueReference& data, const std::optional& cur) -> hilti::rt::Resumable; - extern auto parse3(spicy::rt::ParsedUnit& gunit, hilti::rt::ValueReference& data, const std::optional& cur) -> hilti::rt::Resumable; + extern auto parse1(::hilti::rt::ValueReference<::hilti::rt::Stream>& data, const std::optional<::hilti::rt::stream::View>& cur, const std::optional<::spicy::rt::UnitContext>& context) -> ::hilti::rt::Resumable; + extern auto parse2(::hilti::rt::ValueReference<__hlt::MyHTTP::RequestLine>& unit, ::hilti::rt::ValueReference<::hilti::rt::Stream>& data, const std::optional<::hilti::rt::stream::View>& cur, const std::optional<::spicy::rt::UnitContext>& context) -> ::hilti::rt::Resumable; + extern auto parse3(::hilti::rt::ValueReference<::spicy::rt::ParsedUnit>& gunit, ::hilti::rt::ValueReference<::hilti::rt::Stream>& data, const std::optional<::hilti::rt::stream::View>& cur, const std::optional<::spicy::rt::UnitContext>& context) -> ::hilti::rt::Resumable; } [...] From ce99a8dee523eac6ffe618bb12de73a563d50beb Mon Sep 17 00:00:00 2001 From: Anthony VEREZ Date: Fri, 17 Nov 2023 08:07:54 +0000 Subject: [PATCH 3/7] doc: Fix compilation command for host application --- doc/host-applications.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/host-applications.rst b/doc/host-applications.rst index 6b3201f64..37490e217 100644 --- a/doc/host-applications.rst +++ b/doc/host-applications.rst @@ -148,7 +148,7 @@ If we want that, we can use ``parse2()`` instead and provide it with a :: - # clang++ -o my-http my-http-host.cc my-http-host.cc $(spicy-config --cxxflags --ldflags) + # clang++ -o my-http my-http-host.cc my-http.cc my-http-linker.cc $(spicy-config --cxxflags --ldflags) # ./my-http $'GET index.html HTTP/1.0\n' GET, /index.html, 1.0 method : GET From 35b902a5d3f642d6ccbf36810d07eacf7e6bd051 Mon Sep 17 00:00:00 2001 From: netantho Date: Fri, 17 Nov 2023 10:15:47 +0100 Subject: [PATCH 4/7] doc: fix Retrieving Available Parsers --- doc/host-applications.rst | 2 +- tests/spicy/doc/my-http-host-driver.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/host-applications.rst b/doc/host-applications.rst index 37490e217..00eeb5291 100644 --- a/doc/host-applications.rst +++ b/doc/host-applications.rst @@ -240,7 +240,7 @@ prints out our one available parser: .. literalinclude:: examples/my-http-host-driver.cc :caption: my-http-host.cc - :lines: 9-12,31-42,57-64 + :lines: 9-12,31-44,59-64 :language: c++ :: diff --git a/tests/spicy/doc/my-http-host-driver.cc b/tests/spicy/doc/my-http-host-driver.cc index 923e5bde5..bb99a4ee8 100644 --- a/tests/spicy/doc/my-http-host-driver.cc +++ b/tests/spicy/doc/my-http-host-driver.cc @@ -53,7 +53,7 @@ int main(int argc, char** argv) { auto unit = driver.processInput(**parser, data); assert(unit); - // Print out conntent of parsed unit. + // Print out content of parsed unit. print(unit->value()); // Wrap up runtime libraries. From c146154b97989ebb1fd35bbc4262332503a5f9a8 Mon Sep 17 00:00:00 2001 From: netantho Date: Fri, 17 Nov 2023 10:26:11 +0100 Subject: [PATCH 5/7] doc: Fix missing parenthesis --- doc/host-applications.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/host-applications.rst b/doc/host-applications.rst index 00eeb5291..a767a6670 100644 --- a/doc/host-applications.rst +++ b/doc/host-applications.rst @@ -277,7 +277,7 @@ generically over HILTI types like this unit: :lines: 15-30 :language: c++ -Adding ``print(unit->value()`` after the call to ``processInput()`` +Adding ``print(unit->value())`` after the call to ``processInput()`` then gives us this output: :: From b2d0750c40663e014ff5186f376082bb383c9ac8 Mon Sep 17 00:00:00 2001 From: netantho Date: Fri, 17 Nov 2023 10:57:59 +0100 Subject: [PATCH 6/7] Fix comment typo --- tests/spicy/doc/my-http-host-driver-hlto.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/spicy/doc/my-http-host-driver-hlto.cc b/tests/spicy/doc/my-http-host-driver-hlto.cc index eafc96edf..0f58d55f9 100644 --- a/tests/spicy/doc/my-http-host-driver-hlto.cc +++ b/tests/spicy/doc/my-http-host-driver-hlto.cc @@ -59,7 +59,7 @@ int main(int argc, char** argv) { auto unit = driver.processInput(**parser, data); assert(unit); - // Print out conntent of parsed unit. + // Print out content of parsed unit. print(unit->value()); // Wrap up runtime libraries. From a58d53884c6f053fec9d3d9f6ac3338fc637ac95 Mon Sep 17 00:00:00 2001 From: netantho Date: Fri, 17 Nov 2023 11:14:27 +0100 Subject: [PATCH 7/7] Fix commands for dynamic loading example --- doc/host-applications.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/host-applications.rst b/doc/host-applications.rst index a767a6670..b68d5cf5c 100644 --- a/doc/host-applications.rst +++ b/doc/host-applications.rst @@ -308,8 +308,9 @@ taking the file to load from the command line: :: # $(spicy-config --cxx) -o my-driver my-driver.cc $(spicy-config --cxxflags --ldflags --dynamic-loading) - # spicyc -j my-http.spicy >my-http.hlto - # ./my-driver my-http.hlto "$(cat data)" + # spicyc -j -o my-http.hlto my-http.spicy + # echo "GET /index.html HTTP/1.0\n\n" > data + # ./my-driver my-http.hlto MyHTTP::RequestLine "$(cat data)" Available parsers: MyHTTP::RequestLine