Improve performance
This commit is contained in:
parent
92df1aa6db
commit
c9456ee993
@ -11,9 +11,10 @@ trace = ["nom-tracable/trace"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
nom = "5.0.0"
|
nom = "5.0.0"
|
||||||
nom_locate = "1.0.0"
|
nom_locate = "1.0.0"
|
||||||
nom-packrat = "0.2.0"
|
#nom-packrat = "0.2.0"
|
||||||
|
nom-packrat = {path = "../../nom-packrat/nom-packrat"}
|
||||||
nom-recursive = {version = "0.1.1", features = ["tracer128"]}
|
nom-recursive = {version = "0.1.1", features = ["tracer128"]}
|
||||||
nom-tracable = "0.3.1"
|
nom-tracable = "0.4.0"
|
||||||
str-concat = "0.1.4"
|
str-concat = "0.1.4"
|
||||||
sv-parser-macros = {path = "../sv-parser-macros"}
|
sv-parser-macros = {path = "../sv-parser-macros"}
|
||||||
sv-parser-syntaxtree = {path = "../sv-parser-syntaxtree"}
|
sv-parser-syntaxtree = {path = "../sv-parser-syntaxtree"}
|
||||||
|
@ -218,6 +218,9 @@ pub(crate) fn constant_indexed_range(s: Span) -> IResult<Span, ConstantIndexedRa
|
|||||||
#[packrat_parser]
|
#[packrat_parser]
|
||||||
pub(crate) fn expression(s: Span) -> IResult<Span, Expression> {
|
pub(crate) fn expression(s: Span) -> IResult<Span, Expression> {
|
||||||
alt((
|
alt((
|
||||||
|
map(terminated(primary, peek(one_of(",();"))), |x| {
|
||||||
|
Expression::Primary(Box::new(x))
|
||||||
|
}),
|
||||||
expression_binary,
|
expression_binary,
|
||||||
map(conditional_expression, |x| {
|
map(conditional_expression, |x| {
|
||||||
Expression::ConditionalExpression(Box::new(x))
|
Expression::ConditionalExpression(Box::new(x))
|
||||||
|
@ -153,18 +153,18 @@ pub(crate) fn module_path_primary_mintypmax_expression(
|
|||||||
#[packrat_parser]
|
#[packrat_parser]
|
||||||
pub(crate) fn primary(s: Span) -> IResult<Span, Primary> {
|
pub(crate) fn primary(s: Span) -> IResult<Span, Primary> {
|
||||||
alt((
|
alt((
|
||||||
|
terminated(
|
||||||
|
primary_hierarchical,
|
||||||
|
peek(not(alt((
|
||||||
|
map(one_of("(.'"), |_| ()),
|
||||||
|
map(keyword("with"), |_| ()),
|
||||||
|
)))),
|
||||||
|
),
|
||||||
map(assignment_pattern_expression, |x| {
|
map(assignment_pattern_expression, |x| {
|
||||||
Primary::AssignmentPatternExpression(Box::new(x))
|
Primary::AssignmentPatternExpression(Box::new(x))
|
||||||
}),
|
}),
|
||||||
map(primary_literal, |x| Primary::PrimaryLiteral(Box::new(x))),
|
map(primary_literal, |x| Primary::PrimaryLiteral(Box::new(x))),
|
||||||
map(cast, |x| Primary::Cast(Box::new(x))),
|
map(cast, |x| Primary::Cast(Box::new(x))),
|
||||||
terminated(
|
|
||||||
primary_hierarchical,
|
|
||||||
peek(not(alt((
|
|
||||||
map(one_of("(."), |_| ()),
|
|
||||||
map(keyword("with"), |_| ()),
|
|
||||||
)))),
|
|
||||||
),
|
|
||||||
map(empty_unpacked_array_concatenation, |x| {
|
map(empty_unpacked_array_concatenation, |x| {
|
||||||
Primary::EmptyUnpackedArrayConcatenation(Box::new(x))
|
Primary::EmptyUnpackedArrayConcatenation(Box::new(x))
|
||||||
}),
|
}),
|
||||||
|
@ -82,7 +82,7 @@ impl HasExtraState<()> for SpanInfo {
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
nom_packrat::storage!(AnyNode);
|
nom_packrat::storage!(AnyNode, 1024);
|
||||||
|
|
||||||
pub fn sv_parser(s: Span) -> IResult<Span, SourceText> {
|
pub fn sv_parser(s: Span) -> IResult<Span, SourceText> {
|
||||||
source_text(s)
|
source_text(s)
|
||||||
|
@ -138,10 +138,10 @@ pub(crate) fn module_item(s: Span) -> IResult<Span, ModuleItem> {
|
|||||||
pub(crate) fn module_or_generate_item(s: Span) -> IResult<Span, ModuleOrGenerateItem> {
|
pub(crate) fn module_or_generate_item(s: Span) -> IResult<Span, ModuleOrGenerateItem> {
|
||||||
alt((
|
alt((
|
||||||
module_or_generate_item_parameter,
|
module_or_generate_item_parameter,
|
||||||
module_or_generate_item_gate,
|
|
||||||
module_or_generate_item_udp,
|
|
||||||
module_or_generate_item_module,
|
module_or_generate_item_module,
|
||||||
module_or_generate_item_module_item,
|
module_or_generate_item_module_item,
|
||||||
|
module_or_generate_item_gate,
|
||||||
|
module_or_generate_item_udp,
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15704,10 +15704,5 @@ mod spec {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn debug() {
|
fn debug() {
|
||||||
test!(
|
nom_tracable::cumulative_histogram();
|
||||||
source_text,
|
|
||||||
r##"//aaa
|
|
||||||
//bbb"##,
|
|
||||||
Ok((_, _))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -260,8 +260,10 @@ pub(crate) fn white_space(s: Span) -> IResult<Span, WhiteSpace> {
|
|||||||
map(multispace1, |x: Span| {
|
map(multispace1, |x: Span| {
|
||||||
WhiteSpace::Space(Box::new(into_locate(x)))
|
WhiteSpace::Space(Box::new(into_locate(x)))
|
||||||
}),
|
}),
|
||||||
map(comment, |x| WhiteSpace::Comment(Box::new(x))),
|
map(preceded(peek(char('/')), comment), |x| {
|
||||||
map(compiler_directive, |x| {
|
WhiteSpace::Comment(Box::new(x))
|
||||||
|
}),
|
||||||
|
map(preceded(peek(char('`')), compiler_directive), |x| {
|
||||||
WhiteSpace::CompilerDirective(Box::new(x))
|
WhiteSpace::CompilerDirective(Box::new(x))
|
||||||
}),
|
}),
|
||||||
))(s)
|
))(s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user