#![deny(unreachable_pub)]
pub mod ast;
pub mod firsts;
pub mod follows;
pub mod grammar;
pub mod parser;
pub use self::{
grammar::{AssocKind, Precedence, SentenceGenerator, YaccGrammar},
parser::{YaccGrammarError, YaccGrammarErrorKind, YaccGrammarWarning, YaccGrammarWarningKind},
};
use proc_macro2::TokenStream;
use quote::quote;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum YaccKindResolver {
Force(YaccKind),
Default(YaccKind),
NoDefault,
}
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[non_exhaustive]
pub enum YaccKind {
Original(YaccOriginalActionKind),
Grmtools,
Eco,
}
impl quote::ToTokens for YaccKind {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.extend(match *self {
YaccKind::Grmtools => quote!(::cfgrammar::yacc::YaccKind::Grmtools),
YaccKind::Original(action_kind) => {
quote!(::cfgrammar::yacc::YaccKind::Original(#action_kind))
}
YaccKind::Eco => quote!(::cfgrammar::yacc::YaccKind::Eco),
})
}
}
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum YaccOriginalActionKind {
UserAction,
GenericParseTree,
NoAction,
}
impl quote::ToTokens for YaccOriginalActionKind {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.extend(match *self {
YaccOriginalActionKind::UserAction => {
quote!(::cfgrammar::yacc::YaccOriginalActionKind::UserAction)
}
YaccOriginalActionKind::GenericParseTree => {
quote!(::cfgrammar::yacc::YaccOriginalActionKind::GenericParseTree)
}
YaccOriginalActionKind::NoAction => {
quote!(::cfgrammar::yacc::YaccOriginalActionKind::NoAction)
}
})
}
}