From ce50d7aa603db2729d4c7ea2cc6410bc3ffdc404 Mon Sep 17 00:00:00 2001 From: Igor Dejanovic Date: Sat, 9 Nov 2024 21:06:55 +0100 Subject: [PATCH] feat: location info in AST refs #2 --- check-update-all.sh | 4 +- rustemo-compiler/src/generator/actions/mod.rs | 39 ++- .../src/generator/actions/production.rs | 141 +++++--- rustemo-compiler/src/main.rs | 6 + rustemo-compiler/src/settings.rs | 9 + rustemo/src/context.rs | 2 +- rustemo/src/glr/gss.rs | 82 ++++- rustemo/src/glr/parser.rs | 2 +- rustemo/src/location.rs | 16 +- rustemo/src/lr/parser.rs | 2 +- tests/build.rs | 11 +- tests/src/builder/loc_info/json.rustemo | 18 + tests/src/builder/loc_info/loc_info.ast | 327 ++++++++++++++++++ tests/src/builder/loc_info/loc_info.json | 22 ++ tests/src/builder/loc_info/mod.rs | 19 + tests/src/builder/mod.rs | 1 + tests/src/glr/build/{ => basic}/calc.rustemo | 0 tests/src/glr/build/basic/mod.rs | 60 ++++ .../{ => basic}/tree_build_default_1.ast | 0 .../{ => basic}/tree_build_default_2.ast | 0 .../{ => basic}/tree_build_generic_1.ast | 10 +- .../{ => basic}/tree_build_generic_2.ast | 10 +- tests/src/glr/build/loc_info/json.rustemo | 18 + tests/src/glr/build/loc_info/loc_info.ast | 325 +++++++++++++++++ tests/src/glr/build/loc_info/loc_info.json | 22 ++ tests/src/glr/build/loc_info/mod.rs | 25 ++ tests/src/glr/build/mod.rs | 74 +--- .../src/glr/special/bounded_ambiguity/mod.rs | 14 +- .../glr/special/bounded_ambiguity/tree_1.ast | 16 +- .../glr/special/bounded_ambiguity/tree_2.ast | 16 +- .../special/bounded_direct_ambiguity/mod.rs | 14 +- .../bounded_direct_ambiguity/tree_1.ast | 22 +- .../bounded_direct_ambiguity/tree_2.ast | 22 +- .../bounded_direct_ambiguity/tree_3.ast | 22 +- .../bounded_direct_ambiguity/tree_4.ast | 22 +- .../bounded_direct_ambiguity/tree_5.ast | 22 +- tests/src/glr/special/farshi_g7/mod.rs | 14 +- tests/src/glr/special/farshi_g7/tree.ast | 26 +- tests/src/glr/special/farshi_g8/mod.rs | 14 +- tests/src/glr/special/farshi_g8/tree_1.ast | 26 +- tests/src/glr/special/farshi_g8/tree_2.ast | 22 +- tests/src/glr/special/farshi_g8/tree_3.ast | 22 +- tests/src/glr/special/farshi_g8/tree_4.ast | 18 +- tests/src/glr/special/farshi_g8/tree_5.ast | 22 +- tests/src/glr/special/farshi_g8/tree_6.ast | 18 +- tests/src/glr/special/farshi_g8/tree_7.ast | 18 +- tests/src/glr/special/farshi_g8/tree_8.ast | 14 +- tests/src/glr/special/highly_ambiguous/mod.rs | 14 +- .../glr/special/highly_ambiguous/tree_1.ast | 12 +- .../glr/special/highly_ambiguous/tree_10.ast | 14 +- .../glr/special/highly_ambiguous/tree_2.ast | 12 +- .../glr/special/highly_ambiguous/tree_3.ast | 12 +- .../glr/special/highly_ambiguous/tree_4.ast | 14 +- .../glr/special/highly_ambiguous/tree_5.ast | 14 +- .../glr/special/highly_ambiguous/tree_6.ast | 12 +- .../glr/special/highly_ambiguous/tree_7.ast | 14 +- .../glr/special/highly_ambiguous/tree_8.ast | 14 +- .../glr/special/highly_ambiguous/tree_9.ast | 12 +- .../glr/special/reduce_enough_empty/mod.rs | 14 +- .../glr/special/reduce_enough_empty/tree.ast | 14 +- .../special/reduce_enough_many_empty/mod.rs | 14 +- .../special/reduce_enough_many_empty/tree.ast | 20 +- tests/src/glr/special/right_nullable/mod.rs | 14 +- .../src/glr/special/right_nullable/tree_1.ast | 12 +- .../src/glr/special/right_nullable/tree_2.ast | 10 +- .../glr/special/unbounded_ambiguity/mod.rs | 14 +- .../special/unbounded_ambiguity/tree_1.ast | 22 +- .../special/unbounded_ambiguity/tree_2.ast | 22 +- .../special/unbounded_ambiguity/tree_3.ast | 22 +- .../special/unbounded_ambiguity/tree_4.ast | 22 +- .../special/unbounded_ambiguity/tree_5.ast | 20 +- 71 files changed, 1448 insertions(+), 545 deletions(-) create mode 100644 tests/src/builder/loc_info/json.rustemo create mode 100644 tests/src/builder/loc_info/loc_info.ast create mode 100644 tests/src/builder/loc_info/loc_info.json create mode 100644 tests/src/builder/loc_info/mod.rs rename tests/src/glr/build/{ => basic}/calc.rustemo (100%) create mode 100644 tests/src/glr/build/basic/mod.rs rename tests/src/glr/build/{ => basic}/tree_build_default_1.ast (100%) rename tests/src/glr/build/{ => basic}/tree_build_default_2.ast (100%) rename tests/src/glr/build/{ => basic}/tree_build_generic_1.ast (89%) rename tests/src/glr/build/{ => basic}/tree_build_generic_2.ast (89%) create mode 100644 tests/src/glr/build/loc_info/json.rustemo create mode 100644 tests/src/glr/build/loc_info/loc_info.ast create mode 100644 tests/src/glr/build/loc_info/loc_info.json create mode 100644 tests/src/glr/build/loc_info/mod.rs diff --git a/check-update-all.sh b/check-update-all.sh index a8b1088b..684d1f22 100755 --- a/check-update-all.sh +++ b/check-update-all.sh @@ -13,8 +13,8 @@ cargo nextest run -p rustemo-compiler cargo install --path rustemo-compiler --debug # README Examples -rcomp docs/src/readme_example/src/textlr/calclr.rustemo -rcomp --parser-algo glr docs/src/readme_example/src/textglr/calc.rustemo +rcomp docs/src/readme_example/src/testlr/calclr.rustemo +rcomp --parser-algo glr docs/src/readme_example/src/testglr/calc.rustemo cd docs/src/tutorials/calculator/ for i in {1..5}; do diff --git a/rustemo-compiler/src/generator/actions/mod.rs b/rustemo-compiler/src/generator/actions/mod.rs index aff162be..572f7fe7 100644 --- a/rustemo-compiler/src/generator/actions/mod.rs +++ b/rustemo-compiler/src/generator/actions/mod.rs @@ -20,24 +20,35 @@ use super::ParserGenerator; mod production; pub(crate) trait ActionsGenerator { - fn terminal_type(&self, terminal: &Terminal) -> syn::Item { - let type_name_ident = format_ident!("{}", terminal.name); - parse_quote! { - pub type #type_name_ident = String; + fn terminal_type(&self, terminal: &Terminal, settings: &Settings) -> syn::Item { + let type_name = format_ident!("{}", terminal.name); + if settings.builder_loc_info { + parse_quote! { + pub type #type_name = ValLoc; + } + } else { + parse_quote! { + pub type #type_name = String; + } } } - fn terminal_action(&self, terminal: &Terminal, _settings: &Settings) -> syn::Item { + fn terminal_action(&self, terminal: &Terminal, settings: &Settings) -> syn::Item { let type_name = format_ident!("{}", terminal.name); let action_name = format_ident!("{}", to_snake_case(&terminal.name)); + let body: syn::Expr = if settings.builder_loc_info { + parse_quote! { #type_name::new(token.value.into(), Some(_ctx.location())) } + } else { + parse_quote! { token.value.into() } + }; parse_quote! { pub fn #action_name(_ctx: &Ctx, token: Token) -> #type_name { - token.value.into() + #body } } } /// Create Rust types for the given non-terminal. - fn nonterminal_types(&self, nonterminal: &NonTerminal) -> Vec; + fn nonterminal_types(&self, nonterminal: &NonTerminal, settings: &Settings) -> Vec; /// Creates an action function for each production of the given non-terminal. fn nonterminal_actions( @@ -73,11 +84,16 @@ pub(super) fn generate_parser_actions(generator: &ParserGenerator) -> Result<()> use super::#lexer_mod::Input; }, }; + let mut base_use: Vec = vec![]; + if generator.settings.builder_loc_info { + base_use.push(parse_quote! {use rustemo::{ValLoc, Context as C};}) + }; + base_use.push(parse_quote! {use rustemo::Token as RustemoToken;}); + base_use.push(parse_quote! {use super::#parser_mod::{TokenKind, Context};}); parse_quote! { /// This file is maintained by rustemo but can be modified manually. /// All manual changes will be preserved except non-doc comments. - use rustemo::Token as RustemoToken; - use super::#parser_mod::{TokenKind, Context}; + #(#base_use)* #input_type pub type Ctx<'i> = Context<'i, Input>; #[allow(dead_code)] @@ -135,7 +151,8 @@ pub(super) fn generate_parser_actions(generator: &ParserGenerator) -> Result<()> let type_name = &terminal.name; if !type_names.contains(type_name) { log!("Create type for terminal '{type_name}'."); - ast.items.push(actions_generator.terminal_type(terminal)); + ast.items + .push(actions_generator.terminal_type(terminal, generator.settings)); } // Add terminal actions let action_name = to_snake_case(&terminal.name); @@ -156,7 +173,7 @@ pub(super) fn generate_parser_actions(generator: &ParserGenerator) -> Result<()> // Add non-terminal type if !type_names.contains(&nonterminal.name) { log!("Creating types for non-terminal '{}'.", nonterminal.name); - for ty in actions_generator.nonterminal_types(nonterminal) { + for ty in actions_generator.nonterminal_types(nonterminal, generator.settings) { ast.items.push(ty); } } diff --git a/rustemo-compiler/src/generator/actions/production.rs b/rustemo-compiler/src/generator/actions/production.rs index 54a4b343..894a76d2 100644 --- a/rustemo-compiler/src/generator/actions/production.rs +++ b/rustemo-compiler/src/generator/actions/production.rs @@ -12,6 +12,16 @@ use crate::{ use super::ActionsGenerator; +macro_rules! name_valloc { + ($base_str:expr, $s:ident) => { + if $s.builder_loc_info { + format!("{}Base", $base_str) + } else { + $base_str.to_string() + } + }; +} + pub(crate) struct ProductionActionsGenerator<'t> { types: &'t SymbolTypes, term_len: usize, @@ -57,8 +67,15 @@ impl<'t> ProductionActionsGenerator<'t> { fn_args } - fn get_action_body(&self, ty: &SymbolType, target_type: &str, choice: &Choice) -> syn::Expr { + fn get_action_body( + &self, + ty: &SymbolType, + target_type: &str, + choice: &Choice, + settings: &Settings, + ) -> syn::Expr { let target_type = format_ident!("{target_type}"); + let target_type_base = format_ident!("{target_type}Base"); let choice_ident = format_ident!("{}", choice.name); let expr: syn::Expr = match &choice.kind { ChoiceKind::Plain => { @@ -66,6 +83,7 @@ impl<'t> ProductionActionsGenerator<'t> { } ChoiceKind::Struct { type_name, fields } => { let struct_ty = format_ident!("{type_name}"); + let struct_ty_base = format_ident!("{type_name}Base"); let fields: Vec = fields .iter() .map(|f| { @@ -79,12 +97,28 @@ impl<'t> ProductionActionsGenerator<'t> { .collect(); if matches!(ty.kind, SymbolTypeKind::Enum { .. }) { + if settings.builder_loc_info { + parse_quote! { + #target_type::#choice_ident( + #struct_ty::new(#struct_ty_base { + #(#fields),* + }, Some(_ctx.location())) + ) + } + } else { + parse_quote! { + #target_type::#choice_ident( + #struct_ty { + #(#fields),* + } + ) + } + } + } else if settings.builder_loc_info { parse_quote! { - #target_type::#choice_ident( - #struct_ty { - #(#fields),* - } - ) + #target_type::new(#target_type_base { + #(#fields),* + }, Some(_ctx.location())) } } else { parse_quote! { @@ -126,58 +160,70 @@ impl<'t> ProductionActionsGenerator<'t> { } impl ActionsGenerator for ProductionActionsGenerator<'_> { - fn nonterminal_types(&self, nonterminal: &NonTerminal) -> Vec { + fn nonterminal_types(&self, nonterminal: &NonTerminal, settings: &Settings) -> Vec { let ty = self .types .get_type(nonterminal.idx.symbol_index(self.term_len)); let type_ident = format_ident!("{}", ty.name); - fn get_choice_type(choice: &Choice, type_name: Option<&str>) -> Option { - match &choice.kind { - ChoiceKind::Struct { - type_name: struct_type, - fields, - } => { - let type_ident = if let Some(type_name) = type_name { - format_ident!("{type_name}") - } else { - format_ident!("{struct_type}") - }; + let get_choice_type = + |choice: &Choice, type_name: Option<&str>| -> Option> { + match &choice.kind { + ChoiceKind::Struct { + type_name: struct_type, + fields, + } => { + let type_name = if let Some(type_name) = type_name { + type_name.to_string() + } else { + struct_type.into() + }; + let type_ident = format_ident!("{}", name_valloc!(type_name, settings)); - let fields: Vec = fields - .iter() - .map(|f| { - let field_name = format_ident!("{}", f.name); - let field_type = format_ident!("{}", f.ref_type); - syn::Field::parse_named - .parse2(if f.recursive.get() { - // Handle direct recursion - quote! { pub #field_name: Box<#field_type> } - } else { - quote! {pub #field_name: #field_type} - }) - .unwrap() - }) - .collect(); - Some(parse_quote! { - #[derive(Debug, Clone)] - pub struct #type_ident { - #(#fields),* + let fields: Vec = fields + .iter() + .map(|f| { + let field_name = format_ident!("{}", f.name); + let field_type = format_ident!("{}", f.ref_type); + syn::Field::parse_named + .parse2(if f.recursive.get() { + // Handle direct recursion + quote! { pub #field_name: Box<#field_type> } + } else { + quote! {pub #field_name: #field_type} + }) + .unwrap() + }) + .collect(); + + let mut types = vec![]; + types.push(parse_quote! { + #[derive(Debug, Clone)] + pub struct #type_ident { + #(#fields),* + } + }); + if settings.builder_loc_info { + let type_ident_loc = format_ident!("{type_name}"); + types.push(parse_quote! { + pub type #type_ident_loc = ValLoc<#type_ident>; + }); } - }) + Some(types) + } + _ => None, } - _ => None, - } - } + }; - fn get_choice_types(choices: &[Choice], type_name: Option<&str>) -> Vec { + let get_choice_types = |choices: &[Choice], type_name: Option<&str>| -> Vec { choices .iter() .filter_map(|choice| get_choice_type(choice, type_name)) + .flatten() .collect() - } + }; - fn get_variants(choices: &[Choice]) -> Vec { + let get_variants = |choices: &[Choice]| -> Vec { choices .iter() .filter_map(|v| { @@ -204,7 +250,7 @@ impl ActionsGenerator for ProductionActionsGenerator<'_> { } }) .collect() - } + }; match &ty.kind { SymbolTypeKind::Enum { @@ -269,7 +315,7 @@ impl ActionsGenerator for ProductionActionsGenerator<'_> { fn nonterminal_actions( &self, nonterminal: &NonTerminal, - _settings: &Settings, + settings: &Settings, ) -> Vec<(String, syn::Item)> { let ty = self .types @@ -293,8 +339,7 @@ impl ActionsGenerator for ProductionActionsGenerator<'_> { let action_name = action_name(nonterminal, choice); let action = format_ident!("{action_name}"); let args = self.get_action_args(ty, choice); - let body = self.get_action_body(ty, target_type, choice); - + let body = self.get_action_body(ty, target_type, choice, settings); ( action_name, parse_quote! { diff --git a/rustemo-compiler/src/main.rs b/rustemo-compiler/src/main.rs index f2900889..a860a4da 100644 --- a/rustemo-compiler/src/main.rs +++ b/rustemo-compiler/src/main.rs @@ -76,6 +76,11 @@ struct Cli { #[clap(short, long, arg_enum, default_value_t)] builder_type: BuilderType, + /// Should generated default AST builder types contain location/layout information + /// This is only used for the default builder type. + #[clap(long)] + builder_loc_info: bool, + /// Lexical disambiguation using most specific match strategy. #[clap(long, default_missing_value = "true", require_equals = true)] lexical_disamb_most_specific: Option, @@ -133,6 +138,7 @@ fn main() { .generator_table_type(cli.generator_table_type) .lexer_type(cli.lexer_type) .builder_type(cli.builder_type) + .builder_loc_info(cli.builder_loc_info) .input_type(cli.input_type); if let Some(most_specific) = cli.lexical_disamb_most_specific { diff --git a/rustemo-compiler/src/settings.rs b/rustemo-compiler/src/settings.rs index 9945f53c..ea2dddd0 100644 --- a/rustemo-compiler/src/settings.rs +++ b/rustemo-compiler/src/settings.rs @@ -91,6 +91,7 @@ pub struct Settings { pub(crate) lexer_type: LexerType, pub(crate) builder_type: BuilderType, + pub(crate) builder_loc_info: bool, pub(crate) generator_table_type: GeneratorTableType, pub(crate) input_type: String, @@ -131,6 +132,7 @@ impl Default for Settings { notrace: false, lexer_type: Default::default(), builder_type: Default::default(), + builder_loc_info: false, generator_table_type: Default::default(), input_type: "str".into(), lexical_disamb_most_specific: true, @@ -260,6 +262,13 @@ impl Settings { self } + /// Should generated default AST builder types contain location/layout information + /// This is only used if builder-type is default. + pub fn builder_loc_info(mut self, builder_loc_info: bool) -> Self { + self.builder_loc_info = builder_loc_info; + self + } + /// Sets generator table type. The default is nested static arrays. pub fn generator_table_type(mut self, generator_table_type: GeneratorTableType) -> Self { self.generator_table_type = generator_table_type; diff --git a/rustemo/src/context.rs b/rustemo/src/context.rs index 073a6969..9758e458 100644 --- a/rustemo/src/context.rs +++ b/rustemo/src/context.rs @@ -4,7 +4,7 @@ use crate::{input::Input, lexer::Token, location::Location, parser::State}; /// Lexer/Parser context is used to keep the state. It provides necessary /// information to parsers and actions. -pub trait Context<'i, I: Input + ?Sized, S: State, TK> { +pub trait Context<'i, I: Input + ?Sized, S: State, TK>: Default { /// The current parser state. fn state(&self) -> S; fn set_state(&mut self, state: S); diff --git a/rustemo/src/glr/gss.rs b/rustemo/src/glr/gss.rs index 3d8bca40..c52cc8fd 100644 --- a/rustemo/src/glr/gss.rs +++ b/rustemo/src/glr/gss.rs @@ -349,6 +349,8 @@ where /// the parent links keeps all solutions along that back-path. children: RefCell>>>, }, + // Empty Tree + Empty, } impl<'i, I, P, TK> SPPFTree<'i, I, P, TK> @@ -362,13 +364,14 @@ where SPPFTree::NonTerm { children, .. } => { children.borrow().iter().map(|p| p.solutions()).product() } + SPPFTree::Empty => 0, } } #[allow(clippy::mutable_key_type)] fn ambiguities(&self, visited: &mut HashSet>>) -> usize { match self { - SPPFTree::Term { .. } => 0, + SPPFTree::Term { .. } | SPPFTree::Empty => 0, SPPFTree::NonTerm { children, .. } => children .borrow() .iter() @@ -385,6 +388,69 @@ where } } +/// Implementation of Context trait for usage in Tree::build. +impl<'i, I, S, P, TK> Context<'i, I, S, TK> for SPPFTree<'i, I, P, TK> +where + I: Input + ?Sized, + TK: Copy, + S: State, +{ + fn state(&self) -> S { + panic!("state() called on SPPFTree") + } + + fn set_state(&mut self, _state: S) {} + + fn position(&self) -> usize { + panic!("position() called on SPPFTree") + } + + fn set_position(&mut self, _position: usize) {} + + fn location(&self) -> Location { + match self { + SPPFTree::Term { data, .. } | SPPFTree::NonTerm { data, .. } => data.location, + _ => panic!("Called location() on empty tree!"), + } + } + + fn set_location(&mut self, _location: Location) {} + + fn range(&self) -> Range { + match self { + SPPFTree::Term { data, .. } | SPPFTree::NonTerm { data, .. } => data.range.clone(), + _ => panic!("Called range() on empty tree!"), + } + } + + fn set_range(&mut self, _range: Range) {} + + fn token_ahead(&self) -> Option<&Token<'i, I, TK>> { + None + } + + fn set_token_ahead(&mut self, _token: Token<'i, I, TK>) {} + + fn layout_ahead(&self) -> Option<&'i I> { + match self { + SPPFTree::Term { data, .. } | SPPFTree::NonTerm { data, .. } => data.layout, + _ => panic!("Called layout_ahead() on empty tree!"), + } + } + + fn set_layout_ahead(&mut self, _layout: Option<&'i I>) {} +} + +impl<'i, I, P, TK> Default for SPPFTree<'i, I, P, TK> +where + I: Input + ?Sized, + TK: Copy, +{ + fn default() -> Self { + Self::Empty + } +} + impl Clone for SPPFTree<'_, I, P, TK> where I: Input + ?Sized, @@ -406,6 +472,7 @@ where data: data.clone(), children: children.clone(), }, + Self::Empty => Self::Empty, } } } @@ -547,6 +614,7 @@ where match &*self.root { SPPFTree::Term { token, .. } => write!(f, "{:#?}", token.value), SPPFTree::NonTerm { .. } => write!(f, "{:#?}", self.children()), + SPPFTree::Empty => write!(f, "EMPTY"), } } } @@ -564,7 +632,7 @@ where /// current tree index and weighted numbering system. pub fn children(&self) -> Vec> { match *self.root { - SPPFTree::Term { .. } => vec![], + SPPFTree::Term { .. } | SPPFTree::Empty => vec![], SPPFTree::NonTerm { ref children, .. } => { let mut tree_idx = self.idx; // Calculate counter division based on weighted numbering @@ -594,13 +662,15 @@ where } /// Build an output of the tree using the given builder. - pub fn build, C, S>(&self, builder: &mut B) -> B::Output + pub fn build, S, P, TK>, S>( + &self, + builder: &mut B, + ) -> B::Output where - C: Context<'i, I, S, TK> + Default, S: State, P: Copy, { - let mut context = C::default(); + let mut context = GssHead::default(); self.build_inner(&mut context, builder); builder.get_result() } @@ -611,6 +681,7 @@ where S: State, P: Copy, { + context.set_location(Context::::location(&*self.root)); match &*self.root { SPPFTree::Term { token, .. } => builder.shift_action(context, token.clone()), SPPFTree::NonTerm { prod, .. } => { @@ -620,6 +691,7 @@ where }); builder.reduce_action(context, *prod, children.len()) } + SPPFTree::Empty => (), } } diff --git a/rustemo/src/glr/parser.rs b/rustemo/src/glr/parser.rs index 0b303d09..5d102b23 100644 --- a/rustemo/src/glr/parser.rs +++ b/rustemo/src/glr/parser.rs @@ -561,7 +561,7 @@ where // based on the same production || gss.parent(edge).possibilities.borrow().iter().all( |t| match **t { - SPPFTree::Term { .. } => false, + SPPFTree::Term { .. } | SPPFTree::Empty => false, SPPFTree::NonTerm { prod, ref children, ..} => { prod != production || (path.parents.len() == children.borrow().len()) } diff --git a/rustemo/src/location.rs b/rustemo/src/location.rs index c4528fb2..66ba1120 100644 --- a/rustemo/src/location.rs +++ b/rustemo/src/location.rs @@ -1,4 +1,7 @@ -use std::fmt::{Debug, Display}; +use std::{ + fmt::{Debug, Display}, + ops::Deref, +}; /// A line-column based location for use where applicable (e.g. plain text). #[derive(PartialEq, Eq, Debug, Copy, Clone)] @@ -126,11 +129,13 @@ impl Display for ValLoc { write!(f, "{}", self.value) } } + impl AsRef for ValLoc { fn as_ref(&self) -> &T { &self.value } } + impl From for ValLoc { fn from(value: T) -> Self { Self { @@ -139,6 +144,15 @@ impl From for ValLoc { } } } + +impl Deref for ValLoc { + type Target = T; + + fn deref(&self) -> &Self::Target { + &self.value + } +} + impl From> for String { fn from(value: ValLoc) -> Self { value.value diff --git a/rustemo/src/lr/parser.rs b/rustemo/src/lr/parser.rs index 30ce2d1c..26b8e8f0 100644 --- a/rustemo/src/lr/parser.rs +++ b/rustemo/src/lr/parser.rs @@ -297,7 +297,7 @@ where impl<'i, C, S, P, I, TK, NTK, D, L, B> Parser<'i, I, C, S, TK> for LRParser<'i, C, S, P, TK, NTK, D, L, B, I> where - C: Context<'i, I, S, TK> + Default, + C: Context<'i, I, S, TK>, S: State + Debug, P: Debug + Copy + Into, I: Input + ?Sized + Debug + 'i, diff --git a/tests/build.rs b/tests/build.rs index 12e85e90..733ef80d 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -67,6 +67,7 @@ fn main() { s.force(false).actions_in_source_tree() }), ), + ("builder/loc_info", Box::new(|s| s.builder_loc_info(true))), // Lexer ( "lexer/custom_lexer", @@ -85,7 +86,15 @@ fn main() { // GLR ("glr/errors", Box::new(|s| s.parser_algo(ParserAlgo::GLR))), ("glr/forest", Box::new(|s| s.parser_algo(ParserAlgo::GLR))), - ("glr/build", Box::new(|s| s.parser_algo(ParserAlgo::GLR))), + // GLR builders + ( + "glr/build/basic", + Box::new(|s| s.parser_algo(ParserAlgo::GLR)), + ), + ( + "glr/build/loc_info", + Box::new(|s| s.parser_algo(ParserAlgo::GLR).builder_loc_info(true)), + ), // GLR lexical ambiguities ( "glr/lexical_ambiguity/priorities", diff --git a/tests/src/builder/loc_info/json.rustemo b/tests/src/builder/loc_info/json.rustemo new file mode 100644 index 00000000..b5bb14c7 --- /dev/null +++ b/tests/src/builder/loc_info/json.rustemo @@ -0,0 +1,18 @@ +Value: False | True | Null | Object | Array | JsonNumber | JsonString; +Object: "{" Member*[Comma] "}"; +Member: JsonString ":" Value; +Array: "[" Value*[Comma] "]"; + +terminals +False: 'false'; +True: 'true'; +Null: 'null'; +Comma: ','; +JsonNumber: /-?\d+(\.\d+)?(e|E[-+]?\d+)?/; +JsonString: /"((\\")|[^"])*"/; + +OBracket: '['; +CBracket: ']'; +OBrace: '{'; +CBrace: '}'; +Colon: ':'; diff --git a/tests/src/builder/loc_info/loc_info.ast b/tests/src/builder/loc_info/loc_info.ast new file mode 100644 index 00000000..837570bb --- /dev/null +++ b/tests/src/builder/loc_info/loc_info.ast @@ -0,0 +1,327 @@ +Ok( + Object( + Some( + [ + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"glossary\"", + location: Some( + [2,4-2,14], + ), + }, + value: Object( + Some( + [ + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"title\"", + location: Some( + [3,8-3,15], + ), + }, + value: JsonString( + ValLoc { + value: "\"example glossary\"", + location: Some( + [3,17-3,35], + ), + }, + ), + }, + location: Some( + [3,8-3,35], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossDiv\"", + location: Some( + [4,8-4,18], + ), + }, + value: Object( + Some( + [ + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"title\"", + location: Some( + [5,12-5,19], + ), + }, + value: JsonString( + ValLoc { + value: "\"S\"", + location: Some( + [5,21-5,24], + ), + }, + ), + }, + location: Some( + [5,12-5,24], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossList\"", + location: Some( + [6,12-6,23], + ), + }, + value: Object( + Some( + [ + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossEntry\"", + location: Some( + [7,16-7,28], + ), + }, + value: Object( + Some( + [ + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"ID\"", + location: Some( + [8,20-8,24], + ), + }, + value: JsonString( + ValLoc { + value: "\"SGML\"", + location: Some( + [8,26-8,32], + ), + }, + ), + }, + location: Some( + [8,20-8,32], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"SortAs\"", + location: Some( + [9,20-9,28], + ), + }, + value: JsonString( + ValLoc { + value: "\"SGML\"", + location: Some( + [9,30-9,36], + ), + }, + ), + }, + location: Some( + [9,20-9,36], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossTerm\"", + location: Some( + [10,20-10,31], + ), + }, + value: JsonString( + ValLoc { + value: "\"Standard Generalized Markup Language\"", + location: Some( + [10,33-10,71], + ), + }, + ), + }, + location: Some( + [10,20-10,71], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"Acronym\"", + location: Some( + [11,20-11,29], + ), + }, + value: JsonString( + ValLoc { + value: "\"SGML\"", + location: Some( + [11,31-11,37], + ), + }, + ), + }, + location: Some( + [11,20-11,37], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"Abbrev\"", + location: Some( + [12,20-12,28], + ), + }, + value: JsonString( + ValLoc { + value: "\"ISO 8879:1986\"", + location: Some( + [12,30-12,45], + ), + }, + ), + }, + location: Some( + [12,20-12,45], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossDef\"", + location: Some( + [13,20-13,30], + ), + }, + value: Object( + Some( + [ + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"para\"", + location: Some( + [14,24-14,30], + ), + }, + value: JsonString( + ValLoc { + value: "\"A meta-markup language, used to create markup languages such as DocBook.\"", + location: Some( + [14,32-14,106], + ), + }, + ), + }, + location: Some( + [14,24-14,106], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossSeeAlso\"", + location: Some( + [15,24-15,38], + ), + }, + value: Array( + Some( + [ + JsonString( + ValLoc { + value: "\"GML\"", + location: Some( + [15,41-15,46], + ), + }, + ), + JsonString( + ValLoc { + value: "\"XML\"", + location: Some( + [15,48-15,53], + ), + }, + ), + ], + ), + ), + }, + location: Some( + [15,24-15,54], + ), + }, + ], + ), + ), + }, + location: Some( + [13,20-16,21], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossSee\"", + location: Some( + [17,20-17,30], + ), + }, + value: JsonString( + ValLoc { + value: "\"markup\"", + location: Some( + [17,32-17,40], + ), + }, + ), + }, + location: Some( + [17,20-17,40], + ), + }, + ], + ), + ), + }, + location: Some( + [7,16-18,17], + ), + }, + ], + ), + ), + }, + location: Some( + [6,12-19,13], + ), + }, + ], + ), + ), + }, + location: Some( + [4,8-20,9], + ), + }, + ], + ), + ), + }, + location: Some( + [2,4-21,5], + ), + }, + ], + ), + ), +) \ No newline at end of file diff --git a/tests/src/builder/loc_info/loc_info.json b/tests/src/builder/loc_info/loc_info.json new file mode 100644 index 00000000..c8f1d8c6 --- /dev/null +++ b/tests/src/builder/loc_info/loc_info.json @@ -0,0 +1,22 @@ +{ + "glossary": { + "title": "example glossary", + "GlossDiv": { + "title": "S", + "GlossList": { + "GlossEntry": { + "ID": "SGML", + "SortAs": "SGML", + "GlossTerm": "Standard Generalized Markup Language", + "Acronym": "SGML", + "Abbrev": "ISO 8879:1986", + "GlossDef": { + "para": "A meta-markup language, used to create markup languages such as DocBook.", + "GlossSeeAlso": ["GML", "XML"] + }, + "GlossSee": "markup" + } + } + } + } +} diff --git a/tests/src/builder/loc_info/mod.rs b/tests/src/builder/loc_info/mod.rs new file mode 100644 index 00000000..dd345ac8 --- /dev/null +++ b/tests/src/builder/loc_info/mod.rs @@ -0,0 +1,19 @@ +use rustemo::{rustemo_mod, Parser}; +use rustemo_compiler::{local_file, output_cmp}; + +use self::json::JsonParser; + +rustemo_mod!(json, "/src/builder/loc_info"); +rustemo_mod!(json_actions, "/src/builder/loc_info"); + +// ANCHOR: loc_info +#[test] +fn loc_info() { + let mut parser = JsonParser::new(); + let result = parser.parse_file(local_file!(file!(), "loc_info.json")); + output_cmp!( + "src/builder/loc_info/loc_info.ast", + format!("{:#?}", result) + ); +} +// ANCHOR_END: loc_info diff --git a/tests/src/builder/mod.rs b/tests/src/builder/mod.rs index e27e1192..24144008 100644 --- a/tests/src/builder/mod.rs +++ b/tests/src/builder/mod.rs @@ -1,3 +1,4 @@ mod custom_builder; mod generic_tree; +mod loc_info; mod use_context; diff --git a/tests/src/glr/build/calc.rustemo b/tests/src/glr/build/basic/calc.rustemo similarity index 100% rename from tests/src/glr/build/calc.rustemo rename to tests/src/glr/build/basic/calc.rustemo diff --git a/tests/src/glr/build/basic/mod.rs b/tests/src/glr/build/basic/mod.rs new file mode 100644 index 00000000..663ca559 --- /dev/null +++ b/tests/src/glr/build/basic/mod.rs @@ -0,0 +1,60 @@ +use rustemo::{rustemo_mod, Parser, TreeBuilder}; +use rustemo_compiler::output_cmp; + +rustemo_mod!(calc, "/src/glr/build/basic"); +rustemo_mod!(calc_actions, "/src/glr/build/basic"); + +use self::calc::CalcParser; + +// ANCHOR: build +#[test] +fn glr_tree_build_default() { + let forest = CalcParser::new().parse("1 + 4 * 9").unwrap(); + assert_eq!(forest.solutions(), 2); + + let mut builder = calc::DefaultBuilder::new(); + output_cmp!( + "src/glr/build/basic/tree_build_default_1.ast", + format!( + "{:#?}", + forest.get_first_tree().unwrap().build(&mut builder) + ) + ); + output_cmp!( + "src/glr/build/basic/tree_build_default_2.ast", + format!("{:#?}", forest.get_tree(1).unwrap().build(&mut builder)) + ); +} +// ANCHOR_END: build + +#[test] +fn glr_tree_build_generic() { + let forest = CalcParser::new().parse("1 + 4 * 9").unwrap(); + assert_eq!(forest.solutions(), 2); + + let mut builder = TreeBuilder::new(); + output_cmp!( + "src/glr/build/basic/tree_build_generic_1.ast", + format!( + "{:#?}", + forest + .get_first_tree() + .unwrap() + .build::, calc::State>( + &mut builder + ) + ) + ); + output_cmp!( + "src/glr/build/basic/tree_build_generic_2.ast", + format!( + "{:#?}", + forest + .get_tree(1) + .unwrap() + .build::, calc::State>( + &mut builder + ) + ) + ); +} diff --git a/tests/src/glr/build/tree_build_default_1.ast b/tests/src/glr/build/basic/tree_build_default_1.ast similarity index 100% rename from tests/src/glr/build/tree_build_default_1.ast rename to tests/src/glr/build/basic/tree_build_default_1.ast diff --git a/tests/src/glr/build/tree_build_default_2.ast b/tests/src/glr/build/basic/tree_build_default_2.ast similarity index 100% rename from tests/src/glr/build/tree_build_default_2.ast rename to tests/src/glr/build/basic/tree_build_default_2.ast diff --git a/tests/src/glr/build/tree_build_generic_1.ast b/tests/src/glr/build/basic/tree_build_generic_1.ast similarity index 89% rename from tests/src/glr/build/tree_build_generic_1.ast rename to tests/src/glr/build/basic/tree_build_generic_1.ast index 86802cde..f69a9ccc 100644 --- a/tests/src/glr/build/tree_build_generic_1.ast +++ b/tests/src/glr/build/basic/tree_build_generic_1.ast @@ -1,14 +1,14 @@ NonTermNode { prod: E: E Mul E, - location: [1,0], + location: [0], children: [ NonTermNode { prod: E: E Plus E, - location: [1,0], + location: [0], children: [ NonTermNode { prod: E: Num, - location: [1,0], + location: [0], children: [ TermNode { token: Num("\"1\"" [1,0-1,1]), @@ -23,7 +23,7 @@ NonTermNode { }, NonTermNode { prod: E: Num, - location: [1,0], + location: [0], children: [ TermNode { token: Num("\"4\"" [1,4-1,5]), @@ -41,7 +41,7 @@ NonTermNode { }, NonTermNode { prod: E: Num, - location: [1,0], + location: [0], children: [ TermNode { token: Num("\"9\"" [1,8-1,9]), diff --git a/tests/src/glr/build/tree_build_generic_2.ast b/tests/src/glr/build/basic/tree_build_generic_2.ast similarity index 89% rename from tests/src/glr/build/tree_build_generic_2.ast rename to tests/src/glr/build/basic/tree_build_generic_2.ast index a8407e6a..a8f542ed 100644 --- a/tests/src/glr/build/tree_build_generic_2.ast +++ b/tests/src/glr/build/basic/tree_build_generic_2.ast @@ -1,10 +1,10 @@ NonTermNode { prod: E: E Plus E, - location: [1,0], + location: [0], children: [ NonTermNode { prod: E: Num, - location: [1,0], + location: [0], children: [ TermNode { token: Num("\"1\"" [1,0-1,1]), @@ -19,11 +19,11 @@ NonTermNode { }, NonTermNode { prod: E: E Mul E, - location: [1,0], + location: [0], children: [ NonTermNode { prod: E: Num, - location: [1,0], + location: [0], children: [ TermNode { token: Num("\"4\"" [1,4-1,5]), @@ -38,7 +38,7 @@ NonTermNode { }, NonTermNode { prod: E: Num, - location: [1,0], + location: [0], children: [ TermNode { token: Num("\"9\"" [1,8-1,9]), diff --git a/tests/src/glr/build/loc_info/json.rustemo b/tests/src/glr/build/loc_info/json.rustemo new file mode 100644 index 00000000..b5bb14c7 --- /dev/null +++ b/tests/src/glr/build/loc_info/json.rustemo @@ -0,0 +1,18 @@ +Value: False | True | Null | Object | Array | JsonNumber | JsonString; +Object: "{" Member*[Comma] "}"; +Member: JsonString ":" Value; +Array: "[" Value*[Comma] "]"; + +terminals +False: 'false'; +True: 'true'; +Null: 'null'; +Comma: ','; +JsonNumber: /-?\d+(\.\d+)?(e|E[-+]?\d+)?/; +JsonString: /"((\\")|[^"])*"/; + +OBracket: '['; +CBracket: ']'; +OBrace: '{'; +CBrace: '}'; +Colon: ':'; diff --git a/tests/src/glr/build/loc_info/loc_info.ast b/tests/src/glr/build/loc_info/loc_info.ast new file mode 100644 index 00000000..c17d80a9 --- /dev/null +++ b/tests/src/glr/build/loc_info/loc_info.ast @@ -0,0 +1,325 @@ +Object( + Some( + [ + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"glossary\"", + location: Some( + [0], + ), + }, + value: Object( + Some( + [ + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"title\"", + location: Some( + [0], + ), + }, + value: JsonString( + ValLoc { + value: "\"example glossary\"", + location: Some( + [0], + ), + }, + ), + }, + location: Some( + [0], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossDiv\"", + location: Some( + [0], + ), + }, + value: Object( + Some( + [ + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"title\"", + location: Some( + [0], + ), + }, + value: JsonString( + ValLoc { + value: "\"S\"", + location: Some( + [0], + ), + }, + ), + }, + location: Some( + [0], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossList\"", + location: Some( + [0], + ), + }, + value: Object( + Some( + [ + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossEntry\"", + location: Some( + [0], + ), + }, + value: Object( + Some( + [ + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"ID\"", + location: Some( + [0], + ), + }, + value: JsonString( + ValLoc { + value: "\"SGML\"", + location: Some( + [0], + ), + }, + ), + }, + location: Some( + [0], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"SortAs\"", + location: Some( + [0], + ), + }, + value: JsonString( + ValLoc { + value: "\"SGML\"", + location: Some( + [0], + ), + }, + ), + }, + location: Some( + [0], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossTerm\"", + location: Some( + [0], + ), + }, + value: JsonString( + ValLoc { + value: "\"Standard Generalized Markup Language\"", + location: Some( + [0], + ), + }, + ), + }, + location: Some( + [0], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"Acronym\"", + location: Some( + [0], + ), + }, + value: JsonString( + ValLoc { + value: "\"SGML\"", + location: Some( + [0], + ), + }, + ), + }, + location: Some( + [0], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"Abbrev\"", + location: Some( + [0], + ), + }, + value: JsonString( + ValLoc { + value: "\"ISO 8879:1986\"", + location: Some( + [0], + ), + }, + ), + }, + location: Some( + [0], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossDef\"", + location: Some( + [0], + ), + }, + value: Object( + Some( + [ + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"para\"", + location: Some( + [0], + ), + }, + value: JsonString( + ValLoc { + value: "\"A meta-markup language, used to create markup languages such as DocBook.\"", + location: Some( + [0], + ), + }, + ), + }, + location: Some( + [0], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossSeeAlso\"", + location: Some( + [0], + ), + }, + value: Array( + Some( + [ + JsonString( + ValLoc { + value: "\"GML\"", + location: Some( + [0], + ), + }, + ), + JsonString( + ValLoc { + value: "\"XML\"", + location: Some( + [0], + ), + }, + ), + ], + ), + ), + }, + location: Some( + [0], + ), + }, + ], + ), + ), + }, + location: Some( + [0], + ), + }, + ValLoc { + value: MemberBase { + json_string: ValLoc { + value: "\"GlossSee\"", + location: Some( + [0], + ), + }, + value: JsonString( + ValLoc { + value: "\"markup\"", + location: Some( + [0], + ), + }, + ), + }, + location: Some( + [0], + ), + }, + ], + ), + ), + }, + location: Some( + [0], + ), + }, + ], + ), + ), + }, + location: Some( + [0], + ), + }, + ], + ), + ), + }, + location: Some( + [0], + ), + }, + ], + ), + ), + }, + location: Some( + [0], + ), + }, + ], + ), +) \ No newline at end of file diff --git a/tests/src/glr/build/loc_info/loc_info.json b/tests/src/glr/build/loc_info/loc_info.json new file mode 100644 index 00000000..c8f1d8c6 --- /dev/null +++ b/tests/src/glr/build/loc_info/loc_info.json @@ -0,0 +1,22 @@ +{ + "glossary": { + "title": "example glossary", + "GlossDiv": { + "title": "S", + "GlossList": { + "GlossEntry": { + "ID": "SGML", + "SortAs": "SGML", + "GlossTerm": "Standard Generalized Markup Language", + "Acronym": "SGML", + "Abbrev": "ISO 8879:1986", + "GlossDef": { + "para": "A meta-markup language, used to create markup languages such as DocBook.", + "GlossSeeAlso": ["GML", "XML"] + }, + "GlossSee": "markup" + } + } + } + } +} diff --git a/tests/src/glr/build/loc_info/mod.rs b/tests/src/glr/build/loc_info/mod.rs new file mode 100644 index 00000000..f03d61ae --- /dev/null +++ b/tests/src/glr/build/loc_info/mod.rs @@ -0,0 +1,25 @@ +use rustemo::{rustemo_mod, Parser}; +use rustemo_compiler::{local_file, output_cmp}; + +use self::json::JsonParser; + +rustemo_mod!(json, "/src/glr/build/loc_info"); +rustemo_mod!(json_actions, "/src/glr/build/loc_info"); + +// ANCHOR: loc_info +#[test] +fn glr_loc_info() { + let mut parser = JsonParser::new(); + let forest = parser + .parse_file(local_file!(file!(), "loc_info.json")) + .unwrap(); + + let mut builder = self::json::DefaultBuilder::new(); + let result = forest.get_first_tree().unwrap().build(&mut builder); + + output_cmp!( + "src/glr/build/loc_info/loc_info.ast", + format!("{:#?}", result) + ); +} +// ANCHOR_END: loc_info diff --git a/tests/src/glr/build/mod.rs b/tests/src/glr/build/mod.rs index 47628422..022eb0b3 100644 --- a/tests/src/glr/build/mod.rs +++ b/tests/src/glr/build/mod.rs @@ -1,72 +1,2 @@ -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; - -// ANCHOR: build -#[test] -fn glr_tree_build_default() { - let forest = CalcParser::new().parse("1 + 4 * 9").unwrap(); - assert_eq!(forest.solutions(), 2); - - let mut builder = calc::DefaultBuilder::new(); - output_cmp!( - "src/glr/build/tree_build_default_1.ast", - format!( - "{:#?}", - forest.get_first_tree().unwrap().build(&mut builder) - ) - ); - output_cmp!( - "src/glr/build/tree_build_default_2.ast", - format!("{:#?}", forest.get_tree(1).unwrap().build(&mut builder)) - ); -} -// ANCHOR_END: build - -#[test] -fn glr_tree_build_generic() { - let forest = CalcParser::new().parse("1 + 4 * 9").unwrap(); - assert_eq!(forest.solutions(), 2); - - let mut builder = TreeBuilder::new(); - output_cmp!( - "src/glr/build/tree_build_generic_1.ast", - format!( - "{:#?}", - forest.get_first_tree().unwrap().build::, GssHead< - '_, - str, - calc::State, - calc::TokenKind, - >, calc::State>( - &mut builder - ) - ) - ); - output_cmp!( - "src/glr/build/tree_build_generic_2.ast", - format!( - "{:#?}", - forest.get_tree(1).unwrap().build::, GssHead< - '_, - str, - calc::State, - calc::TokenKind, - >, calc::State>(&mut builder) - ) - ); -} +mod basic; +mod loc_info; diff --git a/tests/src/glr/special/bounded_ambiguity/mod.rs b/tests/src/glr/special/bounded_ambiguity/mod.rs index afa231f5..f40690f2 100644 --- a/tests/src/glr/special/bounded_ambiguity/mod.rs +++ b/tests/src/glr/special/bounded_ambiguity/mod.rs @@ -1,4 +1,4 @@ -use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; +use rustemo::{rustemo_mod, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/bounded_ambiguity"); @@ -17,14 +17,10 @@ fn glr_special_bounded_ambiguity() { &format!("src/glr/special/bounded_ambiguity/tree_{}.ast", i), format!( "{:#?}", - tree.unwrap().build::, GssHead<'_, str, lang::State, lang::TokenKind>, lang::State>( - &mut builder - ) + tree.unwrap() + .build::, lang::State>( + &mut builder + ) ) ); }); diff --git a/tests/src/glr/special/bounded_ambiguity/tree_1.ast b/tests/src/glr/special/bounded_ambiguity/tree_1.ast index da3f60dd..a53f6968 100644 --- a/tests/src/glr/special/bounded_ambiguity/tree_1.ast +++ b/tests/src/glr/special/bounded_ambiguity/tree_1.ast @@ -1,40 +1,40 @@ NonTermNode { prod: S: M, - location: [1,0], + location: [0], children: [ NonTermNode { prod: M: A M Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: M: A M Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: M: A M Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: M: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), diff --git a/tests/src/glr/special/bounded_ambiguity/tree_2.ast b/tests/src/glr/special/bounded_ambiguity/tree_2.ast index 6da53517..4500bae5 100644 --- a/tests/src/glr/special/bounded_ambiguity/tree_2.ast +++ b/tests/src/glr/special/bounded_ambiguity/tree_2.ast @@ -1,40 +1,40 @@ NonTermNode { prod: S: N, - location: [1,0], + location: [0], children: [ NonTermNode { prod: N: A N Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: N: A N Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: N: A N Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: N: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), diff --git a/tests/src/glr/special/bounded_direct_ambiguity/mod.rs b/tests/src/glr/special/bounded_direct_ambiguity/mod.rs index 10589549..64d2b09d 100644 --- a/tests/src/glr/special/bounded_direct_ambiguity/mod.rs +++ b/tests/src/glr/special/bounded_direct_ambiguity/mod.rs @@ -1,4 +1,4 @@ -use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; +use rustemo::{rustemo_mod, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/bounded_direct_ambiguity"); @@ -17,14 +17,10 @@ fn glr_special_bounded_direct_ambiguity() { &format!("src/glr/special/bounded_direct_ambiguity/tree_{}.ast", i), format!( "{:#?}", - tree.unwrap().build::, GssHead<'_, str, lang::State, lang::TokenKind>, lang::State>( - &mut builder - ) + tree.unwrap() + .build::, lang::State>( + &mut builder + ) ) ); }); diff --git a/tests/src/glr/special/bounded_direct_ambiguity/tree_1.ast b/tests/src/glr/special/bounded_direct_ambiguity/tree_1.ast index a87f34d3..978a58c9 100644 --- a/tests/src/glr/special/bounded_direct_ambiguity/tree_1.ast +++ b/tests/src/glr/special/bounded_direct_ambiguity/tree_1.ast @@ -1,10 +1,10 @@ NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: Tt, - location: [1,0], + location: [0], children: [ TermNode { token: Tt("\"t\"" [1,0-1,1]), @@ -15,47 +15,47 @@ NonTermNode { }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,1-1,2]), diff --git a/tests/src/glr/special/bounded_direct_ambiguity/tree_2.ast b/tests/src/glr/special/bounded_direct_ambiguity/tree_2.ast index f4555432..bb89c3f3 100644 --- a/tests/src/glr/special/bounded_direct_ambiguity/tree_2.ast +++ b/tests/src/glr/special/bounded_direct_ambiguity/tree_2.ast @@ -1,30 +1,30 @@ NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: Tt, - location: [1,0], + location: [0], children: [ TermNode { token: Tt("\"t\"" [1,0-1,1]), @@ -35,27 +35,27 @@ NonTermNode { }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,1-1,2]), diff --git a/tests/src/glr/special/bounded_direct_ambiguity/tree_3.ast b/tests/src/glr/special/bounded_direct_ambiguity/tree_3.ast index 2893e0b3..fd8dd6cb 100644 --- a/tests/src/glr/special/bounded_direct_ambiguity/tree_3.ast +++ b/tests/src/glr/special/bounded_direct_ambiguity/tree_3.ast @@ -1,50 +1,50 @@ NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: Tt, - location: [1,0], + location: [0], children: [ TermNode { token: Tt("\"t\"" [1,0-1,1]), @@ -55,7 +55,7 @@ NonTermNode { }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,1-1,2]), diff --git a/tests/src/glr/special/bounded_direct_ambiguity/tree_4.ast b/tests/src/glr/special/bounded_direct_ambiguity/tree_4.ast index 4374fe08..36bcc538 100644 --- a/tests/src/glr/special/bounded_direct_ambiguity/tree_4.ast +++ b/tests/src/glr/special/bounded_direct_ambiguity/tree_4.ast @@ -1,40 +1,40 @@ NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: Tt, - location: [1,0], + location: [0], children: [ TermNode { token: Tt("\"t\"" [1,0-1,1]), @@ -45,17 +45,17 @@ NonTermNode { }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,1-1,2]), diff --git a/tests/src/glr/special/bounded_direct_ambiguity/tree_5.ast b/tests/src/glr/special/bounded_direct_ambiguity/tree_5.ast index 75ea9cac..4a63dd16 100644 --- a/tests/src/glr/special/bounded_direct_ambiguity/tree_5.ast +++ b/tests/src/glr/special/bounded_direct_ambiguity/tree_5.ast @@ -1,20 +1,20 @@ NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: Tt, - location: [1,0], + location: [0], children: [ TermNode { token: Tt("\"t\"" [1,0-1,1]), @@ -25,37 +25,37 @@ NonTermNode { }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,1-1,2]), diff --git a/tests/src/glr/special/farshi_g7/mod.rs b/tests/src/glr/special/farshi_g7/mod.rs index d35d9d35..1ee077d4 100644 --- a/tests/src/glr/special/farshi_g7/mod.rs +++ b/tests/src/glr/special/farshi_g7/mod.rs @@ -1,4 +1,4 @@ -use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; +use rustemo::{rustemo_mod, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/farshi_g7"); @@ -20,14 +20,10 @@ fn glr_special_farshi_g7() { "src/glr/special/farshi_g7/tree.ast", format!( "{:#?}", - tree.unwrap().build::, GssHead<'_, str, lang::State, lang::TokenKind>, lang::State>( - &mut builder - ) + tree.unwrap() + .build::, lang::State>( + &mut builder + ) ) ); } diff --git a/tests/src/glr/special/farshi_g7/tree.ast b/tests/src/glr/special/farshi_g7/tree.ast index ad3b7ac1..98d9e8ce 100644 --- a/tests/src/glr/special/farshi_g7/tree.ast +++ b/tests/src/glr/special/farshi_g7/tree.ast @@ -1,6 +1,6 @@ NonTermNode { prod: S: Ta S Ta, - location: [1,0], + location: [0], children: [ TermNode { token: Ta("\"a\"" [1,0-1,1]), @@ -8,7 +8,7 @@ NonTermNode { }, NonTermNode { prod: S: Ta S Ta, - location: [1,0], + location: [0], children: [ TermNode { token: Ta("\"a\"" [1,1-1,2]), @@ -16,11 +16,11 @@ NonTermNode { }, NonTermNode { prod: S: C S Tc, - location: [1,0], + location: [0], children: [ NonTermNode { prod: C: Ta, - location: [1,0], + location: [0], children: [ TermNode { token: Ta("\"a\"" [1,2-1,3]), @@ -31,7 +31,7 @@ NonTermNode { }, NonTermNode { prod: S: Ta S Ta, - location: [1,0], + location: [0], children: [ TermNode { token: Ta("\"a\"" [1,3-1,4]), @@ -39,7 +39,7 @@ NonTermNode { }, NonTermNode { prod: S: Ta S Ta, - location: [1,0], + location: [0], children: [ TermNode { token: Ta("\"a\"" [1,4-1,5]), @@ -47,11 +47,11 @@ NonTermNode { }, NonTermNode { prod: S: C S Tc, - location: [1,0], + location: [0], children: [ NonTermNode { prod: C: Ta, - location: [1,0], + location: [0], children: [ TermNode { token: Ta("\"a\"" [1,5-1,6]), @@ -62,11 +62,11 @@ NonTermNode { }, NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: Ta, - location: [1,0], + location: [0], children: [ TermNode { token: Ta("\"a\"" [1,6-1,7]), @@ -77,11 +77,11 @@ NonTermNode { }, NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: Ta, - location: [1,0], + location: [0], children: [ TermNode { token: Ta("\"a\"" [1,7-1,8]), @@ -92,7 +92,7 @@ NonTermNode { }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,8-1,9]), diff --git a/tests/src/glr/special/farshi_g8/mod.rs b/tests/src/glr/special/farshi_g8/mod.rs index 3ac54684..169027df 100644 --- a/tests/src/glr/special/farshi_g8/mod.rs +++ b/tests/src/glr/special/farshi_g8/mod.rs @@ -1,4 +1,4 @@ -use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; +use rustemo::{rustemo_mod, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/farshi_g8"); @@ -17,14 +17,10 @@ fn glr_special_farshi_g8() { &format!("src/glr/special/farshi_g8/tree_{}.ast", i), format!( "{:#?}", - tree.unwrap().build::, GssHead<'_, str, lang::State, lang::TokenKind>, lang::State>( - &mut builder - ) + tree.unwrap() + .build::, lang::State>( + &mut builder + ) ) ); }); diff --git a/tests/src/glr/special/farshi_g8/tree_1.ast b/tests/src/glr/special/farshi_g8/tree_1.ast index 6d98294c..908ab479 100644 --- a/tests/src/glr/special/farshi_g8/tree_1.ast +++ b/tests/src/glr/special/farshi_g8/tree_1.ast @@ -1,20 +1,20 @@ NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: A A, - location: [1,0], + location: [1,0-1,0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, @@ -23,21 +23,21 @@ NonTermNode { }, NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: A A, - location: [1,0], + location: [1,0-1,0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, @@ -46,21 +46,21 @@ NonTermNode { }, NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: A A, - location: [1,0], + location: [1,0-1,0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, @@ -69,7 +69,7 @@ NonTermNode { }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), diff --git a/tests/src/glr/special/farshi_g8/tree_2.ast b/tests/src/glr/special/farshi_g8/tree_2.ast index a7845d78..e69a8351 100644 --- a/tests/src/glr/special/farshi_g8/tree_2.ast +++ b/tests/src/glr/special/farshi_g8/tree_2.ast @@ -1,20 +1,20 @@ NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: A A, - location: [1,0], + location: [1,0-1,0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, @@ -23,21 +23,21 @@ NonTermNode { }, NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: A A, - location: [1,0], + location: [1,0-1,0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, @@ -46,17 +46,17 @@ NonTermNode { }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), diff --git a/tests/src/glr/special/farshi_g8/tree_3.ast b/tests/src/glr/special/farshi_g8/tree_3.ast index d5fe54c9..bbd45e1c 100644 --- a/tests/src/glr/special/farshi_g8/tree_3.ast +++ b/tests/src/glr/special/farshi_g8/tree_3.ast @@ -1,20 +1,20 @@ NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: A A, - location: [1,0], + location: [1,0-1,0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, @@ -23,31 +23,31 @@ NonTermNode { }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: A A, - location: [1,0], + location: [1,0-1,0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, @@ -56,7 +56,7 @@ NonTermNode { }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), diff --git a/tests/src/glr/special/farshi_g8/tree_4.ast b/tests/src/glr/special/farshi_g8/tree_4.ast index b9609053..08b25f6b 100644 --- a/tests/src/glr/special/farshi_g8/tree_4.ast +++ b/tests/src/glr/special/farshi_g8/tree_4.ast @@ -1,20 +1,20 @@ NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: A A, - location: [1,0], + location: [1,0-1,0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, @@ -23,27 +23,27 @@ NonTermNode { }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), diff --git a/tests/src/glr/special/farshi_g8/tree_5.ast b/tests/src/glr/special/farshi_g8/tree_5.ast index 1ba02bb7..08983cf0 100644 --- a/tests/src/glr/special/farshi_g8/tree_5.ast +++ b/tests/src/glr/special/farshi_g8/tree_5.ast @@ -1,30 +1,30 @@ NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: A A, - location: [1,0], + location: [1,0-1,0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, @@ -33,21 +33,21 @@ NonTermNode { }, NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: A A, - location: [1,0], + location: [1,0-1,0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, @@ -56,7 +56,7 @@ NonTermNode { }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), diff --git a/tests/src/glr/special/farshi_g8/tree_6.ast b/tests/src/glr/special/farshi_g8/tree_6.ast index 5a2443b8..aa3a6cf6 100644 --- a/tests/src/glr/special/farshi_g8/tree_6.ast +++ b/tests/src/glr/special/farshi_g8/tree_6.ast @@ -1,30 +1,30 @@ NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: A A, - location: [1,0], + location: [1,0-1,0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, @@ -33,17 +33,17 @@ NonTermNode { }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), diff --git a/tests/src/glr/special/farshi_g8/tree_7.ast b/tests/src/glr/special/farshi_g8/tree_7.ast index b0907e69..7089a2c9 100644 --- a/tests/src/glr/special/farshi_g8/tree_7.ast +++ b/tests/src/glr/special/farshi_g8/tree_7.ast @@ -1,40 +1,40 @@ NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: B: A A, - location: [1,0], + location: [1,0-1,0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, @@ -43,7 +43,7 @@ NonTermNode { }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), diff --git a/tests/src/glr/special/farshi_g8/tree_8.ast b/tests/src/glr/special/farshi_g8/tree_8.ast index 1839d709..d65c49f0 100644 --- a/tests/src/glr/special/farshi_g8/tree_8.ast +++ b/tests/src/glr/special/farshi_g8/tree_8.ast @@ -1,36 +1,36 @@ NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), diff --git a/tests/src/glr/special/highly_ambiguous/mod.rs b/tests/src/glr/special/highly_ambiguous/mod.rs index 7d79960d..af1572cf 100644 --- a/tests/src/glr/special/highly_ambiguous/mod.rs +++ b/tests/src/glr/special/highly_ambiguous/mod.rs @@ -1,4 +1,4 @@ -use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; +use rustemo::{rustemo_mod, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/highly_ambiguous"); @@ -20,14 +20,10 @@ fn glr_special_highly_ambiguous() { &format!("src/glr/special/highly_ambiguous/tree_{}.ast", i), format!( "{:#?}", - tree.unwrap().build::, GssHead<'_, str, lang::State, lang::TokenKind>, lang::State>( - &mut builder - ) + tree.unwrap() + .build::, lang::State>( + &mut builder + ) ) ); }); diff --git a/tests/src/glr/special/highly_ambiguous/tree_1.ast b/tests/src/glr/special/highly_ambiguous/tree_1.ast index 351e2e9d..babd41ef 100644 --- a/tests/src/glr/special/highly_ambiguous/tree_1.ast +++ b/tests/src/glr/special/highly_ambiguous/tree_1.ast @@ -1,10 +1,10 @@ NonTermNode { prod: S: S S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,0-1,1]), @@ -15,11 +15,11 @@ NonTermNode { }, NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,1-1,2]), @@ -30,7 +30,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,2-1,3]), @@ -44,7 +44,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,3-1,4]), diff --git a/tests/src/glr/special/highly_ambiguous/tree_10.ast b/tests/src/glr/special/highly_ambiguous/tree_10.ast index bd239a79..6d43d561 100644 --- a/tests/src/glr/special/highly_ambiguous/tree_10.ast +++ b/tests/src/glr/special/highly_ambiguous/tree_10.ast @@ -1,14 +1,14 @@ NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,0-1,1]), @@ -19,7 +19,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,1-1,2]), @@ -33,11 +33,11 @@ NonTermNode { }, NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,2-1,3]), @@ -48,7 +48,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,3-1,4]), diff --git a/tests/src/glr/special/highly_ambiguous/tree_2.ast b/tests/src/glr/special/highly_ambiguous/tree_2.ast index 3ce18387..3d21861c 100644 --- a/tests/src/glr/special/highly_ambiguous/tree_2.ast +++ b/tests/src/glr/special/highly_ambiguous/tree_2.ast @@ -1,14 +1,14 @@ NonTermNode { prod: S: S S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,0-1,1]), @@ -19,7 +19,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,1-1,2]), @@ -33,7 +33,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,2-1,3]), @@ -44,7 +44,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,3-1,4]), diff --git a/tests/src/glr/special/highly_ambiguous/tree_3.ast b/tests/src/glr/special/highly_ambiguous/tree_3.ast index c77e11db..ffe21151 100644 --- a/tests/src/glr/special/highly_ambiguous/tree_3.ast +++ b/tests/src/glr/special/highly_ambiguous/tree_3.ast @@ -1,14 +1,14 @@ NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: S S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,0-1,1]), @@ -19,7 +19,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,1-1,2]), @@ -30,7 +30,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,2-1,3]), @@ -44,7 +44,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,3-1,4]), diff --git a/tests/src/glr/special/highly_ambiguous/tree_4.ast b/tests/src/glr/special/highly_ambiguous/tree_4.ast index 9d80ad5f..fc29e031 100644 --- a/tests/src/glr/special/highly_ambiguous/tree_4.ast +++ b/tests/src/glr/special/highly_ambiguous/tree_4.ast @@ -1,18 +1,18 @@ NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,0-1,1]), @@ -23,7 +23,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,1-1,2]), @@ -37,7 +37,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,2-1,3]), @@ -51,7 +51,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,3-1,4]), diff --git a/tests/src/glr/special/highly_ambiguous/tree_5.ast b/tests/src/glr/special/highly_ambiguous/tree_5.ast index c6c2481a..00cf0806 100644 --- a/tests/src/glr/special/highly_ambiguous/tree_5.ast +++ b/tests/src/glr/special/highly_ambiguous/tree_5.ast @@ -1,14 +1,14 @@ NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,0-1,1]), @@ -19,11 +19,11 @@ NonTermNode { }, NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,1-1,2]), @@ -34,7 +34,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,2-1,3]), @@ -51,7 +51,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,3-1,4]), diff --git a/tests/src/glr/special/highly_ambiguous/tree_6.ast b/tests/src/glr/special/highly_ambiguous/tree_6.ast index 1f44bcf6..3b81e012 100644 --- a/tests/src/glr/special/highly_ambiguous/tree_6.ast +++ b/tests/src/glr/special/highly_ambiguous/tree_6.ast @@ -1,10 +1,10 @@ NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,0-1,1]), @@ -15,11 +15,11 @@ NonTermNode { }, NonTermNode { prod: S: S S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,1-1,2]), @@ -30,7 +30,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,2-1,3]), @@ -41,7 +41,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,3-1,4]), diff --git a/tests/src/glr/special/highly_ambiguous/tree_7.ast b/tests/src/glr/special/highly_ambiguous/tree_7.ast index ec3cb24d..a4c5b6fd 100644 --- a/tests/src/glr/special/highly_ambiguous/tree_7.ast +++ b/tests/src/glr/special/highly_ambiguous/tree_7.ast @@ -1,10 +1,10 @@ NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,0-1,1]), @@ -15,15 +15,15 @@ NonTermNode { }, NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,1-1,2]), @@ -34,7 +34,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,2-1,3]), @@ -48,7 +48,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,3-1,4]), diff --git a/tests/src/glr/special/highly_ambiguous/tree_8.ast b/tests/src/glr/special/highly_ambiguous/tree_8.ast index 3239dbca..7bf6ea68 100644 --- a/tests/src/glr/special/highly_ambiguous/tree_8.ast +++ b/tests/src/glr/special/highly_ambiguous/tree_8.ast @@ -1,10 +1,10 @@ NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,0-1,1]), @@ -15,11 +15,11 @@ NonTermNode { }, NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,1-1,2]), @@ -30,11 +30,11 @@ NonTermNode { }, NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,2-1,3]), @@ -45,7 +45,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,3-1,4]), diff --git a/tests/src/glr/special/highly_ambiguous/tree_9.ast b/tests/src/glr/special/highly_ambiguous/tree_9.ast index 6ef2d8fe..0355bae2 100644 --- a/tests/src/glr/special/highly_ambiguous/tree_9.ast +++ b/tests/src/glr/special/highly_ambiguous/tree_9.ast @@ -1,10 +1,10 @@ NonTermNode { prod: S: S S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,0-1,1]), @@ -15,7 +15,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,1-1,2]), @@ -26,11 +26,11 @@ NonTermNode { }, NonTermNode { prod: S: S S, - location: [1,0], + location: [0], children: [ NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,2-1,3]), @@ -41,7 +41,7 @@ NonTermNode { }, NonTermNode { prod: S: Tb, - location: [1,0], + location: [0], children: [ TermNode { token: Tb("\"b\"" [1,3-1,4]), diff --git a/tests/src/glr/special/reduce_enough_empty/mod.rs b/tests/src/glr/special/reduce_enough_empty/mod.rs index 7532b5dd..c0923607 100644 --- a/tests/src/glr/special/reduce_enough_empty/mod.rs +++ b/tests/src/glr/special/reduce_enough_empty/mod.rs @@ -1,4 +1,4 @@ -use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; +use rustemo::{rustemo_mod, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/reduce_enough_empty"); @@ -16,14 +16,10 @@ fn glr_special_reduce_enough_empty() { "src/glr/special/reduce_enough_empty/tree.ast", format!( "{:#?}", - tree.unwrap().build::, GssHead<'_, str, lang::State, lang::TokenKind>, lang::State>( - &mut builder - ) + tree.unwrap() + .build::, lang::State>( + &mut builder + ) ) ); } diff --git a/tests/src/glr/special/reduce_enough_empty/tree.ast b/tests/src/glr/special/reduce_enough_empty/tree.ast index 1839d709..d65c49f0 100644 --- a/tests/src/glr/special/reduce_enough_empty/tree.ast +++ b/tests/src/glr/special/reduce_enough_empty/tree.ast @@ -1,36 +1,36 @@ NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), 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 e15fb8ff..a3a879a9 100644 --- a/tests/src/glr/special/reduce_enough_many_empty/mod.rs +++ b/tests/src/glr/special/reduce_enough_many_empty/mod.rs @@ -1,4 +1,4 @@ -use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; +use rustemo::{rustemo_mod, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/reduce_enough_many_empty"); @@ -16,14 +16,10 @@ fn glr_special_reduce_enough_many_empty() { "src/glr/special/reduce_enough_many_empty/tree.ast", format!( "{:#?}", - tree.unwrap().build::, GssHead<'_, str, lang::State, lang::TokenKind>, lang::State>( - &mut builder - ) + tree.unwrap() + .build::, lang::State>( + &mut builder + ) ) ); } diff --git a/tests/src/glr/special/reduce_enough_many_empty/tree.ast b/tests/src/glr/special/reduce_enough_many_empty/tree.ast index 28df41bd..5490ca37 100644 --- a/tests/src/glr/special/reduce_enough_many_empty/tree.ast +++ b/tests/src/glr/special/reduce_enough_many_empty/tree.ast @@ -1,54 +1,54 @@ NonTermNode { prod: S: A B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: B: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: B: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: A B S Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: B: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: S: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), diff --git a/tests/src/glr/special/right_nullable/mod.rs b/tests/src/glr/special/right_nullable/mod.rs index 0f790520..f11af80f 100644 --- a/tests/src/glr/special/right_nullable/mod.rs +++ b/tests/src/glr/special/right_nullable/mod.rs @@ -1,4 +1,4 @@ -use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; +use rustemo::{rustemo_mod, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/right_nullable"); @@ -16,14 +16,10 @@ fn glr_special_right_nullable_g2() { &format!("src/glr/special/right_nullable/tree_{}.ast", i), format!( "{:#?}", - tree.unwrap().build::, GssHead<'_, str, lang::State, lang::TokenKind>, lang::State>( - &mut builder - ) + tree.unwrap() + .build::, lang::State>( + &mut builder + ) ) ); }) diff --git a/tests/src/glr/special/right_nullable/tree_1.ast b/tests/src/glr/special/right_nullable/tree_1.ast index 08af5e28..140a6ba9 100644 --- a/tests/src/glr/special/right_nullable/tree_1.ast +++ b/tests/src/glr/special/right_nullable/tree_1.ast @@ -1,6 +1,6 @@ NonTermNode { prod: S: Ta S A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Ta("\"a\"" [1,0-1,1]), @@ -8,7 +8,7 @@ NonTermNode { }, NonTermNode { prod: S: Ta S A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Ta("\"a\"" [1,1-1,2]), @@ -16,11 +16,11 @@ NonTermNode { }, NonTermNode { prod: S: A, - location: [1,0], + location: [0-0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, @@ -29,7 +29,7 @@ NonTermNode { }, NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, @@ -38,7 +38,7 @@ NonTermNode { }, NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, diff --git a/tests/src/glr/special/right_nullable/tree_2.ast b/tests/src/glr/special/right_nullable/tree_2.ast index 0d35d21a..d183e291 100644 --- a/tests/src/glr/special/right_nullable/tree_2.ast +++ b/tests/src/glr/special/right_nullable/tree_2.ast @@ -1,6 +1,6 @@ NonTermNode { prod: S: Ta S A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Ta("\"a\"" [1,0-1,1]), @@ -8,7 +8,7 @@ NonTermNode { }, NonTermNode { prod: S: Ta S A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Ta("\"a\"" [1,1-1,2]), @@ -16,13 +16,13 @@ NonTermNode { }, NonTermNode { prod: S: , - location: [1,0], + location: [0-0], children: [], layout: None, }, NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, @@ -31,7 +31,7 @@ NonTermNode { }, NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, diff --git a/tests/src/glr/special/unbounded_ambiguity/mod.rs b/tests/src/glr/special/unbounded_ambiguity/mod.rs index da3f9aab..8cc66686 100644 --- a/tests/src/glr/special/unbounded_ambiguity/mod.rs +++ b/tests/src/glr/special/unbounded_ambiguity/mod.rs @@ -1,4 +1,4 @@ -use rustemo::{rustemo_mod, GssHead, Parser, TreeBuilder}; +use rustemo::{rustemo_mod, Parser, TreeBuilder}; use rustemo_compiler::output_cmp; rustemo_mod!(lang, "/src/glr/special/unbounded_ambiguity"); @@ -17,14 +17,10 @@ fn glr_special_unbounded_ambiguity() { &format!("src/glr/special/unbounded_ambiguity/tree_{}.ast", i), format!( "{:#?}", - tree.unwrap().build::, GssHead<'_, str, lang::State, lang::TokenKind>, lang::State>( - &mut builder - ) + tree.unwrap() + .build::, lang::State>( + &mut builder + ) ) ); }); diff --git a/tests/src/glr/special/unbounded_ambiguity/tree_1.ast b/tests/src/glr/special/unbounded_ambiguity/tree_1.ast index a42ce947..6136c000 100644 --- a/tests/src/glr/special/unbounded_ambiguity/tree_1.ast +++ b/tests/src/glr/special/unbounded_ambiguity/tree_1.ast @@ -1,50 +1,50 @@ NonTermNode { prod: S: M N, - location: [1,0], + location: [0], children: [ NonTermNode { prod: M: A M Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: M: A M Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: M: A M Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: M: A M Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: M: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), @@ -83,7 +83,7 @@ NonTermNode { }, NonTermNode { prod: N: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,5-1,6]), diff --git a/tests/src/glr/special/unbounded_ambiguity/tree_2.ast b/tests/src/glr/special/unbounded_ambiguity/tree_2.ast index 3e2517da..07cda791 100644 --- a/tests/src/glr/special/unbounded_ambiguity/tree_2.ast +++ b/tests/src/glr/special/unbounded_ambiguity/tree_2.ast @@ -1,40 +1,40 @@ NonTermNode { prod: S: M N, - location: [1,0], + location: [0-0], children: [ NonTermNode { prod: M: A M Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: M: A M Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: M: A M Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: M: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), @@ -66,7 +66,7 @@ NonTermNode { }, NonTermNode { prod: N: Tb N A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Tb("\"b\"" [1,4-1,5]), @@ -74,7 +74,7 @@ NonTermNode { }, NonTermNode { prod: N: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,5-1,6]), @@ -85,7 +85,7 @@ NonTermNode { }, NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, diff --git a/tests/src/glr/special/unbounded_ambiguity/tree_3.ast b/tests/src/glr/special/unbounded_ambiguity/tree_3.ast index d8f6223b..750e12c0 100644 --- a/tests/src/glr/special/unbounded_ambiguity/tree_3.ast +++ b/tests/src/glr/special/unbounded_ambiguity/tree_3.ast @@ -1,30 +1,30 @@ NonTermNode { prod: S: M N, - location: [1,0], + location: [0-0], children: [ NonTermNode { prod: M: A M Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: M: A M Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: M: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), @@ -49,7 +49,7 @@ NonTermNode { }, NonTermNode { prod: N: Tb N A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Tb("\"b\"" [1,3-1,4]), @@ -57,7 +57,7 @@ NonTermNode { }, NonTermNode { prod: N: Tb N A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Tb("\"b\"" [1,4-1,5]), @@ -65,7 +65,7 @@ NonTermNode { }, NonTermNode { prod: N: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,5-1,6]), @@ -76,7 +76,7 @@ NonTermNode { }, NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, @@ -85,7 +85,7 @@ NonTermNode { }, NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, diff --git a/tests/src/glr/special/unbounded_ambiguity/tree_4.ast b/tests/src/glr/special/unbounded_ambiguity/tree_4.ast index d6fb465f..5f9c62fe 100644 --- a/tests/src/glr/special/unbounded_ambiguity/tree_4.ast +++ b/tests/src/glr/special/unbounded_ambiguity/tree_4.ast @@ -1,20 +1,20 @@ NonTermNode { prod: S: M N, - location: [1,0], + location: [0-0], children: [ NonTermNode { prod: M: A M Tb, - location: [1,0], + location: [0], children: [ NonTermNode { prod: A: , - location: [1,0], + location: [1,0-1,0], children: [], layout: None, }, NonTermNode { prod: M: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), @@ -32,7 +32,7 @@ NonTermNode { }, NonTermNode { prod: N: Tb N A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Tb("\"b\"" [1,2-1,3]), @@ -40,7 +40,7 @@ NonTermNode { }, NonTermNode { prod: N: Tb N A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Tb("\"b\"" [1,3-1,4]), @@ -48,7 +48,7 @@ NonTermNode { }, NonTermNode { prod: N: Tb N A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Tb("\"b\"" [1,4-1,5]), @@ -56,7 +56,7 @@ NonTermNode { }, NonTermNode { prod: N: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,5-1,6]), @@ -67,7 +67,7 @@ NonTermNode { }, NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, @@ -76,7 +76,7 @@ NonTermNode { }, NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, @@ -85,7 +85,7 @@ NonTermNode { }, NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, diff --git a/tests/src/glr/special/unbounded_ambiguity/tree_5.ast b/tests/src/glr/special/unbounded_ambiguity/tree_5.ast index 80d9045f..3840ecdc 100644 --- a/tests/src/glr/special/unbounded_ambiguity/tree_5.ast +++ b/tests/src/glr/special/unbounded_ambiguity/tree_5.ast @@ -1,10 +1,10 @@ NonTermNode { prod: S: M N, - location: [1,0], + location: [0-0], children: [ NonTermNode { prod: M: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,0-1,1]), @@ -15,7 +15,7 @@ NonTermNode { }, NonTermNode { prod: N: Tb N A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Tb("\"b\"" [1,1-1,2]), @@ -23,7 +23,7 @@ NonTermNode { }, NonTermNode { prod: N: Tb N A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Tb("\"b\"" [1,2-1,3]), @@ -31,7 +31,7 @@ NonTermNode { }, NonTermNode { prod: N: Tb N A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Tb("\"b\"" [1,3-1,4]), @@ -39,7 +39,7 @@ NonTermNode { }, NonTermNode { prod: N: Tb N A, - location: [1,0], + location: [0-0], children: [ TermNode { token: Tb("\"b\"" [1,4-1,5]), @@ -47,7 +47,7 @@ NonTermNode { }, NonTermNode { prod: N: Tx, - location: [1,0], + location: [0], children: [ TermNode { token: Tx("\"x\"" [1,5-1,6]), @@ -58,7 +58,7 @@ NonTermNode { }, NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, @@ -67,7 +67,7 @@ NonTermNode { }, NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, }, @@ -76,7 +76,7 @@ NonTermNode { }, NonTermNode { prod: A: , - location: [1,0], + location: [0-0], children: [], layout: None, },