Skip to content

Commit 2e9dedd

Browse files
RawkMattias Wallin
authored andcommitted
feat(parser): Split up combined reserved words
For example, split "SEQUENCE OF" into it's two reserved character sequences "SEQUENCE" and "OF". This is to better follow the reserved words, and also allows white space between words.
1 parent 006e3e9 commit 2e9dedd

19 files changed

+4992
-334
lines changed

rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@itu-t_h_h235.0_2005_H235-SECURITY-MESSAGES.asn1.snap

Lines changed: 1037 additions & 39 deletions
Large diffs are not rendered by default.

rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@itu-t_h_h235_1998_H235-SECURITY-MESSAGES.asn1.snap

Lines changed: 654 additions & 38 deletions
Large diffs are not rendered by default.

rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@itu-t_h_h235_2000_H235-SECURITY-MESSAGES.asn1.snap

Lines changed: 795 additions & 38 deletions
Large diffs are not rendered by default.

rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@itu-t_h_h235_2003-amd1_H235-SECURITY-MESSAGES.asn1.snap

Lines changed: 1033 additions & 39 deletions
Large diffs are not rendered by default.

rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@itu-t_h_h235_2003_H235-SECURITY-MESSAGES.asn1.snap

Lines changed: 989 additions & 38 deletions
Large diffs are not rendered by default.

rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@itu-t_q_q1238.4_2000_IN-CS3-SCF-SDF-Additional-Definitions.asn1.snap

