MCPcopy Index your code
hub / github.com/aiscript-dev/aiscript / parseNamedType

Function parseNamedType

src/parser/syntaxes/types.ts:153–176  ·  view source on GitHub ↗

* ```abnf * NamedType = IDENT ["<" Type ">"] * ```

(s: ITokenStream)

Source from the content-addressed store, hash-verified

151 * ```
152*/
153function parseNamedType(s: ITokenStream): Ast.TypeSource {
154 const startPos = s.getPos();
155
156 let name: string;
157 if (s.is(TokenKind.Identifier)) {
158 name = s.getTokenValue();
159 s.next();
160 } else {
161 s.expect(TokenKind.NullKeyword);
162 s.next();
163 name = 'null';
164 }
165
166 // inner type
167 let inner: Ast.TypeSource | undefined;
168 if (s.is(TokenKind.Lt)) {
169 s.next();
170 inner = parseType(s);
171 s.expect(TokenKind.Gt);
172 s.next();
173 }
174
175 return NODE('namedTypeSource', { name, inner }, startPos, s.getPos());
176}

Callers 1

parseUnionTypeInnerFunction · 0.85

Calls 7

parseTypeFunction · 0.85
NODEFunction · 0.85
getPosMethod · 0.65
isMethod · 0.65
getTokenValueMethod · 0.65
nextMethod · 0.65
expectMethod · 0.65

Tested by

no test coverage detected