MCPcopy Index your code
hub / github.com/arktypeio/arktype / parseString

Function parseString

ark/type/parser/string.ts:21–40  ·  view source on GitHub ↗
(
	def: string,
	ctx: BaseParseContext
)

Source from the content-addressed store, hash-verified

19} from "./shift/operator/operator.ts"
20
21export const parseString = (
22 def: string,
23 ctx: BaseParseContext
24): InnerParseResult => {
25 const aliasResolution = ctx.$.maybeResolveRoot(def)
26 if (aliasResolution) return aliasResolution
27
28 if (def.endsWith("[]")) {
29 const possibleElementResolution = ctx.$.maybeResolveRoot(def.slice(0, -2))
30 if (possibleElementResolution) return possibleElementResolution.array()
31 }
32
33 const s = new RuntimeState(new Scanner(def), ctx)
34
35 const node = fullStringParse(s)
36
37 if (s.finalizer === ">") throwParseError(writeUnexpectedCharacterMessage(">"))
38
39 return node
40}
41
42/**
43 * Try to parse the definition from right to left using the most common syntax.

Callers 1

parseInnerDefinitionFunction · 0.90

Calls 4

throwParseErrorFunction · 0.90
fullStringParseFunction · 0.85
arrayMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…