Lines changed: 96 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,99 @@
22
source: rasn-compiler-tests/tests/parse_test.rs
33
input_file: rasn-compiler-tests/tests/modules/itu-t_q_q1238.4_2000_IN-CS3-SCF-SDF-Additional-Definitions.asn1
44
---
5-
Error matching ASN syntax at while parsing:
6-
╭─[line 218, column 6]
7-
8-
9-
218 │ (WITH COMPONENTS { ◀▪▪▪▪▪▪▪▪▪▪ FAILED AT THIS LINE
10-
219 │ ...,
11-
220 │ toBeProtected (WITH COMPONENTS {
12-
221 │ ...,
13-
222 │ searchInfo (WITH COMPONENTS {
14-
223 │ ...,
15-
224 │ entries (WITH
16-
225 │ COMPONENT
17-
226 │ (IN-EntryInformation)),
18-
227 │ partialOutcomeQualifier (PartialOutcomeQualifier
19-
228 │ (WITH COMPONENTS {
20-
229 │ ...,
21-
230 │ queryReference ABSENT
22-
231 │ }))OPTIONAL
23-
232 │ })
24-
233 │ })
25-
234 │ })
26-
236-- Errors definition
27-
28-
─────╯
5+
Warnings:
6+
LinkerError in ASN grammar: Failed to resolve reference of ElsewhereDefined: ERROR
7+
LinkerError in ASN grammar: Failed to resolve reference of ElsewhereDefined: ERROR
8+
9+
10+
Generated:
11+
#[allow(
12+
non_camel_case_types,
13+
non_snake_case,
14+
non_upper_case_globals,
15+
unused,
16+
clippy::too_many_arguments
17+
)]
18+
pub mod in_cs3_scf_sdf_additional_definitions {
19+
extern crate alloc;
20+
use super::directory_abstract_service::{
21+
AddEntryArgument, AddEntryResult, CommonArguments, DirectoryBindArgument,
22+
DirectoryBindResult, EntryInformation, EntryInformationSelection, ModifyEntryArgument,
23+
ModifyEntryResult, PartialOutcomeQualifier, RemoveEntryArgument, RemoveEntryResult,
24+
SearchArgument, SearchResult, SecurityProblem, ServiceControls, ServiceProblem,
25+
ATTRIBUTE_ERROR, DIRECTORY_BIND_ERROR, NAME_ERROR, REFERRAL, SECURITY_ERROR, SERVICE_ERROR,
26+
UPDATE_ERROR,
27+
};
28+
use super::directory_access_protocol::{
29+
ID_OPCODE_ADD_ENTRY, ID_OPCODE_MODIFY_ENTRY, ID_OPCODE_REMOVE_ENTRY, ID_OPCODE_SEARCH,
30+
};
31+
use super::in_cs3_errortypes::EXECUTION_ERROR;
32+
use super::in_cs3_object_identifiers::{
33+
DS_USEFUL_DEFINITIONS, ERRORTYPES, OPERATIONCODES, ROS_INFORMATION_OBJECTS,
34+
SCF_SDF_OPERATIONS,
35+
};
36+
use super::in_cs3_operationcodes::OPCODE_EXECUTE;
37+
use super::in_cs3_scf_sdf_operations::{ExecuteArgument, ExecuteResult, EXECUTE};
38+
use super::remote_operations_information_objects::*;
39+
use super::useful_definitions::{DAP, DIRECTORY_ABSTRACT_SERVICE};
40+
use core::borrow::Borrow;
41+
use rasn::prelude::*;
42+
use std::sync::LazyLock;
43+
#[doc = " Direction: SCF->SDF"]
44+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
45+
#[rasn(delegate, identifier = "IN-AddEntryArgument")]
46+
pub struct INAddEntryArgument(pub AddEntryArgument);
47+
#[doc = " Information types and common procedures"]
48+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
49+
#[rasn(delegate, identifier = "IN-CommonArguments")]
50+
pub struct INCommonArguments(pub CommonArguments);
51+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
52+
#[rasn(delegate, identifier = "IN-EntryInformation")]
53+
pub struct INEntryInformation(pub EntryInformation);
54+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
55+
#[rasn(delegate, identifier = "IN-EntryInformationSelection")]
56+
pub struct INEntryInformationSelection(pub EntryInformationSelection);
57+
#[doc = " Operations, Arguments and Results definition"]
58+
#[doc = " EDITOR: \u{93}execute\u{94} has been imported and cannot be redefined"]
59+
#[doc = "execute OPERATION ::= {"]
60+
#[doc = "\tARGUMENT\tIN-ExecuteArgument"]
61+
#[doc = "\tRESULT\t\tExecuteResult"]
62+
#[doc = "\tERRORS \t\t{ attributeError | nameError | in-ServiceError | referral |"]
63+
#[doc = "\t\t\t\tsecurityError | updateError | executionError }"]
64+
#[doc = "\tCODE\t\topcode-execute }"]
65+
#[doc = " Direction: SCF->SDF"]
66+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
67+
#[rasn(delegate, identifier = "IN-ExecuteArgument")]
68+
pub struct INExecuteArgument(pub ExecuteArgument);
69+
#[doc = " Direction: SCF->SDF"]
70+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
71+
#[rasn(delegate, identifier = "IN-ModifyEntryArgument")]
72+
pub struct INModifyEntryArgument(pub ModifyEntryArgument);
73+
#[doc = " Note that CommonArguments in X.511 ModifyEntryArgument is replaced with IN-CommonArguments."]
74+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
75+
#[rasn(delegate, identifier = "IN-ModifyEntryResult")]
76+
pub struct INModifyEntryResult(pub ModifyEntryResult);
77+
#[doc = " Direction: SCF->SDF"]
78+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
79+
#[rasn(delegate, identifier = "IN-RemoveEntryArgument")]
80+
pub struct INRemoveEntryArgument(pub RemoveEntryArgument);
81+
#[doc = " Direction: SCF->SDF"]
82+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
83+
#[rasn(delegate, identifier = "IN-SearchArgument")]
84+
pub struct INSearchArgument(pub SearchArgument);
85+
#[doc = " Note that CommonArguments in X.511 SearchArgument is replaced with IN-CommonArguments."]
86+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
87+
#[rasn(delegate, identifier = "IN-SearchResult")]
88+
pub struct INSearchResult(pub SearchResult);
89+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
90+
#[rasn(delegate, identifier = "IN-ServiceControls")]
91+
pub struct INServiceControls(pub ServiceControls);
92+
#[doc = " Errors definition"]
93+
pub static IN_DIRECTORY_BIND_ERROR: LazyLock<ERROR> =
94+
LazyLock::new(|| ERROR(DIRECTORY_BIND_ERROR));
95+
#[doc = "EDITOR: The following constraint ought to be applied to the field \"&ParameterType\""]
96+
#[doc = "of the **information object** \"directoryBindError\":"]
97+
#[doc = " SecurityProblem 10 indicates that the supplied SPKM token was found to be valid."]
98+
#[doc = " In reception, all the possible errors should be supported to understand a Bind error"]
99+
pub static IN_SERVICE_ERROR: LazyLock<ERROR> = LazyLock::new(|| ERROR(SERVICE_ERROR));
100+
}

rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@itu-t_q_q1248.4_2001_IN-SCF-SDF-Additional-Definitions.asn1.snap

