Apply packrat_parser

This commit is contained in:
dalance 2019-07-24 16:58:45 +09:00
parent 1d22da04a1
commit 3a7daa174f
7 changed files with 17 additions and 0 deletions

View File

@ -4,6 +4,7 @@ use nom::branch::*;
use nom::combinator::*;
use nom::sequence::*;
use nom::IResult;
use nom_packrat::packrat_parser;
// -----------------------------------------------------------------------------
@ -253,6 +254,7 @@ pub fn assignment_pattern_key(s: Span) -> IResult<Span, AssignmentPatternKey> {
))(s)
}
#[packrat_parser]
#[parser]
pub fn assignment_pattern_expression(s: Span) -> IResult<Span, AssignmentPatternExpression> {
let (s, a) = opt(assignment_pattern_expression_type)(s)?;

View File

@ -5,6 +5,7 @@ use nom::combinator::*;
use nom::multi::*;
use nom::sequence::*;
use nom::IResult;
use nom_packrat::packrat_parser;
// -----------------------------------------------------------------------------
@ -285,6 +286,7 @@ pub struct TypeReferenceDataType {
// -----------------------------------------------------------------------------
#[packrat_parser]
#[parser]
pub fn casting_type(s: Span) -> IResult<Span, CastingType> {
alt((
@ -459,6 +461,7 @@ pub fn enum_name_declaration(s: Span) -> IResult<Span, EnumNameDeclaration> {
Ok((s, EnumNameDeclaration { nodes: (a, b, c) }))
}
#[packrat_parser]
#[parser]
pub fn class_scope(s: Span) -> IResult<Span, ClassScope> {
let (s, a) = class_type(s)?;
@ -592,6 +595,7 @@ pub fn signing(s: Span) -> IResult<Span, Signing> {
))(s)
}
#[packrat_parser]
#[parser]
pub fn simple_type(s: Span) -> IResult<Span, SimpleType> {
alt((

View File

@ -3,6 +3,7 @@ use crate::parser::*;
use nom::branch::*;
use nom::combinator::*;
use nom::IResult;
use nom_packrat::packrat_parser;
// -----------------------------------------------------------------------------
@ -72,6 +73,7 @@ pub struct NonrangeVariableLvalue {
// -----------------------------------------------------------------------------
#[packrat_parser]
#[parser]
pub fn net_lvalue(s: Span) -> IResult<Span, NetLvalue> {
alt((net_lvalue_identifier, net_lvalue_lvalue, net_lvalue_pattern))(s)
@ -106,6 +108,7 @@ pub fn net_lvalue_lvalue(s: Span) -> IResult<Span, NetLvalue> {
))
}
#[packrat_parser]
#[parser]
pub fn variable_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
alt((

View File

@ -2,6 +2,7 @@ use crate::ast::*;
use crate::parser::*;
use nom::branch::*;
use nom::IResult;
use nom_packrat::packrat_parser;
// -----------------------------------------------------------------------------
@ -32,6 +33,7 @@ pub struct BinaryModulePathOperator {
// -----------------------------------------------------------------------------
#[packrat_parser]
#[parser]
pub fn unary_operator(s: Span) -> IResult<Span, UnaryOperator> {
let (s, a) = alt((

View File

@ -474,6 +474,7 @@ pub fn range_expression(s: Span) -> IResult<Span, RangeExpression> {
))(s)
}
#[packrat_parser]
#[parser]
pub fn primary_literal(s: Span) -> IResult<Span, PrimaryLiteral> {
alt((

View File

@ -5,6 +5,7 @@ use nom::combinator::*;
use nom::multi::*;
use nom::sequence::*;
use nom::IResult;
use nom_packrat::packrat_parser;
// -----------------------------------------------------------------------------
@ -224,6 +225,7 @@ pub fn system_tf_call_arg_expression(s: Span) -> IResult<Span, SystemTfCall> {
))
}
#[packrat_parser]
#[parser]
pub fn subroutine_call(s: Span) -> IResult<Span, SubroutineCall> {
alt((

View File

@ -885,6 +885,7 @@ pub fn package_identifier(s: Span) -> IResult<Span, PackageIdentifier> {
Ok((s, PackageIdentifier { nodes: (a,) }))
}
#[packrat_parser]
#[parser]
pub fn package_scope(s: Span) -> IResult<Span, PackageScope> {
alt((package_scope_package, map(unit, |x| PackageScope::Unit(x))))(s)
@ -1074,6 +1075,7 @@ pub fn ps_or_hierarchical_tf_identifier_package_scope(
))
}
#[packrat_parser]
#[parser]
pub fn ps_parameter_identifier(s: Span) -> IResult<Span, PsParameterIdentifier> {
alt((
@ -1106,6 +1108,7 @@ pub fn ps_parameter_identifier_generate(s: Span) -> IResult<Span, PsParameterIde
))
}
#[packrat_parser]
#[parser]
pub fn ps_type_identifier(s: Span) -> IResult<Span, PsTypeIdentifier> {
let (s, a) = opt(local_or_package_scope_or_class_scope)(s)?;