@cratis/screenplay-language 4.259.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/bundles/compiler/Authoring/QuickFixes.js +6 -2
  2. package/dist/bundles/compiler/Authoring/QuickFixes.js.map +1 -1
  3. package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js +3 -0
  4. package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js.map +1 -0
  5. package/dist/bundles/compiler/Dependencies/SliceReferences.js +1 -1
  6. package/dist/bundles/compiler/Dependencies/SliceReferences.js.map +1 -1
  7. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
  8. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
  9. package/dist/bundles/compiler/Files/PlayFolderMerge.js +1 -1
  10. package/dist/bundles/compiler/Files/PlayFolderMerge.js.map +1 -1
  11. package/dist/bundles/compiler/Parsing/CaptureParser.js +1 -1
  12. package/dist/bundles/compiler/Parsing/CaptureParser.js.map +1 -1
  13. package/dist/bundles/compiler/Parsing/CompositionParser.js +1 -1
  14. package/dist/bundles/compiler/Parsing/CompositionParser.js.map +1 -1
  15. package/dist/bundles/compiler/Parsing/ExpressionParser.js +1 -1
  16. package/dist/bundles/compiler/Parsing/ExpressionParser.js.map +1 -1
  17. package/dist/bundles/compiler/Parsing/OperationParser.js +1 -1
  18. package/dist/bundles/compiler/Parsing/OperationParser.js.map +1 -1
  19. package/dist/bundles/compiler/Parsing/ProducesParser.js +1 -1
  20. package/dist/bundles/compiler/Parsing/ProducesParser.js.map +1 -1
  21. package/dist/bundles/compiler/Parsing/ProjectionParser.js +1 -1
  22. package/dist/bundles/compiler/Parsing/ProjectionParser.js.map +1 -1
  23. package/dist/bundles/compiler/Parsing/ReactionParser.js +1 -1
  24. package/dist/bundles/compiler/Parsing/ReactionParser.js.map +1 -1
  25. package/dist/bundles/compiler/Parsing/ScreenParser.js +1 -1
  26. package/dist/bundles/compiler/Parsing/ScreenParser.js.map +1 -1
  27. package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
  28. package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
  29. package/dist/bundles/compiler/Parsing/SeedParser.js +1 -1
  30. package/dist/bundles/compiler/Parsing/SeedParser.js.map +1 -1
  31. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js +1 -1
  32. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js.map +1 -1
  33. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js +1 -1
  34. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js.map +1 -1
  35. package/dist/bundles/compiler/Parsing/SpecificationParser.js +1 -1
  36. package/dist/bundles/compiler/Parsing/SpecificationParser.js.map +1 -1
  37. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js +1 -1
  38. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js.map +1 -1
  39. package/dist/bundles/compiler/Parsing/StateMachineParser.js +2 -0
  40. package/dist/bundles/compiler/Parsing/StateMachineParser.js.map +1 -0
  41. package/dist/bundles/compiler/Parsing/StructuredBlockParser.js +2 -0
  42. package/dist/bundles/compiler/Parsing/StructuredBlockParser.js.map +1 -0
  43. package/dist/bundles/compiler/Parsing/UiBindingParser.js +1 -1
  44. package/dist/bundles/compiler/Parsing/UiBindingParser.js.map +1 -1
  45. package/dist/bundles/compiler/Parsing/WorkflowParser.js +2 -0
  46. package/dist/bundles/compiler/Parsing/WorkflowParser.js.map +1 -0
  47. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js +1 -1
  48. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -1
  49. package/dist/bundles/compiler/Syntax/Structure.js.map +1 -1
  50. package/dist/bundles/compiler/Syntax/SyntaxCollections.js +1 -1
  51. package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
  52. package/dist/bundles/completion-items.js +22 -16
  53. package/dist/bundles/completion-items.js.map +1 -1
  54. package/dist/bundles/completion-planner.js +2 -2
  55. package/dist/bundles/completion-planner.js.map +1 -1
  56. package/dist/bundles/example-analysis.js +1 -1
  57. package/dist/bundles/example-analysis.js.map +1 -1
  58. package/dist/bundles/keyword-docs.js +1 -1
  59. package/dist/bundles/keyword-docs.js.map +1 -1
  60. package/dist/bundles/language.js +1 -1
  61. package/dist/bundles/language.js.map +1 -1
  62. package/dist/bundles/tokens.js +1 -1
  63. package/dist/bundles/tokens.js.map +1 -1
  64. package/dist/completion-items.d.ts +3 -0
  65. package/dist/completion-items.d.ts.map +1 -1
  66. package/dist/completion-planner.d.ts.map +1 -1
  67. package/dist/keyword-docs.d.ts.map +1 -1
  68. package/dist/language.d.ts.map +1 -1
  69. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SpecificationParser.js","names":["parseMappingSource","operationStepPrefix","pattern","operationStep","header","callerPersonaPattern","nativePattern","prefix","exactly","dotNetWhitespace","givenPattern","whenAppendPattern","whenPattern","thenEventPattern","thenQueryPrefix","readModelPrefix","givenReadModelPattern","thenReadModelPattern","thenNoPrefix","thenErrorPattern","stringBodyPattern","mappingPattern","nativeMappingPattern","givenTimeZonePrefix","givenTimeZonePattern","givenClockPrefix","givenCapturePrefix","thenInvokesPrefix","thenInvokesPattern","givenGeneratedPrefix","givenGeneratedPattern","whenClockPrefix","whenTriggerPrefix","whenCapturePrefix","whenQueryPrefix","thenResultPrefix","noResultPrefix","whenRedeliveredPrefix","whenRedeliveredPattern","noEventsPrefix","clockPattern","whenTriggerPattern","capturePattern","whenQueryPattern","thenResultPattern","thenAbsentReadModelPattern","absentKeyStringPattern","thenQueryPattern","name","line","context","DiagnosticCodes","locationOf","description","parameters","cases","body","child","isFileDirective","keyword","firstWord","parameter","parseParameter","row","parseCase","parseDescription","_","_noEventsLine","members","specification","validateTable","action","query","outcome","match","values","value","parseConcreteMapping","rejectOperationChildren","unescapeString","pinned","capture","readModel","event","callerRolePattern","callerClaimPattern","authenticated","roles","claims","role","claim","containsCaseReference","appends","code","generatedValues","thenReturnsPrefix","expectation","parseReturn","invocation","caseValue","parseSpecificationValue","error","absent","key","exact","at","message","args","results","hasArguments","keyText","concrete","hasChildren","indent","location","source","parseConcrete","regex","expected","create","queryArguments","specificationStream","sourceStreamPattern","specificationStreamId","addInlineValue","parent","inline","eventSource","stream","noStream","hasRoute","generated","generatedFixturePrefix","fixture","generatedFixturePattern","mapping","addFixtureValue","eventKeyword","route","diagnosticText","streamId","streamIdParts","block","directiveLocations","parseRouteParts","part","nativeIdentifiers","queryArgumentsContext","existing"],"sources":["../../../../../../Compiler/Parsing/SpecificationParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { parseRouteParts } from './EventSourceParser';\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport {\n SpecificationCaptureSyntax, SpecificationClockSyntax, SpecificationTimeZoneSyntax, SpecificationGeneratedValueSyntax, SpecificationCommandSyntax, SpecificationErrorSyntax, SpecificationEventSyntax, SpecificationStreamSyntax, SpecificationNoStreamSyntax,\n SpecificationNoResultSyntax, SpecificationQueryResultSyntax, SpecificationReadModelSyntax, SpecificationSyntax, SpecificationTriggerSyntax,\n SpecificationWhenQuerySyntax, SpecificationCallerPersonaSyntax, SpecificationOperationFailureSyntax, SpecificationOperationSyntax, SpecificationCompensatedSyntax, SpecificationRedeliverySyntax,\n} from '../Syntax/Specifications';\nimport { SpecificationDeniedSyntax, SpecificationReturnSyntax } from '../Syntax/Responses';\nimport { dotNetWhitespace, nativePattern, pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { containsCaseReference, parseCase, parseParameter, parseSpecificationValue as parseMappingSource, validateTable } from './SpecificationCaseParser';\nimport { parseDescription } from './DescriptionParser';\nimport { isFileDirective } from './FileReferences';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { addFixtureValue, addInlineValue } from './SpecificationExampleParser';\nimport { rejectOperationChildren } from './OperationParser';\nimport { generatedFixturePattern, generatedFixturePrefix, parseConcrete, parseConcreteMapping, parseReturn, thenReturnsPrefix } from './SpecificationResponseParser';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { SpecificationAbsentReadModelSyntax, SpecificationCallerClaimSyntax, SpecificationCallerSyntax, SpecificationInvocationSyntax, SpecificationQuerySyntax } from '../Syntax/Specifications';\n\nconst operationStepPrefix = pattern('^(?:given\\\\s+operation|then\\\\s+(?:operation|compensated))(?:\\\\s|$)');\nconst operationStep = pattern('^(given operation|then operation|then compensated)\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)(\\\\s+fails)?$');\nconst header = pattern('^specification\\\\s+([A-Za-z_]\\\\w*)$');\nconst callerPersonaPattern = pattern('^given caller as ([A-Za-z_]\\\\w*)$');\nconst stepName = '([A-Z]\\\\w*(?:\\\\.\\\\w+)*)';\nconst inlineAssignment = '(?:\\\\s+(?<property>[\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(?<value>.+))?';\nconst stepPattern = (prefix: string, exactly = ''): RegExp => nativePattern(`^${prefix}\\\\s+${stepName}${exactly}${inlineAssignment}$`.replaceAll('\\\\s', dotNetWhitespace));\nconst givenPattern = stepPattern('given');\nconst whenAppendPattern = stepPattern('when\\\\s+append');\nconst whenPattern = stepPattern('when');\nconst thenEventPattern = stepPattern('then');\nconst thenQueryPrefix = pattern('^then\\\\s+query\\\\b');\nconst readModelPrefix = pattern('^(?:given|then)\\\\s+readmodel\\\\b');\nconst givenReadModelPattern = stepPattern('given\\\\s+readmodel');\nconst thenReadModelPattern = stepPattern('then\\\\s+readmodel', '(?<exactly>\\\\s+exactly)?');\nconst thenNoPrefix = pattern('^then\\\\s+no\\\\b');\nconst thenErrorPattern = pattern(`^then\\\\s+error\\\\s+\"(${stringBodyPattern})\"$`);\nconst mappingPattern = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst nativeMappingPattern = nativePattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst givenTimeZonePrefix = pattern('^given\\\\s+time\\\\s+zone\\\\b');\nconst givenTimeZonePattern = pattern(`^given\\\\s+time\\\\s+zone\\\\s+\"(${stringBodyPattern})\"$`);\nconst givenClockPrefix = pattern('^given\\\\s+clock\\\\b');\nconst givenCapturePrefix = pattern('^given\\\\s+capture\\\\b');\nconst thenInvokesPrefix = pattern('^then\\\\s+invokes\\\\b');\nconst thenInvokesPattern = pattern('^then\\\\s+invokes\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)$');\nconst givenGeneratedPrefix = pattern('^given\\\\s+generated\\\\b');\nconst givenGeneratedPattern = pattern('^given\\\\s+generated\\\\s+([A-Z]\\\\w*)\\\\.([a-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst whenClockPrefix = pattern('^when\\\\s+clock\\\\b');\nconst whenTriggerPrefix = pattern('^when\\\\s+trigger\\\\b');\nconst whenCapturePrefix = pattern('^when\\\\s+capture\\\\b');\nconst whenQueryPrefix = pattern('^when\\\\s+query\\\\b');\nconst thenResultPrefix = pattern('^then\\\\s+result\\\\b');\nconst noResultPrefix = pattern('^then\\\\s+no\\\\s+result\\\\b');\nconst whenRedeliveredPrefix = nativePattern('^when\\\\s+redelivered\\\\b');\nconst whenRedeliveredPattern = nativePattern('^when\\\\s+redelivered\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)\\\\s+to\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst noEventsPrefix = pattern('^then\\\\s+no\\\\s+events\\\\b');\n\n// An instant in ISO 8601 - a date, a time to the minute or finer, and an explicit offset or Z - so the same text\n// means the same moment wherever the specification runs.\nconst clockPattern = pattern('^(given|when)\\\\s+clock\\\\s+\"(\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}(?::\\\\d{2}(?:\\\\.\\\\d+)?)?(?:Z|[+-]\\\\d{2}:\\\\d{2}))\"$');\nconst whenTriggerPattern = pattern('^when\\\\s+trigger\\\\s+([A-Za-z_]\\\\w*)$');\nconst capturePattern = pattern('^(?:given|when)\\\\s+capture\\\\s+([A-Za-z_]\\\\w*)$');\nconst whenQueryPattern = pattern('^when\\\\s+query\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst thenResultPattern = pattern('^then\\\\s+result(\\\\s+exactly)?$');\nconst thenAbsentReadModelPattern = nativePattern('^then\\\\s+no\\\\s+readmodel\\\\s+([A-Z]\\\\w*)\\\\s+for\\\\s+(.+)$');\nconst absentKeyStringPattern = nativePattern(`^(?:\"${stringBodyPattern}\"|'(?:[^'\\\\\\\\]|\\\\\\\\.)*')$`);\nconst thenQueryPattern = nativePattern('^then\\\\s+query\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)(\\\\s+exactly)?$');\n\ninterface SpecificationBody {\n given: SpecificationEventSyntax[];\n givenReadModels: SpecificationReadModelSyntax[];\n when: SpecificationCommandSyntax | null;\n whenAppended: SpecificationEventSyntax | null;\n whenRedelivered: SpecificationRedeliverySyntax | null;\n whenDeclared: boolean;\n thenEvents: SpecificationEventSyntax[];\n thenEventsInAnyOrder: boolean;\n thenNoEvents: boolean;\n noEventsLine?: SourceLine;\n thenReadModels: SpecificationReadModelSyntax[];\n thenErrors: SpecificationErrorSyntax[];\n thenAbsentReadModels: SpecificationAbsentReadModelSyntax[];\n thenQueries: SpecificationQuerySyntax[];\n givenClock: SpecificationClockSyntax | null;\n givenTimeZone: SpecificationTimeZoneSyntax | null;\n givenCaptures: SpecificationCaptureSyntax[];\n givenGenerated?: SpecificationGeneratedValueSyntax[];\n whenClock: SpecificationClockSyntax | null;\n whenTrigger: SpecificationTriggerSyntax | null;\n whenCapture: SpecificationCaptureSyntax | null;\n whenQuery: SpecificationWhenQuerySyntax | null;\n thenResults: SpecificationQueryResultSyntax[];\n thenNoResult: SpecificationNoResultSyntax | null;\n thenDenied: SpecificationDeniedSyntax | null;\n givenCaller: SpecificationCallerSyntax | null;\n givenCallerPersona?: SpecificationCallerPersonaSyntax;\n thenReturns: SpecificationReturnSyntax | null;\n givenOperationFailures: SpecificationOperationFailureSyntax[];\n thenOperations: SpecificationOperationSyntax[];\n thenCompensated: SpecificationCompensatedSyntax[];\n thenInvocations?: SpecificationInvocationSyntax[];\n}\n\nexport function parseSpecification(context: ParserContext, line: SourceLine): SpecificationSyntax {\n const name = header.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidSpecificationDeclaration, `Invalid specification declaration '${line.content}' - expected 'specification <Name>'`, locationOf(line));\n }\n let description: string | null = null;\n const parameters: NonNullable<SpecificationSyntax['parameters']>[number][] = [];\n const cases: NonNullable<SpecificationSyntax['cases']>[number][] = [];\n const body: SpecificationBody = {\n givenOperationFailures: [], thenOperations: [], thenCompensated: [], thenAbsentReadModels: [], thenQueries: [],\n given: [], givenReadModels: [], when: null, whenAppended: null, whenRedelivered: null, whenDeclared: false,\n thenEvents: [], thenEventsInAnyOrder: false, thenNoEvents: false, thenReadModels: [], thenErrors: [],\n givenClock: null, givenTimeZone: null, givenCaptures: [], whenClock: null, whenTrigger: null, whenCapture: null, whenQuery: null, thenResults: [], thenNoResult: null, thenDenied: null, givenCaller: null, thenReturns: null,\n };\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (isFileDirective(child)) {\n continue;\n }\n if (parseOperationStep(context, child, body)) continue;\n // Absence assertions admit any whitespace after 'then'; every other directive keeps its first word.\n const keyword = thenNoPrefix.test(child.content) ? 'then' : firstWord(child.content);\n if (keyword === 'parameter') {\n const parameter = parseParameter(context, child);\n if (parameter !== null) parameters.push(parameter);\n } else if (keyword === 'case') {\n const row = parseCase(context, child);\n if (row !== null) cases.push(row);\n } else if (keyword === 'description') {\n description = parseDescription(context, child, description, `Specification '${name}'`);\n } else if (keyword === 'given') {\n parseGiven(context, child, body);\n } else if (keyword === 'when') {\n parseWhen(context, child, body, name);\n } else if (keyword === 'then') {\n parseThen(context, child, body);\n } else {\n context.error(DiagnosticCodes.UnknownSpecificationDirective, `Unexpected '${firstWord(child.content)}' in specification body`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n if (body.noEventsLine !== undefined && (body.thenEvents.length > 0 || body.thenEventsInAnyOrder || body.thenErrors.length > 0 || body.thenDenied !== null)) {\n context.error(DiagnosticCodes.InvalidNoEventsExpectation,\n \"'then no events' cannot accompany event, event-order, error or denial expectations.\", locationOf(body.noEventsLine));\n }\n validateQueryRejection(context, line, body);\n const { whenDeclared: _, noEventsLine: _noEventsLine, ...members } = body;\n const specification: SpecificationSyntax = { kind: 'SpecificationSyntax', sourceOptions: context.sourceOptions, name, description, ...members,\n ...(parameters.length === 0 ? {} : { parameters }), ...(cases.length === 0 ? {} : { cases }), location: locationOf(line) };\n validateTable(specification, context);\n return specification;\n}\n\nfunction validateQueryRejection(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n if (!isQueryRejectionCandidate(body) || isWellFormedQueryRejection(body)) return;\n context.error(DiagnosticCodes.MismatchedSpecificationQueryResult,\n \"A query rejection requires exactly one query and one 'then error', no action, and no other outcomes\", locationOf(line));\n}\n\nfunction isQueryRejectionCandidate(body: SpecificationBody): boolean {\n return body.thenErrors.length > 0 && queriedCallCount(body) > 0 && (body.whenQuery !== null || !hasAction(body));\n}\n\nfunction isWellFormedQueryRejection(body: SpecificationBody): boolean {\n return !hasAction(body) && hasOneQueryAndOneError(body) && !hasOtherOutcome(body);\n}\n\nfunction hasOneQueryAndOneError(body: SpecificationBody): boolean {\n return queriedCallCount(body) === 1 && body.thenErrors.length === 1;\n}\n\nfunction hasAction(body: SpecificationBody): boolean {\n return [body.when, body.whenAppended, body.whenClock, body.whenTrigger, body.whenCapture, body.whenRedelivered].some(action => action !== null);\n}\n\nfunction queriedCallCount(body: SpecificationBody): number {\n return body.thenQueries.length + (body.whenQuery === null ? 0 : 1);\n}\n\nfunction hasOtherOutcome(body: SpecificationBody): boolean {\n return [\n body.thenResults.length > 0,\n body.thenNoResult !== null,\n body.thenDenied !== null,\n body.thenEvents.length > 0,\n body.thenNoEvents,\n body.thenEventsInAnyOrder,\n body.thenReadModels.length > 0,\n body.thenAbsentReadModels.length > 0,\n body.thenReturns !== null,\n body.thenQueries.some(query => query.results.length > 0)\n ].some(outcome => outcome);\n}\n\nfunction parseOperationStep(context: ParserContext, line: SourceLine, body: SpecificationBody): boolean {\n if (!operationStepPrefix.test(line.content)) return false;\n const match = operationStep.exec(line.content);\n if (match === null || (match[1] === 'given operation') !== (match[3] !== undefined)) {\n context.error(DiagnosticCodes.InvalidOperationSpecification, \"Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.\", locationOf(line));\n skipBody(context, line.indent);\n } else if (match[1] === 'then operation') {\n const values: PropertyMappingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const value = parseConcreteMapping(context, child, mappingPattern, DiagnosticCodes.InvalidOperationSpecification);\n if (value !== null) values.push(value);\n }\n body.thenOperations.push({ kind: 'SpecificationOperationSyntax', operation: match[2], values, location: locationOf(line) });\n } else {\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidOperationSpecification, 'Failure and compensation assertions cannot have children.');\n if (match[1] === 'given operation') body.givenOperationFailures.push({ kind: 'SpecificationOperationFailureSyntax', operation: match[2], location: locationOf(line) });\n else body.thenCompensated.push({ kind: 'SpecificationCompensatedSyntax', operation: match[2], location: locationOf(line) });\n }\n return true;\n}\n\nfunction parseGiven(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n if (givenClockPrefix.test(line.content)) {\n if (body.givenClock !== null) {\n context.error(DiagnosticCodes.InvalidSpecificationClock, 'A specification states its clock at most once.', locationOf(line));\n skipBody(context, line.indent);\n } else {\n body.givenClock = parseClock(context, line, 'given');\n }\n } else if (givenTimeZonePrefix.test(line.content)) {\n const match = givenTimeZonePattern.exec(line.content);\n skipBody(context, line.indent);\n if (body.givenTimeZone !== null || match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationTimeZone, \"A specification states its time zone at most once, as 'given time zone \\\"<id>\\\"'.\", locationOf(line));\n } else {\n body.givenTimeZone = { kind: 'SpecificationTimeZoneSyntax', id: unescapeString(match[1]), location: locationOf(line) };\n }\n } else if (givenGeneratedPrefix.test(line.content)) {\n const pinned = parseGivenGenerated(context, line);\n if (pinned !== null) {\n (body.givenGenerated ??= []).push(pinned);\n }\n } else if (givenCapturePrefix.test(line.content)) {\n const capture = parseCapture(context, line, 'given');\n if (capture !== null) {\n body.givenCaptures.push(capture);\n }\n } else if (line.content.startsWith('given caller')) {\n if (body.givenCaller !== null || body.givenCallerPersona !== undefined) {\n context.error(DiagnosticCodes.DuplicateSpecificationCallerOrDenied, \"A specification has at most one 'given caller' block.\", locationOf(line));\n context.skipBlock(line.indent);\n } else if (line.content.startsWith('given caller as')) {\n const match = callerPersonaPattern.exec(line.content);\n if (match === null) context.error(DiagnosticCodes.InvalidSpecificationCallerPersona, \"Expected 'given caller as <Persona>'.\", locationOf(line));\n const child = context.peekChild(line.indent);\n if (child !== undefined) context.error(DiagnosticCodes.InvalidSpecificationCallerPersona, \"'given caller as <Persona>' has no body; use an explicit 'given caller' for refinements.\", locationOf(child));\n skipBody(context, line.indent);\n if (match !== null) body.givenCallerPersona = { kind: 'SpecificationCallerPersonaSyntax', name: match[1], location: locationOf(line) };\n } else {\n body.givenCaller = parseCaller(context, line);\n }\n } else if (readModelPrefix.test(line.content)) {\n const readModel = parseReadModelStep(context, line, givenReadModelPattern, 'given');\n if (readModel !== undefined) {\n body.givenReadModels.push(readModel);\n }\n } else {\n const event = parseEventStep(context, line, givenPattern, 'given');\n if (event !== undefined) {\n body.given.push(event);\n }\n }\n}\n\nconst callerRolePattern = pattern(`^role${dotNetWhitespace}+\"(${stringBodyPattern})\"$`);\nconst callerClaimPattern = pattern(`^claim${dotNetWhitespace}+\"(${stringBodyPattern})\"${dotNetWhitespace}*=${dotNetWhitespace}*\"(${stringBodyPattern})\"$`);\n\n// 'given caller' and the authenticated, role and claim lines under it.\nfunction parseCaller(context: ParserContext, line: SourceLine): SpecificationCallerSyntax | null {\n if (line.content !== 'given caller') {\n context.error(DiagnosticCodes.InvalidSpecificationCaller, \"Expected exactly 'given caller'.\", locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n let authenticated = false;\n const roles: string[] = [];\n const claims: SpecificationCallerClaimSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const role = callerRolePattern.exec(child.content);\n const claim = callerClaimPattern.exec(child.content);\n if (child.content === 'authenticated' && !authenticated) {\n authenticated = true;\n } else if (role !== null) {\n roles.push(unescapeString(role[1]));\n } else if (claim !== null) {\n claims.push({ kind: 'SpecificationCallerClaimSyntax', type: unescapeString(claim[1]), value: unescapeString(claim[2]), location: locationOf(child) });\n } else {\n context.error(containsCaseReference(child.content) ? DiagnosticCodes.InvalidSpecificationCaseReference : DiagnosticCodes.InvalidSpecificationCaller, `Invalid caller fixture '${child.content}' - expected authenticated, role \"...\", or claim \"...\" = \"...\".`, locationOf(child));\n }\n }\n return { kind: 'SpecificationCallerSyntax', authenticated, roles, claims, location: locationOf(line) };\n}\n\nfunction parseWhen(context: ParserContext, line: SourceLine, body: SpecificationBody, name: string): void {\n const appends = line.content.startsWith('when append');\n if (body.whenDeclared) {\n const code = body.whenAppended !== null || appends ? DiagnosticCodes.ConflictingSpecificationActions : DiagnosticCodes.DuplicateSpecificationWhen;\n context.error(code, `Specification '${name}' already declares a 'when' - a specification can have at most one`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n body.whenDeclared = true;\n if (appends) {\n body.whenAppended = parseEventStep(context, line, whenAppendPattern, 'when append') ?? null;\n return;\n }\n if (whenRedeliveredPrefix.test(line.content)) {\n const match = whenRedeliveredPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnmatchedRedeliveredOccurrence, \"Expected 'when redelivered <Event> to <Reaction>'.\", locationOf(line));\n skipBody(context, line.indent);\n } else {\n body.whenRedelivered = { kind: 'SpecificationRedeliverySyntax', eventType: match[1], reaction: match[2], ...parseValuesWithEventSource(context, line, undefined, undefined, 'when redelivered'), location: locationOf(line) };\n }\n return;\n }\n if (whenClockPrefix.test(line.content)) {\n body.whenClock = parseClock(context, line, 'when');\n return;\n }\n if (whenTriggerPrefix.test(line.content)) {\n body.whenTrigger = parseNamedStep(context, line, whenTriggerPattern, DiagnosticCodes.InvalidSpecificationTrigger, 'when trigger', 'when trigger <Trigger>',\n (trigger, values) => ({ kind: 'SpecificationTriggerSyntax', trigger, values, location: locationOf(line) }));\n return;\n }\n if (whenCapturePrefix.test(line.content)) {\n body.whenCapture = parseCapture(context, line, 'when');\n return;\n }\n if (whenQueryPrefix.test(line.content)) {\n body.whenQuery = parseNamedStep(context, line, whenQueryPattern, DiagnosticCodes.InvalidSpecificationQueryAction, 'when query', 'when query <Query>',\n (query, values) => ({ kind: 'SpecificationWhenQuerySyntax', query, arguments: values, location: locationOf(line) }), true);\n return;\n }\n const match = whenPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationWhen, `Invalid 'when' declaration '${line.content}' - expected 'when <CommandType>' or 'when append <EventType>'`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n const generatedValues: PropertyMappingSyntax[] = [];\n const values = parseValuesWithEventSource(context, line, generatedValues, match);\n body.when = { kind: 'SpecificationCommandSyntax', commandType: match[1], ...values, generatedValues, inlineProperty: match.groups?.property ?? null, location: locationOf(line) };\n}\n\nfunction parseThen(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n if (noEventsPrefix.test(line.content)) {\n if (line.content !== 'then no events' || body.thenNoEvents) {\n context.error(DiagnosticCodes.InvalidNoEventsExpectation, \"Expected one 'then no events' directive.\", locationOf(line));\n } else {\n body.thenNoEvents = true;\n body.noEventsLine = line;\n }\n const child = context.peekChild(line.indent);\n if (child !== undefined) context.error(DiagnosticCodes.InvalidNoEventsExpectation, \"'then no events' cannot have child mappings.\", locationOf(child));\n skipBody(context, line.indent);\n return;\n }\n if (thenReturnsPrefix.test(line.content)) {\n const expectation = parseReturn(context, line);\n if (body.thenReturns !== null) {\n context.error(DiagnosticCodes.InvalidReturnExpectation, 'A specification declares at most one return expectation.', locationOf(line));\n } else {\n body.thenReturns = expectation;\n }\n return;\n }\n if (line.content.startsWith('then events')) {\n if (line.content !== 'then events in any order' || body.thenEventsInAnyOrder) {\n context.error(DiagnosticCodes.InvalidSpecificationEventOrder, 'Expected one \\'then events in any order\\' directive.', locationOf(line));\n } else {\n body.thenEventsInAnyOrder = true;\n }\n skipBody(context, line.indent);\n return;\n }\n if (thenResultPrefix.test(line.content)) {\n parseResult(context, line, body);\n return;\n }\n if (noResultPrefix.test(line.content)) {\n if (line.content !== 'then no result' || body.thenNoResult !== null) {\n context.error(DiagnosticCodes.InvalidSpecificationQueryAction, 'Expected one \\'then no result\\' directive.', locationOf(line));\n } else {\n body.thenNoResult = { kind: 'SpecificationNoResultSyntax', location: locationOf(line) };\n }\n skipBody(context, line.indent);\n return;\n }\n if (thenInvokesPrefix.test(line.content)) {\n const invocation = parseNamedStep(context, line, thenInvokesPattern, DiagnosticCodes.InvalidSpecificationInvocation, 'then invokes', 'then invokes <Command>',\n (command, values): SpecificationInvocationSyntax => ({ kind: 'SpecificationInvocationSyntax', command, values, location: locationOf(line) }));\n if (invocation !== null) (body.thenInvocations ??= []).push(invocation);\n return;\n }\n if (line.content.startsWith('then denied')) {\n if (line.content !== 'then denied') {\n context.error(DiagnosticCodes.InvalidSpecificationDenied, 'Expected exactly \\'then denied\\'.', locationOf(line));\n skipBody(context, line.indent);\n } else if (body.thenDenied !== null) {\n context.error(DiagnosticCodes.DuplicateSpecificationCallerOrDenied, \"A specification has at most one 'then denied' outcome.\", locationOf(line));\n } else {\n body.thenDenied = { kind: 'SpecificationDeniedSyntax', location: locationOf(line) };\n }\n return;\n }\n if (line.content === 'then error') {\n body.thenErrors.push({ kind: 'SpecificationErrorSyntax', name: null, location: locationOf(line) });\n return;\n }\n if (line.content.startsWith('then error case.')) {\n const caseValue = parseMappingSource(line.content.substring(11), { ...locationOf(line), column: locationOf(line).column + 11 }, context);\n if (caseValue.kind === 'CaseValueExpressionSyntax') body.thenErrors.push({ kind: 'SpecificationErrorSyntax', name: null, caseValue, location: locationOf(line) });\n return;\n }\n const error = thenErrorPattern.exec(line.content);\n if (error !== null) {\n body.thenErrors.push({ kind: 'SpecificationErrorSyntax', name: unescapeString(error[1]), location: locationOf(line) });\n return;\n }\n if (firstWord(line.content.substring('then'.length).trim()) === 'error') {\n context.error(DiagnosticCodes.InvalidThenError, `Invalid 'then error' declaration '${line.content}' - expected 'then error' or 'then error \"<reason>\"'`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n if (thenNoPrefix.test(line.content)) {\n // Legacy documents keep skipping these assertions silently; Exact mirrors the native diagnostics.\n if (context.sourceOptions.numericMode === 'exact') {\n const absent = parseAbsentReadModel(context, line);\n if (absent !== null) body.thenAbsentReadModels.push(absent);\n return;\n }\n const match = thenAbsentReadModelPattern.exec(line.content);\n if (match !== null && !match[2].endsWith(' exactly')) {\n const key = parseMappingSource(match[2].trim(), locationOf(line), context.valueContext);\n if (key.kind === 'LiteralExpressionSyntax' || key.kind === 'ObjectExpressionSyntax' || key.kind === 'CaseValueExpressionSyntax') body.thenAbsentReadModels.push({ kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key, location: locationOf(line) });\n }\n context.skipOpaqueBlock(line.indent);\n return;\n }\n if (thenQueryPrefix.test(line.content)) {\n // Legacy documents keep skipping malformed query bodies silently; Exact reports what the native parser reports.\n const exact = context.sourceOptions.numericMode === 'exact';\n const reject = (code: string, message: string, at: SourceLine): void => {\n if (!exact) return context.skipOpaqueBlock(at.indent);\n context.error(code, message, locationOf(at));\n context.skipBlock(at.indent);\n };\n const match = thenQueryPattern.exec(line.content);\n if (match === null) return reject(DiagnosticCodes.InvalidSpecificationQuery, `Invalid 'then query' declaration '${line.content}' - expected 'then query <Query> [exactly]'`, line);\n const args: PropertyMappingSyntax[] = [];\n const results: SpecificationQueryResultSyntax[] = [];\n let hasArguments = false;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'arguments' && !hasArguments) args.push(...parseValues(context.valueContext, child, true, undefined, context));\n else if (child.content === 'arguments') reject(DiagnosticCodes.DuplicateSpecificationQueryArguments, `Query assertion '${match[1]}' already declares arguments`, child);\n else if (child.content === 'result') results.push({ kind: 'SpecificationQueryResultSyntax', properties: parseValues(context.valueContext, child, true), exactly: false, location: locationOf(child) });\n else reject(DiagnosticCodes.UnknownSpecificationQueryDirective, `Unexpected '${firstWord(child.content)}' in 'then query' body - expected arguments or result`, child);\n hasArguments ||= child.content === 'arguments';\n }\n body.thenQueries.push({ kind: 'SpecificationQuerySyntax', query: match[1], arguments: args, results, exactly: match[2] !== undefined, location: locationOf(line) });\n return;\n }\n if (readModelPrefix.test(line.content)) {\n const readModel = parseReadModelStep(context, line, thenReadModelPattern, 'then');\n if (readModel !== undefined) {\n body.thenReadModels.push(readModel);\n }\n return;\n }\n const event = parseEventStep(context, line, thenEventPattern, 'then');\n if (event !== undefined) {\n body.thenEvents.push(event);\n }\n}\n\n// The Exact port of C# ParseAbsentReadModel: every malformed part is reported rather than dropped.\nfunction parseAbsentReadModel(context: ParserContext, line: SourceLine): SpecificationAbsentReadModelSyntax | null {\n const match = thenAbsentReadModelPattern.exec(line.content);\n if (match === null || match[2].endsWith(' exactly')) {\n context.error(DiagnosticCodes.InvalidAbsentReadModelStep, `Invalid absence assertion '${line.content}' - expected 'then no readmodel <ReadModelType> for <key>'`, locationOf(line));\n skipBody(context, line.indent);\n return null;\n }\n const keyText = match[2].trim();\n const validString = !(keyText.startsWith('\"') || keyText.startsWith(\"'\")) || absentKeyStringPattern.test(keyText);\n const key = validString ? parseMappingSource(keyText, locationOf(line), context.valueContext) : null;\n const concrete = key !== null && (key.kind === 'LiteralExpressionSyntax' || key.kind === 'ObjectExpressionSyntax' || key.kind === 'CaseValueExpressionSyntax');\n if (!concrete) context.error(DiagnosticCodes.InvalidAbsentReadModelStep, `Invalid absence key '${keyText}' - expected exactly one concrete value.`, locationOf(line));\n let hasChildren = false;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n context.error(DiagnosticCodes.InvalidAbsentReadModelStep, 'An absent read model assertion cannot have child mappings.', locationOf(child));\n hasChildren = true;\n }\n return hasChildren || !concrete ? null : { kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key, location: locationOf(line) } as SpecificationAbsentReadModelSyntax;\n}\n\nfunction skipBody(context: ParserContext, indent: number): void {\n if (context.sourceOptions.numericMode !== 'exact') return context.skipBlock(indent);\n context.skipOpaqueBlock(indent);\n}\n\nfunction parseClock(context: ParserContext, line: SourceLine, keyword: string): SpecificationClockSyntax | null {\n const match = clockPattern.exec(line.content);\n skipBody(context, line.indent);\n if (match === null || match[1] !== keyword) {\n context.error(containsCaseReference(line.content) ? DiagnosticCodes.InvalidSpecificationCaseReference : DiagnosticCodes.InvalidSpecificationClock,\n `Invalid '${keyword} clock' - expected '${keyword} clock \"<ISO 8601 instant>\"', such as '${keyword} clock \"2026-10-05T08:00:00Z\"'`, locationOf(line));\n return null;\n }\n return { kind: 'SpecificationClockSyntax', instant: match[2], location: locationOf(line) };\n}\n\nfunction parseGivenGenerated(context: ParserContext, line: SourceLine): SpecificationGeneratedValueSyntax | null {\n const match = givenGeneratedPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidGeneratedFixture, \"Expected 'given generated <Command>.<property> = <value>' with exactly one concrete value.\", locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n const location = locationOf(line);\n const source = parseConcrete(context, match[3], { ...location, column: location.column + line.content.indexOf(match[3], line.content.indexOf('=') + 1) }, DiagnosticCodes.InvalidGeneratedFixture);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidGeneratedFixture, 'A pinned generated value cannot have child directives.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return source === null ? null : { kind: 'SpecificationGeneratedValueSyntax', command: match[1], property: match[2], source, location };\n}\n\nfunction parseCapture(context: ParserContext, line: SourceLine, keyword: string): SpecificationCaptureSyntax | null {\n return parseNamedStep(context, line, capturePattern, DiagnosticCodes.InvalidSpecificationCapture, `${keyword} capture`, `${keyword} capture <Capture>`,\n (capture, record) => ({ kind: 'SpecificationCaptureSyntax', capture, record, location: locationOf(line) }));\n}\n\n// A step naming one thing on its header line, with '<field> = <value>' lines beneath it.\nfunction parseNamedStep<T>(\n context: ParserContext, line: SourceLine, regex: RegExp, code: string, keyword: string, expected: string,\n create: (name: string, values: PropertyMappingSyntax[]) => T, queryArguments = false): T | null {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(code, `Invalid '${keyword}' declaration '${line.content}' - expected '${expected}'`, locationOf(line));\n skipBody(context, line.indent);\n return null;\n }\n return create(match[1], parseValues(context, line, false, undefined, queryArguments ? context : undefined));\n}\n\nfunction parseResult(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n const match = thenResultPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationQueryAction, `Invalid 'then result' declaration '${line.content}' - expected 'then result [exactly]'`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n body.thenResults.push({ kind: 'SpecificationQueryResultSyntax', properties: parseValues(context, line), exactly: match[1] !== undefined, location: locationOf(line) });\n}\n\nfunction parseReadModelStep(context: ParserContext, line: SourceLine, regex: RegExp, keyword: string): SpecificationReadModelSyntax | undefined {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidReadModelStep, `Invalid '${keyword} readmodel' declaration '${line.content}' - expected '${keyword} readmodel <ReadModelType>'`, locationOf(line));\n skipBody(context, line.indent);\n return undefined;\n }\n return {\n kind: 'SpecificationReadModelSyntax',\n name: match[1],\n properties: parseValues(context, line, false, match),\n exactly: keyword === 'then' && match.groups?.exactly !== undefined,\n inlineProperty: match.groups?.property ?? null,\n location: locationOf(line),\n };\n}\n\nfunction parseEventStep(context: ParserContext, line: SourceLine, regex: RegExp, keyword: string): SpecificationEventSyntax | undefined {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidEventStep, `Invalid '${keyword}' declaration '${line.content}' - expected '${keyword} <EventType>'`, locationOf(line));\n skipBody(context, line.indent);\n return undefined;\n }\n return { kind: 'SpecificationEventSyntax', eventType: match[1], ...parseValuesWithEventSource(context, line, undefined, match, keyword), inlineProperty: match.groups?.property ?? null, location: locationOf(line) };\n}\n\nexport const specificationStream = sourceStreamPattern('^stream\\\\s+([A-Za-z_]\\\\w*)\\\\.([A-Za-z_]\\\\w*)$');\nconst specificationStreamId = pattern('^streamId\\\\s*=(?!=|>)\\\\s*(.+)$');\n\nfunction parseValuesWithEventSource(context: ParserContext, parent: SourceLine, generated?: PropertyMappingSyntax[], inline?: RegExpExecArray, eventKeyword?: string): { values: PropertyMappingSyntax[]; for: ExpressionSyntax | null; stream?: SpecificationStreamSyntax; noStream?: SpecificationNoStreamSyntax } {\n const values: PropertyMappingSyntax[] = [];\n addInlineValue(context, parent, inline, values);\n let eventSource: ExpressionSyntax | null = null;\n let stream: SpecificationStreamSyntax | undefined;\n let noStream: SpecificationNoStreamSyntax | undefined;\n let hasRoute = false;\n for (let child = context.peekChild(parent.indent); child !== undefined; child = context.peekChild(parent.indent)) {\n context.reader.takeSignificant();\n if (generated !== undefined && generatedFixturePrefix.test(child.content)) {\n const fixture = parseConcreteMapping(context, child, generatedFixturePattern, DiagnosticCodes.InvalidGeneratedFixture);\n if (fixture !== null) generated.push(fixture);\n continue;\n }\n const mapping = mappingPattern.exec(child.content);\n if (mapping !== null) {\n addFixtureValue(context, values, mappingOf(context, child, mapping));\n } else if (firstWord(child.content) === 'stream' || child.content.startsWith('no stream')) {\n if (eventKeyword === undefined) {\n context.error(DiagnosticCodes.SpecificationStreamOnCommand, 'A command occurrence cannot declare a route; assert it on a then event.', locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n if (hasRoute) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, 'An event occurrence declares at most one stream or no stream directive.', locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const route = specificationStream.exec(child.content);\n if (child.content === 'no stream' && (eventKeyword === 'then' || eventKeyword === 'when redelivered')) {\n noStream = { kind: 'SpecificationNoStreamSyntax', location: locationOf(child) };\n hasRoute = true;\n rejectSpecificationRouteChildren(context, child);\n } else if (route !== null) {\n stream = parseSpecificationStream(context, child, route);\n hasRoute = true;\n } else {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Expected 'stream Source.Stream', or 'no stream' on a then event.\", locationOf(child));\n context.skipBlock(child.indent);\n }\n } else if (firstWord(child.content) === 'for') {\n const source = child.content.substring('for'.length).trim();\n if (source.length === 0) {\n context.error(DiagnosticCodes.InvalidSpecificationEventSource, 'Invalid event-source assertion \\'for\\' - expected \\'for <value>\\'', locationOf(child));\n } else if (eventSource !== null) {\n context.error(DiagnosticCodes.DuplicateSpecificationEventSource, 'A specification step can declare its event-source assertion only once', locationOf(child));\n } else {\n eventSource = parseMappingSource(source, locationOf(child), context);\n }\n } else {\n context.error(DiagnosticCodes.InvalidSpecificationValue, `Invalid property mapping '${child.content}' - expected '<property> = <value>'`, locationOf(child), diagnosticText('text', child.content));\n }\n }\n return { values, for: eventSource, ...(stream === undefined ? {} : { stream }), ...(noStream === undefined ? {} : { noStream }) };\n}\n\nexport function parseSpecificationStream(context: ParserContext, header: SourceLine, route: RegExpExecArray): SpecificationStreamSyntax {\n let streamId: PropertyMappingSyntax | null = null;\n let streamIdParts: PropertyMappingSyntax[] = [];\n let block = false;\n const directiveLocations: Record<string, ReturnType<typeof locationOf>> = {};\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'streamId') {\n if (streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Declare either one 'streamId = <literal>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n } else {\n block = true;\n directiveLocations.streamId = locationOf(child);\n streamIdParts = parseRouteParts(context, child, DiagnosticCodes.InvalidSpecificationStream).map(part => part.source.kind === 'PathExpressionSyntax' && part.source.path.startsWith('case.')\n ? { ...part, source: parseMappingSource(part.source.path, part.source.location, context) } : part);\n }\n continue;\n }\n const mapping = specificationStreamId.exec(child.content);\n if (mapping === null || streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Declare either one 'streamId = <literal>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const location = { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(mapping[1], child.content.indexOf('=') + 1) };\n streamId = { kind: 'PropertyMappingSyntax', property: 'streamId', source: parseMappingSource(mapping[1], location, context), location: locationOf(child) };\n rejectSpecificationRouteChildren(context, child);\n }\n return { kind: 'SpecificationStreamSyntax', eventSource: route[1], stream: route[2], streamId, streamIdParts, directiveLocations,\n referenceLocation: { ...locationOf(header), column: header.indent + 1 + header.content.indexOf(route[1], 'stream'.length) },\n referenceLength: route[1].length + 1 + route[2].length, location: locationOf(header) };\n}\n\nexport function rejectSpecificationRouteChildren(context: ParserContext, line: SourceLine): void {\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, 'This directive cannot have children.', locationOf(child));\n context.skipBlock(line.indent);\n }\n}\n\nfunction parseValues(context: ParserContext, parent: SourceLine, nativeIdentifiers = false, inline?: RegExpExecArray, queryArgumentsContext?: ParserContext): PropertyMappingSyntax[] {\n const values: PropertyMappingSyntax[] = [];\n addInlineValue(context, parent, inline, values);\n for (let child = context.peekChild(parent.indent); child !== undefined; child = context.peekChild(parent.indent)) {\n context.reader.takeSignificant();\n const mapping = (nativeIdentifiers || context.sourceOptions.numericMode === 'exact' ? nativeMappingPattern : mappingPattern).exec(child.content);\n if (mapping === null) {\n context.error(DiagnosticCodes.InvalidSpecificationValue, `Invalid property mapping '${child.content}' - expected '<property> = <value>'`, locationOf(child), diagnosticText('text', child.content));\n continue;\n }\n const value = mappingOf(context, child, mapping, nativeIdentifiers);\n if (queryArgumentsContext !== undefined) {\n if (values.some(existing => existing.property === value.property)) {\n queryArgumentsContext.error(DiagnosticCodes.UnknownSpecificationQueryArgument, `Query argument '${value.property}' is repeated.`, value.location, diagnosticText('argument', value.property));\n }\n values.push(value);\n } else {\n addFixtureValue(context, values, value);\n }\n }\n return values;\n}\n\nfunction mappingOf(context: ParserContext, line: SourceLine, match: RegExpExecArray, nativeIdentifiers = false): PropertyMappingSyntax {\n return { kind: 'PropertyMappingSyntax', property: match[1], source: parseMappingSource(match[2], locationOf(line), context, nativeIdentifiers), location: locationOf(line) };\n}\n"],"mappings":"spCA2BA,MAAMC,EAAsBC,EAAQ,oEAAoE,EAClGC,EAAgBD,EAAQ,yGAAyG,EACjIE,EAASF,EAAQ,oCAAoC,EACrDG,EAAuBH,EAAQ,mCAAmC,EAGlE,aAAe,EAAgB,EAAU,KAAeI,EAAc,IAAIC,EAAO,6BAAiBC,8DAA8B,WAAW,MAAOC,CAAgB,CAAC,EACnKC,EAAe,YAAY,OAAO,EAClCC,EAAoB,YAAY,gBAAgB,EAChDC,EAAc,YAAY,MAAM,EAChCC,EAAmB,YAAY,MAAM,EACrCC,EAAkBZ,EAA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pattern","operationStep","header","specificationHeader","callerPersonaPattern","nativePattern","prefix","exactly","dotNetWhitespace","givenPattern","whenAppendPattern","whenPattern","thenEventPattern","thenQueryPrefix","readModelPrefix","givenReadModelPattern","thenReadModelPattern","thenNoPrefix","thenErrorPattern","stringBodyPattern","mappingPattern","nativeMappingPattern","givenTimeZonePrefix","givenTimeZonePattern","givenClockPrefix","givenCapturePrefix","thenInvokesPrefix","thenInvokesPattern","givenGeneratedPrefix","givenGeneratedPattern","givenGeneratedBlockPattern","whenClockPrefix","whenTriggerPrefix","whenCapturePrefix","whenQueryPrefix","thenResultPrefix","noResultPrefix","whenRedeliveredPrefix","whenRedeliveredPattern","noEventsPrefix","clockPattern","whenTriggerPattern","capturePattern","whenQueryPattern","thenResultPattern","thenAbsentReadModelPattern","absentKeyStringPattern","thenQueryPattern","name","line","context","DiagnosticCodes","locationOf","description","parameters","cases","body","child","isFileDirective","keyword","firstWord","parameter","parseParameter","row","parseCase","parseDescription","_","_noEventsLine","members","specification","validateTable","action","query","outcome","match","values","value","parseConcreteMapping","rejectOperationChildren","unescapeString","pinned","capture","readModel","event","callerRolePattern","callerClaimPattern","authenticated","roles","claims","role","claim","containsCaseReference","appends","code","generatedValues","thenReturnsPrefix","expectation","parseReturn","invocation","caseValue","parseSpecificationValue","error","absent","parseStructuredValue","key","exact","at","message","args","results","hasArguments","keyText","concrete","hasChildren","indent","block","location","source","parseConcrete","regex","expected","create","queryArguments","specificationStream","sourceStreamPattern","specificationStreamId","addInlineValue","parent","inline","eventSource","stream","noStream","hasRoute","structured","generated","generatedFixturePrefix","fixture","generatedFixturePattern","mapping","addFixtureValue","eventKeyword","route","tryParseStructuredMapping","diagnosticText","streamId","streamIdParts","directiveLocations","parseRouteParts","part","nativeIdentifiers","queryArgumentsContext","existing","lifecycleWhenStart","lifecycleOutcome","lifecycleThen","word","given","whenAppended","whenStarted","whenDeclared","outcomes","then","fact","start","index","sourceLocation"],"sources":["../../../../../../Compiler/Parsing/SpecificationParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { parseRouteParts } from './EventSourceParser';\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport {\n SpecificationCaptureSyntax, SpecificationClockSyntax, SpecificationTimeZoneSyntax, SpecificationGeneratedValueSyntax, SpecificationCommandSyntax, SpecificationErrorSyntax, SpecificationEventSyntax, SpecificationStreamSyntax, SpecificationNoStreamSyntax,\n SpecificationNoResultSyntax, SpecificationQueryResultSyntax, SpecificationReadModelSyntax, SpecificationSyntax, SpecificationTriggerSyntax,\n SpecificationWhenQuerySyntax, SpecificationCallerPersonaSyntax, SpecificationOperationFailureSyntax, SpecificationOperationSyntax, SpecificationCompensatedSyntax, SpecificationRedeliverySyntax,\n} from '../Syntax/Specifications';\nimport { SpecificationDeniedSyntax, SpecificationReturnSyntax } from '../Syntax/Responses';\nimport { dotNetWhitespace, nativePattern, pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { containsCaseReference, parseCase, parseParameter, parseSpecificationValue as parseMappingSource, validateTable } from './SpecificationCaseParser';\nimport { parseDescription } from './DescriptionParser';\nimport { isFileDirective } from './FileReferences';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { addFixtureValue, addInlineValue } from './SpecificationExampleParser';\nimport { rejectOperationChildren } from './OperationParser';\nimport { generatedFixturePattern, generatedFixturePrefix, parseConcrete, parseConcreteMapping, parseReturn, thenReturnsPrefix } from './SpecificationResponseParser';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { SourceLocation, sourceLocation } from '../Diagnostics/SourceLocation';\nimport { LifecycleExpectationKind, LifecycleExpectationSyntax, LifecycleOutcomeSyntax, LifecycleSpecificationSyntax } from '../Syntax/Lifecycles';\nimport { SpecificationAbsentReadModelSyntax, SpecificationCallerClaimSyntax, SpecificationCallerSyntax, SpecificationInvocationSyntax, SpecificationQuerySyntax } from '../Syntax/Specifications';\nimport { parseStructuredValue, StructuredMarker, tryParseStructuredMapping } from './StructuredBlockParser';\n\nconst operationStepPrefix = pattern('^(?:given\\\\s+operation|then\\\\s+(?:operation|compensated))(?:\\\\s|$)');\nconst operationStep = pattern('^(given operation|then operation|then compensated)\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)(\\\\s+fails)?$');\nconst header = pattern('^specification\\\\s+([A-Za-z_]\\\\w*)$');\nconst specificationHeader = header;\nconst callerPersonaPattern = pattern('^given caller as ([A-Za-z_]\\\\w*)$');\nconst stepName = '([A-Z]\\\\w*(?:\\\\.\\\\w+)*)';\nconst inlineAssignment = '(?:\\\\s+(?<property>[\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(?<value>.+))?';\nconst stepPattern = (prefix: string, exactly = ''): RegExp => nativePattern(`^${prefix}\\\\s+${stepName}${exactly}${inlineAssignment}$`.replaceAll('\\\\s', dotNetWhitespace));\nconst givenPattern = stepPattern('given');\nconst whenAppendPattern = stepPattern('when\\\\s+append');\nconst whenPattern = stepPattern('when');\nconst thenEventPattern = stepPattern('then');\nconst thenQueryPrefix = pattern('^then\\\\s+query\\\\b');\nconst readModelPrefix = pattern('^(?:given|then)\\\\s+readmodel\\\\b');\nconst givenReadModelPattern = stepPattern('given\\\\s+readmodel');\nconst thenReadModelPattern = stepPattern('then\\\\s+readmodel', '(?<exactly>\\\\s+exactly)?');\nconst thenNoPrefix = pattern('^then\\\\s+no\\\\b');\nconst thenErrorPattern = pattern(`^then\\\\s+error\\\\s+\"(${stringBodyPattern})\"$`);\nconst mappingPattern = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst nativeMappingPattern = nativePattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst givenTimeZonePrefix = pattern('^given\\\\s+time\\\\s+zone\\\\b');\nconst givenTimeZonePattern = pattern(`^given\\\\s+time\\\\s+zone\\\\s+\"(${stringBodyPattern})\"$`);\nconst givenClockPrefix = pattern('^given\\\\s+clock\\\\b');\nconst givenCapturePrefix = pattern('^given\\\\s+capture\\\\b');\nconst thenInvokesPrefix = pattern('^then\\\\s+invokes\\\\b');\nconst thenInvokesPattern = pattern('^then\\\\s+invokes\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)$');\nconst givenGeneratedPrefix = pattern('^given\\\\s+generated\\\\b');\nconst givenGeneratedPattern = pattern('^given\\\\s+generated\\\\s+([A-Z]\\\\w*)\\\\.([a-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst givenGeneratedBlockPattern = pattern('^given\\\\s+generated\\\\s+([A-Z]\\\\w*)\\\\.([a-z_]\\\\w*)(?:\\\\s+(none|empty))?$');\nconst whenClockPrefix = pattern('^when\\\\s+clock\\\\b');\nconst whenTriggerPrefix = pattern('^when\\\\s+trigger\\\\b');\nconst whenCapturePrefix = pattern('^when\\\\s+capture\\\\b');\nconst whenQueryPrefix = pattern('^when\\\\s+query\\\\b');\nconst thenResultPrefix = pattern('^then\\\\s+result\\\\b');\nconst noResultPrefix = pattern('^then\\\\s+no\\\\s+result\\\\b');\nconst whenRedeliveredPrefix = nativePattern('^when\\\\s+redelivered\\\\b');\nconst whenRedeliveredPattern = nativePattern('^when\\\\s+redelivered\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)\\\\s+to\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst noEventsPrefix = pattern('^then\\\\s+no\\\\s+events\\\\b');\n\n// An instant in ISO 8601 - a date, a time to the minute or finer, and an explicit offset or Z - so the same text\n// means the same moment wherever the specification runs.\nconst clockPattern = pattern('^(given|when)\\\\s+clock\\\\s+\"(\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}(?::\\\\d{2}(?:\\\\.\\\\d+)?)?(?:Z|[+-]\\\\d{2}:\\\\d{2}))\"$');\nconst whenTriggerPattern = pattern('^when\\\\s+trigger\\\\s+([A-Za-z_]\\\\w*)$');\nconst capturePattern = pattern('^(?:given|when)\\\\s+capture\\\\s+([A-Za-z_]\\\\w*)$');\nconst whenQueryPattern = pattern('^when\\\\s+query\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst thenResultPattern = pattern('^then\\\\s+result(\\\\s+exactly)?$');\nconst thenAbsentReadModelPattern = nativePattern('^then\\\\s+no\\\\s+readmodel\\\\s+([A-Z]\\\\w*)\\\\s+for(?:\\\\s+(.+))?$');\nconst absentKeyStringPattern = nativePattern(`^(?:\"${stringBodyPattern}\"|'(?:[^'\\\\\\\\]|\\\\\\\\.)*')$`);\nconst thenQueryPattern = nativePattern('^then\\\\s+query\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)(\\\\s+exactly)?$');\n\ninterface SpecificationBody {\n given: SpecificationEventSyntax[];\n givenReadModels: SpecificationReadModelSyntax[];\n when: SpecificationCommandSyntax | null;\n whenAppended: SpecificationEventSyntax | null;\n whenRedelivered: SpecificationRedeliverySyntax | null;\n whenDeclared: boolean;\n thenEvents: SpecificationEventSyntax[];\n thenEventsInAnyOrder: boolean;\n thenNoEvents: boolean;\n noEventsLine?: SourceLine;\n thenReadModels: SpecificationReadModelSyntax[];\n thenErrors: SpecificationErrorSyntax[];\n thenAbsentReadModels: SpecificationAbsentReadModelSyntax[];\n thenQueries: SpecificationQuerySyntax[];\n givenClock: SpecificationClockSyntax | null;\n givenTimeZone: SpecificationTimeZoneSyntax | null;\n givenCaptures: SpecificationCaptureSyntax[];\n givenGenerated?: SpecificationGeneratedValueSyntax[];\n whenClock: SpecificationClockSyntax | null;\n whenTrigger: SpecificationTriggerSyntax | null;\n whenCapture: SpecificationCaptureSyntax | null;\n whenQuery: SpecificationWhenQuerySyntax | null;\n thenResults: SpecificationQueryResultSyntax[];\n thenNoResult: SpecificationNoResultSyntax | null;\n thenDenied: SpecificationDeniedSyntax | null;\n givenCaller: SpecificationCallerSyntax | null;\n givenCallerPersona?: SpecificationCallerPersonaSyntax;\n thenReturns: SpecificationReturnSyntax | null;\n givenOperationFailures: SpecificationOperationFailureSyntax[];\n thenOperations: SpecificationOperationSyntax[];\n thenCompensated: SpecificationCompensatedSyntax[];\n thenInvocations?: SpecificationInvocationSyntax[];\n}\n\nexport function parseSpecification(context: ParserContext, line: SourceLine): SpecificationSyntax {\n const name = header.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidSpecificationDeclaration, `Invalid specification declaration '${line.content}' - expected 'specification <Name>'`, locationOf(line));\n }\n let description: string | null = null;\n const parameters: NonNullable<SpecificationSyntax['parameters']>[number][] = [];\n const cases: NonNullable<SpecificationSyntax['cases']>[number][] = [];\n const body: SpecificationBody = {\n givenOperationFailures: [], thenOperations: [], thenCompensated: [], thenAbsentReadModels: [], thenQueries: [],\n given: [], givenReadModels: [], when: null, whenAppended: null, whenRedelivered: null, whenDeclared: false,\n thenEvents: [], thenEventsInAnyOrder: false, thenNoEvents: false, thenReadModels: [], thenErrors: [],\n givenClock: null, givenTimeZone: null, givenCaptures: [], whenClock: null, whenTrigger: null, whenCapture: null, whenQuery: null, thenResults: [], thenNoResult: null, thenDenied: null, givenCaller: null, thenReturns: null,\n };\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (isFileDirective(child)) {\n continue;\n }\n if (parseOperationStep(context, child, body)) continue;\n // Absence assertions admit any whitespace after 'then'; every other directive keeps its first word.\n const keyword = thenNoPrefix.test(child.content) ? 'then' : firstWord(child.content);\n if (keyword === 'parameter') {\n const parameter = parseParameter(context, child);\n if (parameter !== null) parameters.push(parameter);\n } else if (keyword === 'case') {\n const row = parseCase(context, child);\n if (row !== null) cases.push(row);\n } else if (keyword === 'description') {\n description = parseDescription(context, child, description, `Specification '${name}'`);\n } else if (keyword === 'given') {\n parseGiven(context, child, body);\n } else if (keyword === 'when') {\n parseWhen(context, child, body, name);\n } else if (keyword === 'then') {\n parseThen(context, child, body);\n } else {\n context.error(DiagnosticCodes.UnknownSpecificationDirective, `Unexpected '${firstWord(child.content)}' in specification body`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n if (body.noEventsLine !== undefined && (body.thenEvents.length > 0 || body.thenEventsInAnyOrder || body.thenErrors.length > 0 || body.thenDenied !== null)) {\n context.error(DiagnosticCodes.InvalidNoEventsExpectation,\n \"'then no events' cannot accompany event, event-order, error or denial expectations.\", locationOf(body.noEventsLine));\n }\n validateQueryRejection(context, line, body);\n const { whenDeclared: _, noEventsLine: _noEventsLine, ...members } = body;\n const specification: SpecificationSyntax = { kind: 'SpecificationSyntax', sourceOptions: context.sourceOptions, name, description, ...members,\n ...(parameters.length === 0 ? {} : { parameters }), ...(cases.length === 0 ? {} : { cases }), location: locationOf(line) };\n validateTable(specification, context);\n return specification;\n}\n\nfunction validateQueryRejection(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n if (!isQueryRejectionCandidate(body) || isWellFormedQueryRejection(body)) return;\n context.error(DiagnosticCodes.MismatchedSpecificationQueryResult,\n \"A query rejection requires exactly one query and one 'then error', no action, and no other outcomes\", locationOf(line));\n}\n\nfunction isQueryRejectionCandidate(body: SpecificationBody): boolean {\n return body.thenErrors.length > 0 && queriedCallCount(body) > 0 && (body.whenQuery !== null || !hasAction(body));\n}\n\nfunction isWellFormedQueryRejection(body: SpecificationBody): boolean {\n return !hasAction(body) && hasOneQueryAndOneError(body) && !hasOtherOutcome(body);\n}\n\nfunction hasOneQueryAndOneError(body: SpecificationBody): boolean {\n return queriedCallCount(body) === 1 && body.thenErrors.length === 1;\n}\n\nfunction hasAction(body: SpecificationBody): boolean {\n return [body.when, body.whenAppended, body.whenClock, body.whenTrigger, body.whenCapture, body.whenRedelivered].some(action => action !== null);\n}\n\nfunction queriedCallCount(body: SpecificationBody): number {\n return body.thenQueries.length + (body.whenQuery === null ? 0 : 1);\n}\n\nfunction hasOtherOutcome(body: SpecificationBody): boolean {\n return [\n body.thenResults.length > 0,\n body.thenNoResult !== null,\n body.thenDenied !== null,\n body.thenEvents.length > 0,\n body.thenNoEvents,\n body.thenEventsInAnyOrder,\n body.thenReadModels.length > 0,\n body.thenAbsentReadModels.length > 0,\n body.thenReturns !== null,\n body.thenQueries.some(query => query.results.length > 0)\n ].some(outcome => outcome);\n}\n\nfunction parseOperationStep(context: ParserContext, line: SourceLine, body: SpecificationBody): boolean {\n if (!operationStepPrefix.test(line.content)) return false;\n const match = operationStep.exec(line.content);\n if (match === null || (match[1] === 'given operation') !== (match[3] !== undefined)) {\n context.error(DiagnosticCodes.InvalidOperationSpecification, \"Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.\", locationOf(line));\n skipBody(context, line.indent);\n } else if (match[1] === 'then operation') {\n const values: PropertyMappingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const value = parseConcreteMapping(context, child, mappingPattern, DiagnosticCodes.InvalidOperationSpecification);\n if (value !== null) values.push(value);\n }\n body.thenOperations.push({ kind: 'SpecificationOperationSyntax', operation: match[2], values, location: locationOf(line) });\n } else {\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidOperationSpecification, 'Failure and compensation assertions cannot have children.');\n if (match[1] === 'given operation') body.givenOperationFailures.push({ kind: 'SpecificationOperationFailureSyntax', operation: match[2], location: locationOf(line) });\n else body.thenCompensated.push({ kind: 'SpecificationCompensatedSyntax', operation: match[2], location: locationOf(line) });\n }\n return true;\n}\n\nfunction parseGiven(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n if (givenClockPrefix.test(line.content)) {\n if (body.givenClock !== null) {\n context.error(DiagnosticCodes.InvalidSpecificationClock, 'A specification states its clock at most once.', locationOf(line));\n skipBody(context, line.indent);\n } else {\n body.givenClock = parseClock(context, line, 'given');\n }\n } else if (givenTimeZonePrefix.test(line.content)) {\n const match = givenTimeZonePattern.exec(line.content);\n skipBody(context, line.indent);\n if (body.givenTimeZone !== null || match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationTimeZone, \"A specification states its time zone at most once, as 'given time zone \\\"<id>\\\"'.\", locationOf(line));\n } else {\n body.givenTimeZone = { kind: 'SpecificationTimeZoneSyntax', id: unescapeString(match[1]), location: locationOf(line) };\n }\n } else if (givenGeneratedPrefix.test(line.content)) {\n const pinned = parseGivenGenerated(context, line);\n if (pinned !== null) {\n (body.givenGenerated ??= []).push(pinned);\n }\n } else if (givenCapturePrefix.test(line.content)) {\n const capture = parseCapture(context, line, 'given');\n if (capture !== null) {\n body.givenCaptures.push(capture);\n }\n } else if (line.content.startsWith('given caller')) {\n if (body.givenCaller !== null || body.givenCallerPersona !== undefined) {\n context.error(DiagnosticCodes.DuplicateSpecificationCallerOrDenied, \"A specification has at most one 'given caller' block.\", locationOf(line));\n context.skipBlock(line.indent);\n } else if (line.content.startsWith('given caller as')) {\n const match = callerPersonaPattern.exec(line.content);\n if (match === null) context.error(DiagnosticCodes.InvalidSpecificationCallerPersona, \"Expected 'given caller as <Persona>'.\", locationOf(line));\n const child = context.peekChild(line.indent);\n if (child !== undefined) context.error(DiagnosticCodes.InvalidSpecificationCallerPersona, \"'given caller as <Persona>' has no body; use an explicit 'given caller' for refinements.\", locationOf(child));\n skipBody(context, line.indent);\n if (match !== null) body.givenCallerPersona = { kind: 'SpecificationCallerPersonaSyntax', name: match[1], location: locationOf(line) };\n } else {\n body.givenCaller = parseCaller(context, line);\n }\n } else if (readModelPrefix.test(line.content)) {\n const readModel = parseReadModelStep(context, line, givenReadModelPattern, 'given');\n if (readModel !== undefined) {\n body.givenReadModels.push(readModel);\n }\n } else {\n const event = parseEventStep(context, line, givenPattern, 'given');\n if (event !== undefined) {\n body.given.push(event);\n }\n }\n}\n\nconst callerRolePattern = pattern(`^role${dotNetWhitespace}+\"(${stringBodyPattern})\"$`);\nconst callerClaimPattern = pattern(`^claim${dotNetWhitespace}+\"(${stringBodyPattern})\"${dotNetWhitespace}*=${dotNetWhitespace}*\"(${stringBodyPattern})\"$`);\n\n// 'given caller' and the authenticated, role and claim lines under it.\nfunction parseCaller(context: ParserContext, line: SourceLine): SpecificationCallerSyntax | null {\n if (line.content !== 'given caller') {\n context.error(DiagnosticCodes.InvalidSpecificationCaller, \"Expected exactly 'given caller'.\", locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n let authenticated = false;\n const roles: string[] = [];\n const claims: SpecificationCallerClaimSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const role = callerRolePattern.exec(child.content);\n const claim = callerClaimPattern.exec(child.content);\n if (child.content === 'authenticated' && !authenticated) {\n authenticated = true;\n } else if (role !== null) {\n roles.push(unescapeString(role[1]));\n } else if (claim !== null) {\n claims.push({ kind: 'SpecificationCallerClaimSyntax', type: unescapeString(claim[1]), value: unescapeString(claim[2]), location: locationOf(child) });\n } else {\n context.error(containsCaseReference(child.content) ? DiagnosticCodes.InvalidSpecificationCaseReference : DiagnosticCodes.InvalidSpecificationCaller, `Invalid caller fixture '${child.content}' - expected authenticated, role \"...\", or claim \"...\" = \"...\".`, locationOf(child));\n }\n }\n return { kind: 'SpecificationCallerSyntax', authenticated, roles, claims, location: locationOf(line) };\n}\n\nfunction parseWhen(context: ParserContext, line: SourceLine, body: SpecificationBody, name: string): void {\n const appends = line.content.startsWith('when append');\n if (body.whenDeclared) {\n const code = body.whenAppended !== null || appends ? DiagnosticCodes.ConflictingSpecificationActions : DiagnosticCodes.DuplicateSpecificationWhen;\n context.error(code, `Specification '${name}' already declares a 'when' - a specification can have at most one`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n body.whenDeclared = true;\n if (appends) {\n body.whenAppended = parseEventStep(context, line, whenAppendPattern, 'when append') ?? null;\n return;\n }\n if (whenRedeliveredPrefix.test(line.content)) {\n const match = whenRedeliveredPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnmatchedRedeliveredOccurrence, \"Expected 'when redelivered <Event> to <Reaction>'.\", locationOf(line));\n skipBody(context, line.indent);\n } else {\n body.whenRedelivered = { kind: 'SpecificationRedeliverySyntax', eventType: match[1], reaction: match[2], ...parseValuesWithEventSource(context, line, undefined, undefined, 'when redelivered'), location: locationOf(line) };\n }\n return;\n }\n if (whenClockPrefix.test(line.content)) {\n body.whenClock = parseClock(context, line, 'when');\n return;\n }\n if (whenTriggerPrefix.test(line.content)) {\n body.whenTrigger = parseNamedStep(context, line, whenTriggerPattern, DiagnosticCodes.InvalidSpecificationTrigger, 'when trigger', 'when trigger <Trigger>',\n (trigger, values) => ({ kind: 'SpecificationTriggerSyntax', trigger, values, location: locationOf(line) }));\n return;\n }\n if (whenCapturePrefix.test(line.content)) {\n body.whenCapture = parseCapture(context, line, 'when');\n return;\n }\n if (whenQueryPrefix.test(line.content)) {\n body.whenQuery = parseNamedStep(context, line, whenQueryPattern, DiagnosticCodes.InvalidSpecificationQueryAction, 'when query', 'when query <Query>',\n (query, values) => ({ kind: 'SpecificationWhenQuerySyntax', query, arguments: values, location: locationOf(line) }), true);\n return;\n }\n const match = whenPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationWhen, `Invalid 'when' declaration '${line.content}' - expected 'when <CommandType>' or 'when append <EventType>'`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n const generatedValues: PropertyMappingSyntax[] = [];\n const values = parseValuesWithEventSource(context, line, generatedValues, match);\n body.when = { kind: 'SpecificationCommandSyntax', commandType: match[1], ...values, generatedValues, inlineProperty: match.groups?.property ?? null, location: locationOf(line) };\n}\n\nfunction parseThen(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n if (noEventsPrefix.test(line.content)) {\n if (line.content !== 'then no events' || body.thenNoEvents) {\n context.error(DiagnosticCodes.InvalidNoEventsExpectation, \"Expected one 'then no events' directive.\", locationOf(line));\n } else {\n body.thenNoEvents = true;\n body.noEventsLine = line;\n }\n const child = context.peekChild(line.indent);\n if (child !== undefined) context.error(DiagnosticCodes.InvalidNoEventsExpectation, \"'then no events' cannot have child mappings.\", locationOf(child));\n skipBody(context, line.indent);\n return;\n }\n if (thenReturnsPrefix.test(line.content)) {\n const expectation = parseReturn(context, line);\n if (body.thenReturns !== null) {\n context.error(DiagnosticCodes.InvalidReturnExpectation, 'A specification declares at most one return expectation.', locationOf(line));\n } else {\n body.thenReturns = expectation;\n }\n return;\n }\n if (line.content.startsWith('then events')) {\n if (line.content !== 'then events in any order' || body.thenEventsInAnyOrder) {\n context.error(DiagnosticCodes.InvalidSpecificationEventOrder, 'Expected one \\'then events in any order\\' directive.', locationOf(line));\n } else {\n body.thenEventsInAnyOrder = true;\n }\n skipBody(context, line.indent);\n return;\n }\n if (thenResultPrefix.test(line.content)) {\n parseResult(context, line, body);\n return;\n }\n if (noResultPrefix.test(line.content)) {\n if (line.content !== 'then no result' || body.thenNoResult !== null) {\n context.error(DiagnosticCodes.InvalidSpecificationQueryAction, 'Expected one \\'then no result\\' directive.', locationOf(line));\n } else {\n body.thenNoResult = { kind: 'SpecificationNoResultSyntax', location: locationOf(line) };\n }\n skipBody(context, line.indent);\n return;\n }\n if (thenInvokesPrefix.test(line.content)) {\n const invocation = parseNamedStep(context, line, thenInvokesPattern, DiagnosticCodes.InvalidSpecificationInvocation, 'then invokes', 'then invokes <Command>',\n (command, values): SpecificationInvocationSyntax => ({ kind: 'SpecificationInvocationSyntax', command, values, location: locationOf(line) }));\n if (invocation !== null) (body.thenInvocations ??= []).push(invocation);\n return;\n }\n if (line.content.startsWith('then denied')) {\n if (line.content !== 'then denied') {\n context.error(DiagnosticCodes.InvalidSpecificationDenied, 'Expected exactly \\'then denied\\'.', locationOf(line));\n skipBody(context, line.indent);\n } else if (body.thenDenied !== null) {\n context.error(DiagnosticCodes.DuplicateSpecificationCallerOrDenied, \"A specification has at most one 'then denied' outcome.\", locationOf(line));\n } else {\n body.thenDenied = { kind: 'SpecificationDeniedSyntax', location: locationOf(line) };\n }\n return;\n }\n if (line.content === 'then error') {\n body.thenErrors.push({ kind: 'SpecificationErrorSyntax', name: null, location: locationOf(line) });\n return;\n }\n if (line.content.startsWith('then error case.')) {\n const caseValue = parseMappingSource(line.content.substring(11), { ...locationOf(line), column: locationOf(line).column + 11 }, context);\n if (caseValue.kind === 'CaseValueExpressionSyntax') body.thenErrors.push({ kind: 'SpecificationErrorSyntax', name: null, caseValue, location: locationOf(line) });\n return;\n }\n const error = thenErrorPattern.exec(line.content);\n if (error !== null) {\n body.thenErrors.push({ kind: 'SpecificationErrorSyntax', name: unescapeString(error[1]), location: locationOf(line) });\n return;\n }\n if (firstWord(line.content.substring('then'.length).trim()) === 'error') {\n context.error(DiagnosticCodes.InvalidThenError, `Invalid 'then error' declaration '${line.content}' - expected 'then error' or 'then error \"<reason>\"'`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n if (thenNoPrefix.test(line.content)) {\n // Legacy documents keep skipping these assertions silently; Exact mirrors the native diagnostics.\n if (context.sourceOptions.numericMode === 'exact') {\n const absent = parseAbsentReadModel(context, line);\n if (absent !== null) body.thenAbsentReadModels.push(absent);\n return;\n }\n const match = thenAbsentReadModelPattern.exec(line.content);\n if (match !== null && match[2] === undefined && context.peekChild(line.indent) !== undefined) {\n // 'for' ending the line opens the key's members as an indented block.\n body.thenAbsentReadModels.push({ kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key: parseStructuredValue(context.valueContext, line, undefined), location: locationOf(line) });\n return;\n }\n if (match !== null && match[2] !== undefined && !match[2].endsWith(' exactly')) {\n const key = parseMappingSource(match[2].trim(), locationOf(line), context.valueContext);\n if (key.kind === 'LiteralExpressionSyntax' || key.kind === 'ObjectExpressionSyntax' || key.kind === 'CaseValueExpressionSyntax') body.thenAbsentReadModels.push({ kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key, location: locationOf(line) });\n }\n context.skipOpaqueBlock(line.indent);\n return;\n }\n if (thenQueryPrefix.test(line.content)) {\n // Legacy documents keep skipping malformed query bodies silently; Exact reports what the native parser reports.\n const exact = context.sourceOptions.numericMode === 'exact';\n const reject = (code: string, message: string, at: SourceLine): void => {\n if (!exact) return context.skipOpaqueBlock(at.indent);\n context.error(code, message, locationOf(at));\n context.skipBlock(at.indent);\n };\n const match = thenQueryPattern.exec(line.content);\n if (match === null) return reject(DiagnosticCodes.InvalidSpecificationQuery, `Invalid 'then query' declaration '${line.content}' - expected 'then query <Query> [exactly]'`, line);\n const args: PropertyMappingSyntax[] = [];\n const results: SpecificationQueryResultSyntax[] = [];\n let hasArguments = false;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'arguments' && !hasArguments) args.push(...parseValues(context.valueContext, child, true, undefined, context));\n else if (child.content === 'arguments') reject(DiagnosticCodes.DuplicateSpecificationQueryArguments, `Query assertion '${match[1]}' already declares arguments`, child);\n else if (child.content === 'result') results.push({ kind: 'SpecificationQueryResultSyntax', properties: parseValues(context.valueContext, child, true), exactly: false, location: locationOf(child) });\n else reject(DiagnosticCodes.UnknownSpecificationQueryDirective, `Unexpected '${firstWord(child.content)}' in 'then query' body - expected arguments or result`, child);\n hasArguments ||= child.content === 'arguments';\n }\n body.thenQueries.push({ kind: 'SpecificationQuerySyntax', query: match[1], arguments: args, results, exactly: match[2] !== undefined, location: locationOf(line) });\n return;\n }\n if (readModelPrefix.test(line.content)) {\n const readModel = parseReadModelStep(context, line, thenReadModelPattern, 'then');\n if (readModel !== undefined) {\n body.thenReadModels.push(readModel);\n }\n return;\n }\n const event = parseEventStep(context, line, thenEventPattern, 'then');\n if (event !== undefined) {\n body.thenEvents.push(event);\n }\n}\n\n// The Exact port of C# ParseAbsentReadModel: every malformed part is reported rather than dropped.\nfunction parseAbsentReadModel(context: ParserContext, line: SourceLine): SpecificationAbsentReadModelSyntax | null {\n const match = thenAbsentReadModelPattern.exec(line.content);\n if (match !== null && match[2] === undefined && context.peekChild(line.indent) !== undefined) {\n return { kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key: parseStructuredValue(context, line, undefined), location: locationOf(line) } as SpecificationAbsentReadModelSyntax;\n }\n if (match === null || match[2] === undefined || match[2].endsWith(' exactly')) {\n context.error(DiagnosticCodes.InvalidAbsentReadModelStep, `Invalid absence assertion '${line.content}' - expected 'then no readmodel <ReadModelType> for <key>'`, locationOf(line));\n skipBody(context, line.indent);\n return null;\n }\n const keyText = match[2].trim();\n const validString = !(keyText.startsWith('\"') || keyText.startsWith(\"'\")) || absentKeyStringPattern.test(keyText);\n const key = validString ? parseMappingSource(keyText, locationOf(line), context.valueContext) : null;\n const concrete = key !== null && (key.kind === 'LiteralExpressionSyntax' || key.kind === 'ObjectExpressionSyntax' || key.kind === 'CaseValueExpressionSyntax');\n if (!concrete) context.error(DiagnosticCodes.InvalidAbsentReadModelStep, `Invalid absence key '${keyText}' - expected exactly one concrete value.`, locationOf(line));\n let hasChildren = false;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n context.error(DiagnosticCodes.InvalidAbsentReadModelStep, 'An absent read model assertion cannot have child mappings.', locationOf(child));\n hasChildren = true;\n }\n return hasChildren || !concrete ? null : { kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key, location: locationOf(line) } as SpecificationAbsentReadModelSyntax;\n}\n\nfunction skipBody(context: ParserContext, indent: number): void {\n if (context.sourceOptions.numericMode !== 'exact') return context.skipBlock(indent);\n context.skipOpaqueBlock(indent);\n}\n\nfunction parseClock(context: ParserContext, line: SourceLine, keyword: string): SpecificationClockSyntax | null {\n const match = clockPattern.exec(line.content);\n skipBody(context, line.indent);\n if (match === null || match[1] !== keyword) {\n context.error(containsCaseReference(line.content) ? DiagnosticCodes.InvalidSpecificationCaseReference : DiagnosticCodes.InvalidSpecificationClock,\n `Invalid '${keyword} clock' - expected '${keyword} clock \"<ISO 8601 instant>\"', such as '${keyword} clock \"2026-10-05T08:00:00Z\"'`, locationOf(line));\n return null;\n }\n return { kind: 'SpecificationClockSyntax', instant: match[2], location: locationOf(line) };\n}\n\nfunction parseGivenGenerated(context: ParserContext, line: SourceLine): SpecificationGeneratedValueSyntax | null {\n const match = givenGeneratedPattern.exec(line.content);\n const block = match === null ? givenGeneratedBlockPattern.exec(line.content) : null;\n if (block !== null) {\n return { kind: 'SpecificationGeneratedValueSyntax', command: block[1], property: block[2], source: parseStructuredValue(context, line, block[3] as StructuredMarker), location: locationOf(line) };\n }\n if (match === null) {\n context.error(DiagnosticCodes.InvalidGeneratedFixture, \"Expected 'given generated <Command>.<property> = <value>' with exactly one concrete value.\", locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n const location = locationOf(line);\n const source = parseConcrete(context, match[3], { ...location, column: location.column + line.content.indexOf(match[3], line.content.indexOf('=') + 1) }, DiagnosticCodes.InvalidGeneratedFixture);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidGeneratedFixture, 'A pinned generated value cannot have child directives.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return source === null ? null : { kind: 'SpecificationGeneratedValueSyntax', command: match[1], property: match[2], source, location };\n}\n\nfunction parseCapture(context: ParserContext, line: SourceLine, keyword: string): SpecificationCaptureSyntax | null {\n return parseNamedStep(context, line, capturePattern, DiagnosticCodes.InvalidSpecificationCapture, `${keyword} capture`, `${keyword} capture <Capture>`,\n (capture, record) => ({ kind: 'SpecificationCaptureSyntax', capture, record, location: locationOf(line) }));\n}\n\n// A step naming one thing on its header line, with '<field> = <value>' lines beneath it.\nfunction parseNamedStep<T>(\n context: ParserContext, line: SourceLine, regex: RegExp, code: string, keyword: string, expected: string,\n create: (name: string, values: PropertyMappingSyntax[]) => T, queryArguments = false): T | null {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(code, `Invalid '${keyword}' declaration '${line.content}' - expected '${expected}'`, locationOf(line));\n skipBody(context, line.indent);\n return null;\n }\n return create(match[1], parseValues(context, line, false, undefined, queryArguments ? context : undefined));\n}\n\nfunction parseResult(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n const match = thenResultPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationQueryAction, `Invalid 'then result' declaration '${line.content}' - expected 'then result [exactly]'`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n body.thenResults.push({ kind: 'SpecificationQueryResultSyntax', properties: parseValues(context, line), exactly: match[1] !== undefined, location: locationOf(line) });\n}\n\nfunction parseReadModelStep(context: ParserContext, line: SourceLine, regex: RegExp, keyword: string): SpecificationReadModelSyntax | undefined {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidReadModelStep, `Invalid '${keyword} readmodel' declaration '${line.content}' - expected '${keyword} readmodel <ReadModelType>'`, locationOf(line));\n skipBody(context, line.indent);\n return undefined;\n }\n return {\n kind: 'SpecificationReadModelSyntax',\n name: match[1],\n properties: parseValues(context, line, false, match),\n exactly: keyword === 'then' && match.groups?.exactly !== undefined,\n inlineProperty: match.groups?.property ?? null,\n location: locationOf(line),\n };\n}\n\nfunction parseEventStep(context: ParserContext, line: SourceLine, regex: RegExp, keyword: string): SpecificationEventSyntax | undefined {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidEventStep, `Invalid '${keyword}' declaration '${line.content}' - expected '${keyword} <EventType>'`, locationOf(line));\n skipBody(context, line.indent);\n return undefined;\n }\n return { kind: 'SpecificationEventSyntax', eventType: match[1], ...parseValuesWithEventSource(context, line, undefined, match, keyword), inlineProperty: match.groups?.property ?? null, location: locationOf(line) };\n}\n\nexport const specificationStream = sourceStreamPattern('^stream\\\\s+([A-Za-z_]\\\\w*)\\\\.([A-Za-z_]\\\\w*)$');\nconst specificationStreamId = pattern('^streamId\\\\s*=(?!=|>)\\\\s*(.+)$');\n\nfunction parseValuesWithEventSource(context: ParserContext, parent: SourceLine, generated?: PropertyMappingSyntax[], inline?: RegExpExecArray, eventKeyword?: string): { values: PropertyMappingSyntax[]; for: ExpressionSyntax | null; stream?: SpecificationStreamSyntax; noStream?: SpecificationNoStreamSyntax } {\n const values: PropertyMappingSyntax[] = [];\n addInlineValue(context, parent, inline, values);\n let eventSource: ExpressionSyntax | null = null;\n let stream: SpecificationStreamSyntax | undefined;\n let noStream: SpecificationNoStreamSyntax | undefined;\n let hasRoute = false;\n for (let child = context.peekChild(parent.indent); child !== undefined; child = context.peekChild(parent.indent)) {\n context.reader.takeSignificant();\n let structured: PropertyMappingSyntax | undefined;\n if (generated !== undefined && generatedFixturePrefix.test(child.content)) {\n const fixture = parseConcreteMapping(context, child, generatedFixturePattern, DiagnosticCodes.InvalidGeneratedFixture);\n if (fixture !== null) generated.push(fixture);\n continue;\n }\n const mapping = mappingPattern.exec(child.content);\n if (mapping !== null) {\n addFixtureValue(context, values, mappingOf(context, child, mapping));\n } else if (firstWord(child.content) === 'stream' || child.content.startsWith('no stream')) {\n if (eventKeyword === undefined) {\n context.error(DiagnosticCodes.SpecificationStreamOnCommand, 'A command occurrence cannot declare a route; assert it on a then event.', locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n if (hasRoute) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, 'An event occurrence declares at most one stream or no stream directive.', locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const route = specificationStream.exec(child.content);\n if (child.content === 'no stream' && (eventKeyword === 'then' || eventKeyword === 'when redelivered')) {\n noStream = { kind: 'SpecificationNoStreamSyntax', location: locationOf(child) };\n hasRoute = true;\n rejectSpecificationRouteChildren(context, child);\n } else if (route !== null) {\n stream = parseSpecificationStream(context, child, route);\n hasRoute = true;\n } else {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Expected 'stream Source.Stream', or 'no stream' on a then event.\", locationOf(child));\n context.skipBlock(child.indent);\n }\n } else if (firstWord(child.content) === 'for') {\n const source = child.content.substring('for'.length).trim();\n if (source.length === 0) {\n context.error(DiagnosticCodes.InvalidSpecificationEventSource, 'Invalid event-source assertion \\'for\\' - expected \\'for <value>\\'', locationOf(child));\n } else if (eventSource !== null) {\n context.error(DiagnosticCodes.DuplicateSpecificationEventSource, 'A specification step can declare its event-source assertion only once', locationOf(child));\n } else {\n eventSource = parseMappingSource(source, locationOf(child), context);\n }\n } else if ((structured = tryParseStructuredMapping(context, child)) !== undefined) {\n addFixtureValue(context, values, structured);\n } else {\n context.error(DiagnosticCodes.InvalidSpecificationValue, `Invalid property mapping '${child.content}' - expected '<property> = <value>'`, locationOf(child), diagnosticText('text', child.content));\n }\n }\n return { values, for: eventSource, ...(stream === undefined ? {} : { stream }), ...(noStream === undefined ? {} : { noStream }) };\n}\n\nexport function parseSpecificationStream(context: ParserContext, header: SourceLine, route: RegExpExecArray): SpecificationStreamSyntax {\n let streamId: PropertyMappingSyntax | null = null;\n let streamIdParts: PropertyMappingSyntax[] = [];\n let block = false;\n const directiveLocations: Record<string, ReturnType<typeof locationOf>> = {};\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'streamId') {\n if (streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Declare either one 'streamId = <literal>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n } else {\n block = true;\n directiveLocations.streamId = locationOf(child);\n streamIdParts = parseRouteParts(context, child, DiagnosticCodes.InvalidSpecificationStream).map(part => part.source.kind === 'PathExpressionSyntax' && part.source.path.startsWith('case.')\n ? { ...part, source: parseMappingSource(part.source.path, part.source.location, context) } : part);\n }\n continue;\n }\n const mapping = specificationStreamId.exec(child.content);\n if (mapping === null || streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Declare either one 'streamId = <literal>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const location = { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(mapping[1], child.content.indexOf('=') + 1) };\n streamId = { kind: 'PropertyMappingSyntax', property: 'streamId', source: parseMappingSource(mapping[1], location, context), location: locationOf(child) };\n rejectSpecificationRouteChildren(context, child);\n }\n return { kind: 'SpecificationStreamSyntax', eventSource: route[1], stream: route[2], streamId, streamIdParts, directiveLocations,\n referenceLocation: { ...locationOf(header), column: header.indent + 1 + header.content.indexOf(route[1], 'stream'.length) },\n referenceLength: route[1].length + 1 + route[2].length, location: locationOf(header) };\n}\n\nexport function rejectSpecificationRouteChildren(context: ParserContext, line: SourceLine): void {\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, 'This directive cannot have children.', locationOf(child));\n context.skipBlock(line.indent);\n }\n}\n\nfunction parseValues(context: ParserContext, parent: SourceLine, nativeIdentifiers = false, inline?: RegExpExecArray, queryArgumentsContext?: ParserContext): PropertyMappingSyntax[] {\n const values: PropertyMappingSyntax[] = [];\n addInlineValue(context, parent, inline, values);\n for (let child = context.peekChild(parent.indent); child !== undefined; child = context.peekChild(parent.indent)) {\n context.reader.takeSignificant();\n const mapping = (nativeIdentifiers || context.sourceOptions.numericMode === 'exact' ? nativeMappingPattern : mappingPattern).exec(child.content);\n const structured = mapping === null ? tryParseStructuredMapping(context, child) : undefined;\n if (mapping === null && structured === undefined) {\n context.error(DiagnosticCodes.InvalidSpecificationValue, `Invalid property mapping '${child.content}' - expected '<property> = <value>'`, locationOf(child), diagnosticText('text', child.content));\n continue;\n }\n const value = structured ?? mappingOf(context, child, mapping!, nativeIdentifiers);\n if (queryArgumentsContext !== undefined) {\n if (values.some(existing => existing.property === value.property)) {\n queryArgumentsContext.error(DiagnosticCodes.UnknownSpecificationQueryArgument, `Query argument '${value.property}' is repeated.`, value.location, diagnosticText('argument', value.property));\n }\n values.push(value);\n } else {\n addFixtureValue(context, values, value);\n }\n }\n return values;\n}\n\nfunction mappingOf(context: ParserContext, line: SourceLine, match: RegExpExecArray, nativeIdentifiers = false): PropertyMappingSyntax {\n return { kind: 'PropertyMappingSyntax', property: match[1], source: parseMappingSource(match[2], locationOf(line), context, nativeIdentifiers), location: locationOf(line) };\n}\n\nconst lifecycleWhenStart = pattern('^when\\\\s+start\\\\s+(.+)$');\nconst lifecycleOutcome = pattern('^outcome\\\\s+([A-Za-z_]\\\\w*)\\\\s+([A-Za-z_]\\\\w*)$');\nconst lifecycleThen = pattern('^then\\\\s+(is|sends|starts|completes|fails\\\\s+at|waits\\\\s+at)(?:\\\\s+([A-Za-z_]\\\\w*))?$');\n\nfunction lifecycleExpectation(line: SourceLine): LifecycleExpectationSyntax | undefined {\n const match = lifecycleThen.exec(line.content);\n if (match === null) return undefined;\n const word = match[1].replace(/\\s+/g, ' ');\n const expectation: LifecycleExpectationKind = word === 'is' ? 'State' : word === 'sends' ? 'Sends' : word === 'starts' ? 'Starts' : word === 'completes' ? 'Completes' : word === 'fails at' ? 'Fails' : 'Waits';\n if ((match[2] !== undefined) === (expectation === 'Completes')) return undefined;\n return { kind: 'LifecycleExpectationSyntax', expectation, target: match[2] ?? null, location: locationOf(line) };\n}\n\n// A specification written inside a statemachine or a workflow - the port of C# SpecificationParser.ParseLifecycle.\nexport function parseLifecycleSpecification(context: ParserContext, header: SourceLine, code: string): LifecycleSpecificationSyntax {\n const match = specificationHeader.exec(header.content);\n if (match === null) {\n context.error(code, `Invalid specification '${header.content}' - expected 'specification <Name>'.`, locationOf(header));\n skipBody(context, header.indent);\n return { kind: 'LifecycleSpecificationSyntax', name: '', description: null, given: [], whenAppended: null, whenStarted: null, outcomes: [], then: [], location: locationOf(header) };\n }\n const name = match[1];\n let description: string | null = null;\n const given: SpecificationEventSyntax[] = [];\n let whenAppended: SpecificationEventSyntax | null = null;\n let whenStarted: ExpressionSyntax | null = null;\n let whenDeclared = false;\n const outcomes: LifecycleOutcomeSyntax[] = [];\n const then: LifecycleExpectationSyntax[] = [];\n const directiveLocations: Record<string, SourceLocation> = {};\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(line.content);\n if (keyword === 'description') {\n description = parseDescription(context, line, description, `Specification '${name}'`);\n directiveLocations.description ??= locationOf(line);\n } else if (keyword === 'given') {\n const fact = parseEventStep(context, line, givenPattern, 'given');\n if (fact !== undefined) given.push(fact);\n } else if (keyword === 'when') {\n if (whenDeclared) {\n context.error(code, `Specification '${name}' already declares a 'when'.`, locationOf(line));\n skipBody(context, line.indent);\n continue;\n }\n whenDeclared = true;\n const start = lifecycleWhenStart.exec(line.content);\n if (start !== null) {\n const index = line.content.indexOf(start[1], 'when start'.length);\n whenStarted = parseMappingSource(start[1].trim(), sourceLocation(line.number, line.indent + (line.contentOffset ?? 0) + 1 + index, line.path), context);\n } else if (line.content.startsWith('when append')) whenAppended = parseEventStep(context, line, whenAppendPattern, 'when append') ?? null;\n else {\n context.error(code, `Invalid '${line.content}' - expected 'when append <Event>' or 'when start <key>'.`, locationOf(line));\n skipBody(context, line.indent);\n }\n } else if (keyword === 'outcome') {\n const outcome = lifecycleOutcome.exec(line.content);\n if (outcome !== null) outcomes.push({ kind: 'LifecycleOutcomeSyntax', node: outcome[1], outlet: outcome[2], location: locationOf(line) });\n else context.error(code, `Invalid outcome '${line.content}' - expected 'outcome <Node> <outlet>'.`, locationOf(line));\n rejectOperationChildren(context, line, code, 'An outcome cannot have children.');\n } else if (keyword === 'then') {\n const expectation = lifecycleExpectation(line);\n if (expectation !== undefined) then.push(expectation);\n else context.error(code, `Invalid '${line.content}' - expected 'then is <State>', 'then sends <Command>', 'then starts <Workflow>', 'then completes', 'then fails at <Node>' or 'then waits at <Node>'.`, locationOf(line));\n rejectOperationChildren(context, line, code, 'A then line cannot have children.');\n } else {\n context.error(code, `Unexpected '${line.content}' in specification '${name}' - expected description, given, when, outcome or then.`, locationOf(line));\n context.skipBlock(line.indent);\n }\n }\n return { kind: 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F,GAAiB,KAAKxG,EAAK,OAAO,EAC9CwB,IAAY,KACXvB,EAAQ,MAAM2C,EAAM,oBAAoB5C,EAAK,QAAQ,yCAA0CG,EAAWH,CAAI,CAAC,EAD9F+G,EAAS,KAAK,CAAE,KAAM,yBAA0B,KAAMvF,EAAQ,GAAI,OAAQA,EAAQ,GAAI,SAAUrB,EAAWH,CAAI,CAAE,CAAC,EAExI6B,EAAwB5B,EAASD,EAAM4C,EAAM,kCAAkC,CACnF,MAAO,GAAIlC,IAAY,OAAQ,CAC3B,IAAMqC,EAAc,qBAAqB/C,CAAI,EACzC+C,IAAgB,IAAA,GACf9C,EAAQ,MAAM2C,EAAM,YAAY5C,EAAK,QAAQ,uJAAwJG,EAAWH,CAAI,CAAC,EAD3LgH,EAAK,KAAKjE,CAAW,EAEpDlB,EAAwB5B,EAASD,EAAM4C,EAAM,mCAAmC,CACpF,MACI3C,EAAQ,MAAM2C,EAAM,eAAe5C,EAAK,QAAQ,sBAAsBD,EAAK,yDAA0DI,EAAWH,CAAI,CAAC,EACrJC,EAAQ,UAAUD,EAAK,MAAM,CAErC,CACA,MAAO,CAAE,KAAM,+BAAgC,OAAM,cAAa,QAAO,eAAc,cAAa,WAAU,OAAM,SAAUG,EAAWlD,CAAM,EAAG,oBAAmB,CACzK"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t}from"../Text/StringLiteral.js";import{pattern as n}from"../Text/patterns.js";import{locationOf as r}from"./SourceLine.js";import{parseMappingSource as i}from"./ExpressionParser.js";import{diagnosticText as a}from"../Diagnostics/DiagnosticArgument.js";import{containsCaseReference as o,parseSpecificationValue as s}from"./SpecificationCaseParser.js";const c=n(`^then\\s+returns\\b`),l=n(`^generated\\s+(?=\\S)(?![=])`),u=n(`^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$`),d=n(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),f=n(`^(?:"${t}"|'(?:[^'\\\\]|\\\\.)*')$`);function parseConcrete(t,n,r,c){if(n.startsWith(`case.`))return s(n,r,t);o(n)&&t.error(e.InvalidSpecificationCaseReference,`A case reference fills a whole value position; it cannot occur inside a structured value or expression.`,r);let l=c===e.InvalidSpecificationValue||c===e.InvalidSpecificationCaseValue?a(`text`,n):{};if((n.startsWith(`"`)||n.startsWith(`'`))&&!f.test(n))return t.error(c,`Expected exactly one concrete value.`,r,l),null;let u=i(n,r,t);return![`LiteralExpressionSyntax`,`ObjectExpressionSyntax`,`ListExpressionSyntax`].includes(u.kind)||u.kind===`LiteralExpressionSyntax`&&typeof u.value==`number`&&!Number.isFinite(u.value)?(t.error(c,`Expected exactly one concrete literal or structured value, not an expression.`,r,l),null):u}function parseConcreteMapping(e,t,n,i){let a=n.exec(t.content);if(a===null)return e.error(i,`Expected a named fixture or assertion with exactly one concrete value.`,r(t)),e.skipBlock(t.indent),null;let o=r(t),s=parseConcrete(e,a[2],{...o,column:o.column+t.content.indexOf(a[2],t.content.indexOf(`=`)+1)},i),c=e.peekChild(t.indent);return c!==void 0&&(e.error(i,`A fixture or return field cannot have child directives.`,r(c)),e.skipBlock(t.indent)),s===null?null:{kind:`PropertyMappingSyntax`,property:a[1],source:s,location:o}}function parseReturn(t,n){let i=c.exec(n.content)[0].length,a=n.content.substring(i).trim(),o=r(n);if(a.length>0){let s=parseConcrete(t,a,{...o,column:o.column+n.content.indexOf(a,i)},e.InvalidReturnExpectation),c=t.peekChild(n.indent);return c!==void 0&&(t.error(e.InvalidReturnExpectation,`A scalar return expectation cannot have child assertions.`,r(c)),t.skipBlock(n.indent)),s===null?null:{kind:`ScalarSpecificationReturnSyntax`,value:s,location:o}}let s=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=parseConcreteMapping(t,r,d,e.InvalidReturnExpectation);n!==null&&s.push(n)}return{kind:`RecordSpecificationReturnSyntax`,fields:s,location:o}}export{u as generatedFixturePattern,l as generatedFixturePrefix,parseConcrete,parseConcreteMapping,parseReturn,c as thenReturnsPrefix};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t}from"../Text/StringLiteral.js";import{pattern as n}from"../Text/patterns.js";import{locationOf as r}from"./SourceLine.js";import{parseMappingSource as i}from"./ExpressionParser.js";import{diagnosticText as a}from"../Diagnostics/DiagnosticArgument.js";import{parseStructuredValue as o,tryParseStructuredMapping as s}from"./StructuredBlockParser.js";import{containsCaseReference as c,parseSpecificationValue as l}from"./SpecificationCaseParser.js";const u=`value`,d=n(`^then\\s+returns\\b`),f=n(`^generated\\s+(?=\\S)(?![=])`),p=n(`^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$`),m=n(`^generated\\s+([a-z_]\\w*)(?:\\s+(none|empty))?$`),h=n(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),g=n(`^(?:"${t}"|'(?:[^'\\\\]|\\\\.)*')$`);function parseConcrete(t,n,r,o){if(n.startsWith(`case.`))return l(n,r,t);c(n)&&t.error(e.InvalidSpecificationCaseReference,`A case reference fills a whole value position; it cannot occur inside a structured value or expression.`,r);let s=o===e.InvalidSpecificationValue||o===e.InvalidSpecificationCaseValue?a(`text`,n):{};if((n.startsWith(`"`)||n.startsWith(`'`))&&!g.test(n))return t.error(o,`Expected exactly one concrete value.`,r,s),null;let u=i(n,r,t);return![`LiteralExpressionSyntax`,`ObjectExpressionSyntax`,`ListExpressionSyntax`].includes(u.kind)||u.kind===`LiteralExpressionSyntax`&&typeof u.value==`number`&&!Number.isFinite(u.value)?(t.error(o,`Expected exactly one concrete literal or structured value, not an expression.`,r,s),null):u}function parseConcreteMapping(e,t,n,i){let a=n.exec(t.content),c=a===null?m.exec(t.content):null;if(c!==null)return{kind:`PropertyMappingSyntax`,property:c[1],source:o(e,t,c[2]),location:r(t)};let l=a===null?s(e,t):void 0;if(l!==void 0)return l;if(a===null)return e.error(i,`Expected a named fixture or assertion with exactly one concrete value.`,r(t)),e.skipBlock(t.indent),null;let u=r(t),d=parseConcrete(e,a[2],{...u,column:u.column+t.content.indexOf(a[2],t.content.indexOf(`=`)+1)},i),f=e.peekChild(t.indent);return f!==void 0&&(e.error(i,`A fixture or return field cannot have child directives.`,r(f)),e.skipBlock(t.indent)),d===null?null:{kind:`PropertyMappingSyntax`,property:a[1],source:d,location:u}}function parseReturn(t,n){let i=d.exec(n.content)[0].length,a=n.content.substring(i).trim(),s=r(n);if(a===`value`||a===`value none`||a===`value empty`)return{kind:`ScalarSpecificationReturnSyntax`,value:o(t,n,a.substring(6)||void 0),location:s};if(a.length>0){let o=parseConcrete(t,a,{...s,column:s.column+n.content.indexOf(a,i)},e.InvalidReturnExpectation),c=t.peekChild(n.indent);return c!==void 0&&(t.error(e.InvalidReturnExpectation,`A scalar return expectation cannot have child assertions.`,r(c)),t.skipBlock(n.indent)),o===null?null:{kind:`ScalarSpecificationReturnSyntax`,value:o,location:s}}let c=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=parseConcreteMapping(t,r,h,e.InvalidReturnExpectation);n!==null&&c.push(n)}return{kind:`RecordSpecificationReturnSyntax`,fields:c,location:s}}export{p as generatedFixturePattern,f as generatedFixturePrefix,parseConcrete,parseConcreteMapping,parseReturn,u as structuredReturnKeyword,d as thenReturnsPrefix};
2
2
  //# sourceMappingURL=SpecificationResponseParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SpecificationResponseParser.js","names":["thenReturnsPrefix","pattern","generatedFixturePrefix","generatedFixturePattern","fieldPattern","quotedValue","stringBodyPattern","text","parseSpecificationValue","location","context","containsCaseReference","DiagnosticCodes","subjects","code","diagnosticText","expression","parseMappingSource","match","regex","line","locationOf","source","child","prefix","value","concrete","fields","field"],"sources":["../../../../../../Compiler/Parsing/SpecificationResponseParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SpecificationReturnSyntax } from '../Syntax/Responses';\nimport { pattern } from '../Text/patterns';\nimport { stringBodyPattern } from '../Text/StringLiteral';\nimport { parseMappingSource } from './ExpressionParser';\nimport { containsCaseReference, parseSpecificationValue } from './SpecificationCaseParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nexport const thenReturnsPrefix = pattern('^then\\\\s+returns\\\\b');\nexport const generatedFixturePrefix = pattern('^generated\\\\s+(?=\\\\S)(?![=])');\nexport const generatedFixturePattern = pattern('^generated\\\\s+([a-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst fieldPattern = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst quotedValue = pattern(`^(?:\"${stringBodyPattern}\"|'(?:[^'\\\\\\\\]|\\\\\\\\.)*')$`);\n\nexport function parseConcrete(context: ParserContext, text: string, location: SourceLocation, code: string): ExpressionSyntax | null {\n if (text.startsWith('case.')) return parseSpecificationValue(text, location, context);\n if (containsCaseReference(text)) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, 'A case reference fills a whole value position; it cannot occur inside a structured value or expression.', location);\n const subjects = code === DiagnosticCodes.InvalidSpecificationValue || code === DiagnosticCodes.InvalidSpecificationCaseValue ? diagnosticText('text', text) : {};\n if ((text.startsWith('\"') || text.startsWith(\"'\")) && !quotedValue.test(text)) {\n context.error(code, 'Expected exactly one concrete value.', location, subjects);\n return null;\n }\n const expression = parseMappingSource(text, location, context);\n if (!['LiteralExpressionSyntax', 'ObjectExpressionSyntax', 'ListExpressionSyntax'].includes(expression.kind) || (expression.kind === 'LiteralExpressionSyntax' && typeof expression.value === 'number' && !Number.isFinite(expression.value))) {\n context.error(code, 'Expected exactly one concrete literal or structured value, not an expression.', location, subjects);\n return null;\n }\n return expression;\n}\n\nexport function parseConcreteMapping(context: ParserContext, line: SourceLine, regex: RegExp, code: string): PropertyMappingSyntax | null {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(code, 'Expected a named fixture or assertion with exactly one concrete value.', locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n const location = locationOf(line);\n const source = parseConcrete(context, match[2], { ...location, column: location.column + line.content.indexOf(match[2], line.content.indexOf('=') + 1) }, code);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(code, 'A fixture or return field cannot have child directives.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return source === null ? null : { kind: 'PropertyMappingSyntax', property: match[1], source, location };\n}\n\nexport function parseReturn(context: ParserContext, line: SourceLine): SpecificationReturnSyntax | null {\n const prefix = thenReturnsPrefix.exec(line.content)![0].length;\n const value = line.content.substring(prefix).trim();\n const location = locationOf(line);\n if (value.length > 0) {\n const concrete = parseConcrete(context, value, { ...location, column: location.column + line.content.indexOf(value, prefix) }, DiagnosticCodes.InvalidReturnExpectation);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidReturnExpectation, 'A scalar return expectation cannot have child assertions.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return concrete === null ? null : { kind: 'ScalarSpecificationReturnSyntax', value: concrete, location };\n }\n const fields: PropertyMappingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const field = parseConcreteMapping(context, child, fieldPattern, DiagnosticCodes.InvalidReturnExpectation);\n if (field !== null) fields.push(field);\n }\n return { kind: 'RecordSpecificationReturnSyntax', fields, location };\n}\n"],"mappings":"ofAeA,MAAaA,EAAoBC,EAAQ,qBAAqB,EACjDC,EAAy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CACvE"}
1
+ {"version":3,"file":"SpecificationResponseParser.js","names":["structuredReturnKeyword","thenReturnsPrefix","pattern","generatedFixturePrefix","generatedFixturePattern","generatedFixtureBlockPattern","fieldPattern","quotedValue","stringBodyPattern","text","parseSpecificationValue","location","context","containsCaseReference","DiagnosticCodes","subjects","code","diagnosticText","expression","parseMappingSource","match","regex","line","generated","parseStructuredValue","locationOf","structured","tryParseStructuredMapping","source","child","prefix","value","concrete","fields","field"],"sources":["../../../../../../Compiler/Parsing/SpecificationResponseParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SpecificationReturnSyntax } from '../Syntax/Responses';\nimport { pattern } from '../Text/patterns';\nimport { stringBodyPattern } from '../Text/StringLiteral';\nimport { parseMappingSource } from './ExpressionParser';\nimport { containsCaseReference, parseSpecificationValue } from './SpecificationCaseParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { emptyKeyword, noneKeyword, parseStructuredValue, StructuredMarker, tryParseStructuredMapping } from './StructuredBlockParser';\n\n// The word after 'then returns' that opens a structured scalar response as an indented block.\nexport const structuredReturnKeyword = 'value';\nexport const thenReturnsPrefix = pattern('^then\\\\s+returns\\\\b');\nexport const generatedFixturePrefix = pattern('^generated\\\\s+(?=\\\\S)(?![=])');\nexport const generatedFixturePattern = pattern('^generated\\\\s+([a-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst generatedFixtureBlockPattern = pattern('^generated\\\\s+([a-z_]\\\\w*)(?:\\\\s+(none|empty))?$');\nconst fieldPattern = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst quotedValue = pattern(`^(?:\"${stringBodyPattern}\"|'(?:[^'\\\\\\\\]|\\\\\\\\.)*')$`);\n\nexport function parseConcrete(context: ParserContext, text: string, location: SourceLocation, code: string): ExpressionSyntax | null {\n if (text.startsWith('case.')) return parseSpecificationValue(text, location, context);\n if (containsCaseReference(text)) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, 'A case reference fills a whole value position; it cannot occur inside a structured value or expression.', location);\n const subjects = code === DiagnosticCodes.InvalidSpecificationValue || code === DiagnosticCodes.InvalidSpecificationCaseValue ? diagnosticText('text', text) : {};\n if ((text.startsWith('\"') || text.startsWith(\"'\")) && !quotedValue.test(text)) {\n context.error(code, 'Expected exactly one concrete value.', location, subjects);\n return null;\n }\n const expression = parseMappingSource(text, location, context);\n if (!['LiteralExpressionSyntax', 'ObjectExpressionSyntax', 'ListExpressionSyntax'].includes(expression.kind) || (expression.kind === 'LiteralExpressionSyntax' && typeof expression.value === 'number' && !Number.isFinite(expression.value))) {\n context.error(code, 'Expected exactly one concrete literal or structured value, not an expression.', location, subjects);\n return null;\n }\n return expression;\n}\n\nexport function parseConcreteMapping(context: ParserContext, line: SourceLine, regex: RegExp, code: string): PropertyMappingSyntax | null {\n const match = regex.exec(line.content);\n const generated = match === null ? generatedFixtureBlockPattern.exec(line.content) : null;\n if (generated !== null) return { kind: 'PropertyMappingSyntax', property: generated[1], source: parseStructuredValue(context, line, generated[2] as StructuredMarker), location: locationOf(line) };\n const structured = match === null ? tryParseStructuredMapping(context, line) : undefined;\n if (structured !== undefined) return structured;\n if (match === null) {\n context.error(code, 'Expected a named fixture or assertion with exactly one concrete value.', locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n const location = locationOf(line);\n const source = parseConcrete(context, match[2], { ...location, column: location.column + line.content.indexOf(match[2], line.content.indexOf('=') + 1) }, code);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(code, 'A fixture or return field cannot have child directives.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return source === null ? null : { kind: 'PropertyMappingSyntax', property: match[1], source, location };\n}\n\nexport function parseReturn(context: ParserContext, line: SourceLine): SpecificationReturnSyntax | null {\n const prefix = thenReturnsPrefix.exec(line.content)![0].length;\n const value = line.content.substring(prefix).trim();\n const location = locationOf(line);\n // 'then returns value' opens a structured scalar - an object or a list - as an indented block.\n if (value === structuredReturnKeyword || value === `${structuredReturnKeyword} ${noneKeyword}` || value === `${structuredReturnKeyword} ${emptyKeyword}`) {\n return { kind: 'ScalarSpecificationReturnSyntax', value: parseStructuredValue(context, line, value.substring(structuredReturnKeyword.length + 1) as StructuredMarker || undefined), location };\n }\n if (value.length > 0) {\n const concrete = parseConcrete(context, value, { ...location, column: location.column + line.content.indexOf(value, prefix) }, DiagnosticCodes.InvalidReturnExpectation);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidReturnExpectation, 'A scalar return expectation cannot have child assertions.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return concrete === null ? null : { kind: 'ScalarSpecificationReturnSyntax', value: concrete, location };\n }\n const fields: PropertyMappingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const field = parseConcreteMapping(context, child, fieldPattern, DiagnosticCodes.InvalidReturnExpectation);\n if (field !== null) fields.push(field);\n }\n return { kind: 'RecordSpecificationReturnSyntax', fields, location };\n}\n"],"mappings":"qlBAiBA,MAAaA,EAA0B,QAC1BC,EAAoBC,EAAQ,qBAAqB,EACjDC,EAAyBD,EAAQ,8BAA8B,EAC/DE,EAA0BF,EAAQ,iDAAiD,EAC1FG,EAA+BH,EAAQ,kDAAkD,EACzFI,EAAeJ,EAAQ,iCAAiC,EACxDK,EAAcL,EAAQ,QAAQM,EAAkB,0BAA0B,EAEhF,SAAgB,cAAc,EAAwB,EAAc,EAA0B,EAAuC,CACjI,GAAIC,EAAK,WAAW,OAAO,EAAG,OAAOC,EAAwBD,EAAME,EAAUC,C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IAAA,GAAW,EAAQjB,EAAQ,UAAUU,EAAK,MAAM,EAAG,CAC1GV,EAAQ,OAAO,gBAAgB,EAC/B,IAAMsB,EAAQ,qBAAqBtB,EAASiB,EAAOvB,EAAcQ,EAAgB,wBAAwB,EACrGoB,IAAU,MAAMD,EAAO,KAAKC,CAAK,CACzC,CACA,MAAO,CAAE,KAAM,kCAAmC,SAAQ,UAAS,CACvE"}
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r}from"./LineText.js";import{parseDescription as i}from"./DescriptionParser.js";import{parseCondition as a}from"./ConditionParser.js";import{rejectOperationChildren as o}from"./OperationParser.js";import{parseLifecycleSpecification as s}from"./SpecificationParser.js";const c=t(`^statemachine\\s+([A-Za-z_]\\w*)$`),l=t(`^follows\\s+([A-Za-z_]\\w*)$`),u=t(`^state\\s+([A-Za-z_]\\w*)((?:\\s+(?:initial|final))*)$`),d=t(`^entering\\s+(send|start)\\s+([A-Za-z_]\\w*)$`),f=t(`^on\\s+([A-Za-z_][\\w.]*)(?:\\s+when\\s+(.+?))?\\s*->\\s*([A-Za-z_]\\w*)$`);function parseStateMachine(t,a){let u=c.exec(a.content);if(u===null)return t.error(e.InvalidStateMachineDeclaration,`Invalid state machine declaration '${a.content}' - expected 'statemachine <Name>'.`,n(a)),t.skipBlock(a.indent),{kind:`StateMachineSyntax`,name:r(a.content),follows:``,description:null,states:[],specifications:[],location:n(a)};let d=u[1],f=null,p=null,m=[],h=[],g={};for(let c=t.peekChild(a.indent);c!==void 0;c=t.peekChild(a.indent))switch(t.reader.takeSignificant(),r(c.content)){case`description`:f=i(t,c,f,`State machine '${d}'`),g.description??=n(c);break;case`follows`:{let r=l.exec(c.content);r===null?t.error(e.InvalidStateMachineDeclaration,`Invalid follows '${c.content}' - expected 'follows <ReadModel>'.`,n(c)):p===null?(p=r[1],g.follows=n(c)):t.error(e.InvalidStateMachineDeclaration,`State machine '${d}' follows more than one read model.`,n(c)),o(t,c,e.InvalidStateMachineDeclaration,`A follows line cannot have children.`);break}case`state`:m.push(parseState(t,c,d));break;case`specification`:h.push(s(t,c,e.InvalidStateMachineDeclaration));break;default:t.error(e.InvalidStateMachineDeclaration,`Unexpected '${c.content}' in state machine '${d}' - expected description, follows, state or specification.`,n(c)),t.skipBlock(c.indent)}p===null&&t.error(e.InvalidStateMachineDeclaration,`State machine '${d}' must follow a read model: 'follows <ReadModel>'.`,n(a));let _=/* @__PURE__ */ new Set;for(let n of m)_.has(n.name)&&t.error(e.InvalidStateMachineDeclaration,`State machine '${d}' declares state '${n.name}' more than once.`,n.location),_.add(n.name);return{kind:`StateMachineSyntax`,name:d,follows:p??``,description:f,states:m,specifications:h,location:n(a),directiveLocations:g}}function parseState(t,i,s){let c=u.exec(i.content);if(c===null)return t.error(e.InvalidStateMachineDeclaration,`Invalid state '${i.content}' - expected 'state <Name> [initial] [final]'.`,n(i)),t.skipBlock(i.indent),{kind:`StateSyntax`,name:``,isInitial:!1,isFinal:!1,entering:[],transitions:[],location:n(i)};let l=c[2].split(` `).filter(e=>e.length>0);l.length!==new Set(l).size&&t.error(e.InvalidStateMachineDeclaration,`State '${c[1]}' repeats a modifier.`,n(i));let p=[],m=[];for(let l=t.peekChild(i.indent);l!==void 0;l=t.peekChild(i.indent))switch(t.reader.takeSignificant(),r(l.content)){case`entering`:{let r=d.exec(l.content);r===null?t.error(e.InvalidStateMachineDeclaration,`Invalid entering '${l.content}' - expected 'entering send <Command>' or 'entering start <Workflow>'.`,n(l)):p.push({kind:`StateEntrySyntax`,entryKind:r[1]===`send`?`Send`:`Start`,target:r[2],location:n(l)}),o(t,l,e.InvalidStateMachineDeclaration,`An entering line cannot have children.`);break}case`on`:{let r=f.exec(l.content);if(r===null)t.error(e.InvalidStateMachineDeclaration,`Invalid transition '${l.content}' - expected 'on <Event> [when <condition>] -> <State>'.`,n(l));else{let e=null,i=!1;r[2]!==void 0&&(e=a(t,r[2],n(l)),i=e===null),i||m.push({kind:`StateTransitionSyntax`,event:r[1],when:e,target:r[3],location:n(l)})}o(t,l,e.InvalidStateMachineDeclaration,`A transition cannot have children.`);break}default:t.error(e.InvalidStateMachineDeclaration,`Unexpected '${l.content}' in state '${c[1]}' of '${s}' - expected entering or on.`,n(l)),t.skipBlock(l.indent)}return{kind:`StateSyntax`,name:c[1],isInitial:l.includes(`initial`),isFinal:l.includes(`final`),entering:p,transitions:m,location:n(i)}}export{parseStateMachine};
2
+ //# sourceMappingURL=StateMachineParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StateMachineParser.js","names":["headerPattern","pattern","followsPattern","statePattern","enteringPattern","transitionPattern","match","header","context","DiagnosticCodes","locationOf","firstWord","name","description","follows","states","specifications","directiveLocations","line","parseDescription","followed","rejectOperationChildren","parseLifecycleSpecification","seen","state","modifiers","word","entering","transitions","entry","transition","when","failed","parseCondition","machine"],"sources":["../../../../../../Compiler/Parsing/StateMachineParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ConditionSyntax } from '../Syntax/Conditions';\nimport { LifecycleSpecificationSyntax, StateEntrySyntax, StateMachineSyntax, StateSyntax, StateTransitionSyntax } from '../Syntax/Lifecycles';\nimport { pattern } from '../Text/patterns';\nimport { parseCondition } from './ConditionParser';\nimport { parseDescription } from './DescriptionParser';\nimport { firstWord } from './LineText';\nimport { rejectOperationChildren } from './OperationParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { parseLifecycleSpecification } from './SpecificationParser';\n\nconst headerPattern = pattern('^statemachine\\\\s+([A-Za-z_]\\\\w*)$');\nconst followsPattern = pattern('^follows\\\\s+([A-Za-z_]\\\\w*)$');\nconst statePattern = pattern('^state\\\\s+([A-Za-z_]\\\\w*)((?:\\\\s+(?:initial|final))*)$');\nconst enteringPattern = pattern('^entering\\\\s+(send|start)\\\\s+([A-Za-z_]\\\\w*)$');\nconst transitionPattern = pattern('^on\\\\s+([A-Za-z_][\\\\w.]*)(?:\\\\s+when\\\\s+(.+?))?\\\\s*->\\\\s*([A-Za-z_]\\\\w*)$');\n\n// The port of C# StateMachineParser.\nexport function parseStateMachine(context: ParserContext, header: SourceLine): StateMachineSyntax {\n const match = headerPattern.exec(header.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid state machine declaration '${header.content}' - expected 'statemachine <Name>'.`, locationOf(header));\n context.skipBlock(header.indent);\n return { kind: 'StateMachineSyntax', name: firstWord(header.content), follows: '', description: null, states: [], specifications: [], location: locationOf(header) };\n }\n const name = match[1];\n let description: string | null = null;\n let follows: string | null = null;\n const states: StateSyntax[] = [];\n const specifications: LifecycleSpecificationSyntax[] = [];\n const directiveLocations: Record<string, SourceLocation> = {};\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(line.content)) {\n case 'description':\n description = parseDescription(context, line, description, `State machine '${name}'`);\n directiveLocations.description ??= locationOf(line);\n break;\n case 'follows': {\n const followed = followsPattern.exec(line.content);\n if (followed === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid follows '${line.content}' - expected 'follows <ReadModel>'.`, locationOf(line));\n else if (follows !== null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State machine '${name}' follows more than one read model.`, locationOf(line));\n else {\n follows = followed[1];\n directiveLocations.follows = locationOf(line);\n }\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidStateMachineDeclaration, 'A follows line cannot have children.');\n break;\n }\n case 'state':\n states.push(parseState(context, line, name));\n break;\n case 'specification':\n specifications.push(parseLifecycleSpecification(context, line, DiagnosticCodes.InvalidStateMachineDeclaration));\n break;\n default:\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Unexpected '${line.content}' in state machine '${name}' - expected description, follows, state or specification.`, locationOf(line));\n context.skipBlock(line.indent);\n }\n }\n if (follows === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State machine '${name}' must follow a read model: 'follows <ReadModel>'.`, locationOf(header));\n const seen = new Set<string>();\n for (const state of states) {\n if (seen.has(state.name)) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State machine '${name}' declares state '${state.name}' more than once.`, state.location);\n seen.add(state.name);\n }\n return { kind: 'StateMachineSyntax', name, follows: follows ?? '', description, states, specifications, location: locationOf(header), directiveLocations };\n}\n\nfunction parseState(context: ParserContext, header: SourceLine, machine: string): StateSyntax {\n const match = statePattern.exec(header.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid state '${header.content}' - expected 'state <Name> [initial] [final]'.`, locationOf(header));\n context.skipBlock(header.indent);\n return { kind: 'StateSyntax', name: '', isInitial: false, isFinal: false, entering: [], transitions: [], location: locationOf(header) };\n }\n const modifiers = match[2].split(' ').filter(word => word.length > 0);\n if (modifiers.length !== new Set(modifiers).size) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State '${match[1]}' repeats a modifier.`, locationOf(header));\n const entering: StateEntrySyntax[] = [];\n const transitions: StateTransitionSyntax[] = [];\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(line.content)) {\n case 'entering': {\n const entry = enteringPattern.exec(line.content);\n if (entry === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid entering '${line.content}' - expected 'entering send <Command>' or 'entering start <Workflow>'.`, locationOf(line));\n else entering.push({ kind: 'StateEntrySyntax', entryKind: entry[1] === 'send' ? 'Send' : 'Start', target: entry[2], location: locationOf(line) });\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidStateMachineDeclaration, 'An entering line cannot have children.');\n break;\n }\n case 'on': {\n const transition = transitionPattern.exec(line.content);\n if (transition === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid transition '${line.content}' - expected 'on <Event> [when <condition>] -> <State>'.`, locationOf(line));\n else {\n let when: ConditionSyntax | null = null;\n let failed = false;\n if (transition[2] !== undefined) {\n when = parseCondition(context, transition[2], locationOf(line));\n failed = when === null;\n }\n if (!failed) transitions.push({ kind: 'StateTransitionSyntax', event: transition[1], when, target: transition[3], location: locationOf(line) });\n }\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidStateMachineDeclaration, 'A transition cannot have children.');\n break;\n }\n default:\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Unexpected '${line.content}' in state '${match[1]}' of '${machine}' - expected entering or on.`, locationOf(line));\n context.skipBlock(line.indent);\n }\n }\n return { kind: 'StateSyntax', name: match[1], isInitial: modifiers.includes('initial'), isFinal: modifiers.includes('final'), entering, transitions, location: locationOf(header) };\n}\n"],"mappings":"ofAgBA,MAAMA,EAAgBC,EAAQ,mCAAmC,EAC3DC,EAAiBD,EAAQ,8BAA8B,EACvDE,EAAeF,EAAQ,wDAAwD,EAC/EG,EAAkBH,EAAQ,+CAA+C,EACzEI,EAAoBJ,EAAQ,2EAA2E,EAG7G,SAAgB,kBAAkB,EAAwB,EAAwC,CAC9F,IAAMK,EAAQN,EAAc,KAAKO,EAAO,OAAO,EAC/C,GAAID,IAAU,KAGV,OAFAE,EAAQ,MAAMC,EAAgB,+BAAgC,sCAAsCF,EAAO,QAAQ,qCAAsCG,EAAWH,CAAM,CAAC,EAC3KC,EAAQ,UAAUD,EAAO,MAAM,EACxB,CAAE,KAAM,qBAAsB,KAAMI,EAAUJ,EAAO,OAAO,EAAG,QAAS,GAAI,YAAa,KAAM,OAAQ,CAAC,EAAG,eAAgB,CAAC,EAAG,SAAUG,EAAWH,CAAM,CAAE,EAEvK,IAAMK,EAAON,EAAM,GACfO,EAA6B,KAC7BC,EAAyB,KACvBC,E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EACxMS,EAAS,KAAK,CAAE,KAAM,mBAAoB,UAAWE,EAAM,KAAO,OAAS,OAAS,QAAS,OAAQA,EAAM,GAAI,SAAUnB,EAAWQ,CAAI,CAAE,CAAC,EAChJG,EAAwBb,EAASU,EAAMT,EAAgB,+BAAgC,wCAAwC,EAC/H,KACJ,CACA,IAAK,KAAM,CACP,IAAMqB,EAAazB,EAAkB,KAAKa,EAAK,OAAO,EACtD,GAAIY,IAAe,KAAMtB,EAAQ,MAAMC,EAAgB,+BAAgC,uBAAuBS,EAAK,QAAQ,0DAA2DR,EAAWQ,CAAI,CAAC,MACjM,CACD,IAAIa,EAA+B,KAC/BC,EAAS,GACTF,EAAW,KAAO,IAAA,KAClB,EAAOG,EAAezB,EAASsB,EAAW,GAAIpB,EAAWQ,CAAI,CAAC,EAC9D,EAASa,IAAS,MAEjBC,GAAQJ,EAAY,KAAK,CAAE,KAAM,wBAAyB,MAAOE,EAAW,GAAI,OAAM,OAAQA,EAAW,GAAI,SAAUpB,EAAWQ,CAAI,CAAE,CAAC,CAClJ,CACAG,EAAwBb,EAASU,EAAMT,EAAgB,+BAAgC,oCAAoC,EAC3H,KACJ,CACA,QACID,EAAQ,MAAMC,EAAgB,+BAAgC,eAAeS,EAAK,QAAQ,cAAcZ,EAAM,GAAG,QAAQ4B,EAAQ,8BAA+BxB,EAAWQ,CAAI,CAAC,EAChLV,EAAQ,UAAUU,EAAK,MAAM,CACrC,CAEJ,MAAO,CAAE,KAAM,cAAe,KAAMZ,EAAM,GAAI,UAAWmB,EAAU,SAAS,SAAS,EAAG,QAASA,EAAU,SAAS,OAAO,EAAG,WAAU,cAAa,SAAUf,EAAWH,CAAM,CAAE,CACtL"}
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{dotNetWhitespace as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{parseLiteral as a,parseMappingSource as o}from"./ExpressionParser.js";import{unescapeIdentifier as s}from"./LineText.js";const c=`item`,l=`none`,u=`empty`,d=`@?[\\p{L}_][\\p{L}\\p{N}_]*`,f=RegExp(`^(?<name>${d}(?:\\.${d})*)(?:${r}+(?<marker>none|empty))?$`,`u`),p=RegExp(`^(?<name>${d}|"${t}")(?:${r}*=${r}*(?<value>\\S.*)|(?:${r}+(?<marker>none|empty))?)$`,`u`),markerOf=e=>e.groups?.marker;function trailingMarker(e){return e.endsWith(` none`)?l:e.endsWith(` empty`)?u:void 0}function tryParseStructuredMapping(e,t){let n=f.exec(t.content);if(!(n===null||n.groups.name===`streamId`||markerOf(n)===void 0&&e.peekChild(t.indent)===void 0))return{kind:`PropertyMappingSyntax`,property:s(n.groups.name),source:parseStructuredValue(e,t,markerOf(n)),location:i(t)}}function parseStructuredValue(t,n,r){let a=i(n);if(r===`none`)return rejectChildren(t,n,`An empty list ('none') has no lines under it.`),{kind:`ListExpressionSyntax`,items:[],location:a};if(r===`empty`)return rejectChildren(t,n,`An object without members ('empty') has no lines under it.`),{kind:`ObjectExpressionSyntax`,members:[],location:a};let o=t.peekChild(n.indent);return o===void 0?(t.error(e.InvalidStructuredValue,`'${n.content}' opens a structured value - indent its 'member = value' lines or 'item' lines under it, or end it in 'none' for an empty list or 'empty' for an object without members`,a),{kind:`ObjectExpressionSyntax`,members:[],location:a}):isItem(o.content)?parseList(t,n):parseObject(t,n)}function parseStructuredScalar(t,n,r){if(n.startsWith(`{`)||n.startsWith(`[`))return o(n,r,t);if(n.startsWith(`case.`))return t.error(e.InvalidSpecificationCaseReference,`A case reference fills a whole value position; it cannot occur inside a structured value or expression.`,r),{kind:`RawExpressionSyntax`,text:n,location:r};let i=a(n,r,t);return i===void 0?(t.error(e.InvalidStructuredValue,`Expected a string, number, true, false or null in a structured value, got '${n}'`,r),{kind:`RawExpressionSyntax`,text:n,location:r}):i}const isItem=e=>e===`item`||e.startsWith(`item `)&&!e.substring(4).trimStart().startsWith(`=`),at=(e,t)=>({...i(e),column:i(e).column+t});function parseList(t,n){let r=[];for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent)){if(t.reader.takeSignificant(),!isItem(a.content)){t.error(e.InvalidStructuredValue,`A list holds one 'item' line per element, got '${a.content}'`,i(a)),t.skipBlock(a.indent);continue}let n=a.content.substring(4).trimStart();n.length===0?r.push(parseStructuredValue(t,a,void 0)):n===`none`||n===`empty`?r.push(parseStructuredValue(t,a,n)):(r.push(parseStructuredScalar(t,n,at(a,a.content.length-n.length))),rejectChildren(t,a,`An 'item' with a value has no lines under it.`))}return{kind:`ListExpressionSyntax`,items:r,location:i(n)}}function parseObject(t,r){let a=[],o=/* @__PURE__ */ new Set;for(let c=t.peekChild(r.indent);c!==void 0;c=t.peekChild(r.indent)){t.reader.takeSignificant();let r=p.exec(c.content);if(r===null){t.error(e.InvalidStructuredValue,isItem(c.content)?`An object holds 'member = value' lines; an 'item' line belongs in a list, got '${c.content}'`:`Expected 'member = value', a member opening an indented block, 'member none' or 'member empty', got '${c.content}'`,i(c)),t.skipBlock(c.indent);continue}let l=r.groups.name,u=l.startsWith(`"`)?n(l.substring(1,l.length-1)):s(l),d;r.groups.value===void 0?d=parseStructuredValue(t,c,markerOf(r)):(d=parseStructuredScalar(t,r.groups.value,at(c,c.content.length-r.groups.value.length)),rejectChildren(t,c,`A member with a value has no lines under it.`)),o.has(u)?t.error(e.DuplicateStructuredValueMember,`Duplicate property '${u}' in structured value`,i(c)):(o.add(u),a.push({kind:`ObjectMemberSyntax`,name:u,value:d,location:i(c)}))}return{kind:`ObjectExpressionSyntax`,members:a,location:i(r)}}function rejectChildren(t,n,r){let a=t.peekChild(n.indent);a!==void 0&&(t.error(e.InvalidStructuredValue,r,i(a)),t.skipBlock(n.indent))}export{u as emptyKeyword,c as itemKeyword,markerOf,l as noneKeyword,parseStructuredScalar,parseStructuredValue,trailingMarker,tryParseStructuredMapping};
2
+ //# sourceMappingURL=StructuredBlockParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StructuredBlockParser.js","names":["itemKeyword","noneKeyword","emptyKeyword","name","mappingHeaderPattern","dotNetWhitespace","memberPattern","stringBodyPattern","match","content","header","line","context","unescapeIdentifier","locationOf","location","marker","first","DiagnosticCodes","text","parseMappingSource","literal","parseLiteral","offset","items","rest","members","names","token","memberName","unescapeString","value","child","message"],"sources":["../../../../../../Compiler/Parsing/StructuredBlockParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ExpressionSyntax, ObjectMemberSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { dotNetWhitespace } from '../Text/patterns';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { parseLiteral, parseMappingSource } from './ExpressionParser';\nimport { unescapeIdentifier } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\n// Reads structured values - objects and lists - written as indented blocks; the port of the C# StructuredBlockParser.\n// Screenplay has no JSON. An object is a header line followed by one indented 'member = value' line per member; a\n// member holding an object or a list opens another indented block. A list is a header line followed by one 'item'\n// line per element: 'item <value>' for a scalar and a bare 'item' with an indented block for an object or a nested\n// list. A header - a property, a member or an 'item' - ending in 'none' is an empty list and one ending in 'empty' an\n// object without members; any other header opens a block, so a stray word is never mistaken for an empty value. A\n// block whose first line is an 'item' is a list; a member named 'item' is written '@item', and a member name that is\n// not an identifier is quoted.\nexport const itemKeyword = 'item';\nexport const noneKeyword = 'none';\nexport const emptyKeyword = 'empty';\nexport type StructuredMarker = typeof noneKeyword | typeof emptyKeyword | undefined;\n\nconst name = '@?[\\\\p{L}_][\\\\p{L}\\\\p{N}_]*';\nconst mappingHeaderPattern = new RegExp(`^(?<name>${name}(?:\\\\.${name})*)(?:${dotNetWhitespace}+(?<marker>none|empty))?$`, 'u');\nconst memberPattern = new RegExp(`^(?<name>${name}|\"${stringBodyPattern}\")(?:${dotNetWhitespace}*=${dotNetWhitespace}*(?<value>\\\\S.*)|(?:${dotNetWhitespace}+(?<marker>none|empty))?)$`, 'u');\n\n// The 'none' or 'empty' marker a header match captured, or undefined when the header opens a block.\nexport const markerOf = (match: RegExpExecArray): StructuredMarker => match.groups?.marker as StructuredMarker;\n\n// The 'none' or 'empty' marker ending a line, such as a typed declaration 'tags String[] none'.\nexport function trailingMarker(content: string): StructuredMarker {\n if (content.endsWith(` ${noneKeyword}`)) return noneKeyword;\n return content.endsWith(` ${emptyKeyword}`) ? emptyKeyword : undefined;\n}\n\n// Reads a '<property>' or '<property> none' header line, already taken from the reader, or undefined when the line is not one.\nexport function tryParseStructuredMapping(context: ParserContext, line: SourceLine): PropertyMappingSyntax | undefined {\n const header = mappingHeaderPattern.exec(line.content);\n // A bare word with nothing under it is a malformed line, not an empty object - an object always has members.\n if (header === null || header.groups!.name === 'streamId' || (markerOf(header) === undefined && context.peekChild(line.indent) === undefined)) return undefined;\n return { kind: 'PropertyMappingSyntax', property: unescapeIdentifier(header.groups!.name), source: parseStructuredValue(context, line, markerOf(header)), location: locationOf(line) };\n}\n\n// Reads the structured value opened by a header line already taken from the reader.\nexport function parseStructuredValue(context: ParserContext, header: SourceLine, marker: StructuredMarker): ExpressionSyntax {\n const location = locationOf(header);\n if (marker === noneKeyword) {\n rejectChildren(context, header, \"An empty list ('none') has no lines under it.\");\n return { kind: 'ListExpressionSyntax', items: [], location };\n }\n if (marker === emptyKeyword) {\n rejectChildren(context, header, \"An object without members ('empty') has no lines under it.\");\n return { kind: 'ObjectExpressionSyntax', members: [], location };\n }\n const first = context.peekChild(header.indent);\n if (first === undefined) {\n context.error(DiagnosticCodes.InvalidStructuredValue, `'${header.content}' opens a structured value - indent its 'member = value' lines or 'item' lines under it, or end it in 'none' for an empty list or 'empty' for an object without members`, location);\n return { kind: 'ObjectExpressionSyntax', members: [], location };\n }\n return isItem(first.content) ? parseList(context, header) : parseObject(context, header);\n}\n\n// Reads a scalar written in a structured block, a member value or an 'item' value.\nexport function parseStructuredScalar(context: ParserContext, text: string, location: SourceLocation): ExpressionSyntax {\n if (text.startsWith('{') || text.startsWith('[')) return parseMappingSource(text, location, context);\n if (text.startsWith('case.')) {\n context.error(DiagnosticCodes.InvalidSpecificationCaseReference, 'A case reference fills a whole value position; it cannot occur inside a structured value or expression.', location);\n return { kind: 'RawExpressionSyntax', text, location };\n }\n const literal = parseLiteral(text, location, context);\n if (literal !== undefined) return literal;\n context.error(DiagnosticCodes.InvalidStructuredValue, `Expected a string, number, true, false or null in a structured value, got '${text}'`, location);\n return { kind: 'RawExpressionSyntax', text, location };\n}\n\nconst isItem = (content: string): boolean =>\n content === itemKeyword || (content.startsWith(`${itemKeyword} `) && !content.substring(itemKeyword.length).trimStart().startsWith('='));\n\nconst at = (line: SourceLine, offset: number): SourceLocation => ({ ...locationOf(line), column: locationOf(line).column + offset });\n\nfunction parseList(context: ParserContext, header: SourceLine): ExpressionSyntax {\n const items: ExpressionSyntax[] = [];\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (!isItem(line.content)) {\n context.error(DiagnosticCodes.InvalidStructuredValue, `A list holds one 'item' line per element, got '${line.content}'`, locationOf(line));\n context.skipBlock(line.indent);\n continue;\n }\n const rest = line.content.substring(itemKeyword.length).trimStart();\n if (rest.length === 0) {\n items.push(parseStructuredValue(context, line, undefined));\n } else if (rest === noneKeyword || rest === emptyKeyword) {\n items.push(parseStructuredValue(context, line, rest));\n } else {\n items.push(parseStructuredScalar(context, rest, at(line, line.content.length - rest.length)));\n rejectChildren(context, line, \"An 'item' with a value has no lines under it.\");\n }\n }\n return { kind: 'ListExpressionSyntax', items, location: locationOf(header) };\n}\n\nfunction parseObject(context: ParserContext, header: SourceLine): ExpressionSyntax {\n const members: ObjectMemberSyntax[] = [];\n const names = new Set<string>();\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const match = memberPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidStructuredValue, isItem(line.content)\n ? `An object holds 'member = value' lines; an 'item' line belongs in a list, got '${line.content}'`\n : `Expected 'member = value', a member opening an indented block, 'member none' or 'member empty', got '${line.content}'`, locationOf(line));\n context.skipBlock(line.indent);\n continue;\n }\n const token = match.groups!.name;\n const memberName = token.startsWith('\"') ? unescapeString(token.substring(1, token.length - 1)) : unescapeIdentifier(token);\n let value: ExpressionSyntax;\n if (match.groups!.value !== undefined) {\n value = parseStructuredScalar(context, match.groups!.value, at(line, line.content.length - match.groups!.value.length));\n rejectChildren(context, line, 'A member with a value has no lines under it.');\n } else {\n value = parseStructuredValue(context, line, markerOf(match));\n }\n if (names.has(memberName)) {\n context.error(DiagnosticCodes.DuplicateStructuredValueMember, `Duplicate property '${memberName}' in structured value`, locationOf(line));\n continue;\n }\n names.add(memberName);\n members.push({ kind: 'ObjectMemberSyntax', name: memberName, value, location: locationOf(line) });\n }\n return { kind: 'ObjectExpressionSyntax', members, location: locationOf(header) };\n}\n\nfunction rejectChildren(context: ParserContext, line: SourceLine, message: string): void {\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidStructuredValue, message, locationOf(child));\n context.skipBlock(line.indent);\n }\n}\n"],"mappings":"8aAqBA,MAAaA,EAAc,OACdC,EAAc,OACdC,EAAe,QAGtBC,EAAO,8BACPC,EAA2B,OAAO,YAAYD,EAAK,QAAQA,EAAK,QAAQE,EAAiB,2BAA4B,GAAG,EACxHC,EAAoB,OAAO,YAAYH,EAAK,IAAII,EAAkB,OAAOF,EAAiB,IAAIA,EAAiB,sBAAsBA,EAAiB,4BAA6B,GAAG,EAG/K,SAAY,GAA6CG,EAAM,QAAQ,OAGpF,SAAgB,eAAe,EAAmC,CAE9D,OADIC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G,CACA,MAAO,CAAE,KAAM,yBAA0B,UAAS,SAAUG,EAAWJ,CAAM,CAAE,CACnF,CAEA,SAAS,eAAe,EAAwB,EAAkB,EAAuB,CACrF,IAAMsB,EAAQpB,EAAQ,UAAUD,EAAK,MAAM,EACvCqB,IAAU,IAAA,KACVpB,EAAQ,MAAMM,EAAgB,uBAAwBe,EAASnB,EAAWkB,CAAK,CAAC,EAChFpB,EAAQ,UAAUD,EAAK,MAAM,EAErC"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{parseMappingSource as n}from"./ExpressionParser.js";const r=t(`^(data|query|component)\\s+(\\S+)(.*)$`),i=t(`^literal\\s+(.+?)(?:\\s+(mode\\s+.+|null\\s+.+|expected\\s+.+))?$`),a=t(`^([A-Za-z_]\\w*)(?:\\.(.+))?$`),o=t(`^(?:([A-Za-z_]\\w*)|"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)")\\.(.+)$`),s=t(`^mode\\s+(oneWay|twoWay)\\b(.*)$`),c=t(`^null\\s+(propagate|clear|preserve)\\b(.*)$`),l=t(`^expected\\s+(\\w+(?:\\.\\w+)*)(.*)$`);function parseFromClause(e,t,n){let r=t.trim(),i=r.split(/\s+/,1)[0];return i===`data`||i===`query`||i===`component`||i===`literal`?parseUiBinding(e,`from ${r}`,n):parseUiBinding(e,r,n)}function parseUiBinding(t,a,o){let s=a.trim();if(!s.startsWith(`from `))return withModifiers(t,create(`DataContext`,s,o),``,o);let c=s.substring(5).trim();if(c.startsWith(`literal `)){let r=i.exec(c);return r===null?(t.error(e.UnknownScreenDirective,`Invalid UI binding '${s}' - expected 'from literal <value>'`,o),{...create(`Invalid`,c,o),rawText:s}):withModifiers(t,{...create(`Literal`,``,o),literal:n(r[1],o,t)},r[2]??``,o)}let l=r.exec(c);return l===null?(t.error(e.UnknownScreenDirective,`Invalid UI binding '${s}' - expected 'from data <path>', 'from query <Query>[.<path>]', 'from component <id>.<path>' or 'from literal <value>'`,o),{...create(`Invalid`,c,o),rawText:s}):withModifiers(t,parseBindingSource(t,l[1],l[2],s,o),l[3],o)}function parseBindingSource(e,t,n,r,i){return t===`data`?create(`DataContext`,n,i):t===`query`?queryBinding(e,n,r,i):componentBinding(e,n,r,i)}function queryBinding(t,n,r,i){let o=a.exec(n);return o===null?(t.error(e.UnknownScreenDirective,`Invalid query binding '${r}' - expected 'from query <Query>[.<path>]'.`,i),{...create(`Invalid`,n,i),rawText:r}):{...create(`QueryResult`,o[2]??``,i),query:o[1]}}function componentBinding(t,n,r,i){let a=o.exec(n);if(a===null)return t.error(e.UnknownScreenDirective,`Invalid component binding '${r}' - expected 'from component <stableInstanceId>.<outputPath>' or 'from component "<stableInstanceId>".<outputPath>'.`,i),{...create(`Invalid`,n,i),rawText:r};let s=a[1]??a[2],c=a[3];return{...create(`ComponentProperty`,c,i),componentId:s,componentPropertyPath:c}}function withModifiers(t,n,r,i){let a=n,o=r.trim();for(;o.length>0;){let n=s.exec(o);if(n!==null){a={...a,mode:n[1]===`twoWay`?`TwoWay`:`OneWay`},o=n[2].trim();continue}let r=c.exec(o);if(r!==null){a={...a,nullBehavior:r[1]===`clear`?`Clear`:r[1]===`preserve`?`Preserve`:`Propagate`},o=r[2].trim();continue}let u=l.exec(o);if(u!==null)a={...a,expectedValueType:u[1]},o=u[2].trim();else return t.error(e.UnknownScreenDirective,`Unsupported UI binding modifier '${o}' - supported modifiers are 'mode oneWay|twoWay', 'null propagate|clear|preserve' and 'expected <Type>'.`,i),{...a,rawText:a.rawText??o}}return a}function create(e,t,n){return{kind:`UiBindingSyntax`,bindingKind:e,path:t,query:null,componentId:null,componentPropertyPath:null,mode:null,nullBehavior:null,expectedValueType:null,literal:null,rawText:null,location:n}}export{parseFromClause,parseUiBinding};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{parseMappingSource as r}from"./ExpressionParser.js";import{markerOf as i,parseStructuredValue as a}from"./StructuredBlockParser.js";const o=t(`^(data|query|component)\\s+(\\S+)(.*)$`),s=t(`^(?:from\\s+)?literal(?:\\s+(?<modifiers>(?:mode|null|expected)\\s+.+?))?(?:\\s+(?<marker>none|empty))?$`),c=t(`^literal\\s+(.+?)(?:\\s+(mode\\s+.+|null\\s+.+|expected\\s+.+))?$`),l=t(`^([A-Za-z_]\\w*)(?:\\.(.+))?$`),u=t(`^(?:([A-Za-z_]\\w*)|"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)")\\.(.+)$`),d=t(`^mode\\s+(oneWay|twoWay)\\b(.*)$`),f=t(`^null\\s+(propagate|clear|preserve)\\b(.*)$`),p=t(`^expected\\s+(\\w+(?:\\.\\w+)*)(.*)$`);function parseFromClauseOn(e,t,r){let o=s.exec(t.trim());if(o===null||i(o)===void 0&&e.peekChild(r.indent)===void 0)return parseFromClause(e,t,n(r));let c=a(e,r,i(o));return withModifiers(e,{...create(`Literal`,``,n(r)),literal:c},o.groups.modifiers??``,n(r))}function parseFromClause(e,t,n){let r=t.trim(),i=r.split(/\s+/,1)[0];return i===`data`||i===`query`||i===`component`||i===`literal`?parseUiBinding(e,`from ${r}`,n):parseUiBinding(e,r,n)}function parseUiBinding(t,n,i){let a=n.trim();if(!a.startsWith(`from `))return withModifiers(t,create(`DataContext`,a,i),``,i);let s=a.substring(5).trim();if(s.startsWith(`literal `)){let n=c.exec(s);return n===null?(t.error(e.UnknownScreenDirective,`Invalid UI binding '${a}' - expected 'from literal <value>'`,i),{...create(`Invalid`,s,i),rawText:a}):withModifiers(t,{...create(`Literal`,``,i),literal:r(n[1],i,t)},n[2]??``,i)}let l=o.exec(s);return l===null?(t.error(e.UnknownScreenDirective,`Invalid UI binding '${a}' - expected 'from data <path>', 'from query <Query>[.<path>]', 'from component <id>.<path>' or 'from literal <value>'`,i),{...create(`Invalid`,s,i),rawText:a}):withModifiers(t,parseBindingSource(t,l[1],l[2],a,i),l[3],i)}function parseBindingSource(e,t,n,r,i){return t===`data`?create(`DataContext`,n,i):t===`query`?queryBinding(e,n,r,i):componentBinding(e,n,r,i)}function queryBinding(t,n,r,i){let a=l.exec(n);return a===null?(t.error(e.UnknownScreenDirective,`Invalid query binding '${r}' - expected 'from query <Query>[.<path>]'.`,i),{...create(`Invalid`,n,i),rawText:r}):{...create(`QueryResult`,a[2]??``,i),query:a[1]}}function componentBinding(t,n,r,i){let a=u.exec(n);if(a===null)return t.error(e.UnknownScreenDirective,`Invalid component binding '${r}' - expected 'from component <stableInstanceId>.<outputPath>' or 'from component "<stableInstanceId>".<outputPath>'.`,i),{...create(`Invalid`,n,i),rawText:r};let o=a[1]??a[2],s=a[3];return{...create(`ComponentProperty`,s,i),componentId:o,componentPropertyPath:s}}function withModifiers(t,n,r,i){let a=n,o=r.trim();for(;o.length>0;){let n=d.exec(o);if(n!==null){a={...a,mode:n[1]===`twoWay`?`TwoWay`:`OneWay`},o=n[2].trim();continue}let r=f.exec(o);if(r!==null){a={...a,nullBehavior:r[1]===`clear`?`Clear`:r[1]===`preserve`?`Preserve`:`Propagate`},o=r[2].trim();continue}let s=p.exec(o);if(s!==null)a={...a,expectedValueType:s[1]},o=s[2].trim();else return t.error(e.UnknownScreenDirective,`Unsupported UI binding modifier '${o}' - supported modifiers are 'mode oneWay|twoWay', 'null propagate|clear|preserve' and 'expected <Type>'.`,i),{...a,rawText:a.rawText??o}}return a}function create(e,t,n){return{kind:`UiBindingSyntax`,bindingKind:e,path:t,query:null,componentId:null,componentPropertyPath:null,mode:null,nullBehavior:null,expectedValueType:null,literal:null,rawText:null,location:n}}export{parseFromClause,parseFromClauseOn,parseUiBinding};
2
2
  //# sourceMappingURL=UiBindingParser.js.map