AXE 2.1
 |
AXE is a recursive descent parser generator C++ library with the following
characteristics:
- uses C++17 facilities for natural EBNF-like grammar specification
- a large set of predefined syntax rules and semantic actions
- many operators overloaded for intuitively describing grammar
- easily extensible with custom rules
- in-site rules and semantic actions creation using lambda functions
- parse tree generation and conversion to xml
- most rules are character type agnostic, and can be reused with different
iterator types
- can be used to create parsers for text, binary, and mixed data
- no arbitrary distinction between lexical analisys (tokenezation) and parsing
- small run-time overhead resulting in fast, compact executable
- header only library, no linking required
- platform agnostic, uses only standard C++17 compiler
|
Examples:
Telephone number parser.
EBNF:
phone_number ::= "(" area_code ")" prefix "-" suffix;
area_code ::= number number number;
prefix ::= number number number;
suffix ::= number number number number;
AXE:
using namespace axe::shortcuts;
auto area_code = _d * 3;
auto prefix = _d * 3;
auto suffix = _d * 4;
auto phone_number = '(' & area_code & ')' & prefix & '-' & suffix;
And you can use in-place extractors to extract those numbers as well:
unsigned area_code, prefix, suffix;
auto phone_number =
'(' & 3*_d >> area_code & ')'
& 3*_d >> prefix
& '-' & 4*_d >> suffix;
assert( parse( phone_number, "(800)555-1234" ).matched );
|
Copyright © 2006-2019 GB Research, LLC. All Rights Reserved.
|