(ast: AST.AST, isDecoding: boolean)
| 750 | ) |
| 751 | |
| 752 | const goMemo = (ast: AST.AST, isDecoding: boolean): Parser => { |
| 753 | const memoMap = isDecoding ? decodeMemoMap : encodeMemoMap |
| 754 | const memo = memoMap.get(ast) |
| 755 | if (memo) { |
| 756 | return memo |
| 757 | } |
| 758 | const raw = go(ast, isDecoding) |
| 759 | const parseOptionsAnnotation = AST.getParseOptionsAnnotation(ast) |
| 760 | const parserWithOptions: Parser = Option.isSome(parseOptionsAnnotation) |
| 761 | ? (i, options) => raw(i, mergeInternalOptions(options, parseOptionsAnnotation.value)) |
| 762 | : raw |
| 763 | const decodingFallbackAnnotation = AST.getDecodingFallbackAnnotation(ast) |
| 764 | const parser: Parser = isDecoding && Option.isSome(decodingFallbackAnnotation) |
| 765 | ? (i, options) => |
| 766 | handleForbidden(orElse(parserWithOptions(i, options), decodingFallbackAnnotation.value), ast, i, options) |
| 767 | : parserWithOptions |
| 768 | memoMap.set(ast, parser) |
| 769 | return parser |
| 770 | } |
| 771 | |
| 772 | const getConcurrency = (ast: AST.AST): Concurrency | undefined => |
| 773 | Option.getOrUndefined(AST.getConcurrencyAnnotation(ast)) |
no test coverage detected