Marmos
v juptune
v asn1
v lang
v ast
v Classes
v Enums
v ir
v parser
v Enums
v Structs
v core
v crypto
v keyexchange
v memory
v data
v alphabet
v buffer
v json
v builder
v parser
v Enums
v Structs
v serialise
v Structs
v Templates
v pem
v Enums
v Structs

Structs Asn1Parser

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
module 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);
    
}

Documentation

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.

Aliases

Name Description
__xdtor

Functions

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