diff --git a/sv-parser-parser/src/general/compiler_directives.rs b/sv-parser-parser/src/general/compiler_directives.rs index 0f6294a..4556c03 100644 --- a/sv-parser-parser/src/general/compiler_directives.rs +++ b/sv-parser-parser/src/general/compiler_directives.rs @@ -204,7 +204,49 @@ pub(crate) fn macro_text(s: Span) -> IResult { #[tracable_parser] #[packrat_parser] pub(crate) fn default_text(s: Span) -> IResult { - let (s, a) = is_not(",)")(s)?; + let (s, a) = many1(alt(( + is_not(",)([{\""), + map(triple(tag("("), opt(is_not(")")), tag(")")), |(x, y, z)| { + if let Some(y) = y { + concat(concat(x, y).unwrap(), z).unwrap() + } else { + concat(x, z).unwrap() + } + }), + map(triple(tag("["), opt(is_not("]")), tag("]")), |(x, y, z)| { + if let Some(y) = y { + concat(concat(x, y).unwrap(), z).unwrap() + } else { + concat(x, z).unwrap() + } + }), + map(triple(tag("{"), opt(is_not("}")), tag("}")), |(x, y, z)| { + if let Some(y) = y { + concat(concat(x, y).unwrap(), z).unwrap() + } else { + concat(x, z).unwrap() + } + }), + map( + triple(tag("\""), opt(is_not("\"")), tag("\"")), + |(x, y, z)| { + if let Some(y) = y { + concat(concat(x, y).unwrap(), z).unwrap() + } else { + concat(x, z).unwrap() + } + }, + ), + )))(s)?; + let mut ret = None; + for x in a { + ret = if let Some(ret) = ret { + Some(concat(ret, x).unwrap()) + } else { + Some(x) + } + } + let a = ret.unwrap(); Ok(( s, DefaultText { @@ -232,8 +274,55 @@ pub(crate) fn list_of_actual_arguments(s: Span) -> IResult IResult { - let (s, a) = expression(s)?; - Ok((s, ActualArgument { nodes: (a,) })) + let (s, a) = many1(alt(( + is_not(",)([{\""), + map(triple(tag("("), opt(is_not(")")), tag(")")), |(x, y, z)| { + if let Some(y) = y { + concat(concat(x, y).unwrap(), z).unwrap() + } else { + concat(x, z).unwrap() + } + }), + map(triple(tag("["), opt(is_not("]")), tag("]")), |(x, y, z)| { + if let Some(y) = y { + concat(concat(x, y).unwrap(), z).unwrap() + } else { + concat(x, z).unwrap() + } + }), + map(triple(tag("{"), opt(is_not("}")), tag("}")), |(x, y, z)| { + if let Some(y) = y { + concat(concat(x, y).unwrap(), z).unwrap() + } else { + concat(x, z).unwrap() + } + }), + map( + triple(tag("\""), opt(is_not("\"")), tag("\"")), + |(x, y, z)| { + if let Some(y) = y { + concat(concat(x, y).unwrap(), z).unwrap() + } else { + concat(x, z).unwrap() + } + }, + ), + )))(s)?; + let mut ret = None; + for x in a { + ret = if let Some(ret) = ret { + Some(concat(ret, x).unwrap()) + } else { + Some(x) + } + } + let a = ret.unwrap(); + Ok(( + s, + ActualArgument { + nodes: (into_locate(a),), + }, + )) } #[tracable_parser]