From 6f259ac4898447d29b31e24d13705c07e0098711 Mon Sep 17 00:00:00 2001 From: Igor Dejanovic Date: Thu, 19 Oct 2023 21:46:21 +0200 Subject: [PATCH] rework: simplify API by reexporting public types --- docs/src/builders.md | 6 +-- docs/src/parsing/expressions/src/main.rs | 2 +- .../calculator/calculator1/src/calculator.rs | 26 +++++----- .../calculator1/src/calculator_actions.rs | 5 +- .../calculator/calculator1/src/main.rs | 2 +- .../calculator/calculator1/src/tests.rs | 2 +- .../calculator/calculator2/src/calculator.rs | 26 +++++----- .../calculator2/src/calculator_actions.rs | 5 +- .../calculator/calculator2/src/main.rs | 2 +- .../calculator/calculator2/src/tests.rs | 2 +- .../calculator/calculator3/src/calculator.rs | 26 +++++----- .../calculator3/src/calculator_actions.rs | 5 +- .../calculator/calculator3/src/main.rs | 2 +- .../calculator/calculator3/src/tests.rs | 2 +- .../calculator/calculator4/src/calculator.rs | 26 +++++----- .../calculator4/src/calculator_actions.rs | 5 +- .../calculator/calculator4/src/main.rs | 2 +- .../calculator/calculator4/src/tests.rs | 2 +- .../calculator/calculator5/src/calculator.rs | 26 +++++----- .../calculator5/src/calculator_actions.rs | 5 +- .../calculator/calculator5/src/main.rs | 2 +- .../calculator/calculator5/src/tests.rs | 2 +- .../src/ast_actions/calculator01_actions.rs | 4 +- .../ast_actions/calculator02_ambig_actions.rs | 4 +- .../calculator03_ambig_prodkind_actions.rs | 4 +- .../calculator04_ambig_lhs_actions.rs | 4 +- examples/calculator/src/ast_actions/tests.rs | 2 +- .../src/calc_actions/calculator01_actions.rs | 4 +- .../calculator02_ambig_actions.rs | 4 +- .../calculator03_ambig_prodkind_actions.rs | 4 +- .../calculator04_ambig_lhs_actions.rs | 4 +- examples/calculator/src/calc_actions/tests.rs | 8 ++-- examples/json/src/json_actions.rs | 4 +- examples/json/src/main.rs | 2 +- rustemo-compiler/src/generator/mod.rs | 2 +- rustemo-compiler/src/grammar/builder.rs | 2 +- rustemo-compiler/src/grammar/mod.rs | 2 +- rustemo/src/lib.rs | 48 +++++++++++++------ tests/src/ambiguity/mod.rs | 3 +- .../custom_builder/custom_builder_builder.rs | 6 +-- tests/src/builder/custom_builder/mod.rs | 4 +- tests/src/builder/generic_tree/mod.rs | 3 +- tests/src/builder/use_context/mod.rs | 3 +- .../use_context/use_context_actions.rs | 5 +- tests/src/from_file/mod.rs | 3 +- tests/src/glr/build/mod.rs | 3 +- tests/src/glr/evaluate/calc_actions.rs | 4 +- tests/src/glr/evaluate/calc_eval_actions.rs | 4 +- tests/src/glr/evaluate/mod.rs | 3 +- tests/src/glr/forest/mod.rs | 3 +- .../src/glr/special/bounded_ambiguity/mod.rs | 4 +- .../special/bounded_direct_ambiguity/mod.rs | 4 +- tests/src/glr/special/cyclic_1/mod.rs | 3 +- tests/src/glr/special/cyclic_2/mod.rs | 3 +- tests/src/glr/special/farshi_g7/mod.rs | 4 +- tests/src/glr/special/farshi_g8/mod.rs | 4 +- tests/src/glr/special/highly_ambiguous/mod.rs | 4 +- tests/src/glr/special/knuth_lr1/mod.rs | 3 +- .../nondeterministic_palindromes/mod.rs | 3 +- .../glr/special/reduce_enough_empty/mod.rs | 4 +- .../special/reduce_enough_many_empty/mod.rs | 4 +- tests/src/glr/special/right_nullable/mod.rs | 3 +- .../glr/special/unbounded_ambiguity/mod.rs | 4 +- tests/src/layout/ast/mod.rs | 3 +- tests/src/layout/generic_tree/mod.rs | 3 +- .../custom_lexer/custom_lexer_1_actions.rs | 4 +- .../custom_lexer/custom_lexer_1_lexer.rs | 10 +--- .../custom_lexer/custom_lexer_2_actions.rs | 4 +- .../custom_lexer/custom_lexer_2_lexer.rs | 10 +--- tests/src/lexer/custom_lexer/mod.rs | 3 +- tests/src/output_dir/mod.rs | 3 +- tests/src/output_dir/output_dir.rs | 26 +++++----- .../src/output_dir/output_dir_act_actions.rs | 4 +- tests/src/output_dir/output_dir_actions.rs | 4 +- tests/src/partial/mod.rs | 3 +- tests/src/rule_patterns/mod.rs | 3 +- .../lalr_reduce_reduce_conflict/mod.rs | 3 +- .../nondeterministic_palindromes/mod.rs | 3 +- tests/src/sugar/one_or_more/mod.rs | 3 +- tests/src/sugar/optional/mod.rs | 3 +- tests/src/sugar/zero_or_more/mod.rs | 3 +- tests/src/unicode/mod.rs | 3 +- 82 files changed, 210 insertions(+), 264 deletions(-) diff --git a/docs/src/builders.md b/docs/src/builders.md index 87dab080..a2c09b60 100644 --- a/docs/src/builders.md +++ b/docs/src/builders.md @@ -160,9 +160,9 @@ If you have a specific requirement for the build process you can implement a builder from scratch. To provide a custom builder you start with a type that implements a -`rustemo::builder::Builder` trait and after that implements a concrete parsing -algorithm trait. Currently, Rustemo is a LR parser thus you can use -`rustemo::builder::lr::Builder` trait. +`rustemo::Builder` trait and after that implements a concrete parsing algorithm +trait. Currently, Rustemo is a LR parser thus you can use `rustemo::LRBuilder` +trait. Let's see how can we do all of this by implementing a builder that does on-the-fly calculation of the arithmetic expression. Start with a type and a diff --git a/docs/src/parsing/expressions/src/main.rs b/docs/src/parsing/expressions/src/main.rs index 440441b5..0d8a81fa 100644 --- a/docs/src/parsing/expressions/src/main.rs +++ b/docs/src/parsing/expressions/src/main.rs @@ -1,6 +1,6 @@ use expressions::ExpressionsParser; -use rustemo::parser::Parser; use rustemo::rustemo_mod; +use rustemo::Parser; rustemo_mod! {#[allow(unused_imports)] pub(crate) expressions, "/src"} diff --git a/docs/src/tutorials/calculator/calculator1/src/calculator.rs b/docs/src/tutorials/calculator/calculator1/src/calculator.rs index 4d847d28..b48776b3 100644 --- a/docs/src/tutorials/calculator/calculator1/src/calculator.rs +++ b/docs/src/tutorials/calculator/calculator1/src/calculator.rs @@ -2,19 +2,17 @@ use std::fmt::Debug; use std::hash::Hash; use std::rc::Rc; -use rustemo::Result; -use rustemo::input; -use rustemo::lexer::{self, Lexer, Token}; -use rustemo::parser::{self, Parser}; -use rustemo::builder::Builder; -use rustemo::lr::parser::ParserDefinition; +use rustemo::{ + Result, Input as InputT, Lexer, Token, TokenRecognizer as TokenRecognizerT, Parser, + ParserDefinition, State as StateT, Builder, +}; use regex::Regex; use once_cell::sync::Lazy; -use rustemo::lexer::StringLexer; -use rustemo::lr::builder::LRBuilder; +use rustemo::StringLexer; +use rustemo::LRBuilder; use super::calculator_actions; -use rustemo::lr::{parser::LRParser, context::LRContext}; -use rustemo::lr::parser::Action::{self, Shift, Reduce, Accept, Error}; +use rustemo::{LRParser, LRContext}; +use rustemo::Action::{self, Shift, Reduce, Accept, Error}; #[allow(unused_imports)] use rustemo::debug::{log, logn}; #[allow(unused_imports)] @@ -78,7 +76,7 @@ pub enum State { OperatorS3, OperandS4, } -impl parser::State for State { +impl StateT for State { fn default_layout() -> Option { None } @@ -162,7 +160,7 @@ for CalculatorParserDefinition { pub(crate) type Context<'i, I> = LRContext<'i, I, State, TokenKind>; pub struct CalculatorParser< 'i, - I: input::Input + ?Sized, + I: InputT + ?Sized, L: Lexer<'i, Context<'i, I>, State, TokenKind, Input = I>, B, >( @@ -205,7 +203,7 @@ impl< impl<'i, I, L, B> Parser<'i, I, Context<'i, I>, L, State, TokenKind> for CalculatorParser<'i, I, L, B> where - I: input::Input + ?Sized + Debug, + I: InputT + ?Sized + Debug, L: Lexer<'i, Context<'i, I>, State, TokenKind, Input = I>, B: LRBuilder<'i, I, Context<'i, I>, State, ProdKind, TokenKind>, { @@ -240,7 +238,7 @@ pub enum Recognizer { #[allow(dead_code)] #[derive(Debug)] pub struct TokenRecognizer(TokenKind, Recognizer); -impl<'i> lexer::TokenRecognizer<'i> for TokenRecognizer { +impl<'i> TokenRecognizerT<'i> for TokenRecognizer { fn recognize(&self, input: &'i str) -> Option<&'i str> { match &self { #[allow(unused_variables)] diff --git a/docs/src/tutorials/calculator/calculator1/src/calculator_actions.rs b/docs/src/tutorials/calculator/calculator1/src/calculator_actions.rs index 0b180eb6..140fbe80 100644 --- a/docs/src/tutorials/calculator/calculator1/src/calculator_actions.rs +++ b/docs/src/tutorials/calculator/calculator1/src/calculator_actions.rs @@ -1,12 +1,11 @@ /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use ::rustemo::context::Context; -use rustemo::lexer; +use ::rustemo::{Context, Token as BaseToken}; use super::calculator::{self, TokenKind}; pub type Input = str; pub type Ctx<'i> = super::calculator::Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Operand = String; pub fn operand(_ctx: &Ctx, token: Token) -> Operand { token.value.into() diff --git a/docs/src/tutorials/calculator/calculator1/src/main.rs b/docs/src/tutorials/calculator/calculator1/src/main.rs index 1317c1d7..40378ca2 100644 --- a/docs/src/tutorials/calculator/calculator1/src/main.rs +++ b/docs/src/tutorials/calculator/calculator1/src/main.rs @@ -1,5 +1,5 @@ // ANCHOR: header -use rustemo::parser::Parser; +use rustemo::Parser; use std::io; // Use the generated parser use crate::calculator::CalculatorParser; diff --git a/docs/src/tutorials/calculator/calculator1/src/tests.rs b/docs/src/tutorials/calculator/calculator1/src/tests.rs index 52cd8391..78a94434 100644 --- a/docs/src/tutorials/calculator/calculator1/src/tests.rs +++ b/docs/src/tutorials/calculator/calculator1/src/tests.rs @@ -1,6 +1,6 @@ // Use the generated parser use crate::calculator::CalculatorParser; -use rustemo::parser::Parser; +use rustemo::Parser; use rustemo_compiler::output_cmp; #[test] diff --git a/docs/src/tutorials/calculator/calculator2/src/calculator.rs b/docs/src/tutorials/calculator/calculator2/src/calculator.rs index e1a3be29..ce170b05 100644 --- a/docs/src/tutorials/calculator/calculator2/src/calculator.rs +++ b/docs/src/tutorials/calculator/calculator2/src/calculator.rs @@ -2,19 +2,17 @@ use std::fmt::Debug; use std::hash::Hash; use std::rc::Rc; -use rustemo::Result; -use rustemo::input; -use rustemo::lexer::{self, Lexer, Token}; -use rustemo::parser::{self, Parser}; -use rustemo::builder::Builder; -use rustemo::lr::parser::ParserDefinition; +use rustemo::{ + Result, Input as InputT, Lexer, Token, TokenRecognizer as TokenRecognizerT, Parser, + ParserDefinition, State as StateT, Builder, +}; use regex::Regex; use once_cell::sync::Lazy; -use rustemo::lexer::StringLexer; -use rustemo::lr::builder::LRBuilder; +use rustemo::StringLexer; +use rustemo::LRBuilder; use super::calculator_actions; -use rustemo::lr::{parser::LRParser, context::LRContext}; -use rustemo::lr::parser::Action::{self, Shift, Reduce, Accept, Error}; +use rustemo::{LRParser, LRContext}; +use rustemo::Action::{self, Shift, Reduce, Accept, Error}; #[allow(unused_imports)] use rustemo::debug::{log, logn}; #[allow(unused_imports)] @@ -99,7 +97,7 @@ pub enum State { ES9, ES10, } -impl parser::State for State { +impl StateT for State { fn default_layout() -> Option { None } @@ -288,7 +286,7 @@ for CalculatorParserDefinition { pub(crate) type Context<'i, I> = LRContext<'i, I, State, TokenKind>; pub struct CalculatorParser< 'i, - I: input::Input + ?Sized, + I: InputT + ?Sized, L: Lexer<'i, Context<'i, I>, State, TokenKind, Input = I>, B, >( @@ -331,7 +329,7 @@ impl< impl<'i, I, L, B> Parser<'i, I, Context<'i, I>, L, State, TokenKind> for CalculatorParser<'i, I, L, B> where - I: input::Input + ?Sized + Debug, + I: InputT + ?Sized + Debug, L: Lexer<'i, Context<'i, I>, State, TokenKind, Input = I>, B: LRBuilder<'i, I, Context<'i, I>, State, ProdKind, TokenKind>, { @@ -366,7 +364,7 @@ pub enum Recognizer { #[allow(dead_code)] #[derive(Debug)] pub struct TokenRecognizer(TokenKind, Recognizer); -impl<'i> lexer::TokenRecognizer<'i> for TokenRecognizer { +impl<'i> TokenRecognizerT<'i> for TokenRecognizer { fn recognize(&self, input: &'i str) -> Option<&'i str> { match &self { #[allow(unused_variables)] diff --git a/docs/src/tutorials/calculator/calculator2/src/calculator_actions.rs b/docs/src/tutorials/calculator/calculator2/src/calculator_actions.rs index 10157b52..28494a59 100644 --- a/docs/src/tutorials/calculator/calculator2/src/calculator_actions.rs +++ b/docs/src/tutorials/calculator/calculator2/src/calculator_actions.rs @@ -1,12 +1,11 @@ /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use ::rustemo::context::Context; -use rustemo::lexer; +use ::rustemo::{Context, Token as BaseToken}; use super::calculator::{self, TokenKind}; pub type Input = str; pub type Ctx<'i> = super::calculator::Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Number = String; pub fn number(_ctx: &Ctx, token: Token) -> Number { token.value.into() diff --git a/docs/src/tutorials/calculator/calculator2/src/main.rs b/docs/src/tutorials/calculator/calculator2/src/main.rs index 50ab1ebe..765baa3c 100644 --- a/docs/src/tutorials/calculator/calculator2/src/main.rs +++ b/docs/src/tutorials/calculator/calculator2/src/main.rs @@ -1,4 +1,4 @@ -use rustemo::parser::Parser; +use rustemo::Parser; use std::io; // Use the generated parser use crate::calculator::CalculatorParser; diff --git a/docs/src/tutorials/calculator/calculator2/src/tests.rs b/docs/src/tutorials/calculator/calculator2/src/tests.rs index a19cd3fc..216836b1 100644 --- a/docs/src/tutorials/calculator/calculator2/src/tests.rs +++ b/docs/src/tutorials/calculator/calculator2/src/tests.rs @@ -1,6 +1,6 @@ // Use the generated parser use crate::calculator::CalculatorParser; -use rustemo::parser::Parser; +use rustemo::Parser; use rustemo_compiler::output_cmp; #[test] diff --git a/docs/src/tutorials/calculator/calculator3/src/calculator.rs b/docs/src/tutorials/calculator/calculator3/src/calculator.rs index 362d5991..d6319749 100644 --- a/docs/src/tutorials/calculator/calculator3/src/calculator.rs +++ b/docs/src/tutorials/calculator/calculator3/src/calculator.rs @@ -2,19 +2,17 @@ use std::fmt::Debug; use std::hash::Hash; use std::rc::Rc; -use rustemo::Result; -use rustemo::input; -use rustemo::lexer::{self, Lexer, Token}; -use rustemo::parser::{self, Parser}; -use rustemo::builder::Builder; -use rustemo::lr::parser::ParserDefinition; +use rustemo::{ + Result, Input as InputT, Lexer, Token, TokenRecognizer as TokenRecognizerT, Parser, + ParserDefinition, State as StateT, Builder, +}; use regex::Regex; use once_cell::sync::Lazy; -use rustemo::lexer::StringLexer; -use rustemo::lr::builder::LRBuilder; +use rustemo::StringLexer; +use rustemo::LRBuilder; use super::calculator_actions; -use rustemo::lr::{parser::LRParser, context::LRContext}; -use rustemo::lr::parser::Action::{self, Shift, Reduce, Accept, Error}; +use rustemo::{LRParser, LRContext}; +use rustemo::Action::{self, Shift, Reduce, Accept, Error}; #[allow(unused_imports)] use rustemo::debug::{log, logn}; #[allow(unused_imports)] @@ -99,7 +97,7 @@ pub enum State { ES9, ES10, } -impl parser::State for State { +impl StateT for State { fn default_layout() -> Option { None } @@ -288,7 +286,7 @@ for CalculatorParserDefinition { pub(crate) type Context<'i, I> = LRContext<'i, I, State, TokenKind>; pub struct CalculatorParser< 'i, - I: input::Input + ?Sized, + I: InputT + ?Sized, L: Lexer<'i, Context<'i, I>, State, TokenKind, Input = I>, B, >( @@ -331,7 +329,7 @@ impl< impl<'i, I, L, B> Parser<'i, I, Context<'i, I>, L, State, TokenKind> for CalculatorParser<'i, I, L, B> where - I: input::Input + ?Sized + Debug, + I: InputT + ?Sized + Debug, L: Lexer<'i, Context<'i, I>, State, TokenKind, Input = I>, B: LRBuilder<'i, I, Context<'i, I>, State, ProdKind, TokenKind>, { @@ -366,7 +364,7 @@ pub enum Recognizer { #[allow(dead_code)] #[derive(Debug)] pub struct TokenRecognizer(TokenKind, Recognizer); -impl<'i> lexer::TokenRecognizer<'i> for TokenRecognizer { +impl<'i> TokenRecognizerT<'i> for TokenRecognizer { fn recognize(&self, input: &'i str) -> Option<&'i str> { match &self { #[allow(unused_variables)] diff --git a/docs/src/tutorials/calculator/calculator3/src/calculator_actions.rs b/docs/src/tutorials/calculator/calculator3/src/calculator_actions.rs index 1d062e5f..c1bc943b 100644 --- a/docs/src/tutorials/calculator/calculator3/src/calculator_actions.rs +++ b/docs/src/tutorials/calculator/calculator3/src/calculator_actions.rs @@ -1,12 +1,11 @@ /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use ::rustemo::context::Context; -use rustemo::lexer; +use ::rustemo::{Context, Token as BaseToken}; use super::calculator::{self, TokenKind}; pub type Input = str; pub type Ctx<'i> = super::calculator::Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Number = String; pub fn number(_ctx: &Ctx, token: Token) -> Number { token.value.into() diff --git a/docs/src/tutorials/calculator/calculator3/src/main.rs b/docs/src/tutorials/calculator/calculator3/src/main.rs index 50ab1ebe..765baa3c 100644 --- a/docs/src/tutorials/calculator/calculator3/src/main.rs +++ b/docs/src/tutorials/calculator/calculator3/src/main.rs @@ -1,4 +1,4 @@ -use rustemo::parser::Parser; +use rustemo::Parser; use std::io; // Use the generated parser use crate::calculator::CalculatorParser; diff --git a/docs/src/tutorials/calculator/calculator3/src/tests.rs b/docs/src/tutorials/calculator/calculator3/src/tests.rs index 0b7d2e28..ff38aeca 100644 --- a/docs/src/tutorials/calculator/calculator3/src/tests.rs +++ b/docs/src/tutorials/calculator/calculator3/src/tests.rs @@ -1,4 +1,4 @@ -use rustemo::parser::Parser; +use rustemo::Parser; // Use the generated parser use crate::calculator::CalculatorParser; use rustemo_compiler::output_cmp; diff --git a/docs/src/tutorials/calculator/calculator4/src/calculator.rs b/docs/src/tutorials/calculator/calculator4/src/calculator.rs index 362d5991..d6319749 100644 --- a/docs/src/tutorials/calculator/calculator4/src/calculator.rs +++ b/docs/src/tutorials/calculator/calculator4/src/calculator.rs @@ -2,19 +2,17 @@ use std::fmt::Debug; use std::hash::Hash; use std::rc::Rc; -use rustemo::Result; -use rustemo::input; -use rustemo::lexer::{self, Lexer, Token}; -use rustemo::parser::{self, Parser}; -use rustemo::builder::Builder; -use rustemo::lr::parser::ParserDefinition; +use rustemo::{ + Result, Input as InputT, Lexer, Token, TokenRecognizer as TokenRecognizerT, Parser, + ParserDefinition, State as StateT, Builder, +}; use regex::Regex; use once_cell::sync::Lazy; -use rustemo::lexer::StringLexer; -use rustemo::lr::builder::LRBuilder; +use rustemo::StringLexer; +use rustemo::LRBuilder; use super::calculator_actions; -use rustemo::lr::{parser::LRParser, context::LRContext}; -use rustemo::lr::parser::Action::{self, Shift, Reduce, Accept, Error}; +use rustemo::{LRParser, LRContext}; +use rustemo::Action::{self, Shift, Reduce, Accept, Error}; #[allow(unused_imports)] use rustemo::debug::{log, logn}; #[allow(unused_imports)] @@ -99,7 +97,7 @@ pub enum State { ES9, ES10, } -impl parser::State for State { +impl StateT for State { fn default_layout() -> Option { None } @@ -288,7 +286,7 @@ for CalculatorParserDefinition { pub(crate) type Context<'i, I> = LRContext<'i, I, State, TokenKind>; pub struct CalculatorParser< 'i, - I: input::Input + ?Sized, + I: InputT + ?Sized, L: Lexer<'i, Context<'i, I>, State, TokenKind, Input = I>, B, >( @@ -331,7 +329,7 @@ impl< impl<'i, I, L, B> Parser<'i, I, Context<'i, I>, L, State, TokenKind> for CalculatorParser<'i, I, L, B> where - I: input::Input + ?Sized + Debug, + I: InputT + ?Sized + Debug, L: Lexer<'i, Context<'i, I>, State, TokenKind, Input = I>, B: LRBuilder<'i, I, Context<'i, I>, State, ProdKind, TokenKind>, { @@ -366,7 +364,7 @@ pub enum Recognizer { #[allow(dead_code)] #[derive(Debug)] pub struct TokenRecognizer(TokenKind, Recognizer); -impl<'i> lexer::TokenRecognizer<'i> for TokenRecognizer { +impl<'i> TokenRecognizerT<'i> for TokenRecognizer { fn recognize(&self, input: &'i str) -> Option<&'i str> { match &self { #[allow(unused_variables)] diff --git a/docs/src/tutorials/calculator/calculator4/src/calculator_actions.rs b/docs/src/tutorials/calculator/calculator4/src/calculator_actions.rs index a00ecbeb..c6e23ee3 100644 --- a/docs/src/tutorials/calculator/calculator4/src/calculator_actions.rs +++ b/docs/src/tutorials/calculator/calculator4/src/calculator_actions.rs @@ -1,12 +1,11 @@ /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use ::rustemo::context::Context; -use rustemo::lexer; +use ::rustemo::{Context, Token as BaseToken}; use super::calculator::{self, TokenKind}; pub type Input = str; pub type Ctx<'i> = super::calculator::Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; /// ANCHOR: number pub type Number = String; /// ANCHOR_END: number diff --git a/docs/src/tutorials/calculator/calculator4/src/main.rs b/docs/src/tutorials/calculator/calculator4/src/main.rs index 39701302..cf63afd3 100644 --- a/docs/src/tutorials/calculator/calculator4/src/main.rs +++ b/docs/src/tutorials/calculator/calculator4/src/main.rs @@ -1,4 +1,4 @@ -use rustemo::parser::Parser; +use rustemo::Parser; use std::io; // Use the generated parser use crate::calculator::CalculatorParser; diff --git a/docs/src/tutorials/calculator/calculator4/src/tests.rs b/docs/src/tutorials/calculator/calculator4/src/tests.rs index cd5d728b..b803cae3 100644 --- a/docs/src/tutorials/calculator/calculator4/src/tests.rs +++ b/docs/src/tutorials/calculator/calculator4/src/tests.rs @@ -1,4 +1,4 @@ -use rustemo::parser::Parser; +use rustemo::Parser; // Use the generated parser use crate::calculator::CalculatorParser; use rustemo_compiler::output_cmp; diff --git a/docs/src/tutorials/calculator/calculator5/src/calculator.rs b/docs/src/tutorials/calculator/calculator5/src/calculator.rs index 362d5991..d6319749 100644 --- a/docs/src/tutorials/calculator/calculator5/src/calculator.rs +++ b/docs/src/tutorials/calculator/calculator5/src/calculator.rs @@ -2,19 +2,17 @@ use std::fmt::Debug; use std::hash::Hash; use std::rc::Rc; -use rustemo::Result; -use rustemo::input; -use rustemo::lexer::{self, Lexer, Token}; -use rustemo::parser::{self, Parser}; -use rustemo::builder::Builder; -use rustemo::lr::parser::ParserDefinition; +use rustemo::{ + Result, Input as InputT, Lexer, Token, TokenRecognizer as TokenRecognizerT, Parser, + ParserDefinition, State as StateT, Builder, +}; use regex::Regex; use once_cell::sync::Lazy; -use rustemo::lexer::StringLexer; -use rustemo::lr::builder::LRBuilder; +use rustemo::StringLexer; +use rustemo::LRBuilder; use super::calculator_actions; -use rustemo::lr::{parser::LRParser, context::LRContext}; -use rustemo::lr::parser::Action::{self, Shift, Reduce, Accept, Error}; +use rustemo::{LRParser, LRContext}; +use rustemo::Action::{self, Shift, Reduce, Accept, Error}; #[allow(unused_imports)] use rustemo::debug::{log, logn}; #[allow(unused_imports)] @@ -99,7 +97,7 @@ pub enum State { ES9, ES10, } -impl parser::State for State { +impl StateT for State { fn default_layout() -> Option { None } @@ -288,7 +286,7 @@ for CalculatorParserDefinition { pub(crate) type Context<'i, I> = LRContext<'i, I, State, TokenKind>; pub struct CalculatorParser< 'i, - I: input::Input + ?Sized, + I: InputT + ?Sized, L: Lexer<'i, Context<'i, I>, State, TokenKind, Input = I>, B, >( @@ -331,7 +329,7 @@ impl< impl<'i, I, L, B> Parser<'i, I, Context<'i, I>, L, State, TokenKind> for CalculatorParser<'i, I, L, B> where - I: input::Input + ?Sized + Debug, + I: InputT + ?Sized + Debug, L: Lexer<'i, Context<'i, I>, State, TokenKind, Input = I>, B: LRBuilder<'i, I, Context<'i, I>, State, ProdKind, TokenKind>, { @@ -366,7 +364,7 @@ pub enum Recognizer { #[allow(dead_code)] #[derive(Debug)] pub struct TokenRecognizer(TokenKind, Recognizer); -impl<'i> lexer::TokenRecognizer<'i> for TokenRecognizer { +impl<'i> TokenRecognizerT<'i> for TokenRecognizer { fn recognize(&self, input: &'i str) -> Option<&'i str> { match &self { #[allow(unused_variables)] diff --git a/docs/src/tutorials/calculator/calculator5/src/calculator_actions.rs b/docs/src/tutorials/calculator/calculator5/src/calculator_actions.rs index faf93832..ae93a06d 100644 --- a/docs/src/tutorials/calculator/calculator5/src/calculator_actions.rs +++ b/docs/src/tutorials/calculator/calculator5/src/calculator_actions.rs @@ -1,12 +1,11 @@ /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use ::rustemo::context::Context; -use rustemo::lexer; +use ::rustemo::{Context, Token as BaseToken}; use super::calculator::{self, TokenKind}; pub type Input = str; pub type Ctx<'i> = super::calculator::Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; /// ANCHOR: number pub type Number = f32; /// ANCHOR_END: number diff --git a/docs/src/tutorials/calculator/calculator5/src/main.rs b/docs/src/tutorials/calculator/calculator5/src/main.rs index 39701302..cf63afd3 100644 --- a/docs/src/tutorials/calculator/calculator5/src/main.rs +++ b/docs/src/tutorials/calculator/calculator5/src/main.rs @@ -1,4 +1,4 @@ -use rustemo::parser::Parser; +use rustemo::Parser; use std::io; // Use the generated parser use crate::calculator::CalculatorParser; diff --git a/docs/src/tutorials/calculator/calculator5/src/tests.rs b/docs/src/tutorials/calculator/calculator5/src/tests.rs index ff1e0ad4..f587ae0b 100644 --- a/docs/src/tutorials/calculator/calculator5/src/tests.rs +++ b/docs/src/tutorials/calculator/calculator5/src/tests.rs @@ -1,4 +1,4 @@ -use rustemo::parser::Parser; +use rustemo::Parser; // Use the generated parser use crate::calculator::CalculatorParser; use rustemo_compiler::output_cmp; diff --git a/examples/calculator/src/ast_actions/calculator01_actions.rs b/examples/calculator/src/ast_actions/calculator01_actions.rs index 5d0cd6e0..7841ef60 100644 --- a/examples/calculator/src/ast_actions/calculator01_actions.rs +++ b/examples/calculator/src/ast_actions/calculator01_actions.rs @@ -1,11 +1,11 @@ use super::calculator01::{Context, TokenKind}; /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use rustemo::lexer; +use rustemo::Token as BaseToken; pub type Input = str; pub type Ctx<'i> = Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Num = String; pub fn num(_ctx: &Ctx, token: Token) -> Num { token.value.into() diff --git a/examples/calculator/src/ast_actions/calculator02_ambig_actions.rs b/examples/calculator/src/ast_actions/calculator02_ambig_actions.rs index 53e98552..92814b1c 100644 --- a/examples/calculator/src/ast_actions/calculator02_ambig_actions.rs +++ b/examples/calculator/src/ast_actions/calculator02_ambig_actions.rs @@ -1,11 +1,11 @@ use super::calculator02_ambig::{Context, TokenKind}; /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use rustemo::lexer; +use rustemo::Token as BaseToken; pub type Input = str; pub type Ctx<'i> = Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Num = String; pub fn num(_ctx: &Ctx, token: Token) -> Num { token.value.into() diff --git a/examples/calculator/src/ast_actions/calculator03_ambig_prodkind_actions.rs b/examples/calculator/src/ast_actions/calculator03_ambig_prodkind_actions.rs index a33ded50..4f84b19f 100644 --- a/examples/calculator/src/ast_actions/calculator03_ambig_prodkind_actions.rs +++ b/examples/calculator/src/ast_actions/calculator03_ambig_prodkind_actions.rs @@ -1,11 +1,11 @@ use super::calculator03_ambig_prodkind::{Context, TokenKind}; /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use rustemo::lexer; +use rustemo::Token as BaseToken; pub type Input = str; pub type Ctx<'i> = Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Num = String; pub fn num(_ctx: &Ctx, token: Token) -> Num { token.value.into() diff --git a/examples/calculator/src/ast_actions/calculator04_ambig_lhs_actions.rs b/examples/calculator/src/ast_actions/calculator04_ambig_lhs_actions.rs index 3b227014..30b920ed 100644 --- a/examples/calculator/src/ast_actions/calculator04_ambig_lhs_actions.rs +++ b/examples/calculator/src/ast_actions/calculator04_ambig_lhs_actions.rs @@ -1,11 +1,11 @@ use super::calculator04_ambig_lhs::{Context, TokenKind}; /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use rustemo::lexer; +use rustemo::Token as BaseToken; pub type Input = str; pub type Ctx<'i> = Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Num = String; pub fn num(_ctx: &Ctx, token: Token) -> Num { token.value.into() diff --git a/examples/calculator/src/ast_actions/tests.rs b/examples/calculator/src/ast_actions/tests.rs index 998eb8bf..684abbc0 100644 --- a/examples/calculator/src/ast_actions/tests.rs +++ b/examples/calculator/src/ast_actions/tests.rs @@ -1,5 +1,5 @@ mod calculator01_ast_tests { - use rustemo::parser::Parser; + use rustemo::Parser; use rustemo_compiler::output_cmp; use crate::ast_actions::{ diff --git a/examples/calculator/src/calc_actions/calculator01_actions.rs b/examples/calculator/src/calc_actions/calculator01_actions.rs index e680c790..c17c639b 100644 --- a/examples/calculator/src/calc_actions/calculator01_actions.rs +++ b/examples/calculator/src/calc_actions/calculator01_actions.rs @@ -1,9 +1,9 @@ use super::calculator01::{Context, TokenKind}; /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use rustemo::lexer; +use rustemo::Token as BaseToken; pub type Input = str; -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Ctx<'i> = Context<'i, Input>; pub type Num = f32; pub fn num(_ctx: &Ctx, token: Token) -> Num { diff --git a/examples/calculator/src/calc_actions/calculator02_ambig_actions.rs b/examples/calculator/src/calc_actions/calculator02_ambig_actions.rs index 86035a4b..1936df66 100644 --- a/examples/calculator/src/calc_actions/calculator02_ambig_actions.rs +++ b/examples/calculator/src/calc_actions/calculator02_ambig_actions.rs @@ -1,9 +1,9 @@ use super::calculator02_ambig::{Context, TokenKind}; /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use rustemo::lexer; +use rustemo::Token as BaseToken; pub type Input = str; -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Ctx<'i> = Context<'i, Input>; pub type Num = f32; pub fn num(_ctx: &Ctx, token: Token) -> Num { diff --git a/examples/calculator/src/calc_actions/calculator03_ambig_prodkind_actions.rs b/examples/calculator/src/calc_actions/calculator03_ambig_prodkind_actions.rs index 9d46bfa7..0646907e 100644 --- a/examples/calculator/src/calc_actions/calculator03_ambig_prodkind_actions.rs +++ b/examples/calculator/src/calc_actions/calculator03_ambig_prodkind_actions.rs @@ -1,10 +1,10 @@ use super::calculator03_ambig_prodkind::{Context, TokenKind}; /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use rustemo::lexer; +use rustemo::Token as BaseToken; pub type Input = str; pub type Ctx<'i> = Context<'i, Input>; -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Num = f32; pub fn num(_ctx: &Ctx, token: Token) -> Num { token.value.parse().unwrap() diff --git a/examples/calculator/src/calc_actions/calculator04_ambig_lhs_actions.rs b/examples/calculator/src/calc_actions/calculator04_ambig_lhs_actions.rs index 028cd05f..591f5474 100644 --- a/examples/calculator/src/calc_actions/calculator04_ambig_lhs_actions.rs +++ b/examples/calculator/src/calc_actions/calculator04_ambig_lhs_actions.rs @@ -1,10 +1,10 @@ use super::calculator04_ambig_lhs::{Context, TokenKind}; /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use rustemo::lexer; +use rustemo::Token as BaseToken; pub type Input = str; pub type Ctx<'i> = Context<'i, Input>; -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Num = f32; pub fn num(_ctx: &Ctx, token: Token) -> Num { token.value.parse().unwrap() diff --git a/examples/calculator/src/calc_actions/tests.rs b/examples/calculator/src/calc_actions/tests.rs index 48f59b0a..e150740f 100644 --- a/examples/calculator/src/calc_actions/tests.rs +++ b/examples/calculator/src/calc_actions/tests.rs @@ -1,5 +1,5 @@ mod calculator01_calc_tests { - use rustemo::parser::Parser; + use rustemo::Parser; use rustemo_compiler::output_cmp; use crate::calc_actions::calculator01::Calculator01Parser; @@ -30,7 +30,7 @@ mod calculator01_calc_tests { mod calculator02_tests { use crate::calc_actions::calculator02_ambig::Calculator02AmbigParser; - use rustemo::parser::Parser; + use rustemo::Parser; #[test] fn test_calculator2_1() { @@ -42,7 +42,7 @@ mod calculator02_tests { mod calculator03_tests { use crate::calc_actions::calculator03_ambig_prodkind::Calculator03AmbigProdkindParser; - use rustemo::parser::Parser; + use rustemo::Parser; #[test] fn test_calculator2_1() { @@ -54,7 +54,7 @@ mod calculator03_tests { mod calculator04_tests { use crate::calc_actions::calculator04_ambig_lhs::Calculator04AmbigLhsParser; - use rustemo::parser::Parser; + use rustemo::Parser; #[test] fn test_calculator2_1() { diff --git a/examples/json/src/json_actions.rs b/examples/json/src/json_actions.rs index 08f01d6c..9581c2cf 100644 --- a/examples/json/src/json_actions.rs +++ b/examples/json/src/json_actions.rs @@ -1,11 +1,11 @@ use super::json::{self, TokenKind}; /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use rustemo::lexer; +use rustemo::Token as BaseToken; pub type Input = str; pub type Ctx<'i> = json::Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type JsonNumber = f32; pub fn json_number(_ctx: &Ctx, token: Token) -> JsonNumber { token.value.parse().unwrap() diff --git a/examples/json/src/main.rs b/examples/json/src/main.rs index ada51515..9a3aa6fb 100644 --- a/examples/json/src/main.rs +++ b/examples/json/src/main.rs @@ -8,7 +8,7 @@ fn main() {} #[cfg(test)] mod tests { use crate::json::JsonParser; - use rustemo::parser::Parser; + use rustemo::Parser; use rustemo_compiler::{local_file, output_cmp}; #[test] diff --git a/rustemo-compiler/src/generator/mod.rs b/rustemo-compiler/src/generator/mod.rs index 711860cd..8cacbe41 100644 --- a/rustemo-compiler/src/generator/mod.rs +++ b/rustemo-compiler/src/generator/mod.rs @@ -1,7 +1,7 @@ pub(crate) mod actions; use quote::format_ident; -use rustemo::parser::Parser; +use rustemo::Parser; use std::{ fs, iter::repeat, diff --git a/rustemo-compiler/src/grammar/builder.rs b/rustemo-compiler/src/grammar/builder.rs index 3038f12e..ec4548bb 100644 --- a/rustemo-compiler/src/grammar/builder.rs +++ b/rustemo-compiler/src/grammar/builder.rs @@ -4,7 +4,7 @@ use std::{ path::Path, }; -use rustemo::{location::ValLoc, Error, Result}; +use rustemo::{Error, Result, ValLoc}; use crate::{ grammar::{Grammar, DEFAULT_PRIORITY}, diff --git a/rustemo-compiler/src/grammar/mod.rs b/rustemo-compiler/src/grammar/mod.rs index afffc05d..3f0b5afc 100644 --- a/rustemo-compiler/src/grammar/mod.rs +++ b/rustemo-compiler/src/grammar/mod.rs @@ -6,7 +6,7 @@ use std::{ str::FromStr, }; -use rustemo::{parser::Parser, Error, Result}; +use rustemo::{Error, Parser, Result}; use crate::{ index::{ diff --git a/rustemo/src/lib.rs b/rustemo/src/lib.rs index 1ea3184e..c76fbcdd 100644 --- a/rustemo/src/lib.rs +++ b/rustemo/src/lib.rs @@ -1,24 +1,44 @@ //! This crate is the runtime for the generated Rustemo parsers. // See: https://github.com/rust-lang/rfcs/issues/2324 // For local std docs browsing -#[doc(inline)] -pub use std; +// #[doc(inline)] +// pub use std; #[macro_use] -pub mod common; -pub mod builder; -pub mod context; -pub mod error; -pub mod input; -pub mod lexer; -pub mod location; -pub mod parser; +mod common; +#[macro_use] +pub mod debug; -pub mod lr; -//#[cfg(feature = "glr")] -pub mod glr; +mod builder; +mod context; +mod error; +mod input; +mod lexer; +mod location; +mod parser; -pub mod debug; +mod lr; +//#[cfg(feature = "glr")] +mod glr; +// Public API +pub use crate::context::Context; pub use crate::error::Error; pub use crate::error::Result; +pub use crate::input::Input; +pub use crate::location::{LineColumn, Location, Position, ValLoc}; + +pub use crate::builder::Builder; +pub use crate::lexer::{Lexer, StringLexer, Token, TokenRecognizer}; +pub use crate::lr::{ + builder::{LRBuilder, SliceBuilder, TreeBuilder, TreeNode}, + context::LRContext, + parser::{Action, LRParser, ParserDefinition}, +}; +pub use crate::parser::{Parser, State}; + +//#[cfg(feature = "glr")] +pub use crate::glr::{ + gss::{Forest, GssHead}, + parser::GlrParser, +}; diff --git a/tests/src/ambiguity/mod.rs b/tests/src/ambiguity/mod.rs index 9c8db8d6..fa39d867 100644 --- a/tests/src/ambiguity/mod.rs +++ b/tests/src/ambiguity/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::{local_file, output_cmp}; use self::reduce_empty_1::ReduceEmpty1Parser; diff --git a/tests/src/builder/custom_builder/custom_builder_builder.rs b/tests/src/builder/custom_builder/custom_builder_builder.rs index fda4a154..c2435ce9 100644 --- a/tests/src/builder/custom_builder/custom_builder_builder.rs +++ b/tests/src/builder/custom_builder/custom_builder_builder.rs @@ -1,12 +1,10 @@ -use rustemo::{ - builder::Builder, lexer::Token, lr::builder::LRBuilder, lr::context, -}; +use rustemo::{Builder, LRBuilder, LRContext, Token}; use super::custom_builder::{ProdKind, State, TokenKind}; // ANCHOR: custom-builder-base pub type E = i32; -pub type Context<'i> = context::LRContext<'i, str, State, TokenKind>; +pub type Context<'i> = LRContext<'i, str, State, TokenKind>; /// Custom builder that perform arithmetic operations. pub struct MyCustomBuilder { diff --git a/tests/src/builder/custom_builder/mod.rs b/tests/src/builder/custom_builder/mod.rs index b630cc33..72e31e1a 100644 --- a/tests/src/builder/custom_builder/mod.rs +++ b/tests/src/builder/custom_builder/mod.rs @@ -1,8 +1,6 @@ mod custom_builder_builder; -use rustemo::builder::Builder; -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Builder, Parser}; use rustemo_compiler::output_cmp; use self::custom_builder::CustomBuilderParser; diff --git a/tests/src/builder/generic_tree/mod.rs b/tests/src/builder/generic_tree/mod.rs index ebac33f0..e56fd21c 100644 --- a/tests/src/builder/generic_tree/mod.rs +++ b/tests/src/builder/generic_tree/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; use self::generic_tree::GenericTreeParser; diff --git a/tests/src/builder/use_context/mod.rs b/tests/src/builder/use_context/mod.rs index 6020e343..eca9bc91 100644 --- a/tests/src/builder/use_context/mod.rs +++ b/tests/src/builder/use_context/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; mod use_context_actions; diff --git a/tests/src/builder/use_context/use_context_actions.rs b/tests/src/builder/use_context/use_context_actions.rs index 18ea4cc6..60bd64f6 100644 --- a/tests/src/builder/use_context/use_context_actions.rs +++ b/tests/src/builder/use_context/use_context_actions.rs @@ -1,11 +1,10 @@ /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. use super::use_context::{self, TokenKind}; -use rustemo::context::Context; -use rustemo::lexer; +use rustemo::{Context, Token as BaseToken}; pub type Input = str; pub type Ctx<'i> = use_context::Context<'i, Input>; -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Num = u32; pub fn num(context: &Ctx, token: Token) -> Num { token.value.parse::().unwrap() + context.position() as u32 diff --git a/tests/src/from_file/mod.rs b/tests/src/from_file/mod.rs index 195b6d3b..3b07f167 100644 --- a/tests/src/from_file/mod.rs +++ b/tests/src/from_file/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::{local_file, output_cmp}; rustemo_mod!(calculator, "/src/from_file"); diff --git a/tests/src/glr/build/mod.rs b/tests/src/glr/build/mod.rs index c8e729af..0ff70446 100644 --- a/tests/src/glr/build/mod.rs +++ b/tests/src/glr/build/mod.rs @@ -1,13 +1,12 @@ use std::borrow::BorrowMut; -use rustemo::{glr::gss::GssHead, lr::builder::TreeBuilder, rustemo_mod}; +use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(calc, "/src/glr/build"); rustemo_mod!(calc_actions, "/src/glr/build"); use self::calc::CalcParser; -use rustemo::parser::Parser; // ANCHOR: build #[test] diff --git a/tests/src/glr/evaluate/calc_actions.rs b/tests/src/glr/evaluate/calc_actions.rs index 92662f07..12030015 100644 --- a/tests/src/glr/evaluate/calc_actions.rs +++ b/tests/src/glr/evaluate/calc_actions.rs @@ -1,11 +1,11 @@ use super::calc::{Context, TokenKind}; /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use rustemo::lexer; +use rustemo::Token as BaseToken; pub type Input = str; pub type Ctx<'i> = Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Num = String; pub fn num(_ctx: &Ctx, token: Token) -> Num { token.value.into() diff --git a/tests/src/glr/evaluate/calc_eval_actions.rs b/tests/src/glr/evaluate/calc_eval_actions.rs index 8cf7fa90..d2bce52e 100644 --- a/tests/src/glr/evaluate/calc_eval_actions.rs +++ b/tests/src/glr/evaluate/calc_eval_actions.rs @@ -1,11 +1,11 @@ use super::calc_eval::{Context, TokenKind}; /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use rustemo::lexer; +use rustemo::Token as BaseToken; pub type Input = str; pub type Ctx<'i> = Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Num = f32; pub fn num(_ctx: &Ctx, token: Token) -> Num { token.value.parse().unwrap() diff --git a/tests/src/glr/evaluate/mod.rs b/tests/src/glr/evaluate/mod.rs index 1c6545cd..aef1408b 100644 --- a/tests/src/glr/evaluate/mod.rs +++ b/tests/src/glr/evaluate/mod.rs @@ -1,6 +1,6 @@ use std::borrow::BorrowMut; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; rustemo_mod!(calc, "/src/glr/evaluate"); @@ -10,7 +10,6 @@ mod calc_eval_actions; use self::calc::CalcParser; use self::calc_eval::CalcEvalParser; -use rustemo::parser::Parser; #[test] fn glr_tree_calc_eval() { diff --git a/tests/src/glr/forest/mod.rs b/tests/src/glr/forest/mod.rs index 512da64d..2e0053f0 100644 --- a/tests/src/glr/forest/mod.rs +++ b/tests/src/glr/forest/mod.rs @@ -1,13 +1,12 @@ use std::borrow::BorrowMut; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; rustemo_mod!(calc, "/src/glr/forest"); rustemo_mod!(calc_actions, "/src/glr/forest"); use self::calc::CalcParser; -use rustemo::parser::Parser; #[test] fn glr_calc_parse_ast() { diff --git a/tests/src/glr/special/bounded_ambiguity/mod.rs b/tests/src/glr/special/bounded_ambiguity/mod.rs index 45d2c2d6..afa231f5 100644 --- a/tests/src/glr/special/bounded_ambiguity/mod.rs +++ b/tests/src/glr/special/bounded_ambiguity/mod.rs @@ -1,6 +1,4 @@ -use rustemo::{ - glr::gss::GssHead, lr::builder::TreeBuilder, parser::Parser, rustemo_mod, -}; +use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/bounded_ambiguity"); diff --git a/tests/src/glr/special/bounded_direct_ambiguity/mod.rs b/tests/src/glr/special/bounded_direct_ambiguity/mod.rs index 18994233..10589549 100644 --- a/tests/src/glr/special/bounded_direct_ambiguity/mod.rs +++ b/tests/src/glr/special/bounded_direct_ambiguity/mod.rs @@ -1,6 +1,4 @@ -use rustemo::{ - glr::gss::GssHead, lr::builder::TreeBuilder, parser::Parser, rustemo_mod, -}; +use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/bounded_direct_ambiguity"); diff --git a/tests/src/glr/special/cyclic_1/mod.rs b/tests/src/glr/special/cyclic_1/mod.rs index cf924239..96813f2f 100644 --- a/tests/src/glr/special/cyclic_1/mod.rs +++ b/tests/src/glr/special/cyclic_1/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/cyclic_1"); diff --git a/tests/src/glr/special/cyclic_2/mod.rs b/tests/src/glr/special/cyclic_2/mod.rs index 2c3cc510..e0fdc308 100644 --- a/tests/src/glr/special/cyclic_2/mod.rs +++ b/tests/src/glr/special/cyclic_2/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/cyclic_2"); diff --git a/tests/src/glr/special/farshi_g7/mod.rs b/tests/src/glr/special/farshi_g7/mod.rs index 9f927931..d35d9d35 100644 --- a/tests/src/glr/special/farshi_g7/mod.rs +++ b/tests/src/glr/special/farshi_g7/mod.rs @@ -1,6 +1,4 @@ -use rustemo::{ - glr::gss::GssHead, lr::builder::TreeBuilder, parser::Parser, rustemo_mod, -}; +use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/farshi_g7"); diff --git a/tests/src/glr/special/farshi_g8/mod.rs b/tests/src/glr/special/farshi_g8/mod.rs index 23bd7c16..3ac54684 100644 --- a/tests/src/glr/special/farshi_g8/mod.rs +++ b/tests/src/glr/special/farshi_g8/mod.rs @@ -1,6 +1,4 @@ -use rustemo::{ - glr::gss::GssHead, lr::builder::TreeBuilder, parser::Parser, rustemo_mod, -}; +use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/farshi_g8"); diff --git a/tests/src/glr/special/highly_ambiguous/mod.rs b/tests/src/glr/special/highly_ambiguous/mod.rs index 0095884c..7d79960d 100644 --- a/tests/src/glr/special/highly_ambiguous/mod.rs +++ b/tests/src/glr/special/highly_ambiguous/mod.rs @@ -1,6 +1,4 @@ -use rustemo::{ - glr::gss::GssHead, lr::builder::TreeBuilder, parser::Parser, rustemo_mod, -}; +use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/highly_ambiguous"); diff --git a/tests/src/glr/special/knuth_lr1/mod.rs b/tests/src/glr/special/knuth_lr1/mod.rs index 2a503d53..055992b2 100644 --- a/tests/src/glr/special/knuth_lr1/mod.rs +++ b/tests/src/glr/special/knuth_lr1/mod.rs @@ -1,11 +1,10 @@ -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/knuth_lr1"); rustemo_mod!(lang_actions, "/src/glr/special/knuth_lr1"); use self::lang::LangParser; -use rustemo::parser::Parser; #[test] fn glr_special_knuth_lr1() { diff --git a/tests/src/glr/special/nondeterministic_palindromes/mod.rs b/tests/src/glr/special/nondeterministic_palindromes/mod.rs index 4ebf6e2e..bdb92e6d 100644 --- a/tests/src/glr/special/nondeterministic_palindromes/mod.rs +++ b/tests/src/glr/special/nondeterministic_palindromes/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/nondeterministic_palindromes"); diff --git a/tests/src/glr/special/reduce_enough_empty/mod.rs b/tests/src/glr/special/reduce_enough_empty/mod.rs index f7658e83..7532b5dd 100644 --- a/tests/src/glr/special/reduce_enough_empty/mod.rs +++ b/tests/src/glr/special/reduce_enough_empty/mod.rs @@ -1,6 +1,4 @@ -use rustemo::{ - glr::gss::GssHead, lr::builder::TreeBuilder, parser::Parser, rustemo_mod, -}; +use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/reduce_enough_empty"); diff --git a/tests/src/glr/special/reduce_enough_many_empty/mod.rs b/tests/src/glr/special/reduce_enough_many_empty/mod.rs index 56638308..e15fb8ff 100644 --- a/tests/src/glr/special/reduce_enough_many_empty/mod.rs +++ b/tests/src/glr/special/reduce_enough_many_empty/mod.rs @@ -1,6 +1,4 @@ -use rustemo::{ - glr::gss::GssHead, lr::builder::TreeBuilder, parser::Parser, rustemo_mod, -}; +use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/reduce_enough_many_empty"); diff --git a/tests/src/glr/special/right_nullable/mod.rs b/tests/src/glr/special/right_nullable/mod.rs index 4f5571c8..0f790520 100644 --- a/tests/src/glr/special/right_nullable/mod.rs +++ b/tests/src/glr/special/right_nullable/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::{glr::gss::GssHead, lr::builder::TreeBuilder, rustemo_mod}; +use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/right_nullable"); diff --git a/tests/src/glr/special/unbounded_ambiguity/mod.rs b/tests/src/glr/special/unbounded_ambiguity/mod.rs index ee8c53f3..da3f9aab 100644 --- a/tests/src/glr/special/unbounded_ambiguity/mod.rs +++ b/tests/src/glr/special/unbounded_ambiguity/mod.rs @@ -1,6 +1,4 @@ -use rustemo::{ - glr::gss::GssHead, lr::builder::TreeBuilder, parser::Parser, rustemo_mod, -}; +use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/unbounded_ambiguity"); diff --git a/tests/src/layout/ast/mod.rs b/tests/src/layout/ast/mod.rs index d34db71a..47039378 100644 --- a/tests/src/layout/ast/mod.rs +++ b/tests/src/layout/ast/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; use self::layout::LayoutParser; diff --git a/tests/src/layout/generic_tree/mod.rs b/tests/src/layout/generic_tree/mod.rs index 23666cfb..d76b71cc 100644 --- a/tests/src/layout/generic_tree/mod.rs +++ b/tests/src/layout/generic_tree/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; use self::layout::LayoutParser; diff --git a/tests/src/lexer/custom_lexer/custom_lexer_1_actions.rs b/tests/src/lexer/custom_lexer/custom_lexer_1_actions.rs index fdb0c283..2648ae4c 100644 --- a/tests/src/lexer/custom_lexer/custom_lexer_1_actions.rs +++ b/tests/src/lexer/custom_lexer/custom_lexer_1_actions.rs @@ -2,9 +2,9 @@ /// All manual changes will be preserved except non-doc comments. use super::custom_lexer_1::{self, TokenKind}; use super::custom_lexer_1_lexer::Input; -use rustemo::lexer; +use rustemo::Token as BaseToken; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type Context<'i> = custom_lexer_1::Context<'i, Input>; pub type VarInt = i128; /// Here we convert varint slice of u8 to i128 diff --git a/tests/src/lexer/custom_lexer/custom_lexer_1_lexer.rs b/tests/src/lexer/custom_lexer/custom_lexer_1_lexer.rs index 676fb535..9f5aa643 100644 --- a/tests/src/lexer/custom_lexer/custom_lexer_1_lexer.rs +++ b/tests/src/lexer/custom_lexer/custom_lexer_1_lexer.rs @@ -1,16 +1,10 @@ use super::custom_lexer_1::{State, TokenKind}; -use rustemo::{ - context::Context, - error::Result, - lexer::{self, Lexer, Token}, - location::{Location, Position}, - lr::context, -}; +use rustemo::{Context, LRContext, Lexer, Location, Position, Result, Token}; use std::iter; /// We are parsing a slice of bytes. pub type Input = [u8]; -pub type Ctx<'i> = context::LRContext<'i, Input, State, TokenKind>; +pub type Ctx<'i> = LRContext<'i, Input, State, TokenKind>; pub struct MyCustomLexer1(); diff --git a/tests/src/lexer/custom_lexer/custom_lexer_2_actions.rs b/tests/src/lexer/custom_lexer/custom_lexer_2_actions.rs index 10e2ca30..e652bf7d 100644 --- a/tests/src/lexer/custom_lexer/custom_lexer_2_actions.rs +++ b/tests/src/lexer/custom_lexer/custom_lexer_2_actions.rs @@ -2,10 +2,10 @@ /// All manual changes will be preserved except non-doc comments. use super::custom_lexer_2::{self, TokenKind}; use super::custom_lexer_2_lexer::Input; -use rustemo::lexer; +use rustemo::Token as BaseToken; pub type Context<'i> = custom_lexer_2::Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = BaseToken<'i, Input, TokenKind>; pub type MSBByte = u8; pub fn msbbyte<'i>(_ctx: &Context<'i>, token: Token<'i>) -> MSBByte { token.value[0] diff --git a/tests/src/lexer/custom_lexer/custom_lexer_2_lexer.rs b/tests/src/lexer/custom_lexer/custom_lexer_2_lexer.rs index f0280733..ff7dce4e 100644 --- a/tests/src/lexer/custom_lexer/custom_lexer_2_lexer.rs +++ b/tests/src/lexer/custom_lexer/custom_lexer_2_lexer.rs @@ -1,17 +1,11 @@ use super::custom_lexer_2::{State, TokenKind}; -use rustemo::{ - context::Context, - error::Result, - lexer::{self, Lexer, Token}, - location::{Location, Position}, - lr::context, -}; +use rustemo::{Context, LRContext, Lexer, Location, Position, Result, Token}; use std::iter; // ANCHOR: custom-lexer /// We are parsing a slice of bytes. pub type Input = [u8]; -pub type Ctx<'i> = context::LRContext<'i, Input, State, TokenKind>; +pub type Ctx<'i> = LRContext<'i, Input, State, TokenKind>; pub struct MyCustomLexer2(); diff --git a/tests/src/lexer/custom_lexer/mod.rs b/tests/src/lexer/custom_lexer/mod.rs index 55ec2377..c6a14750 100644 --- a/tests/src/lexer/custom_lexer/mod.rs +++ b/tests/src/lexer/custom_lexer/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; use std::fs; use std::path::PathBuf; diff --git a/tests/src/output_dir/mod.rs b/tests/src/output_dir/mod.rs index 41a44b61..de73e641 100644 --- a/tests/src/output_dir/mod.rs +++ b/tests/src/output_dir/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::{local_file, output_cmp}; use self::output_dir::OutputDirParser; diff --git a/tests/src/output_dir/output_dir.rs b/tests/src/output_dir/output_dir.rs index 6031d246..25711799 100644 --- a/tests/src/output_dir/output_dir.rs +++ b/tests/src/output_dir/output_dir.rs @@ -2,19 +2,17 @@ use std::fmt::Debug; use std::hash::Hash; use std::rc::Rc; -use rustemo::Result; -use rustemo::input; -use rustemo::lexer::{self, Lexer, Token}; -use rustemo::parser::{self, Parser}; -use rustemo::builder::Builder; -use rustemo::lr::parser::ParserDefinition; +use rustemo::{ + Result, Input as InputT, Lexer, Token, TokenRecognizer as TokenRecognizerT, Parser, + ParserDefinition, State as StateT, Builder, +}; use regex::Regex; use once_cell::sync::Lazy; -use rustemo::lexer::StringLexer; -use rustemo::lr::builder::LRBuilder; +use rustemo::StringLexer; +use rustemo::LRBuilder; use super::output_dir_actions; -use rustemo::lr::{parser::LRParser, context::LRContext}; -use rustemo::lr::parser::Action::{self, Shift, Reduce, Accept, Error}; +use rustemo::{LRParser, LRContext}; +use rustemo::Action::{self, Shift, Reduce, Accept, Error}; #[allow(unused_imports)] use rustemo::debug::{log, logn}; #[allow(unused_imports)] @@ -91,7 +89,7 @@ pub enum State { NumS5, BS6, } -impl parser::State for State { +impl StateT for State { fn default_layout() -> Option { None } @@ -185,7 +183,7 @@ for OutputDirParserDefinition { pub(crate) type Context<'i, I> = LRContext<'i, I, State, TokenKind>; pub struct OutputDirParser< 'i, - I: input::Input + ?Sized, + I: InputT + ?Sized, L: Lexer<'i, Context<'i, I>, State, TokenKind, Input = I>, B, >( @@ -228,7 +226,7 @@ impl< impl<'i, I, L, B> Parser<'i, I, Context<'i, I>, L, State, TokenKind> for OutputDirParser<'i, I, L, B> where - I: input::Input + ?Sized + Debug, + I: InputT + ?Sized + Debug, L: Lexer<'i, Context<'i, I>, State, TokenKind, Input = I>, B: LRBuilder<'i, I, Context<'i, I>, State, ProdKind, TokenKind>, { @@ -263,7 +261,7 @@ pub enum Recognizer { #[allow(dead_code)] #[derive(Debug)] pub struct TokenRecognizer(TokenKind, Recognizer); -impl<'i> lexer::TokenRecognizer<'i> for TokenRecognizer { +impl<'i> TokenRecognizerT<'i> for TokenRecognizer { fn recognize(&self, input: &'i str) -> Option<&'i str> { match &self { #[allow(unused_variables)] diff --git a/tests/src/output_dir/output_dir_act_actions.rs b/tests/src/output_dir/output_dir_act_actions.rs index 8147e4ac..9aa38eb0 100644 --- a/tests/src/output_dir/output_dir_act_actions.rs +++ b/tests/src/output_dir/output_dir_act_actions.rs @@ -1,11 +1,11 @@ /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use rustemo::lexer; +use rustemo::Token as RustemoToken; use super::output_dir_act::{TokenKind, Context}; pub type Input = str; pub type Ctx<'i> = Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = RustemoToken<'i, Input, TokenKind>; pub type Num = String; pub fn num(_ctx: &Ctx, token: Token) -> Num { token.value.into() diff --git a/tests/src/output_dir/output_dir_actions.rs b/tests/src/output_dir/output_dir_actions.rs index 176b7735..da754181 100644 --- a/tests/src/output_dir/output_dir_actions.rs +++ b/tests/src/output_dir/output_dir_actions.rs @@ -1,11 +1,11 @@ /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. -use rustemo::lexer; +use rustemo::Token as RustemoToken; use super::output_dir::{TokenKind, Context}; pub type Input = str; pub type Ctx<'i> = Context<'i, Input>; #[allow(dead_code)] -pub type Token<'i> = lexer::Token<'i, Input, TokenKind>; +pub type Token<'i> = RustemoToken<'i, Input, TokenKind>; pub type Num = String; pub fn num(_ctx: &Ctx, token: Token) -> Num { token.value.into() diff --git a/tests/src/partial/mod.rs b/tests/src/partial/mod.rs index e81324e4..f4cd584a 100644 --- a/tests/src/partial/mod.rs +++ b/tests/src/partial/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; use self::partial::PartialParser; diff --git a/tests/src/rule_patterns/mod.rs b/tests/src/rule_patterns/mod.rs index 74f13272..3f65b217 100644 --- a/tests/src/rule_patterns/mod.rs +++ b/tests/src/rule_patterns/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; rustemo_mod!(zero_or_more_1, "/src/rule_patterns"); diff --git a/tests/src/special/lalr_reduce_reduce_conflict/mod.rs b/tests/src/special/lalr_reduce_reduce_conflict/mod.rs index 8f309bb5..7c4bf900 100644 --- a/tests/src/special/lalr_reduce_reduce_conflict/mod.rs +++ b/tests/src/special/lalr_reduce_reduce_conflict/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/special/lalr_reduce_reduce_conflict"); diff --git a/tests/src/special/nondeterministic_palindromes/mod.rs b/tests/src/special/nondeterministic_palindromes/mod.rs index 1765cc4d..5c35d089 100644 --- a/tests/src/special/nondeterministic_palindromes/mod.rs +++ b/tests/src/special/nondeterministic_palindromes/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/special/nondeterministic_palindromes"); diff --git a/tests/src/sugar/one_or_more/mod.rs b/tests/src/sugar/one_or_more/mod.rs index 4cdcd4db..2a44f706 100644 --- a/tests/src/sugar/one_or_more/mod.rs +++ b/tests/src/sugar/one_or_more/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; use self::one_or_more_1::OneOrMore1Parser; diff --git a/tests/src/sugar/optional/mod.rs b/tests/src/sugar/optional/mod.rs index 53172a3d..e1b216d5 100644 --- a/tests/src/sugar/optional/mod.rs +++ b/tests/src/sugar/optional/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; use self::optional_1::Optional1Parser; diff --git a/tests/src/sugar/zero_or_more/mod.rs b/tests/src/sugar/zero_or_more/mod.rs index ea7cbd24..0e6833c6 100644 --- a/tests/src/sugar/zero_or_more/mod.rs +++ b/tests/src/sugar/zero_or_more/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; use self::zero_or_more_1::ZeroOrMore1Parser; diff --git a/tests/src/unicode/mod.rs b/tests/src/unicode/mod.rs index 5e153688..fbba6dff 100644 --- a/tests/src/unicode/mod.rs +++ b/tests/src/unicode/mod.rs @@ -1,5 +1,4 @@ -use rustemo::parser::Parser; -use rustemo::rustemo_mod; +use rustemo::{rustemo_mod, Parser}; use rustemo_compiler::output_cmp; use self::unicode::UnicodeParser;