Skip to content

Instantly share code, notes, and snippets.

View cppljevans's full-sized avatar

Larry Evans cppljevans

  • 01:40 (UTC -12:00)
View GitHub Profile
@cppljevans
cppljevans / parser.hpp
Created June 5, 2024 17:53
parser.hpp revision using simplified macro
// Copyright (C) 2024 T. Zachary Laine
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PARSER_PARSER_HPP
#define BOOST_PARSER_PARSER_HPP
#include <boost/parser/parser_fwd.hpp>
#include <boost/parser/concepts.hpp>
@cppljevans
cppljevans / toy_rule_parse_rule.cpp
Last active September 1, 2020 08:44
prototype_simplified_spirit_x3_rule
//Purpose:
// Simplify rule, rule_definition, parse_rule, BOOST_SPIRIT_DEFINE.
//References:
// [inline]
// https://isocpp.org/wiki/faq/inline-functions#where-to-put-inline-keyword
// https://stackoverflow.com/questions/3992980/c-inline-member-function-in-cpp-file
//===========================================================================
#include "toy_rule_parse_rule.hpp"
///////////////////////////////////////////////////////////////////////////////
// test code
@cppljevans
cppljevans / sehe-coliru-stackoverflow-answer.cpp
Created March 6, 2020 12:19
skipper in recursive context leads to infinite template instantiation
//OriginalCode:
// http://coliru.stacked-crooked.com/a/d149f05af81bf0cf
//WhichWasAnswerTo:
// https://stackoverflow.com/questions/45899090/recursive-rule-in-spirit-x3/45900983
//DownloadedOn:
// 2020-03-06.0512CST
//Modifications:
// WHAT:
// * added macro, USE_TOP_LEVEL_SKIPPER
// * depending on defined(USE_TOP_LEVEL_SKIPPER)
@cppljevans
cppljevans / date_parser-force_attr_propagation.cpp
Last active February 16, 2020 10:06
date_parser solution to stackoverflow problem
//Following code modifies:
// https://gist.github.com/cppljevans/0fede2c9c2e57f25712528dab4e6aec7#file-date_parser-rm_as_define-cpp
//by:
// 1) adding a macro, USE_ALTERNATIVES
// 2) using BOOST_FUSION_ADAPT_STRUCT
// 3) using rule
// 4) using force propagation flag in rule.
//to:
// show that even with attribute propagation, the attributes will not
// propage when there's any ALTERNATIVE's.
@cppljevans
cppljevans / x3-only_1_xform-double_int.cpp
Created March 6, 2019 05:53
Joel's suggested changes (and a little more)
//Purpose:
// Follow Joel's suggestion about changing the
// xform_rule attribute to double expressed here:
// https://github.com/boostorg/spirit/issues/459#issuecomment-469476231
//Result:
// **SAME** result when defined(CALL_RULE_DEFINITION_SPECIALIZATION).
// IOW, the wrong value for `attr_rule`. Without this define,
// the results are as expected, i.e. `attr_rule` == 1235.
// However, that's because, **behind the scenes**, spirit is
// making a redundant (i.e. useless) call to the default
@cppljevans
cppljevans / x3-employee-annot_attr.cpp
Last active June 6, 2018 14:35
x3 employees using alternative to position_tagged
/*=============================================================================
Copyright (c) 2002-2015 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
///////////////////////////////////////////////////////////////////////////////
//
// A parser for arbitrary tuples. This example presents a parser
// for an employee structure.
@cppljevans
cppljevans / Show -I flag OK
Last active March 23, 2018 16:43
variant implicit conversion test
-*- mode: compilation; default-directory: "~/prog_dev/boost/releases/ro/boost_1_65_1/sandbox/kojoley/test/" -*-
Compilation started at Fri Mar 23 11:20:46
make -k ls
ls -ld ../x3-variant-fixes/include/*
drwxrwxr-x 3 evansl evansl 4096 Mar 22 19:40 ../x3-variant-fixes/include/boost
Compilation finished at Fri Mar 23 11:20:46
//Purpose:
// Experiment with different methods for making code here:
// https://github.com/Kojoley/spirit/blob/8b76132c8ded0c63b8ecc7d1689627ae49d1fde9/include/boost/spirit/home/x3/operator/detail/sequence.hpp#L419
// a little more modular and help to answer question about
// whether to use lamba's as posed by Joel here:
// https://github.com/boostorg/spirit/pull/370#issuecomment-369410876
//Result:
// Works both when
// defined(USE_CONSTEXPR_IF_LAMBDA)
// and when
@cppljevans
cppljevans / d0424r0_test.cpp
Created August 16, 2016 12:24
illuminate create_window code in D0424R0.pdf
//Purpose:
// Illustrate the workings of the create_window code found in attachment to:
/*
https://groups.google.com/a/isocpp.org/forum/?utm_medium=email&utm_source=footer#!msg/std-proposals/b1X597zMx9s/4fnQB6gBCwAJ
*/
//Modifications:
// Renamed create_window to named_args and renamed many other
// types and variables to make them more generic or readable.
// Added several comments explaining purpose of various parts.
// Added extensive print statements to illustrate how code
@cppljevans
cppljevans / toy_why_define.cpp
Last active August 24, 2016 08:55
spirit toy.cpp modified to show need for BOOST_SPIRIT_DEFINE
//Purpose:
// Demonstrate the purpose BOOST_SPIRIT_DEFINE
// is to implement recursive rules.
//OriginalSource:
// https://github.com/boostorg/spirit/blob/develop/workbench/x3/toy/toy.cpp
//Modifications:
// Rm'ed use of context to implement recursiion and replaced with
// BOOST_SPIRIT_DEFINE
//===========================================================================
#include <iostream>