From d5c366adb8ed3be1a47d8e0e0a9b7152d24632d9 Mon Sep 17 00:00:00 2001 From: Colin Rundel Date: Sat, 13 Jan 2024 19:52:56 -0500 Subject: [PATCH] Remove non-functional code-block code for now (available in code-block branch) --- R/RcppExports.R | 4 -- src/RcppExports.cpp | 12 ------ src/parse_code_block.h | 83 ------------------------------------------ src/parse_rmd.h | 1 - src/parser.cpp | 15 -------- 5 files changed, 115 deletions(-) delete mode 100644 src/parse_code_block.h diff --git a/R/RcppExports.R b/R/RcppExports.R index aff2988..186156c 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -29,7 +29,3 @@ check_option_parser <- function(str) { .Call(`_parsermd_check_option_parser`, str) } -check_code_block_parser <- function(str) { - .Call(`_parsermd_check_code_block_parser`, str) -} - diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 825b1fd..a230771 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -89,17 +89,6 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } -// check_code_block_parser -Rcpp::List check_code_block_parser(std::string const& str); -RcppExport SEXP _parsermd_check_code_block_parser(SEXP strSEXP) { -BEGIN_RCPP - Rcpp::RObject rcpp_result_gen; - Rcpp::RNGScope rcpp_rngScope_gen; - Rcpp::traits::input_parameter< std::string const& >::type str(strSEXP); - rcpp_result_gen = Rcpp::wrap(check_code_block_parser(str)); - return rcpp_result_gen; -END_RCPP -} static const R_CallMethodDef CallEntries[] = { {"_parsermd_parse_rmd_cpp", (DL_FUNC) &_parsermd_parse_rmd_cpp, 2}, @@ -109,7 +98,6 @@ static const R_CallMethodDef CallEntries[] = { {"_parsermd_check_markdown_parser", (DL_FUNC) &_parsermd_check_markdown_parser, 1}, {"_parsermd_check_markdown_heading_parser", (DL_FUNC) &_parsermd_check_markdown_heading_parser, 1}, {"_parsermd_check_option_parser", (DL_FUNC) &_parsermd_check_option_parser, 1}, - {"_parsermd_check_code_block_parser", (DL_FUNC) &_parsermd_check_code_block_parser, 1}, {NULL, NULL, 0} }; diff --git a/src/parse_code_block.h b/src/parse_code_block.h deleted file mode 100644 index c241b17..0000000 --- a/src/parse_code_block.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef PARSE_CODE_BLOCK_HPP -#define PARSE_CODE_BLOCK_HPP - -//#define BOOST_SPIRIT_X3_DEBUG -#include -#include -#include - -#include "parser_error_handler.h" - -#include "parse_indent.h" -#include "parse_chunk.h" - -namespace client { namespace ast { -namespace x3 = boost::spirit::x3; - -struct code_block : x3::position_tagged{ - std::string indent; - std::string fence; - std::string info; - std::vector code; -}; -} } - -BOOST_FUSION_ADAPT_STRUCT( - client::ast::code_block, - indent, fence, info, code -) - -namespace client { namespace parser { - namespace x3 = boost::spirit::x3; - - auto const fence_pat = x3::rule {"fence"} - = x3::repeat(3, x3::inf)[x3::char_('`')] | - x3::repeat(3, x3::inf)[x3::char_('~')]; - - struct fence{}; - - auto start_fence = x3::rule {"start fence"} - = fence_pat[ - ([](auto& ctx) { - x3::get(ctx) = x3::_attr(ctx); - }) - ]; - - auto end_fence = x3::rule {"end fence"} - = fence_pat[ - ([](auto& ctx) { - x3::_pass(ctx) = (x3::get(ctx) == x3::_attr(ctx)); - }) - ]; - - //auto const block_start = x3::rule {"block start"} - //= - - - auto const block_end = x3::rule {"block end"} - = x3::lexeme[ - x3::expect[ x3::omit[ end_indent ] ] >> - x3::expect[ x3::omit[ end_fence ] ] - ];// >> *x3::lit(" ") >> x3::eol - //| &x3::lexeme[ x3::omit[ end_indent ] >> x3::lit("```{") ]; - // Chunk can be ended by a new chunk starting see Yihui's book Sec 5.1.4 - // look ahead to match but not consume this new chun - - struct code_block_class : error_handler, x3::annotate_on_success {}; - x3::rule const code_block = "code_block"; - - auto const code_block_def - = x3::with(std::string()) [ x3::with(std::string()) [ - x3::lexeme[ - (start_indent >> start_fence >> *(x3::char_ - x3::eol)) >> x3::eol - ] >> - chunk_code >> - x3::expect[block_end] - ] ]; - - BOOST_SPIRIT_DEFINE(code_block); - -} } - - -#endif diff --git a/src/parse_rmd.h b/src/parse_rmd.h index 0f6bd10..8194a11 100644 --- a/src/parse_rmd.h +++ b/src/parse_rmd.h @@ -7,7 +7,6 @@ #include "parse_yaml.h" #include "parse_indent.h" #include "parse_chunk.h" -#include "parse_code_block.h" #include "parse_rmd_ast.h" namespace client { namespace parser { diff --git a/src/parser.cpp b/src/parser.cpp index 6752d16..db0c8b9 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -111,18 +111,3 @@ Rcpp::List check_option_parser(std::string const& str) { } -// [[Rcpp::export]] -Rcpp::List check_code_block_parser(std::string const& str) { - namespace x3 = boost::spirit::x3; - - client::ast::code_block expr; - auto const parser = client::parser::code_block; - parse_str(str, false, parser, expr); - - return Rcpp::List::create( - Rcpp::Named("indent") = expr.indent, - Rcpp::Named("fence") = expr.fence, - Rcpp::Named("info") = expr.info, - Rcpp::Named("code") = expr.code - ); -}