Lines changed: 92 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,95 @@
22
source: rasn-compiler-tests/tests/parse_test.rs
33
input_file: rasn-compiler-tests/tests/modules/itu-t_q_q1248.4_2001_IN-SCF-SDF-Additional-Definitions.asn1
44
---
5-
Error matching ASN syntax at while parsing:
6-
╭─[line 217, column 6]
7-
8-
9-
217 │ (WITH COMPONENTS { ◀▪▪▪▪▪▪▪▪▪▪ FAILED AT THIS LINE
10-
218 │ ...,
11-
219 │ toBeProtected (WITH COMPONENTS {
12-
220 │ ...,
13-
221 │ searchInfo (WITH COMPONENTS {
14-
222 │ ...,
15-
223 │ entries (WITH
16-
224 │ COMPONENT
17-
225 │ (IN-EntryInformation)),
18-
226 │ partialOutcomeQualifier (PartialOutcomeQualifier
19-
227 │ (WITH COMPONENTS {
20-
228 │ ...,
21-
229 │ queryReference ABSENT
22-
230 │ }))OPTIONAL
23-
231 │ })
24-
232 │ })
25-
233 │ })
26-
235-- Errors definition
27-
28-
─────╯
5+
Warnings:
6+
LinkerError in ASN grammar: Failed to resolve reference of ElsewhereDefined: ERROR
7+
LinkerError in ASN grammar: Failed to resolve reference of ElsewhereDefined: ERROR
8+
9+
10+
Generated:
11+
#[allow(
12+
non_camel_case_types,
13+
non_snake_case,
14+
non_upper_case_globals,
15+
unused,
16+
clippy::too_many_arguments
17+
)]
18+
pub mod in_scf_sdf_additional_definitions {
19+
extern crate alloc;
20+
use super::directory_abstract_service::{
21+
AddEntryArgument, AddEntryResult, CommonArguments, DirectoryBindArgument,
22+
DirectoryBindResult, EntryInformation, EntryInformationSelection, ModifyEntryArgument,
23+
ModifyEntryResult, PartialOutcomeQualifier, RemoveEntryArgument, RemoveEntryResult,
24+
SearchArgument, SearchResult, SecurityProblem, ServiceControls, ServiceProblem,
25+
ATTRIBUTE_ERROR, DIRECTORY_BIND_ERROR, NAME_ERROR, REFERRAL, SECURITY_ERROR, SERVICE_ERROR,
26+
UPDATE_ERROR,
27+
};
28+
use super::directory_access_protocol::{
29+
ID_OPCODE_ADD_ENTRY, ID_OPCODE_MODIFY_ENTRY, ID_OPCODE_REMOVE_ENTRY, ID_OPCODE_SEARCH,
30+
};
31+
use super::in_errortypes::EXECUTION_ERROR;
32+
use super::in_object_identifiers::{
33+
DS_USEFUL_DEFINITIONS, ERRORTYPES, OPERATIONCODES, ROS_INFORMATION_OBJECTS,
34+
SCF_SDF_OPERATIONS,
35+
};
36+
use super::in_operationcodes::OPCODE_EXECUTE;
37+
use super::in_scf_sdf_operations::{ExecuteArgument, ExecuteResult};
38+
use super::remote_operations_information_objects::*;
39+
use super::useful_definitions::{DAP, DIRECTORY_ABSTRACT_SERVICE};
40+
use core::borrow::Borrow;
41+
use rasn::prelude::*;
42+
use std::sync::LazyLock;
43+
#[doc = " Direction: SCF->SDF"]
44+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
45+
#[rasn(delegate, identifier = "IN-AddEntryArgument")]
46+
pub struct INAddEntryArgument(pub AddEntryArgument);
47+
#[doc = " Information types and common procedures"]
48+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
49+
#[rasn(delegate, identifier = "IN-CommonArguments")]
50+
pub struct INCommonArguments(pub CommonArguments);
51+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
52+
#[rasn(delegate, identifier = "IN-EntryInformation")]
53+
pub struct INEntryInformation(pub EntryInformation);
54+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
55+
#[rasn(delegate, identifier = "IN-EntryInformationSelection")]
56+
pub struct INEntryInformationSelection(pub EntryInformationSelection);
57+
#[doc = " Direction: SCF->SDF"]
58+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
59+
#[rasn(delegate, identifier = "IN-ExecuteArgument")]
60+
pub struct INExecuteArgument(pub ExecuteArgument);
61+
#[doc = " Direction: SCF->SDF"]
62+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
63+
#[rasn(delegate, identifier = "IN-ModifyEntryArgument")]
64+
pub struct INModifyEntryArgument(pub ModifyEntryArgument);
65+
#[doc = " The last two elements belong to IN-CommonArgument type."]
66+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
67+
#[rasn(delegate, identifier = "IN-ModifyEntryResult")]
68+
pub struct INModifyEntryResult(pub ModifyEntryResult);
69+
#[doc = " Direction: SCF->SDF"]
70+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
71+
#[rasn(delegate, identifier = "IN-RemoveEntryArgument")]
72+
pub struct INRemoveEntryArgument(pub RemoveEntryArgument);
73+
#[doc = " Direction: SCF->SDF"]
74+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
75+
#[rasn(delegate, identifier = "IN-SearchArgument")]
76+
pub struct INSearchArgument(pub SearchArgument);
77+
#[doc = " The last two elements belong to IN-CommonArgument type."]
78+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
79+
#[rasn(delegate, identifier = "IN-SearchResult")]
80+
pub struct INSearchResult(pub SearchResult);
81+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
82+
#[rasn(delegate, identifier = "IN-ServiceControls")]
83+
pub struct INServiceControls(pub ServiceControls);
84+
#[doc = " Errors definition"]
85+
pub static IN_DIRECTORY_BIND_ERROR: LazyLock<ERROR> =
86+
LazyLock::new(|| ERROR(DIRECTORY_BIND_ERROR));
87+
#[doc = " the following constraint shall be applied to the parameter error"]
88+
#[doc = " (WITH COMPONENTS{"]
89+
#[doc = " \t...,"]
90+
#[doc = " \terror (WITH COMPONENTS{"]
91+
#[doc = " \t\tserviceError(ServiceProblem(2)),"]
92+
#[doc = " \t\tsecurityError(SecurityProblem(1|2|7|10)) })})"]
93+
#[doc = " SecurityProblem 10 indicates that the supplied SPKM token was found to be valid."]
94+
#[doc = " In reception, all the possible errors should be supported to understand a Bind error"]
95+
pub static IN_SERVICE_ERROR: LazyLock<ERROR> = LazyLock::new(|| ERROR(SERVICE_ERROR));
96+
}

rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@itu-t_q_q825_1998_ASN1DefinedTypesModuleNew.asn1.snap

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,51 @@
22
source: rasn-compiler-tests/tests/parse_test.rs
33
input_file: rasn-compiler-tests/tests/modules/itu-t_q_q825_1998_ASN1DefinedTypesModuleNew.asn1
44
---
5-
Error matching ASN syntax at while parsing:
6-
╭─[line 26, column 13]
7-
8-
9-
26OF MANAGEMENT-EXTENSION({AllowedAdditionalRecordTypes}) ◀▪▪▪▪▪▪▪▪▪▪ FAILED AT THIS LINE
10-
28-- The AllowedAdditionalRecordTypes is the constraint that allows only certain types to be set as
11-
29-- AdditionalRecordType.
12-
13-
────╯
5+
Generated:
6+
#[allow(
7+
non_camel_case_types,
8+
non_snake_case,
9+
non_upper_case_globals,
10+
unused,
11+
clippy::too_many_arguments
12+
)]
13+
pub mod asn1_defined_types_module_new {
14+
extern crate alloc;
15+
use core::borrow::Borrow;
16+
use rasn::prelude::*;
17+
use std::sync::LazyLock;
18+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
19+
#[rasn(delegate)]
20+
pub struct AdditionalRecordType(pub MANAGEMENTEXTENSION);
21+
#[doc = " dynamically extensible information object set"]
22+
#[doc = " The AdditionalRecordTypes type is to be used in the RecordContent type of"]
23+
#[doc = " ASN1DefinedTypesModule module."]
24+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
25+
#[rasn(delegate)]
26+
pub struct BlockExtension(pub MANAGEMENTEXTENSION);
27+
#[doc = " dynamically extensible information object set"]
28+
#[doc = " The BlockExtensions type is to be used in the BlockHeaderRecord type of"]
29+
#[doc = " ASN1DefinedTypesModule"]
30+
#[doc = " module"]
31+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
32+
#[rasn(delegate)]
33+
pub struct RecordExtension(pub MANAGEMENTEXTENSION);
34+
#[doc = " dynamically extensible information object set"]
35+
#[doc = " The RecordExtensions type is to be used in the CallRecord type of"]
36+
#[doc = " ASN1DefinedTypesModule module"]
37+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
38+
#[rasn(delegate)]
39+
pub struct ServiceSpecificINInformation(pub MANAGEMENTEXTENSION);
40+
#[doc = " dynamically extensible information object set"]
41+
#[doc = " TheServiceSpecificINInformations type is to be used in the CallRecord type of"]
42+
#[doc = " ASN1DefinedTypesModule module."]
43+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
44+
#[rasn(delegate)]
45+
pub struct StandardAdditionalRecordType(pub MANAGEMENTEXTENSION);
46+
#[doc = " dynamically extensible information object set"]
47+
#[doc = " TheStandardAdditionalRecordTypes type is to be used in the RecordContent type of"]
48+
#[doc = " ASN1DefinedTypesModule module."]
49+
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
50+
#[rasn(delegate)]
51+
pub struct StandardExtension(pub MANAGEMENTEXTENSION);
52+
}

0 commit comments

Comments
 (0)