Git Product home page Git Product logo

axe's Introduction

AXE

AXE is a C++ library that provides facilities to build recursive descent parsers. A recursive descent parser is a top-down parser built from a set of mutually-recursive procedures (or classes) where each such procedure (or class) implements one of the production rules of the grammar. AXE library contains a set of classes, functions, and operators to define syntax rules and semantic actions. The library uses standard C++17 and doesn’t require compiler/platform specific facilities. It's been tested with Visual C++ 2017 and expected to work with any other reasonably compliant C++17 compiler. AXE is a header only library, it doesn't require linking. You only need to add

#include <axe.h>

in your source files and set the include directory in your compiler environment to point to axe/include.

axe's People

Contributors

gbresearch avatar

Stargazers

 avatar Basile Starynkevitch avatar ollydbg avatar Max Klimenchuk avatar DD avatar ABMT avatar Elijah Hopp avatar czc avatar Jonas Bülow avatar Darrin Smart avatar Chris Reuter avatar  avatar Andrey Nekrasov avatar myoshika avatar Daniel Shiposha avatar

Watchers

DD avatar Elijah Hopp avatar  avatar ABMT avatar

axe's Issues

VC2019 throws error.

Severity Code Description Project File Line Suppression State
Error C2386 'parse_tree_result_t': a symbol with this name already exists in the current scope UnrealTable C:\Users\foo\Documents\Unreal Projects\AXE\include\axe_composite.h 109

... so I really like the project... but IDK... sorta blocked here. It twiggs many buttons that make me happy, tho.

convert_iterator doesn't work with const char*

convert_iterator (and e.g., r_ucase and other converting rules) assume that the iterator type is a C++ iterator, and not a const char*.
This means parsing rules expect an std::string or other container, and std::string_view will case a compilation error.

How to add semantic attributes

Hi,
I like the library but the documentation does not show how to add semantic elements to the parse rules. Since there's no wiki, i'm asking here.

The documentation says that there is a Data element of the result (that we can fetch using the get_as<> function), which I think can be used but my question how can I define the semantic element so I can build an AST using that data element?. Yacc has $$, $1, $2... to do this, so does axe have an equivalent? For instance how to do something like the following (if possible):

struct value{
  int     intVal;
  double  doubleVal;  
}
auto number = double_ >>[](auto a, auto b){ $$ = value{ -1, atof(*a)}; }
            | _int;   >>[](auto a, auto b){ $$ = value{ atoi(*a), -1.0}; }

auto expr = (number & '+' & number )  >> [](auto a, auto b){
   if ($1.intVal< 0) 
      $$ = value{-1,  $1.doubleVal + ($2.intVal < 0 ?  $2.doubleVal < 0 :  $2.intVal)};
   else 
      $$ = value{$1.intVal+ ($2.intVal < 0 ?  $2.doubleVal < 0 :  $2.intVal)};
};

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.