```{index} single: XS::Parse::Keyword ``` # XS::Parse::Keyword ```{pperl-module-badges} XS::Parse::Keyword ``` The engine new keywords and infix operators are built on: modules such as Syntax::Keyword::Try describe their syntax as a list of pieces - a block, an expression, an identifier, a literal word, parentheses around more pieces - and XS::Parse::Keyword parses the source for them and hands the parsed pieces to the module, which builds the code. XS::Parse::Infix does the same for operators that sit between two expressions, as `eq` and `==` do, at the precedence the operator asks for. The modules built on it are what a program uses; on its own it provides no keyword. XS::Parse::Keyword::FromPerl and XS::Parse::Infix::FromPerl make it available to Perl code. This is a native implementation of XS::Parse::Keyword 0.51's `src/keyword.c` and `src/infix.c` with the interface its consumers bind to; its `XS/Parse/Keyword.pm` and `XS/Parse/Infix.pm` are used unchanged. ## Synopsis ```perl use XS::Parse::Infix; print XS::Parse::Infix::check_opname("isa") ? "valid\n" : "invalid\n"; print "the parser takes infix plugins\n" if XS::Parse::Infix::HAVE_PL_INFIX_PLUGIN; ``` The ABI consumers use is XSParseKeyword.h's and XSParseInfix.h's: `BOOT` publishes its version range and entry points in `PL_modglobal`, which `boot_xs_parse_keyword` and `boot_xs_parse_infix` read. Design: docs/internal/design/xs-parse-keyword.md. ## Modules - [`XS::Parse::Keyword::FromPerl`](Keyword/FromPerl) - New keywords written in Perl: `register_xs_parse_keyword` gives a keyword its syntax as a list of pieces (`XPK_BLOCK`, `XPK_TERMEXPR`, `XPK_PARENS(...)` and the others the module exports) and a `build` sub, which gets the parsed pieces and returns the optree the keyword compiles to, made with Optree::Generate. - [`XS::Parse::Keyword::infix`](Keyword/infix) - XS::Parse::Infix, src/infix.c: infix operators registered by other modules, parsed through perl's `PL_infix_plugin` (5.37.7 on) and offered to keyword pieces (`XPK_INFIX_*`), with an optional wrapper function per operator and a B::Deparse hook. ```{toctree} :hidden: :maxdepth: 1 Keyword/FromPerl Keyword/infix ```