Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ pub struct NonTerminal {
#[derive(Debug)]
pub struct Production {
pub symbols: Vec<Symbol>,
pub action: Action,
}

#[derive(Debug)]
Expand Down Expand Up @@ -131,12 +130,6 @@ pub enum RepeatOp {
Question,
}

#[derive(Debug)]
pub enum Action {
User(syn::Expr),
Fallible(syn::Expr),
}

impl Parse for FieldPattern {
fn parse(input: &ParseBuffer) -> syn::Result<Self> {
let field_name = input.parse::<syn::Ident>()?;
Expand Down Expand Up @@ -325,11 +318,10 @@ impl Parse for NonTerminal {
impl Parse for Production {
fn parse(input: &ParseBuffer) -> syn::Result<Self> {
let mut symbols: Vec<Symbol> = vec![];
while !input.peek(syn::token::FatArrow) {
while !input.peek(syn::token::Comma) {
symbols.push(input.parse::<Symbol>()?);
}
let action = input.parse::<Action>()?;
Ok(Production { symbols, action })
Ok(Production { symbols })
}
}

Expand Down Expand Up @@ -383,18 +375,6 @@ fn symbol0(input: &ParseBuffer) -> syn::Result<Symbol> {
// }
}

impl Parse for Action {
fn parse(input: &ParseBuffer) -> syn::Result<Self> {
input.parse::<syn::token::FatArrow>()?;
if input.peek(syn::token::Question) {
input.parse::<syn::token::Question>()?;
Ok(Action::Fallible(input.parse::<syn::Expr>()?))
} else {
Ok(Action::User(input.parse::<syn::Expr>()?))
}
}
}

impl Parse for GrammarItem {
fn parse(input: &ParseBuffer) -> syn::Result<Self> {
if input.peek(syn::token::Type) {
Expand Down
Loading