Crate tagua_parser

Source
Expand description

Tagua VM

Tagua VM is an experimental PHP Virtual Machine written with the Rust language and the LLVM Compiler Infrastructure.

This library contains lexical and syntactic analysers, aka the parser, for the PHP language.

This is a parser combinator. The immediate consequence is that the lexical and syntax analyzers form a monolithic algorithm. The organization is the following:

  • The tokens module declares all the lexemes,
  • The rules module declares the grammar as a set of rules,
  • The ast module contains the structure that will constitute the AST.

The parser is based on nom. nom is a parser combinator library with a focus on safe parsing, streaming patterns, and as much as possible zero copy. We try to enforce the zero copy property to hold.

Re-exports§

pub use self::internal::*;

Modules§

ast
Structures that will constitute the Abstract Syntax Tree.
internal
Internal utilities for the parser.
macros
Extra macros helping to write parsers.
rules
The grammar as a set of rules.
tokens
List of lexemes.

Macros§

exclude
exclude!(I -> Result<I, O>, I -> Result<I, P>) => I -> Result<I, 0> returns the result of the first parser if the second fails. Both parsers run on the same input.
first
first!(I -> Result<I, O>) => I -> Result<I, O> is applying the skip rule before the first argument; it allows to skip tokens.
itag
itag!(&[T]: nom::AsBytes) => &[T] -> Result<&[T], &[T]> declares a case-insensitive ASCII array as a suite to recognize.
keyword
keyword!(&[T]: nom::AsBytes) => &[T] -> Result<&[T], &[T]> is an alias to the itag macro.

Functions§

parse
Complete parsing of a datum starting by the sentence symbol of the grammar.