Add test and fix bug
This commit is contained in:
parent
4e1c6bd5b7
commit
daa711e81e
@ -51,9 +51,9 @@ pub(crate) fn loop_statement_for(s: Span) -> IResult<Span, LoopStatement> {
|
|||||||
let (s, a) = keyword("for")(s)?;
|
let (s, a) = keyword("for")(s)?;
|
||||||
let (s, b) = paren(tuple((
|
let (s, b) = paren(tuple((
|
||||||
opt(for_initialization),
|
opt(for_initialization),
|
||||||
symbol(":"),
|
symbol(";"),
|
||||||
opt(expression),
|
opt(expression),
|
||||||
symbol(":"),
|
symbol(";"),
|
||||||
opt(for_step),
|
opt(for_step),
|
||||||
)))(s)?;
|
)))(s)?;
|
||||||
let (s, c) = statement_or_null(s)?;
|
let (s, c) = statement_or_null(s)?;
|
||||||
|
@ -121,10 +121,10 @@ pub(crate) fn event_control_sequence_identifier(s: Span) -> IResult<Span, EventC
|
|||||||
#[tracable_parser]
|
#[tracable_parser]
|
||||||
pub(crate) fn event_expression(s: Span) -> IResult<Span, EventExpression> {
|
pub(crate) fn event_expression(s: Span) -> IResult<Span, EventExpression> {
|
||||||
alt((
|
alt((
|
||||||
event_expression_expression,
|
|
||||||
event_expression_sequence,
|
|
||||||
event_expression_or,
|
event_expression_or,
|
||||||
event_expression_comma,
|
event_expression_comma,
|
||||||
|
event_expression_expression,
|
||||||
|
event_expression_sequence,
|
||||||
event_expression_paren,
|
event_expression_paren,
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,10 @@ pub(crate) fn data_type(s: Span) -> IResult<Span, DataType> {
|
|||||||
map(keyword("string"), |x| DataType::String(Box::new(x))),
|
map(keyword("string"), |x| DataType::String(Box::new(x))),
|
||||||
map(keyword("chandle"), |x| DataType::Chandle(Box::new(x))),
|
map(keyword("chandle"), |x| DataType::Chandle(Box::new(x))),
|
||||||
data_type_virtual,
|
data_type_virtual,
|
||||||
|
map(terminated(class_type, peek(not(packed_dimension))), |x| {
|
||||||
|
DataType::ClassType(Box::new(x))
|
||||||
|
}),
|
||||||
data_type_type,
|
data_type_type,
|
||||||
map(class_type, |x| DataType::ClassType(Box::new(x))),
|
|
||||||
map(keyword("event"), |x| DataType::Chandle(Box::new(x))),
|
map(keyword("event"), |x| DataType::Chandle(Box::new(x))),
|
||||||
map(ps_covergroup_identifier, |x| {
|
map(ps_covergroup_identifier, |x| {
|
||||||
DataType::PsCovergroupIdentifier(Box::new(x))
|
DataType::PsCovergroupIdentifier(Box::new(x))
|
||||||
|
@ -151,6 +151,7 @@ pub(crate) fn primary(s: Span) -> IResult<Span, Primary> {
|
|||||||
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))),
|
||||||
terminated(primary_hierarchical, peek(none_of("("))),
|
terminated(primary_hierarchical, peek(none_of("("))),
|
||||||
map(empty_unpacked_array_concatenation, |x| {
|
map(empty_unpacked_array_concatenation, |x| {
|
||||||
Primary::EmptyUnpackedArrayConcatenation(Box::new(x))
|
Primary::EmptyUnpackedArrayConcatenation(Box::new(x))
|
||||||
@ -162,7 +163,6 @@ pub(crate) fn primary(s: Span) -> IResult<Span, Primary> {
|
|||||||
}),
|
}),
|
||||||
map(let_expression, |x| Primary::LetExpression(Box::new(x))),
|
map(let_expression, |x| Primary::LetExpression(Box::new(x))),
|
||||||
primary_mintypmax_expression,
|
primary_mintypmax_expression,
|
||||||
map(cast, |x| Primary::Cast(Box::new(x))),
|
|
||||||
map(streaming_concatenation, |x| {
|
map(streaming_concatenation, |x| {
|
||||||
Primary::StreamingConcatenation(Box::new(x))
|
Primary::StreamingConcatenation(Box::new(x))
|
||||||
}),
|
}),
|
||||||
@ -319,7 +319,10 @@ pub(crate) fn bit_select(s: Span) -> IResult<Span, BitSelect> {
|
|||||||
#[tracable_parser]
|
#[tracable_parser]
|
||||||
pub(crate) fn select(s: Span) -> IResult<Span, Select> {
|
pub(crate) fn select(s: Span) -> IResult<Span, Select> {
|
||||||
let (s, a) = opt(triple(
|
let (s, a) = opt(triple(
|
||||||
many0(triple(symbol("."), member_identifier, bit_select)),
|
many0(terminated(
|
||||||
|
triple(symbol("."), member_identifier, bit_select),
|
||||||
|
peek(symbol(".")),
|
||||||
|
)),
|
||||||
symbol("."),
|
symbol("."),
|
||||||
member_identifier,
|
member_identifier,
|
||||||
))(s)?;
|
))(s)?;
|
||||||
@ -348,7 +351,10 @@ pub(crate) fn constant_bit_select(s: Span) -> IResult<Span, ConstantBitSelect> {
|
|||||||
#[tracable_parser]
|
#[tracable_parser]
|
||||||
pub(crate) fn constant_select(s: Span) -> IResult<Span, ConstantSelect> {
|
pub(crate) fn constant_select(s: Span) -> IResult<Span, ConstantSelect> {
|
||||||
let (s, a) = opt(triple(
|
let (s, a) = opt(triple(
|
||||||
many0(triple(symbol("."), member_identifier, constant_bit_select)),
|
many0(terminated(
|
||||||
|
triple(symbol("."), member_identifier, constant_bit_select),
|
||||||
|
peek(symbol(".")),
|
||||||
|
)),
|
||||||
symbol("."),
|
symbol("."),
|
||||||
member_identifier,
|
member_identifier,
|
||||||
))(s)?;
|
))(s)?;
|
||||||
|
@ -47,9 +47,19 @@ pub(crate) fn include_statement(s: Span) -> IResult<Span, IncludeStatement> {
|
|||||||
Ok((s, IncludeStatement { nodes: (a, b, c) }))
|
Ok((s, IncludeStatement { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO support non literal path
|
|
||||||
#[tracable_parser]
|
#[tracable_parser]
|
||||||
pub(crate) fn file_path_spec(s: Span) -> IResult<Span, FilePathSpec> {
|
pub(crate) fn file_path_spec(s: Span) -> IResult<Span, FilePathSpec> {
|
||||||
let (s, a) = string_literal(s)?;
|
alt((
|
||||||
Ok((s, FilePathSpec { nodes: (a,) }))
|
map(string_literal, |x| FilePathSpec::Literal(x)),
|
||||||
|
file_path_spec_non_literal,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tracable_parser]
|
||||||
|
pub(crate) fn file_path_spec_non_literal(s: Span) -> IResult<Span, FilePathSpec> {
|
||||||
|
let (s, a) = ws(map(is_not(",; "), |x| into_locate(x)))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
FilePathSpec::NonLiteral(FilePathSpecNonLiteral { nodes: a }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -472,9 +472,12 @@ where
|
|||||||
let mut ret = Vec::new();
|
let mut ret = Vec::new();
|
||||||
loop {
|
loop {
|
||||||
if let Ok((t, b)) = f(s) {
|
if let Ok((t, b)) = f(s) {
|
||||||
let (u, c) = g(t)?;
|
if let Ok((u, c)) = g(t) {
|
||||||
s = u;
|
s = u;
|
||||||
ret.push((b, c));
|
ret.push((b, c));
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,12 @@ pub struct IncludeStatement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
#[derive(Clone, Debug, Node)]
|
||||||
pub struct FilePathSpec {
|
pub enum FilePathSpec {
|
||||||
pub nodes: (StringLiteral,),
|
Literal(StringLiteral),
|
||||||
|
NonLiteral(FilePathSpecNonLiteral),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct FilePathSpecNonLiteral {
|
||||||
|
pub nodes: (Locate, Vec<WhiteSpace>),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user