1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283module juptune.asn1.lang.parser;
struct Asn1Parser
{
/++ ALIASES ++/
///
alias __xdtor = __MARMOS_BUG__;
/++ FUNCTIONS ++/
///
Result Assignment(Asn1AssignmentNode node);
///
Result ComponentType(Asn1ComponentTypeNode node);
///
Result ComponentTypeList(Asn1ComponentTypeListNode outNode);
///
Result ComponentTypeLists(Asn1ComponentTypeListsNode node);
///
Result Constraint(Asn1ConstraintNode node);
///
Result DefinedObjectClass(Asn1DefinedObjectClassNode node);
///
Result DefinedValue(Asn1DefinedValueNode node);
///
Result ElementSetSpec(Asn1ElementSetSpecNode node);
///
Result Elements(Asn1ElementsNode node);
///
Result ExceptionSpec(Asn1ExceptionSpecNode node);
///
Result Exclusions(Asn1ExclusionsNode node);
///
Result ExtensionAdditions(Asn1ExtensionAdditionsNode node);
///
Result ExtensionAndException(Asn1ExtensionAndExceptionNode node);
///
Result ExtensionEndMarker(Asn1StaticNode!(Asn1NodeType.ExtensionEndMarker) node);
///
Result ModuleBody(Asn1ModuleBodyNode node);
/// Parsers (can you tell I'm suicidal)
Result ModuleDefinition(Asn1ModuleDefinitionNode node);
///
Result ModuleIdentifier(Asn1ModuleIdentifierNode node);
///
Result NamedNumber(Asn1NamedNumberNode node);
///
Result NamedType(Asn1NamedTypeNode node);
///
Result NamedValueList(Asn1NamedValueListNode node);
///
Result ObjIdComponentsList(Asn1ObjIdComponentsListNode node);
///
Result PlainType(Asn1TypeNode node);
///
Result Reference(Asn1ReferenceNode node);
///
Result SignedNumber(Asn1SignedNumberNode node);
///
Result SymbolList(Asn1SymbolListNode node);
///
Result Type(Asn1TypeNode node);
///
Result Value(Asn1ValueNode node);
///
Result ValueList(Asn1ValueListNode node);
///
Result VersionNumber(Asn1VersionNumberNode node);
///
Result consume(Asn1Token token);
///
Result consume();
///
Result makeError(ErrorT, Args...)(ErrorT error, string message, Asn1Location location, Args args);
///
Asn1Parser opAssign(Asn1Parser p);
/// Standard parsing functions/helpers
Result peek(Asn1Token token);
///
void reportLastError(Asn1ErrorHandler errors);
}
TODO, Organise: Two ways to signal a missing token: initial and non-initial. - Initial is useful for checking whether a particular parser is even suitable. - Non-initial is useful for signalling that there's a syntax error, since a particular parser was able to start - but not finish - parsing. - The .notInitialfunction is used to make it easier to control subparser results.
To make it easier to debug certain cases, all parsers will backtrack to their original position on failure.
Yes, the lexer's lookahead functionality is unused, mainly because of the infinite amount of whitespace and comments that can be between actually useful tokens making things complicated to deal with.
The code structure doesn't try to break things into 1:1 function:node as it becomes very unweidly and somehow harder to read, instead it tries to only DRY common subparsers. It actively avoids the use of helper functions where possible to make debugging less of a PITA (not worth the DRYness).
Currently doesn't even attempt to preserve comments or original formatting - parser isn't completely suitable for all kinds of tooling due to this (adds complexity I don't want to tackle yet).
Yes, the AST is inefficient and parts are unused due to ambiguity that requires a semantic pass - I want to keep syntax and semantic analysis separate for my own sanity. Yes, this does waste a lot more memory than it should.
As most of this file is very, very similar, verbose code, this file is free to take liberties in the name of terseness. i.e. no this.spam; usage of the if(auto r = ...)pattern; less whitespace usage, etc.
| Name | Description |
|---|---|
| __xdtor |
| Name | Description |
|---|---|
| Assignment | |
| ComponentType | |
| ComponentTypeList | |
| ComponentTypeLists | |
| Constraint | |
| DefinedObjectClass | |
| DefinedValue | |
| ElementSetSpec | |
| Elements | |
| ExceptionSpec | |
| Exclusions | |
| ExtensionAdditions | |
| ExtensionAndException | |
| ExtensionEndMarker | |
| ModuleBody | |
| ModuleDefinition |
Parsers (can you tell I'm suicidal) |
| ModuleIdentifier | |
| NamedNumber | |
| NamedType | |
| NamedValueList | |
| ObjIdComponentsList | |
| PlainType | |
| Reference | |
| SignedNumber | |
| SymbolList | |
| Type | |
| Value | |
| ValueList | |
| VersionNumber | |
| consume | |
| consume | |
| makeError | |
| opAssign | |
| peek |
Standard parsing functions/helpers |
| reportLastError |