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, b) = paren(tuple((
|
||||
opt(for_initialization),
|
||||
symbol(":"),
|
||||
symbol(";"),
|
||||
opt(expression),
|
||||
symbol(":"),
|
||||
symbol(";"),
|
||||
opt(for_step),
|
||||
)))(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]
|
||||
pub(crate) fn event_expression(s: Span) -> IResult<Span, EventExpression> {
|
||||
alt((
|
||||
event_expression_expression,
|
||||
event_expression_sequence,
|
||||
event_expression_or,
|
||||
event_expression_comma,
|
||||
event_expression_expression,
|
||||
event_expression_sequence,
|
||||
event_expression_paren,
|
||||
))(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("chandle"), |x| DataType::Chandle(Box::new(x))),
|
||||
data_type_virtual,
|
||||
map(terminated(class_type, peek(not(packed_dimension))), |x| {
|
||||
DataType::ClassType(Box::new(x))
|
||||
}),
|
||||
data_type_type,
|
||||
map(class_type, |x| DataType::ClassType(Box::new(x))),
|
||||
map(keyword("event"), |x| DataType::Chandle(Box::new(x))),
|
||||
map(ps_covergroup_identifier, |x| {
|
||||
DataType::PsCovergroupIdentifier(Box::new(x))
|
||||
|
@ -151,6 +151,7 @@ pub(crate) fn primary(s: Span) -> IResult<Span, Primary> {
|
||||
Primary::AssignmentPatternExpression(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("("))),
|
||||
map(empty_unpacked_array_concatenation, |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))),
|
||||
primary_mintypmax_expression,
|
||||
map(cast, |x| Primary::Cast(Box::new(x))),
|
||||
map(streaming_concatenation, |x| {
|
||||
Primary::StreamingConcatenation(Box::new(x))
|
||||
}),
|
||||
@ -319,7 +319,10 @@ pub(crate) fn bit_select(s: Span) -> IResult<Span, BitSelect> {
|
||||
#[tracable_parser]
|
||||
pub(crate) fn select(s: Span) -> IResult<Span, Select> {
|
||||
let (s, a) = opt(triple(
|
||||
many0(triple(symbol("."), member_identifier, bit_select)),
|
||||
many0(terminated(
|
||||
triple(symbol("."), member_identifier, bit_select),
|
||||
peek(symbol(".")),
|
||||
)),
|
||||
symbol("."),
|
||||
member_identifier,
|
||||
))(s)?;
|
||||
@ -348,7 +351,10 @@ pub(crate) fn constant_bit_select(s: Span) -> IResult<Span, ConstantBitSelect> {
|
||||
#[tracable_parser]
|
||||
pub(crate) fn constant_select(s: Span) -> IResult<Span, ConstantSelect> {
|
||||
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("."),
|
||||
member_identifier,
|
||||
))(s)?;
|
||||
|
@ -47,9 +47,19 @@ pub(crate) fn include_statement(s: Span) -> IResult<Span, IncludeStatement> {
|
||||
Ok((s, IncludeStatement { nodes: (a, b, c) }))
|
||||
}
|
||||
|
||||
//TODO support non literal path
|
||||
#[tracable_parser]
|
||||
pub(crate) fn file_path_spec(s: Span) -> IResult<Span, FilePathSpec> {
|
||||
let (s, a) = string_literal(s)?;
|
||||
Ok((s, FilePathSpec { nodes: (a,) }))
|
||||
alt((
|
||||
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();
|
||||
loop {
|
||||
if let Ok((t, b)) = f(s) {
|
||||
let (u, c) = g(t)?;
|
||||
s = u;
|
||||
ret.push((b, c));
|
||||
if let Ok((u, c)) = g(t) {
|
||||
s = u;
|
||||
ret.push((b, c));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -32,6 +32,12 @@ pub struct IncludeStatement {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Node)]
|
||||
pub struct FilePathSpec {
|
||||
pub nodes: (StringLiteral,),
|
||||
pub enum FilePathSpec {
|
||||
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