style: format imports
This commit is contained in:
parent
a48054f1ae
commit
b35efa8f33
69 changed files with 481 additions and 316 deletions
|
|
@ -1,14 +1,18 @@
|
|||
use super::coincident_tokens::CoincidentTokenIndex;
|
||||
use super::token_conflicts::TokenConflictMap;
|
||||
use crate::generate::dedup::split_state_id_groups;
|
||||
use crate::generate::grammars::{LexicalGrammar, SyntaxGrammar};
|
||||
use crate::generate::nfa::NfaCursor;
|
||||
use crate::generate::rules::{Symbol, TokenSet};
|
||||
use crate::generate::tables::{AdvanceAction, LexState, LexTable, ParseStateId, ParseTable};
|
||||
use std::{
|
||||
collections::{hash_map::Entry, HashMap, VecDeque},
|
||||
mem,
|
||||
};
|
||||
|
||||
use log::info;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::mem;
|
||||
|
||||
use super::{coincident_tokens::CoincidentTokenIndex, token_conflicts::TokenConflictMap};
|
||||
use crate::generate::{
|
||||
dedup::split_state_id_groups,
|
||||
grammars::{LexicalGrammar, SyntaxGrammar},
|
||||
nfa::NfaCursor,
|
||||
rules::{Symbol, TokenSet},
|
||||
tables::{AdvanceAction, LexState, LexTable, ParseStateId, ParseTable},
|
||||
};
|
||||
|
||||
pub fn build_lex_table(
|
||||
parse_table: &mut ParseTable,
|
||||
|
|
|
|||
|
|
@ -1,25 +1,30 @@
|
|||
use super::item::{ParseItem, ParseItemSet, ParseItemSetCore};
|
||||
use super::item_set_builder::ParseItemSetBuilder;
|
||||
use crate::generate::grammars::PrecedenceEntry;
|
||||
use crate::generate::grammars::{
|
||||
InlinedProductionMap, LexicalGrammar, SyntaxGrammar, VariableType,
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
collections::{BTreeMap, HashMap, HashSet, VecDeque},
|
||||
fmt::Write,
|
||||
hash::BuildHasherDefault,
|
||||
};
|
||||
use crate::generate::node_types::VariableInfo;
|
||||
use crate::generate::rules::{Associativity, Precedence, Symbol, SymbolType, TokenSet};
|
||||
use crate::generate::tables::{
|
||||
FieldLocation, GotoAction, ParseAction, ParseState, ParseStateId, ParseTable, ParseTableEntry,
|
||||
ProductionInfo, ProductionInfoId,
|
||||
};
|
||||
use anyhow::{anyhow, Result};
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
|
||||
use std::fmt::Write;
|
||||
use std::hash::BuildHasherDefault;
|
||||
use std::u32;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use indexmap::{map::Entry, IndexMap};
|
||||
use rustc_hash::FxHasher;
|
||||
|
||||
use super::{
|
||||
item::{ParseItem, ParseItemSet, ParseItemSetCore},
|
||||
item_set_builder::ParseItemSetBuilder,
|
||||
};
|
||||
use crate::generate::{
|
||||
grammars::{
|
||||
InlinedProductionMap, LexicalGrammar, PrecedenceEntry, SyntaxGrammar, VariableType,
|
||||
},
|
||||
node_types::VariableInfo,
|
||||
rules::{Associativity, Precedence, Symbol, SymbolType, TokenSet},
|
||||
tables::{
|
||||
FieldLocation, GotoAction, ParseAction, ParseState, ParseStateId, ParseTable,
|
||||
ParseTableEntry, ProductionInfo, ProductionInfoId,
|
||||
},
|
||||
};
|
||||
|
||||
// For conflict reporting, each parse state is associated with an example
|
||||
// sequence of symbols that could lead to that parse state.
|
||||
type SymbolSequence = Vec<Symbol>;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
use crate::generate::grammars::LexicalGrammar;
|
||||
use crate::generate::rules::Symbol;
|
||||
use crate::generate::tables::{ParseStateId, ParseTable};
|
||||
use std::fmt;
|
||||
|
||||
use crate::generate::{
|
||||
grammars::LexicalGrammar,
|
||||
rules::Symbol,
|
||||
tables::{ParseStateId, ParseTable},
|
||||
};
|
||||
|
||||
pub struct CoincidentTokenIndex<'a> {
|
||||
entries: Vec<Vec<ParseStateId>>,
|
||||
grammar: &'a LexicalGrammar,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
use crate::generate::grammars::{LexicalGrammar, Production, ProductionStep, SyntaxGrammar};
|
||||
use crate::generate::rules::{Associativity, Precedence, Symbol, SymbolType, TokenSet};
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
};
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::u32;
|
||||
|
||||
use crate::generate::{
|
||||
grammars::{LexicalGrammar, Production, ProductionStep, SyntaxGrammar},
|
||||
rules::{Associativity, Precedence, Symbol, SymbolType, TokenSet},
|
||||
};
|
||||
|
||||
lazy_static! {
|
||||
static ref START_PRODUCTION: Production = Production {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
fmt,
|
||||
};
|
||||
|
||||
use super::item::{ParseItem, ParseItemDisplay, ParseItemSet, TokenSetDisplay};
|
||||
use crate::generate::grammars::{InlinedProductionMap, LexicalGrammar, SyntaxGrammar};
|
||||
use crate::generate::rules::{Symbol, SymbolType, TokenSet};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::fmt;
|
||||
use crate::generate::{
|
||||
grammars::{InlinedProductionMap, LexicalGrammar, SyntaxGrammar},
|
||||
rules::{Symbol, SymbolType, TokenSet},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
struct TransitiveClosureAddition<'a> {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
use super::token_conflicts::TokenConflictMap;
|
||||
use crate::generate::dedup::split_state_id_groups;
|
||||
use crate::generate::grammars::{LexicalGrammar, SyntaxGrammar, VariableType};
|
||||
use crate::generate::rules::{AliasMap, Symbol, TokenSet};
|
||||
use crate::generate::tables::{
|
||||
GotoAction, ParseAction, ParseState, ParseStateId, ParseTable, ParseTableEntry,
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
mem,
|
||||
};
|
||||
|
||||
use log::info;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::mem;
|
||||
|
||||
use super::token_conflicts::TokenConflictMap;
|
||||
use crate::generate::{
|
||||
dedup::split_state_id_groups,
|
||||
grammars::{LexicalGrammar, SyntaxGrammar, VariableType},
|
||||
rules::{AliasMap, Symbol, TokenSet},
|
||||
tables::{GotoAction, ParseAction, ParseState, ParseStateId, ParseTable, ParseTableEntry},
|
||||
};
|
||||
|
||||
pub fn minimize_parse_table(
|
||||
parse_table: &mut ParseTable,
|
||||
|
|
|
|||
|
|
@ -6,19 +6,25 @@ mod item_set_builder;
|
|||
mod minimize_parse_table;
|
||||
mod token_conflicts;
|
||||
|
||||
use self::build_lex_table::build_lex_table;
|
||||
use self::build_parse_table::{build_parse_table, ParseStateInfo};
|
||||
use self::coincident_tokens::CoincidentTokenIndex;
|
||||
use self::minimize_parse_table::minimize_parse_table;
|
||||
use self::token_conflicts::TokenConflictMap;
|
||||
use crate::generate::grammars::{InlinedProductionMap, LexicalGrammar, SyntaxGrammar};
|
||||
use crate::generate::nfa::NfaCursor;
|
||||
use crate::generate::node_types::VariableInfo;
|
||||
use crate::generate::rules::{AliasMap, Symbol, SymbolType, TokenSet};
|
||||
use crate::generate::tables::{LexTable, ParseAction, ParseTable, ParseTableEntry};
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
|
||||
use anyhow::Result;
|
||||
use log::info;
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
|
||||
use self::{
|
||||
build_lex_table::build_lex_table,
|
||||
build_parse_table::{build_parse_table, ParseStateInfo},
|
||||
coincident_tokens::CoincidentTokenIndex,
|
||||
minimize_parse_table::minimize_parse_table,
|
||||
token_conflicts::TokenConflictMap,
|
||||
};
|
||||
use crate::generate::{
|
||||
grammars::{InlinedProductionMap, LexicalGrammar, SyntaxGrammar},
|
||||
nfa::NfaCursor,
|
||||
node_types::VariableInfo,
|
||||
rules::{AliasMap, Symbol, SymbolType, TokenSet},
|
||||
tables::{LexTable, ParseAction, ParseTable, ParseTableEntry},
|
||||
};
|
||||
|
||||
pub fn build_tables(
|
||||
syntax_grammar: &SyntaxGrammar,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
use crate::generate::build_tables::item::TokenSetDisplay;
|
||||
use crate::generate::grammars::{LexicalGrammar, SyntaxGrammar};
|
||||
use crate::generate::nfa::{CharacterSet, NfaCursor, NfaTransition};
|
||||
use crate::generate::rules::TokenSet;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashSet;
|
||||
use std::fmt;
|
||||
use std::{cmp::Ordering, collections::HashSet, fmt};
|
||||
|
||||
use crate::generate::{
|
||||
build_tables::item::TokenSetDisplay,
|
||||
grammars::{LexicalGrammar, SyntaxGrammar},
|
||||
nfa::{CharacterSet, NfaCursor, NfaTransition},
|
||||
rules::TokenSet,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
struct TokenConflictStatus {
|
||||
|
|
@ -372,9 +373,11 @@ fn compute_conflict_status(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::generate::grammars::{Variable, VariableType};
|
||||
use crate::generate::prepare_grammar::{expand_tokens, ExtractedLexicalGrammar};
|
||||
use crate::generate::rules::{Precedence, Rule, Symbol};
|
||||
use crate::generate::{
|
||||
grammars::{Variable, VariableType},
|
||||
prepare_grammar::{expand_tokens, ExtractedLexicalGrammar},
|
||||
rules::{Precedence, Rule, Symbol},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_starting_characters() {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
use super::write_file;
|
||||
use std::{
|
||||
fs,
|
||||
fs::File,
|
||||
io::BufReader,
|
||||
path::{Path, PathBuf},
|
||||
str,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use heck::{ToKebabCase, ToShoutySnakeCase, ToSnakeCase, ToUpperCamelCase};
|
||||
use indoc::indoc;
|
||||
use serde::Deserialize;
|
||||
use serde_json::{json, Map, Value};
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{fs, str};
|
||||
|
||||
use super::write_file;
|
||||
|
||||
const CLI_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
const CLI_VERSION_PLACEHOLDER: &str = "CLI_VERSION";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
use super::nfa::Nfa;
|
||||
use super::rules::{Alias, Associativity, Precedence, Rule, Symbol};
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::{collections::HashMap, fmt};
|
||||
|
||||
use super::{
|
||||
nfa::Nfa,
|
||||
rules::{Alias, Associativity, Precedence, Rule, Symbol},
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum VariableType {
|
||||
|
|
|
|||
|
|
@ -1,20 +1,21 @@
|
|||
use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Stdio};
|
||||
use std::{env, fs};
|
||||
use std::{
|
||||
env, fs,
|
||||
io::Write,
|
||||
path::{Path, PathBuf},
|
||||
process::{Command, Stdio},
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use lazy_static::lazy_static;
|
||||
use regex::{Regex, RegexBuilder};
|
||||
use semver::Version;
|
||||
|
||||
use build_tables::build_tables;
|
||||
use grammar_files::path_in_ignore;
|
||||
use grammars::{InlinedProductionMap, LexicalGrammar, SyntaxGrammar};
|
||||
use lazy_static::lazy_static;
|
||||
use parse_grammar::parse_grammar;
|
||||
use prepare_grammar::prepare_grammar;
|
||||
use regex::{Regex, RegexBuilder};
|
||||
use render::render_c_code;
|
||||
use rules::AliasMap;
|
||||
use semver::Version;
|
||||
|
||||
mod build_tables;
|
||||
mod char_tree;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
use std::char;
|
||||
use std::cmp::max;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashSet;
|
||||
use std::fmt;
|
||||
use std::mem::swap;
|
||||
use std::ops::Range;
|
||||
use std::{
|
||||
char,
|
||||
cmp::{max, Ordering},
|
||||
collections::HashSet,
|
||||
fmt,
|
||||
mem::swap,
|
||||
ops::Range,
|
||||
};
|
||||
|
||||
/// A set of characters represented as a vector of ranges.
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
use super::grammars::{LexicalGrammar, SyntaxGrammar, VariableType};
|
||||
use super::rules::{Alias, AliasMap, Symbol, SymbolType};
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
collections::{BTreeMap, HashMap, HashSet},
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use serde::Serialize;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
|
||||
use super::{
|
||||
grammars::{LexicalGrammar, SyntaxGrammar, VariableType},
|
||||
rules::{Alias, AliasMap, Symbol, SymbolType},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub enum ChildType {
|
||||
|
|
@ -715,11 +721,13 @@ where
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::generate::grammars::{
|
||||
InputGrammar, LexicalVariable, Production, ProductionStep, SyntaxVariable, Variable,
|
||||
use crate::generate::{
|
||||
grammars::{
|
||||
InputGrammar, LexicalVariable, Production, ProductionStep, SyntaxVariable, Variable,
|
||||
},
|
||||
prepare_grammar::prepare_grammar,
|
||||
rules::Rule,
|
||||
};
|
||||
use crate::generate::prepare_grammar::prepare_grammar;
|
||||
use crate::generate::rules::Rule;
|
||||
|
||||
#[test]
|
||||
fn test_node_types_simple() {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
use super::grammars::{InputGrammar, PrecedenceEntry, Variable, VariableType};
|
||||
use super::rules::{Precedence, Rule};
|
||||
use anyhow::{anyhow, Result};
|
||||
use serde::Deserialize;
|
||||
use serde_json::{Map, Value};
|
||||
|
||||
use super::{
|
||||
grammars::{InputGrammar, PrecedenceEntry, Variable, VariableType},
|
||||
rules::{Precedence, Rule},
|
||||
};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[allow(non_camel_case_types)]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
use std::{collections::HashMap, mem};
|
||||
|
||||
use super::ExtractedSyntaxGrammar;
|
||||
use crate::generate::grammars::{Variable, VariableType};
|
||||
use crate::generate::rules::{Rule, Symbol};
|
||||
use std::collections::HashMap;
|
||||
use std::mem;
|
||||
use crate::generate::{
|
||||
grammars::{Variable, VariableType},
|
||||
rules::{Rule, Symbol},
|
||||
};
|
||||
|
||||
struct Expander {
|
||||
variable_name: String,
|
||||
|
|
|
|||
|
|
@ -1,15 +1,18 @@
|
|||
use super::ExtractedLexicalGrammar;
|
||||
use crate::generate::grammars::{LexicalGrammar, LexicalVariable};
|
||||
use crate::generate::nfa::{CharacterSet, Nfa, NfaState};
|
||||
use crate::generate::rules::{Precedence, Rule};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use lazy_static::lazy_static;
|
||||
use regex_syntax::ast::{
|
||||
parse, Ast, ClassPerlKind, ClassSet, ClassSetBinaryOpKind, ClassSetItem, ClassUnicodeKind,
|
||||
RepetitionKind, RepetitionRange,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
use std::i32;
|
||||
|
||||
use super::ExtractedLexicalGrammar;
|
||||
use crate::generate::{
|
||||
grammars::{LexicalGrammar, LexicalVariable},
|
||||
nfa::{CharacterSet, Nfa, NfaState},
|
||||
rules::{Precedence, Rule},
|
||||
};
|
||||
|
||||
lazy_static! {
|
||||
static ref UNICODE_CATEGORIES: HashMap<&'static str, Vec<u32>> =
|
||||
|
|
@ -539,8 +542,10 @@ impl NfaBuilder {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::generate::grammars::Variable;
|
||||
use crate::generate::nfa::{NfaCursor, NfaTransition};
|
||||
use crate::generate::{
|
||||
grammars::Variable,
|
||||
nfa::{NfaCursor, NfaTransition},
|
||||
};
|
||||
|
||||
fn simulate_nfa<'a>(grammar: &'a LexicalGrammar, s: &'a str) -> Option<(usize, &'a str)> {
|
||||
let start_states = grammar.variables.iter().map(|v| v.start_state).collect();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use crate::generate::grammars::{LexicalGrammar, SyntaxGrammar};
|
||||
use crate::generate::rules::{Alias, AliasMap, Symbol, SymbolType};
|
||||
use crate::generate::{
|
||||
grammars::{LexicalGrammar, SyntaxGrammar},
|
||||
rules::{Alias, AliasMap, Symbol, SymbolType},
|
||||
};
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
struct SymbolStatus {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
use super::{ExtractedLexicalGrammar, ExtractedSyntaxGrammar, InternedGrammar};
|
||||
use crate::generate::grammars::{ExternalToken, Variable, VariableType};
|
||||
use crate::generate::rules::{MetadataParams, Rule, Symbol, SymbolType};
|
||||
use std::{collections::HashMap, mem};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use std::collections::HashMap;
|
||||
use std::mem;
|
||||
|
||||
use super::{ExtractedLexicalGrammar, ExtractedSyntaxGrammar, InternedGrammar};
|
||||
use crate::generate::{
|
||||
grammars::{ExternalToken, Variable, VariableType},
|
||||
rules::{MetadataParams, Rule, Symbol, SymbolType},
|
||||
};
|
||||
|
||||
pub(super) fn extract_tokens(
|
||||
mut grammar: InternedGrammar,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
use super::ExtractedSyntaxGrammar;
|
||||
use crate::generate::grammars::{
|
||||
Production, ProductionStep, SyntaxGrammar, SyntaxVariable, Variable,
|
||||
};
|
||||
use crate::generate::rules::{Alias, Associativity, Precedence, Rule, Symbol};
|
||||
use anyhow::{anyhow, Result};
|
||||
|
||||
use super::ExtractedSyntaxGrammar;
|
||||
use crate::generate::{
|
||||
grammars::{Production, ProductionStep, SyntaxGrammar, SyntaxVariable, Variable},
|
||||
rules::{Alias, Associativity, Precedence, Rule, Symbol},
|
||||
};
|
||||
|
||||
struct RuleFlattener {
|
||||
production: Production,
|
||||
precedence_stack: Vec<Precedence>,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
use super::InternedGrammar;
|
||||
use crate::generate::grammars::{InputGrammar, Variable, VariableType};
|
||||
use crate::generate::rules::{Rule, Symbol};
|
||||
use anyhow::{anyhow, Result};
|
||||
|
||||
use super::InternedGrammar;
|
||||
use crate::generate::{
|
||||
grammars::{InputGrammar, Variable, VariableType},
|
||||
rules::{Rule, Symbol},
|
||||
};
|
||||
|
||||
pub(super) fn intern_symbols(grammar: &InputGrammar) -> Result<InternedGrammar> {
|
||||
let interner = Interner { grammar };
|
||||
|
||||
|
|
|
|||
|
|
@ -6,26 +6,28 @@ mod flatten_grammar;
|
|||
mod intern_symbols;
|
||||
mod process_inlines;
|
||||
|
||||
pub use self::expand_tokens::expand_tokens;
|
||||
|
||||
use self::expand_repeats::expand_repeats;
|
||||
use self::extract_default_aliases::extract_default_aliases;
|
||||
use self::extract_tokens::extract_tokens;
|
||||
use self::flatten_grammar::flatten_grammar;
|
||||
use self::intern_symbols::intern_symbols;
|
||||
use self::process_inlines::process_inlines;
|
||||
use super::grammars::{
|
||||
ExternalToken, InlinedProductionMap, InputGrammar, LexicalGrammar, PrecedenceEntry,
|
||||
SyntaxGrammar, Variable,
|
||||
};
|
||||
use super::rules::{AliasMap, Precedence, Rule, Symbol};
|
||||
use anyhow::{anyhow, Result};
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
collections::{hash_map, HashMap, HashSet},
|
||||
mem,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
|
||||
pub use self::expand_tokens::expand_tokens;
|
||||
use self::{
|
||||
expand_repeats::expand_repeats, extract_default_aliases::extract_default_aliases,
|
||||
extract_tokens::extract_tokens, flatten_grammar::flatten_grammar,
|
||||
intern_symbols::intern_symbols, process_inlines::process_inlines,
|
||||
};
|
||||
use super::{
|
||||
grammars::{
|
||||
ExternalToken, InlinedProductionMap, InputGrammar, LexicalGrammar, PrecedenceEntry,
|
||||
SyntaxGrammar, Variable,
|
||||
},
|
||||
rules::{AliasMap, Precedence, Rule, Symbol},
|
||||
};
|
||||
|
||||
pub struct IntermediateGrammar<T, U> {
|
||||
variables: Vec<Variable>,
|
||||
extra_symbols: Vec<T>,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
|
||||
use crate::generate::{
|
||||
grammars::{InlinedProductionMap, LexicalGrammar, Production, ProductionStep, SyntaxGrammar},
|
||||
rules::SymbolType,
|
||||
};
|
||||
use anyhow::{anyhow, Result};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
struct ProductionStepId {
|
||||
|
|
@ -223,8 +225,10 @@ pub(super) fn process_inlines(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::generate::grammars::{LexicalVariable, SyntaxVariable, VariableType};
|
||||
use crate::generate::rules::{Associativity, Precedence, Symbol};
|
||||
use crate::generate::{
|
||||
grammars::{LexicalVariable, SyntaxVariable, VariableType},
|
||||
rules::{Associativity, Precedence, Symbol},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_basic_inlining() {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,11 @@
|
|||
use core::ops::Range;
|
||||
use std::{
|
||||
cmp,
|
||||
collections::{HashMap, HashSet},
|
||||
fmt::Write,
|
||||
mem::swap,
|
||||
};
|
||||
|
||||
use super::{
|
||||
char_tree::{CharacterTree, Comparator},
|
||||
grammars::{ExternalToken, LexicalGrammar, SyntaxGrammar, VariableType},
|
||||
|
|
@ -7,13 +15,6 @@ use super::{
|
|||
ParseTableEntry,
|
||||
},
|
||||
};
|
||||
use core::ops::Range;
|
||||
use std::{
|
||||
cmp,
|
||||
collections::{HashMap, HashSet},
|
||||
fmt::Write,
|
||||
mem::swap,
|
||||
};
|
||||
|
||||
const LARGE_CHARACTER_RANGE_COUNT: usize = 8;
|
||||
const SMALL_STATE_THRESHOLD: usize = 64;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
use super::grammars::VariableType;
|
||||
use smallbitvec::SmallBitVec;
|
||||
use std::{collections::HashMap, fmt};
|
||||
|
||||
use smallbitvec::SmallBitVec;
|
||||
|
||||
use super::grammars::VariableType;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub enum SymbolType {
|
||||
External,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
use super::nfa::CharacterSet;
|
||||
use super::rules::{Alias, Symbol, TokenSet};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use super::{
|
||||
nfa::CharacterSet,
|
||||
rules::{Alias, Symbol, TokenSet},
|
||||
};
|
||||
pub type ProductionInfoId = usize;
|
||||
pub type ParseStateId = usize;
|
||||
pub type LexStateId = usize;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue