@cratis/screenplay-language 4.125.0 → 4.126.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.
- package/dist/bundles/compiler/Authoring/QuickFixes.js +2 -2
- package/dist/bundles/compiler/Authoring/QuickFixes.js.map +1 -1
- package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
- package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CaptureParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CommandResponseParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CompositionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ConditionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ConstraintParser.js +1 -1
- package/dist/bundles/compiler/Parsing/DeclarationParsers.js +1 -1
- package/dist/bundles/compiler/Parsing/DependencySourceParser.js +1 -1
- package/dist/bundles/compiler/Parsing/DescriptionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/EventMetadataParser.js +1 -1
- package/dist/bundles/compiler/Parsing/EventSourceParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ExpressionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/FeatureBody.js +1 -1
- package/dist/bundles/compiler/Parsing/GuardedActionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/IdentityParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ImplementationParser.js +2 -2
- package/dist/bundles/compiler/Parsing/InputUses.js +1 -1
- package/dist/bundles/compiler/Parsing/InteractionAlternatives.js +1 -1
- package/dist/bundles/compiler/Parsing/ModuleBody.js +1 -1
- package/dist/bundles/compiler/Parsing/OperationParser.js +1 -1
- package/dist/bundles/compiler/Parsing/PolicyParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ProducesParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/PropertyLineParser.js +1 -1
- package/dist/bundles/compiler/Parsing/PurposeParser.js +1 -1
- package/dist/bundles/compiler/Parsing/QueryParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ReactionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ScreenParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SeedParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SliceParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SourceOptionsParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js +1 -1
- package/dist/bundles/compiler/Parsing/TriggerDataParser.js +1 -1
- package/dist/bundles/compiler/index.js +1 -1
- package/dist/bundles/diagnostic-codes.js +1 -1
- package/dist/bundles/diagnostic-codes.js.map +1 -1
- package/dist/bundles/validation.js +1 -1
- package/dist/bundles/validation.js.map +1 -1
- package/dist/diagnostic-codes.d.ts +1 -0
- package/dist/diagnostic-codes.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{
|
|
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{pattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{firstWord as a}from"./LineText.js";import{parseDescription as o}from"./DescriptionParser.js";const s=r(`^purpose\\s+([A-Za-z_]\\w*)$`),c=r(`^(basis|condition)\\s+(\\w+)(?:\\s+"(${t})")?$`),l=r(`^(interest|authorization|retention|recipient)\\s+"(${t})"$`),u=r(`^transfer\\s+"(${t})"\\s+safeguard\\s+"(${t})"$`),d=r(`^[A-Za-z_]\\w*$`),f=r(`^erasure\\s+exception\\s+(\\w+)$`),p=[`consent`,`contract`,`legalObligation`,`vitalInterests`,`publicTask`,`legitimateInterests`],m=[`explicitConsent`,`employmentLaw`,`vitalInterests`,`notForProfit`,`madePublic`,`legalClaims`,`substantialPublicInterest`,`healthCare`,`publicHealth`,`research`],h=[`expression`,`legalObligation`,`publicTask`,`publicHealth`,`archiving`,`legalClaims`];function parsePurpose(t,r){let s=purposeName(t,r),g={kind:`PurposeSyntax`,name:s,description:null,basis:null,basisReference:null,interest:null,condition:null,conditionReference:null,authorization:null,subjects:[],retention:null,recipients:[],transfers:[],erasureException:null,location:i(r)},_=/* @__PURE__ */ new Set,v=[],y=[];for(let b=t.peekChild(r.indent);b!==void 0;b=t.peekChild(r.indent)){t.reader.takeSignificant();let r=a(b.content);if(r!==`recipient`&&r!==`transfer`&&_.has(r))t.error(e.DuplicatePurposeField,`Purpose '${s}' already declares '${r}' - at most one is allowed`,i(b)),t.skipBlock(b.indent);else if(_.add(r),r===`description`)g={...g,description:o(t,b,g.description,`Purpose '${s}'`)};else if(r===`basis`||r===`condition`){let a=c.exec(b.content),o=r===`basis`?p:m;if(a===null||!o.includes(a[2]))t.error(e.InvalidPurposeVocabulary,`Invalid ${r} in purpose '${s}' - expected ${o.join(`, `)} with an optional quoted reference`,i(b));else{let e=a[3]===void 0?null:n(a[3]);g=r===`basis`?{...g,basis:a[2],basisReference:e}:{...g,condition:a[2],conditionReference:e}}}else if(r===`interest`||r===`authorization`||r===`retention`||r===`recipient`){let a=l.exec(b.content);a===null?t.error(e.InvalidPurposeDeclaration,`Invalid purpose field '${b.content}' - expected '${r} "<text>"'`,i(b)):r===`recipient`?v.push(n(a[2])):g={...g,[r]:n(a[2])}}else if(r===`subjects`){let n=b.content.slice(8).split(`,`).map(e=>e.trim());n.every(e=>d.test(e))?g={...g,subjects:[...new Set(n)]}:t.error(e.InvalidPurposeDeclaration,`Invalid purpose subjects '${b.content}' - expected comma-separated identifiers`,i(b))}else if(r===`erasure`){let n=f.exec(b.content);n!==null&&h.includes(n[1])?g={...g,erasureException:n[1]}:t.error(e.InvalidPurposeVocabulary,`Invalid erasure exception '${b.content}' - expected 'erasure exception ${h.join(`|`)}'`,i(b))}else if(r===`transfer`){let r=u.exec(b.content);r===null?t.error(e.InvalidPurposeDeclaration,`Invalid transfer '${b.content}' - expected 'transfer "<destination>" safeguard "<text>"'`,i(b)):y.push({kind:`PurposeTransferSyntax`,destination:n(r[1]),safeguard:n(r[2]),location:i(b)})}else t.error(e.InvalidPurposeDeclaration,`Unexpected '${b.content}' in purpose '${s}'`,i(b)),t.skipBlock(b.indent)}return{...g,recipients:v,transfers:y}}function parsePurposeReference(e,t,n){let r=purposeName(e,t);r.length>0&&!n.some(e=>e.name===r)&&n.push({kind:`PurposeReferenceSyntax`,name:r,location:i(t)})}function purposeName(t,n){let r=s.exec(n.content);return r===null?(t.error(e.InvalidPurposeDeclaration,`Invalid purpose declaration '${n.content}' - expected 'purpose <Name>'`,i(n)),``):r[1]}export{parsePurpose,parsePurposeReference};
|
|
2
2
|
//# sourceMappingURL=PurposeParser.js.map
|
|
@@ -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{
|
|
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{firstWord as i}from"./LineText.js";import{parseTypeRef as a,reportLegacyOptionalSuffix as o}from"./PropertyLineParser.js";import{combineAuthorize as s,parseAuthorize as c}from"./AuthorizeParser.js";import{parseDescription as l}from"./DescriptionParser.js";const u=t(`^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$`),d=t(`^([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$`),f=t(`^scoped\\s+to\\s+([a-z_]\\w*)$`),p=/* @__PURE__ */ new Set([`performer`]);function parseQuery(t,r){let d=u.exec(r.content);if(d===null)return t.error(e.InvalidQueryDeclaration,`Invalid query declaration '${r.content}' - expected 'query <Name> => [observable] <ReadModel>'`,n(r)),t.skipBlock(r.indent),{kind:`QuerySyntax`,name:i(r.content),returnType:a(``,n(r)),by:null,filters:[],description:null,isObservable:!1,scope:null,authorize:null,location:n(r)};let f=d[1],m=a(d[3],{...n(r),column:r.indent+1+d[0].length-d[3].length});(d[2]!==void 0||m.name!==`observable`||!m.isOptional||m.isCollection)&&o(t,m,r);let h=null,g=[],_=null,v=null,y=null;for(let a=t.peekChild(r.indent);a!==void 0;a=t.peekChild(r.indent)){t.reader.takeSignificant();let r=i(a.content);if(r===`description`)_=l(t,a,_,`Query '${f}'`);else if(r===`by`){let r=parseParameter(t,a,`by`);r!==void 0&&(h!==null&&t.error(e.InvalidQueryParameter,`Query '${f}' already declares 'by' - a query can have at most one key parameter`,n(a)),h=r)}else if(r===`filter`){let e=parseParameter(t,a,`filter`);e!==void 0&&g.push(e)}else r===`authorize`?y=s(y,c(t,a)):r===`scoped`?v=parseScope(t,a,v,f)??v:p.has(r)?t.skipOpaqueBlock(a.indent):(t.error(e.UnknownQueryDirective,`Unexpected '${a.content}' in query body - expected description, by, filter, authorize, scoped or performer`,n(a)),t.skipBlock(a.indent))}return{kind:`QuerySyntax`,name:f,returnType:m,by:h,filters:g,description:_,isObservable:d[2]!==void 0,scope:v,authorize:y,location:n(r)}}function parseParameter(t,i,s){let c=d.exec(i.content.substring(s.length).trim());if(c===null){t.error(e.InvalidQueryParameter,`Invalid '${s}' parameter '${i.content}' - expected '${s} <name> <Type> [from <source>]'`,n(i));return}let l=i.content.indexOf(c[1],s.length),u=a(c[2],{...n(i),column:i.indent+1+i.content.indexOf(c[2],l+c[1].length)});return o(t,u,i),{kind:`QueryParameterSyntax`,name:c[1],type:u,source:c[3]===void 0?null:r(c[3],n(i),t.valueContext),location:n(i)}}function parseScope(t,r,i,a){let o=f.exec(r.content);if(o===null)t.error(e.InvalidScopeDeclaration,`Invalid scope declaration '${r.content}' - expected 'scoped to <scope>'`,n(r));else if(i!==null)t.error(e.DuplicateScope,`Query '${a}' already declares a scope - results are narrowed one way`,n(r));else return o[1]}export{parseQuery};
|
|
2
2
|
//# sourceMappingURL=QueryParser.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{
|
|
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";const a=RegExp(`^runs${r}+as${r}+system(?:${r}+role${r}+"${t}"(?:${r}+and${r}+role${r}+"${t}")*)?$`,`u`),o=RegExp(`"(${t})"`,`gu`),s=RegExp(`^runs${r}+as\\b`,`u`),isReactionIdentityLine=e=>s.test(e.content);function parseReactionIdentity(t,r,s){if(s)return t.error(e.InvalidReactionIdentity,`A reaction may declare 'runs as' only once.`,i(r)),t.skipBlock(r.indent),null;if(!a.test(r.content)||t.peekChild(r.indent)!==void 0)return t.error(e.InvalidReactionIdentity,`Expected one reaction-level line: 'runs as system [role "<Role>" and role "<Role>"]'.`,i(r)),t.skipBlock(r.indent),null;let c=[...r.content.matchAll(o)].map(e=>n(e[1]));return c.some(e=>e.length===0)||new Set(c).size!==c.length?(t.error(e.InvalidReactionIdentity,`Reaction identity roles must be nonempty and distinct quoted literals.`,i(r)),null):{kind:`ReactionIdentitySyntax`,syntaxKind:`system`,roles:c,location:i(r)}}function misplacedReactionIdentity(t,n){t.error(e.InvalidReactionIdentity,`'runs as' belongs directly in a reaction body, not under a trigger or invocation.`,i(n)),t.skipBlock(n.indent)}export{isReactionIdentityLine,misplacedReactionIdentity,parseReactionIdentity};
|
|
2
2
|
//# sourceMappingURL=ReactionIdentityParser.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{nativePattern as t,pattern as n}from"../Text/patterns.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{nativePattern as t,pattern as n}from"../Text/patterns.js";import{locationOf as r}from"./SourceLine.js";import{dependencySources as i}from"../Syntax/DependencySources.js";import{parseModeledMappingSource as a}from"./ExpressionParser.js";import{firstWord as o}from"./LineText.js";import{parseDescription as s}from"./DescriptionParser.js";import{parseDocumentation as c}from"./DocumentationParser.js";import{parseCondition as l}from"./ConditionParser.js";import{ParserContext as u}from"./ParserContext.js";import{collectInputUses as d}from"./InputUses.js";import{isReactionIdentityLine as f,misplacedReactionIdentity as p,parseReactionIdentity as m}from"./ReactionIdentityParser.js";import{captureReads as h}from"./DependencySourceParser.js";import{parseProduces as g}from"./ProducesParser.js";import{parseTriggerData as _}from"./TriggerDataParser.js";const v=n(`^reaction\\s+([A-Za-z_]\\w*)$`),y=n(`^when\\s+([A-Za-z_]\\w*)$`),b=n(`^every\\s+(\\d+)\\s+(seconds?|minutes?|hours?|days?)$`),x=n(`^at\\s+(\\d{2}:\\d{2})(?:\\s+on\\s+(?:(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)|day\\s+(\\d{1,2})))?$`),S=/* @__PURE__ */ new Set([`when`,`every`,`at`]),C=n(`^invokes\\s+([A-Z]\\w*)$`),w=t(`^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),T=t(`^on\\s+refused\\b(?=$|\\s+by\\b)`),E=t(`^on\\s+refused(?:\\s+by\\s+(validation|constraint|authorization)(?:\\s+([A-Za-z_]\\w*(?:\\.\\w+)*))?)?$`),D=n(`^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)`);function parseReaction(t,n){let i=v.exec(n.content)?.[1]??``;i===``&&t.error(e.InvalidReactionDeclaration,`Invalid reaction declaration '${n.content}' - expected 'reaction <Name>'`,r(n));let a=null,u=null,d=null,f=null,p=!1,h=[],g=/* @__PURE__ */ new Set,_=!1;for(let v=t.peekChild(n.indent);v!==void 0;v=t.peekChild(n.indent)){t.reader.takeSignificant();let n=o(v.content);if(n===`description`){a=s(t,v,a,`Reaction '${i}'`);continue}if(n===`documentation`){u=c(t,v,u,`Reaction '${i}'`);continue}if(n===`runs`){f=m(t,v,p)??f,p=!0;continue}if(n===`where`){d=l(t,v.content.substring(5).trim(),r(v));continue}if(T.test(v.content)){t.error(e.InvalidRefusalBranch,`A refusal branch belongs inside 'invokes <Command>'.`,r(v)),t.skipBlock(v.indent),_=!0;continue}if(!S.has(n)){t.error(e.InvalidReactionTrigger,`Expected a trigger in reaction body, got '${v.content}' - a reaction is set off by 'when <Name>', 'every <n> <unit>' or 'at <HH:mm>'`,r(v)),t.skipBlock(v.indent),_=!0;continue}let y=parseTriggerSource(t,v);if(y===void 0){_=!0;continue}let b=sourceKey(y);g.has(b)?(t.error(e.DuplicateReactionTrigger,`Reaction '${i}' already declares '${v.content}' - a second says nothing the first did not`,r(v)),t.skipBlock(v.indent)):(g.add(b),h.push(parseTrigger(t,v,y)))}return h.length===0&&!_&&t.error(e.ReactionWithoutTrigger,`Reaction '${i}' must declare at least one trigger - nothing sets it off`,r(n)),{kind:`ReactionSyntax`,name:i,description:a,documentation:u,runsAs:f,where:d,triggers:h,location:r(n)}}function parseTrigger(t,n,c){let l=null,m=[],v=[],y=[],b=[],x=!1;for(let i=t.peekChild(n.indent);i!==void 0;i=t.peekChild(n.indent)){t.reader.takeSignificant();let n=o(i.content);if(n===`runs`&&f(i))p(t,i);else if(n===`description`)l=s(t,i,l,`Trigger '${i.content}'`);else if(n===`produces`){let e=g(t,i);e!==void 0&&m.push(e)}else if(n===`invokes`){let n=C.exec(i.content);if(n===null)t.error(e.InvalidInvokesDeclaration,`Invalid invokes declaration '${i.content}' - expected 'invokes <Command>'`,r(i)),t.skipBlock(i.indent);else{let o=new u(t.reader.fork(),t.path,t.languages);o.scope=t.scope,o.sourceOptions=t.sourceOptions,d(o,i),t.inputUses.push(...o.inputUses);let s=[],c=[];for(let n=t.peekChild(i.indent);n!==void 0;n=t.peekChild(i.indent)){if(t.reader.takeSignificant(),f(n)){p(t,n);continue}if(T.test(n.content)){let e=parseRefusal(t,n);e!==void 0&&c.push(e);continue}let i=w.exec(n.content);i===null?t.error(e.InvalidPropertyMapping,`Invalid property mapping '${n.content}' - expected '<property> = <source>'`,r(n)):s.push({kind:`PropertyMappingSyntax`,property:i[1].replaceAll(`@`,``),source:a(i[2],r(n),t.valueContext),location:r(n)})}v.push({kind:`InvokesSyntax`,command:n[1],mappings:s,onRefused:c,location:r(i)})}}else if(T.test(i.content))t.error(e.InvalidRefusalBranch,`A refusal branch belongs inside 'invokes <Command>'.`,r(i)),t.skipBlock(i.indent);else if(n===`reads`||n===`file`||i.content===`csharp`||i.content.startsWith("```")){x||=n===`file`||i.content===`csharp`||i.content.startsWith("```");let a=h(i);a!==void 0&&y.push(a),D.test(i.content)&&t.error(e.OptionalReadsNotSupported,`Optional reads are not yet supported (see #308).`,r(i)),i.content.startsWith("```")&&t.skipFencedBody(),t.skipOpaqueBlock(i.indent)}else{let e=t.triggerData.length;_(t,i);for(let n of t.triggerData.slice(e))b.push({kind:`TriggerDataSyntax`,name:n.name,type:n.type,location:n.location})}}let S={kind:`ReactionTriggerSyntax`,source:c,description:l,produces:m,invokes:v,location:r(n)};return i.set(S,{reads:y,data:b,implementation:x}),S}function parseRefusal(t,n){let i=E.exec(n.content);if(i===null||i[2]!==void 0&&i[1]!==`constraint`){t.error(e.InvalidRefusalBranch,`Expected 'on refused [by validation | by constraint [<Name>] | by authorization]'.`,r(n)),t.skipBlock(n.indent);return}let a=[],s=!1,c=!1;for(let i=t.peekChild(n.indent);i!==void 0;i=t.peekChild(n.indent))if(t.reader.takeSignificant(),f(i))p(t,i),c=!0;else if(i.content===`acknowledge`)(s||a.length>0||t.peekChild(i.indent)!==void 0)&&(t.error(e.InvalidRefusalBranchBody,`A refusal branch contains 'acknowledge' alone or one or more 'produces' blocks.`,r(i)),c=!0),s=!0,t.skipBlock(i.indent);else if(o(i.content)===`produces`){s&&(t.error(e.InvalidRefusalBranchBody,`A refusal branch cannot combine 'acknowledge' and 'produces'.`,r(i)),c=!0);let n=g(t,i);n===void 0?c=!0:a.push(n)}else t.error(e.InvalidRefusalBranchBody,`Expected 'acknowledge' or 'produces <Event>' in a refusal branch.`,r(i)),t.skipBlock(i.indent),c=!0;return!s&&a.length===0&&!c&&t.error(e.InvalidRefusalBranchBody,`A refusal branch must acknowledge or produce an event.`,r(n)),{kind:`InvocationRefusalSyntax`,selector:i[1]??`any`,constraint:i[2]??null,acknowledge:s,produces:a,location:r(n)}}function sourceKey(e){switch(e.kind){case`NamedTriggerSourceSyntax`:return JSON.stringify([e.kind,e.name]);case`IntervalTriggerSourceSyntax`:return JSON.stringify([e.kind,e.amount,e.unit]);case`ScheduleTriggerSourceSyntax`:return JSON.stringify([e.kind,e.time,e.dayOfWeek,e.dayOfMonth])}}function parseTriggerSource(t,n){let i=r(n);switch(o(n.content)){case`when`:{let r=y.exec(n.content);if(r===null){t.error(e.InvalidReactionTrigger,`Invalid trigger '${n.content}' - expected 'when <Name>'`,i),t.skipBlock(n.indent);return}return{kind:`NamedTriggerSourceSyntax`,name:r[1],location:i}}case`every`:{let r=b.exec(n.content),a=r===null?NaN:Number(r[1]);if(r===null||!Number.isInteger(a)||a<1||a>2147483647){t.error(e.InvalidIntervalTrigger,`Invalid interval '${n.content}' - expected 'every <n> <seconds|minutes|hours|days>'`,i),t.skipBlock(n.indent);return}return{kind:`IntervalTriggerSourceSyntax`,amount:a,unit:unitOf(r[2]),location:i}}default:return parseSchedule(t,n)}}function parseSchedule(t,n){let i=r(n),a=x.exec(n.content),o=a===null?void 0:timeOf(a[1]);if(a===null||o===void 0)t.error(e.InvalidScheduleTrigger,`Invalid schedule '${n.content}' - expected 'at <HH:mm>', optionally followed by 'on <Weekday>' or 'on day <n>'`,i),t.skipBlock(n.indent);else{if(a[3]!==void 0){let r=Number(a[3]);if(r<1||r>31){t.error(e.InvalidScheduleTrigger,`Invalid day of month '${r}' in '${n.content}' - a day of the month is between 1 and 31`,i),t.skipBlock(n.indent);return}return{kind:`ScheduleTriggerSourceSyntax`,time:o,dayOfWeek:null,dayOfMonth:r,location:i}}return{kind:`ScheduleTriggerSourceSyntax`,time:o,dayOfWeek:a[2]??null,dayOfMonth:null,location:i}}}function timeOf(e){let[t,n]=e.split(`:`).map(Number);if(t>=0&&t<=23&&n>=0&&n<=59)return`${e}:00.0000000`}function unitOf(e){switch(e.replace(/s+$/,``)){case`second`:return`Seconds`;case`minute`:return`Minutes`;case`hour`:return`Hours`;default:return`Days`}}export{parseReaction,parseTriggerSource};
|
|
2
2
|
//# sourceMappingURL=ReactionParser.js.map
|
|
@@ -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{stringBodyPattern as n,unescapeString as r}from"../Text/StringLiteral.js";import{parseMappingSource as i}from"./ExpressionParser.js";import{firstWord as a}from"./LineText.js";import{locationOf as o}from"./SourceLine.js";import{parseTypeRef as s}from"./PropertyLineParser.js";import{parseFencedText as c}from"./CodeBlockParser.js";import{parseDescription as l}from"./DescriptionParser.js";import{parseGuardedAction as u}from"./GuardedActionParser.js";import{collectInputUses as d}from"./InputUses.js";import{isFileDirective as f}from"./FileReferences.js";import{parseFromClause as p}from"./UiBindingParser.js";const m=`(?:"(${n})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,h=t(`^screen\\s+([A-Za-z_]\\w*)$`),g=t(`^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$`),_=t(`^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),v=t(`^label\\s+${m}$`),y=t(`^action\\s+${m}$`),b=t(`^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$`),x=t(`^route\\s+${m}$`),S=t(`^outlet\\s+([A-Za-z_]\\w*)$`),C=t(`^contribute\\s+to\\s+([A-Za-z_]\\w*)(?:\\s+order\\s+(-?\\d+))?$`),w=t(`^parameter\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$`),T=t(`^component\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)\\s+([A-Za-z_]\\w*)$`),E=t(`^id\\s+(?:"(${n})"|(\\S+))$`),D=t(`^property\\s+([\\w.]+)\\s+from\\s+(.+)$`),O=t(`^property\\s+([\\w.]+)\\s*=\\s+(.+)$`),k=t(`^exposes\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$`),A=t(`^presentation\\s+([A-Za-z_]\\w*)\\s+${m}$`),j=t(`^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),M=t(`^[a-z_]\\w*$`),N=t(`^title\\s+${m}$`),P=t(`^column\\s+([\\w.]+)(?:\\s+label\\s+${m})?$`),F=t(`^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$`),I=t(`^field\\s+([\\w.]+)\\s+label\\s+${m}$`),operandText=(e,t)=>e[t]===void 0?e[t+1]:r(e[t]),isInteraction=e=>[`on`,`uses`].includes(a(e.content)),isCodeLine=(e,t)=>t.content.startsWith("```")||e.languages.has(t.content);function parseScreen(t,n){let r=h.exec(n.content);r===null&&t.error(e.InvalidScreenDeclaration,`Invalid screen declaration '${n.content}' - expected 'screen <Name>'`,o(n));let i=[],s=[],c=null;for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent))if(t.reader.takeSignificant(),a(e.content)===`contribute`){let n=parseScreenContribution(t,e);n!==void 0&&s.push(n)}else a(e.content)===`description`?c=l(t,e,c,`Screen '${r?.[1]??``}'`):f(e)||pushDirective(t,e,i);return{kind:`ScreenSyntax`,name:r?.[1]??``,directives:i,description:c,...s.length>0?{contributions:s}:{},location:o(n)}}function parseScreenContribution(t,n){let r=C.exec(n.content);if(r===null)t.error(e.UnknownScreenDirective,`Invalid screen contribution '${n.content}' - expected 'contribute to <Point> [order <n>]'`,o(n)),t.skipBlock(n.indent);else return{kind:`ScreenContributionSyntax`,contributionPoint:r[1],order:r[2]===void 0?null:Number(r[2]),directives:parseDirectives(t,n),location:o(n)}}function pushDirective(e,t,n){let r=parseDirective(e,t);r!==void 0&&n.push(r)}function parseDirectives(e,t){let n=[];for(let r=e.peekChild(t.indent);r!==void 0;r=e.peekChild(t.indent))e.reader.takeSignificant(),pushDirective(e,r,n);return n}function parseDirective(t,n){switch(a(n.content)){case`data`:return parseData(t,n);case`action`:return parseAction(t,n);case`template`:return parseTemplateReference(t,n);case`section`:return parseSection(t,n);case`title`:return parseTitle(t,n);case`table`:return parseTable(t,n);case`summary`:return parseSummary(t,n);case`component`:return parseComponent(t,n);case`toolbar`:return parseToolbar(t,n);case`navigate`:return parseNavigate(t,n.content,n);case`on`:return d(t,n),{kind:`ScreenBehaviorSyntax`,location:o(n)};case`uses`:return t.skipOpaqueBlock(n.indent),{kind:`ScreenUsesBehaviorSyntax`,location:o(n)};default:if(isCodeLine(t,n))return parseCode(t,n);t.error(e.UnknownScreenDirective,`Unexpected '${n.content}' in screen body`,o(n)),t.skipBlock(n.indent);return}}function parseData(t,n){let r=g.exec(n.content);if(r===null)t.error(e.InvalidDataDirective,`Invalid data directive '${n.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,o(n));else return{kind:`ScreenDataSyntax`,type:s(r[1],o(n)),query:r[2],by:r[3]??null,location:o(n)}}function parseAction(t,n){let r=y.exec(n.content);if(r!==null)return u(t,n,operandText(r,1),parseNavigate);let i=_.exec(n.content);if(i===null){t.error(e.InvalidActionDirective,`Invalid action directive '${n.content}' - expected 'action <Command>'`,o(n)),t.skipBlock(n.indent);return}let s=null,c=null;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=v.exec(r.content);n===null?a(r.content)===`navigate`?c=parseNavigate(t,r.content,r)??null:t.error(e.UnknownActionDirective,`Unexpected '${r.content}' in action - expected 'label "..."' or 'navigate to ...'`,o(r)):s=operandText(n,1)}return{kind:`ScreenActionSyntax`,command:i[1],label:s,navigate:c,location:o(n)}}function parseNavigate(t,n,r){let i=b.exec(n);if(i===null){t.error(e.InvalidNavigation,`Invalid navigation '${n}' - expected 'navigate to <Screen> [by <param>]'`,o(r));return}let a=[],s=null,c=null;for(let n=t.peekChild(r.indent);n!==void 0;n=t.peekChild(r.indent)){t.reader.takeSignificant();let r=w.exec(n.content);if(r!==null){a.push({kind:`ScreenNavigationParameterSyntax`,name:r[1],binding:p(t,r[2],o(n)),location:o(n)});continue}let i=x.exec(n.content);if(i!==null){s=operandText(i,1);continue}let l=S.exec(n.content);l===null?t.error(e.InvalidNavigation,`Unexpected '${n.content}' in navigation - expected 'route "..."', 'outlet <name>' or 'parameter <name> from <binding>'`,o(n)):c=l[1]}return{kind:`ScreenNavigateSyntax`,screen:i[1],by:i[2]??null,route:s,...c===null?{}:{outlet:c},parameters:a,location:o(r)}}function parseTemplateReference(t,n){let r=n.content.substring(8).trim(),i=[];for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent))t.reader.takeSignificant(),M.test(a.content)?i.push({kind:`ScreenSlotSyntax`,name:a.content,directives:parseDirectives(t,a),location:o(a)}):(t.error(e.InvalidScreenLayoutSlot,`Expected a slot name in template '${r}', got '${a.content}'`,o(a)),t.skipBlock(a.indent));return{kind:`ScreenTemplateReferenceSyntax`,name:r,slots:i,location:o(n)}}function parseSection(e,t){return{kind:`ScreenSectionSyntax`,name:t.content.substring(7).trim(),directives:parseDirectives(e,t),location:o(t)}}function parseTitle(t,n){let r=N.exec(n.content);return r===null?(t.error(e.InvalidTitleDirective,`Invalid title directive '${n.content}' - expected 'title "..."'`,o(n)),{kind:`ScreenTitleSyntax`,text:``,location:o(n)}):{kind:`ScreenTitleSyntax`,text:operandText(r,1),location:o(n)}}function parseTable(t,n){let r=n.content.substring(5).trim(),i=[],s=null;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=P.exec(r.content),c=F.exec(r.content);if(n!==null){let e=n[2]!==void 0||n[3]!==void 0;i.push({kind:`ScreenColumnSyntax`,property:n[1],label:e?operandText(n,2):null,location:o(r)})}else c===null?a(r.content)===`on`?d(t,r):isInteraction(r)?t.skipOpaqueBlock(r.indent):t.error(e.UnknownTableDirective,`Unexpected '${r.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`,o(r)):s=parseNavigate(t,c[1],r)??null}return{kind:`ScreenTableSyntax`,target:r,columns:i,rowClick:s,location:o(n)}}function parseSummary(t,n){let r=n.content.substring(7).trim(),i=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=I.exec(r.content);n===null?t.error(e.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,o(r)):i.push({kind:`ScreenFieldSyntax`,property:n[1],label:operandText(n,2),location:o(r)})}return{kind:`ScreenSummarySyntax`,target:r,fields:i,location:o(n)}}function parseComponent(t,n){let r=T.exec(n.content);if(r===null){t.error(e.UnknownScreenDirective,`Invalid component directive '${n.content}' - expected 'component <Package.Component> <name>'`,o(n)),t.skipBlock(n.indent);return}let i=null,s=null,c=null,l=[],u=[],f=[],p=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent))switch(t.reader.takeSignificant(),a(r.content)){case`context`:i=parseUiContext(t,r);break;case`id`:s=parseStableId(t,r);break;case`property`:parseComponentProperty(t,r,l);break;case`icon`:c=r.content.substring(4).trim();break;case`presentation`:parsePresentationValue(t,r,f);break;case`exposes`:parseExposedValue(t,r,u);break;case`outlet`:p.push({kind:`ComponentOutletSyntax`,name:r.content.substring(6).trim(),directives:parseDirectives(t,r),location:o(r)});break;case`on`:d(t,r);break;case`uses`:t.skipOpaqueBlock(r.indent);break;default:t.error(e.UnknownScreenDirective,`Unexpected '${r.content}' in component - expected context, id, property, icon, presentation, exposes, outlet, on or uses`,o(r)),t.skipBlock(r.indent)}return{kind:`ScreenComponentSyntax`,component:r[1],name:r[2],stableId:s,context:i,properties:l,exposes:u,presentation:f,icon:c,outlets:p,location:o(n)}}function parseUiContext(e,t){return parseUiBindingValue(e,t.content.substring(7).trim(),t)}function parseComponentProperty(t,n,r){let a=D.exec(n.content);if(a!==null){r.push({kind:`ComponentPropertySyntax`,property:a[1],binding:p(t,a[2],o(n)),value:null,location:o(n)});return}let s=O.exec(n.content);s===null?t.error(e.UnknownScreenDirective,`Invalid component property '${n.content}' - expected 'property <path> from <binding>' or 'property <path> = <literal|object|array|null>'`,o(n)):r.push({kind:`ComponentPropertySyntax`,property:s[1],binding:null,value:i(s[2],o(n),t),location:o(n)})}function parseStableId(t,n){let r=E.exec(n.content);return r===null?(t.error(e.UnknownScreenDirective,`Invalid component id '${n.content}' - expected 'id "stable-id"'`,o(n)),null):operandText(r,1)}function parseExposedValue(t,n,r){let i=k.exec(n.content);i===null?t.error(e.UnknownScreenDirective,`Invalid exposed value '${n.content}' - expected 'exposes <name> from <binding>'`,o(n)):r.push({kind:`ComponentExposedValueSyntax`,name:i[1],binding:p(t,i[2],o(n)),location:o(n)})}function parsePresentationValue(t,n,r){let i=A.exec(n.content);i===null?t.error(e.UnknownScreenDirective,`Invalid presentation value '${n.content}' - expected 'presentation <key> "value"'`,o(n)):r.push({kind:`PresentationValueSyntax`,name:i[1],value:operandText(i,2),location:o(n)})}function parseToolbar(e,t){let n=t.content.substring(7).trim(),r=[];for(let n=e.peekChild(t.indent);n!==void 0;n=e.peekChild(t.indent)){e.reader.takeSignificant();let t=parseToolbarItem(e,n);t!==void 0&&r.push(t)}return{kind:`ScreenToolbarSyntax`,name:n,items:r,location:o(t)}}function parseToolbarItem(t,n){let r=j.exec(n.content);if(r===null){t.error(e.UnknownScreenDirective,`Invalid toolbar item '${n.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>' or 'item <name> dialog <DialogTemplate>'`,o(n)),t.skipBlock(n.indent);return}let i=null,s=null,c=[],l=[];for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent)){t.reader.takeSignificant();let n=v.exec(e.content);if(n!==null){i=operandText(n,1);continue}let r=w.exec(e.content);r===null?a(e.content)===`icon`?s=e.content.substring(4).trim():parsePresentationValue(t,e,l):c.push({kind:`ScreenNavigationParameterSyntax`,name:r[1],binding:p(t,r[2],o(e)),location:o(e)})}let u=r[2]===`navigate`?`Navigate`:r[2]===`dialog`?`Dialog`:`Action`;return{kind:`ToolbarItemSyntax`,name:r[1],syntaxKind:u,target:r[3],label:i,icon:s,parameters:c,presentation:l,location:o(n)}}function parseUiBindingValue(e,t,n){return p(e,t,o(n))}function parseCode(t,n){let r=n.content.startsWith("```")?n.content.substring(3):n.content;if(!t.languages.has(r)){t.error(e.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${n.content}'`,o(n));return}n.content.startsWith("```")||t.warning(e.LegacyInlineCodeFence,`'${r}' on its own line is deprecated - use '\`\`\`${r}' instead`,o(n));let i=c(t,r,n);return i===null?void 0:{kind:`ScreenCodeSyntax`,code:{kind:`CodeBlockSyntax`,language:r,code:i,location:o(n)},location:o(n)}}export{parseScreen};
|
|
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{pattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{parseMappingSource as a}from"./ExpressionParser.js";import{firstWord as o}from"./LineText.js";import{parseTypeRef as s}from"./PropertyLineParser.js";import{parseFencedText as c}from"./CodeBlockParser.js";import{parseDescription as l}from"./DescriptionParser.js";import{parseGuardedAction as u}from"./GuardedActionParser.js";import{collectInputUses as d}from"./InputUses.js";import{isFileDirective as f}from"./FileReferences.js";import{parseFromClause as p}from"./UiBindingParser.js";const m=`(?:"(${t})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,h=r(`^screen\\s+([A-Za-z_]\\w*)$`),g=r(`^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$`),_=r(`^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),v=r(`^label\\s+${m}$`),y=r(`^action\\s+${m}$`),b=r(`^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$`),x=r(`^route\\s+${m}$`),S=r(`^outlet\\s+([A-Za-z_]\\w*)$`),C=r(`^contribute\\s+to\\s+([A-Za-z_]\\w*)(?:\\s+order\\s+(-?\\d+))?$`),w=r(`^parameter\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$`),T=r(`^component\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)\\s+([A-Za-z_]\\w*)$`),E=r(`^id\\s+(?:"(${t})"|(\\S+))$`),D=r(`^property\\s+([\\w.]+)\\s+from\\s+(.+)$`),O=r(`^property\\s+([\\w.]+)\\s*=\\s+(.+)$`),k=r(`^exposes\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$`),A=r(`^presentation\\s+([A-Za-z_]\\w*)\\s+${m}$`),j=r(`^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),M=r(`^[a-z_]\\w*$`),N=r(`^title\\s+${m}$`),P=r(`^column\\s+([\\w.]+)(?:\\s+label\\s+${m})?$`),F=r(`^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$`),I=r(`^field\\s+([\\w.]+)\\s+label\\s+${m}$`),operandText=(e,t)=>e[t]===void 0?e[t+1]:n(e[t]),isInteraction=e=>[`on`,`uses`].includes(o(e.content)),isCodeLine=(e,t)=>t.content.startsWith("```")||e.languages.has(t.content);function parseScreen(t,n){let r=h.exec(n.content);r===null&&t.error(e.InvalidScreenDeclaration,`Invalid screen declaration '${n.content}' - expected 'screen <Name>'`,i(n));let a=[],s=[],c=null;for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent))if(t.reader.takeSignificant(),o(e.content)===`contribute`){let n=parseScreenContribution(t,e);n!==void 0&&s.push(n)}else o(e.content)===`description`?c=l(t,e,c,`Screen '${r?.[1]??``}'`):f(e)||pushDirective(t,e,a);return{kind:`ScreenSyntax`,name:r?.[1]??``,directives:a,description:c,...s.length>0?{contributions:s}:{},location:i(n)}}function parseScreenContribution(t,n){let r=C.exec(n.content);if(r===null)t.error(e.UnknownScreenDirective,`Invalid screen contribution '${n.content}' - expected 'contribute to <Point> [order <n>]'`,i(n)),t.skipBlock(n.indent);else return{kind:`ScreenContributionSyntax`,contributionPoint:r[1],order:r[2]===void 0?null:Number(r[2]),directives:parseDirectives(t,n),location:i(n)}}function pushDirective(e,t,n){let r=parseDirective(e,t);r!==void 0&&n.push(r)}function parseDirectives(e,t){let n=[];for(let r=e.peekChild(t.indent);r!==void 0;r=e.peekChild(t.indent))e.reader.takeSignificant(),pushDirective(e,r,n);return n}function parseDirective(t,n){switch(o(n.content)){case`data`:return parseData(t,n);case`action`:return parseAction(t,n);case`template`:return parseTemplateReference(t,n);case`section`:return parseSection(t,n);case`title`:return parseTitle(t,n);case`table`:return parseTable(t,n);case`summary`:return parseSummary(t,n);case`component`:return parseComponent(t,n);case`toolbar`:return parseToolbar(t,n);case`navigate`:return parseNavigate(t,n.content,n);case`on`:return d(t,n),{kind:`ScreenBehaviorSyntax`,location:i(n)};case`uses`:return t.skipOpaqueBlock(n.indent),{kind:`ScreenUsesBehaviorSyntax`,location:i(n)};default:if(isCodeLine(t,n))return parseCode(t,n);t.error(e.UnknownScreenDirective,`Unexpected '${n.content}' in screen body`,i(n)),t.skipBlock(n.indent);return}}function parseData(t,n){let r=g.exec(n.content);if(r===null)t.error(e.InvalidDataDirective,`Invalid data directive '${n.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,i(n));else return{kind:`ScreenDataSyntax`,type:s(r[1],i(n)),query:r[2],by:r[3]??null,location:i(n)}}function parseAction(t,n){let r=y.exec(n.content);if(r!==null)return u(t,n,operandText(r,1),parseNavigate);let a=_.exec(n.content);if(a===null){t.error(e.InvalidActionDirective,`Invalid action directive '${n.content}' - expected 'action <Command>'`,i(n)),t.skipBlock(n.indent);return}let s=null,c=null;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=v.exec(r.content);n===null?o(r.content)===`navigate`?c=parseNavigate(t,r.content,r)??null:t.error(e.UnknownActionDirective,`Unexpected '${r.content}' in action - expected 'label "..."' or 'navigate to ...'`,i(r)):s=operandText(n,1)}return{kind:`ScreenActionSyntax`,command:a[1],label:s,navigate:c,location:i(n)}}function parseNavigate(t,n,r){let a=b.exec(n);if(a===null){t.error(e.InvalidNavigation,`Invalid navigation '${n}' - expected 'navigate to <Screen> [by <param>]'`,i(r));return}let o=[],s=null,c=null;for(let n=t.peekChild(r.indent);n!==void 0;n=t.peekChild(r.indent)){t.reader.takeSignificant();let r=w.exec(n.content);if(r!==null){o.push({kind:`ScreenNavigationParameterSyntax`,name:r[1],binding:p(t,r[2],i(n)),location:i(n)});continue}let a=x.exec(n.content);if(a!==null){s=operandText(a,1);continue}let l=S.exec(n.content);l===null?t.error(e.InvalidNavigation,`Unexpected '${n.content}' in navigation - expected 'route "..."', 'outlet <name>' or 'parameter <name> from <binding>'`,i(n)):c=l[1]}return{kind:`ScreenNavigateSyntax`,screen:a[1],by:a[2]??null,route:s,...c===null?{}:{outlet:c},parameters:o,location:i(r)}}function parseTemplateReference(t,n){let r=n.content.substring(8).trim(),a=[];for(let o=t.peekChild(n.indent);o!==void 0;o=t.peekChild(n.indent))t.reader.takeSignificant(),M.test(o.content)?a.push({kind:`ScreenSlotSyntax`,name:o.content,directives:parseDirectives(t,o),location:i(o)}):(t.error(e.InvalidScreenLayoutSlot,`Expected a slot name in template '${r}', got '${o.content}'`,i(o)),t.skipBlock(o.indent));return{kind:`ScreenTemplateReferenceSyntax`,name:r,slots:a,location:i(n)}}function parseSection(e,t){return{kind:`ScreenSectionSyntax`,name:t.content.substring(7).trim(),directives:parseDirectives(e,t),location:i(t)}}function parseTitle(t,n){let r=N.exec(n.content);return r===null?(t.error(e.InvalidTitleDirective,`Invalid title directive '${n.content}' - expected 'title "..."'`,i(n)),{kind:`ScreenTitleSyntax`,text:``,location:i(n)}):{kind:`ScreenTitleSyntax`,text:operandText(r,1),location:i(n)}}function parseTable(t,n){let r=n.content.substring(5).trim(),a=[],s=null;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=P.exec(r.content),c=F.exec(r.content);if(n!==null){let e=n[2]!==void 0||n[3]!==void 0;a.push({kind:`ScreenColumnSyntax`,property:n[1],label:e?operandText(n,2):null,location:i(r)})}else c===null?o(r.content)===`on`?d(t,r):isInteraction(r)?t.skipOpaqueBlock(r.indent):t.error(e.UnknownTableDirective,`Unexpected '${r.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`,i(r)):s=parseNavigate(t,c[1],r)??null}return{kind:`ScreenTableSyntax`,target:r,columns:a,rowClick:s,location:i(n)}}function parseSummary(t,n){let r=n.content.substring(7).trim(),a=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=I.exec(r.content);n===null?t.error(e.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,i(r)):a.push({kind:`ScreenFieldSyntax`,property:n[1],label:operandText(n,2),location:i(r)})}return{kind:`ScreenSummarySyntax`,target:r,fields:a,location:i(n)}}function parseComponent(t,n){let r=T.exec(n.content);if(r===null){t.error(e.UnknownScreenDirective,`Invalid component directive '${n.content}' - expected 'component <Package.Component> <name>'`,i(n)),t.skipBlock(n.indent);return}let a=null,s=null,c=null,l=[],u=[],f=[],p=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent))switch(t.reader.takeSignificant(),o(r.content)){case`context`:a=parseUiContext(t,r);break;case`id`:s=parseStableId(t,r);break;case`property`:parseComponentProperty(t,r,l);break;case`icon`:c=r.content.substring(4).trim();break;case`presentation`:parsePresentationValue(t,r,f);break;case`exposes`:parseExposedValue(t,r,u);break;case`outlet`:p.push({kind:`ComponentOutletSyntax`,name:r.content.substring(6).trim(),directives:parseDirectives(t,r),location:i(r)});break;case`on`:d(t,r);break;case`uses`:t.skipOpaqueBlock(r.indent);break;default:t.error(e.UnknownScreenDirective,`Unexpected '${r.content}' in component - expected context, id, property, icon, presentation, exposes, outlet, on or uses`,i(r)),t.skipBlock(r.indent)}return{kind:`ScreenComponentSyntax`,component:r[1],name:r[2],stableId:s,context:a,properties:l,exposes:u,presentation:f,icon:c,outlets:p,location:i(n)}}function parseUiContext(e,t){return parseUiBindingValue(e,t.content.substring(7).trim(),t)}function parseComponentProperty(t,n,r){let o=D.exec(n.content);if(o!==null){r.push({kind:`ComponentPropertySyntax`,property:o[1],binding:p(t,o[2],i(n)),value:null,location:i(n)});return}let s=O.exec(n.content);s===null?t.error(e.UnknownScreenDirective,`Invalid component property '${n.content}' - expected 'property <path> from <binding>' or 'property <path> = <literal|object|array|null>'`,i(n)):r.push({kind:`ComponentPropertySyntax`,property:s[1],binding:null,value:a(s[2],i(n),t),location:i(n)})}function parseStableId(t,n){let r=E.exec(n.content);return r===null?(t.error(e.UnknownScreenDirective,`Invalid component id '${n.content}' - expected 'id "stable-id"'`,i(n)),null):operandText(r,1)}function parseExposedValue(t,n,r){let a=k.exec(n.content);a===null?t.error(e.UnknownScreenDirective,`Invalid exposed value '${n.content}' - expected 'exposes <name> from <binding>'`,i(n)):r.push({kind:`ComponentExposedValueSyntax`,name:a[1],binding:p(t,a[2],i(n)),location:i(n)})}function parsePresentationValue(t,n,r){let a=A.exec(n.content);a===null?t.error(e.UnknownScreenDirective,`Invalid presentation value '${n.content}' - expected 'presentation <key> "value"'`,i(n)):r.push({kind:`PresentationValueSyntax`,name:a[1],value:operandText(a,2),location:i(n)})}function parseToolbar(e,t){let n=t.content.substring(7).trim(),r=[];for(let n=e.peekChild(t.indent);n!==void 0;n=e.peekChild(t.indent)){e.reader.takeSignificant();let t=parseToolbarItem(e,n);t!==void 0&&r.push(t)}return{kind:`ScreenToolbarSyntax`,name:n,items:r,location:i(t)}}function parseToolbarItem(t,n){let r=j.exec(n.content);if(r===null){t.error(e.UnknownScreenDirective,`Invalid toolbar item '${n.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>' or 'item <name> dialog <DialogTemplate>'`,i(n)),t.skipBlock(n.indent);return}let a=null,s=null,c=[],l=[];for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent)){t.reader.takeSignificant();let n=v.exec(e.content);if(n!==null){a=operandText(n,1);continue}let r=w.exec(e.content);r===null?o(e.content)===`icon`?s=e.content.substring(4).trim():parsePresentationValue(t,e,l):c.push({kind:`ScreenNavigationParameterSyntax`,name:r[1],binding:p(t,r[2],i(e)),location:i(e)})}let u=r[2]===`navigate`?`Navigate`:r[2]===`dialog`?`Dialog`:`Action`;return{kind:`ToolbarItemSyntax`,name:r[1],syntaxKind:u,target:r[3],label:a,icon:s,parameters:c,presentation:l,location:i(n)}}function parseUiBindingValue(e,t,n){return p(e,t,i(n))}function parseCode(t,n){let r=n.content.startsWith("```")?n.content.substring(3):n.content;if(!t.languages.has(r)){t.error(e.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${n.content}'`,i(n));return}n.content.startsWith("```")||t.warning(e.LegacyInlineCodeFence,`'${r}' on its own line is deprecated - use '\`\`\`${r}' instead`,i(n));let a=c(t,r,n);return a===null?void 0:{kind:`ScreenCodeSyntax`,code:{kind:`CodeBlockSyntax`,language:r,code:a,location:i(n)},location:i(n)}}export{parseScreen};
|
|
2
2
|
//# sourceMappingURL=ScreenParser.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{
|
|
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{pattern as r}from"../Text/patterns.js";import{locationOf as i,startOf as a}from"./SourceLine.js";import{parseComplianceDirective as o,parseComplianceMarkers as s}from"./ConceptComplianceParser.js";import{firstWord as c,unescapeIdentifier as l}from"./LineText.js";import{describePlacement as u,documentPlacement as d,isDocumentPlacement as f}from"../Files/PlayPlacement.js";import{parseDescription as p}from"./DescriptionParser.js";import{parsePurpose as m}from"./PurposeParser.js";import{isFileImport as h,parseFileImport as g}from"./FileImportParser.js";import{recordAuthoredDocument as _}from"../Syntax/SourceOptions.js";import{collectInputUses as v}from"./InputUses.js";import{misplacedReactionIdentity as y}from"./ReactionIdentityParser.js";import{parseEventSource as b}from"./EventSourceParser.js";import{isFileDirective as x}from"./FileReferences.js";import{parseSystem as S}from"./OperationParser.js";import{parseExample as C}from"./SpecificationExampleParser.js";import{isBlankPublicEventOrigin as w}from"../Syntax/PublicEventInvariants.js";import{parseType as T}from"./DeclarationParsers.js";import{parseValidate as E}from"./CommandParser.js";import{parseTriggerDeclaration as D}from"./TriggerDataParser.js";import{FeatureBody as O,featureBodyExpected as k}from"./FeatureBody.js";import{ModuleBody as A,moduleBodyExpected as j,modulePattern as M,parseModule as N}from"./ModuleBody.js";import{parseIdentity as P}from"./IdentityParser.js";import{parsePolicy as F}from"./PolicyParser.js";import{parseSeed as I}from"./SeedParser.js";import{parseExposure as L,parseInstance as R}from"./CompositionParser.js";const z=r(`^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`),B=r(`^import\\s+([\\w.]+)(?:\\s+from\\s+"(?<origin>${t})")?$`),V=r(`^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$`),H=r(`^@?[a-z_]\\w*$`),U=r(`^persona\\s+([A-Za-z_]\\w*)$`),W=r(`^policy\\s+([A-Za-z_]\\w*)$`),G=/^[ ]*\t/,K=[`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`],q=/* @__PURE__ */ new Set([`policy`,`authentication`,`seed`,`ui`,`theme`,`trigger`,`layout`,`behavior`]),J=/* @__PURE__ */ new Set([`slice`,`feature`,`description`,`documentation`,`authorize`,`screen`,`dialog`,`form`,`contribute`,`on`,`uses`]);function parseApplication(t,r,a=d){t.deferIdentityValidation=!0,warnOnTabIndentation(t,r);let o=a.length===1?new A(a[0]):void 0,s=a.length>1?new O(a[a.length-1]):void 0,l=o??s,u=null,p=null,x=[],E=[],k=[],j=[],M=[],z=[],V=[],H=[],U=[],W=[],G=[],K=[],J=[],Y=[],X=[],Z=!1;for(let r=t.reader.peekSignificant();r!==void 0;r=t.reader.peekSignificant()){t.reader.takeSignificant();let s=c(r.content);if(s===`runs`)y(t,r);else if(s===`domain`)t.authoredDeclarations=!0,p=parseDomain(t,r,p,Z);else if(Z||=declaresConstruct(s,r,a),t.authoredDeclarations||=s!==`import`&&declaresConstruct(s,r,a),s===`import`&&h(r.content))l===void 0?g(t,r,E):l.tryParse(t,r);else if(s===`import`){let a=B.exec(r.content);if(a===null)t.error(e.InvalidImportDeclaration,`Invalid import '${r.content}' - expected 'import <Qualified.Name> [from "<origin>"]'`,i(r));else{let o=a.groups?.origin===void 0?null:n(a.groups.origin);o!==null&&w(o)&&t.error(e.InvalidImportDeclaration,`An import origin must be a nonblank quoted string`,i(r)),x.push({kind:`ImportSyntax`,qualifiedName:a[1],origin:o,visibility:o===null?`Private`:`Public`,location:i(r)})}}else if(s===`example`)l===void 0?K.push(C(t,r)):l.tryParse(t,r);else if(s===`eventsource`)z.push(b(t,r));else if(s===`system`)M.push(S(t,r));else if(s===`concept`)k.push(parseConcept(t,r));else if(s===`type`)j.push(T(t,r));else if(s===`module`&&!f(a))parseModuleInPlacedFile(t,r,a,o);else if(s===`module`)V.push(N(t,r));else if(s===`persona`)H.push(parsePersona(t,r));else if(s===`seed`)G.push(I(t.valueContext,r));else if(s===`purpose`&&l!==void 0)l.tryParse(t,r);else if(s===`purpose`)W.push(m(t,r));else if(s===`identity`)u=P(t,r,u);else if(s===`policy`)U.push(F(t,r));else if(s===`exposure`)Y.push(L(t,r));else if(s===`instance`)X.push(R(t,r));else if(s===`trigger`){let e=D(t,r),n=/^trigger\s+([A-Za-z_]\w*)$/.exec(r.content)?.[1];n!==void 0&&J.push({name:n,data:e})}else q.has(s)?s===`behavior`||s===`layout`?v(t,r):t.skipOpaqueBlock(r.indent):l?.tryParse(t,r)!==!0&&reportUnexpectedTopLevel(t,r,a)}o===void 0?s!==void 0&&V.unshift(place(a,s.build(t.start,!0),t.start)):V.unshift(o.build(t.start,!0));let Q={kind:`ApplicationSyntax`,...u===null?{}:{identity:u},sourceOptions:t.sourceOptions,domain:p,imports:x,concepts:k,types:j,systems:M,eventSources:z,examples:K,modules:V,personas:H,policies:U,purposes:W,seeds:G,declaredTriggers:J,fileImports:E,...Y.length>0?{exposures:Y}:{},...X.length>0?{instanceContributions:X}:{},location:t.start};return t.authoredDeclarations&&_(Q),Q}function declaresConstruct(e,t,n){return e===`import`?B.test(t.content):e===`module`?f(n):e===`identity`?t.content===`identity`:e===`purpose`||e===`example`||e===`exposure`||e===`instance`||e===`eventsource`||e===`system`||e===`concept`||e===`type`||e===`persona`||q.has(e)}function parseModuleInPlacedFile(t,n,r,a){let o=M.exec(n.content)?.[1]??``;a!==void 0&&o===r[0]?(t.authoredDeclarations=!0,a.parseChildren(t,n)):(t.error(e.ModuleInPlacedFile,`This file is imported into ${u(r)}, so it cannot declare module '${o}' - import it at the top level of a document instead`,i(n)),t.skipBlock(n.indent))}function reportUnexpectedTopLevel(t,n,r){let a=c(n.content);if(f(r)){let r=J.has(a)?` - '${a}' belongs in a module or feature; wrap it in one, or import this file from inside one`:` - expected domain, import, concept, type, policy, persona, authentication, identity, module, seed, trigger, behavior, ui profile, theme or layout`;t.error(e.UnknownTopLevelConstruct,`Unexpected '${a}' at the top level${r}`,i(n))}else{let o=r.length===1?j:k;t.error(e.UnexpectedInPlacedFile,`Unexpected '${a}' in a file imported into ${u(r)} - expected an application declaration or ${o}`,i(n))}t.skipBlock(n.indent)}function place(e,t,n){let r=t;for(let t=e.length-2;t>=1;t--)r={kind:`FeatureSyntax`,name:e[t],description:null,authorize:null,features:[r],slices:[],fileImports:[],isPlacement:!0,location:n};return{kind:`ModuleSyntax`,name:e[0],description:null,authorize:null,features:[r],fileImports:[],isPlacement:!0,location:n}}function parseDomain(t,n,r,a){let o=z.exec(n.content);return o===null?(t.error(e.InvalidDomainDeclaration,`Invalid domain declaration '${n.content}' - expected 'domain <Qualified.Name>'`,i(n)),r):r===null?(a&&t.error(e.DomainNotFirst,`'domain' must be declared before any other construct`,i(n)),{kind:`DomainSyntax`,name:o[1],location:i(n)}):(t.error(e.DuplicateDomain,`The document already declares a domain - a document can have at most one`,i(n)),r)}function warnOnTabIndentation(t,n){let r=!1;for(let i of n)i.raw.trimStart().startsWith("```")?r=!r:!r&&G.test(i.raw)&&t.warning(e.TabIndentation,`Screenplay is indentation based - use spaces, not tabs`,a(i))}function parseConcept(t,n){let r=V.exec(n.content);if(r===null)return t.error(e.InvalidConceptDeclaration,`Invalid concept declaration '${n.content}' - expected 'concept <Name> : <Type>'`,i(n)),t.skipBlock(n.indent),{kind:`ConceptSyntax`,name:c(n.content),type:``,attributes:[],values:[],location:i(n)};let[,a,u,d]=r,f=s(t,n,a,d);u!==`Enum`&&!K.includes(u)&&t.error(e.UnknownPrimitiveType,`Unknown primitive type '${u}' - expected ${K.join(`, `)} or Enum`,i(n));let m=[],h=null,g=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent))if(t.reader.takeSignificant(),c(r.content)===`description`&&(u!==`Enum`||r.content!==`description`||t.peekChild(r.indent)?.content.startsWith("```")===!0))h=p(t,r,h,`Concept '${a}'`);else if(x(r))continue;else if(c(r.content)===`validate`){u===`Enum`&&r.content===`validate`&&t.peekChild(r.indent)===void 0&&t.warning(e.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${a}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,i(r));let n=E(t,r,`concept`);n!==void 0&&g.push(n)}else o(t,r,a,f)||(u===`Enum`&&H.test(r.content)?m.push(l(r.content)):u===`Enum`?t.error(e.InvalidEnumerationValue,`Invalid enum value '${r.content}' - expected an identifier`,i(r)):(t.error(e.UnknownConceptDirective,`Unexpected '${r.content}' in concept body - expected validate, 'file <path>' or '<attribute> reason "<text>"'`,i(r)),t.skipBlock(r.indent)));return{kind:`ConceptSyntax`,name:a,type:u,attributes:f,values:m,validations:g,description:h,location:i(n)}}function parsePersona(t,n){let r=U.exec(n.content)?.[1]??``;r===``&&t.error(e.InvalidPersonaDeclaration,`Invalid persona declaration '${n.content}' - expected 'persona <Name>'`,i(n));let a=null,o=[];for(let s=t.peekChild(n.indent);s!==void 0;s=t.peekChild(n.indent)){t.reader.takeSignificant();let n=c(s.content);if(n===`description`)a=p(t,s,a,`Persona '${r}'`);else if(n===`policy`){let n=W.exec(s.content);n===null?t.error(e.InvalidPersonaPolicyReference,`Invalid policy reference '${s.content}' - expected 'policy <Name>'`,i(s)):o.push(n[1])}else t.error(e.UnknownPersonaDirective,`Unexpected '${n}' in persona body - expected description or policy`,i(s)),t.skipBlock(s.indent)}return{kind:`PersonaSyntax`,name:r,description:a,policies:o,location:i(n)}}export{parseApplication};
|
|
2
2
|
//# sourceMappingURL=ScreenplayParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScreenplayParser.js","names":["domainPattern","pattern","importPattern","stringBodyPattern","conceptPattern","enumValuePattern","personaPattern","personaPolicyPattern","tabIndentPattern","primitiveTypes","opaqueTopLevel","bodyKeywords","documentPlacement","context","lines","moduleBody","placement","ModuleBody","featureBody","FeatureBody","placedBody","identity","domain","imports","fileImports","concepts","types","systems","eventSources","modules","personas","policies","purposes","seeds","examples","declaredTriggers","exposures","instanceContributions","sawOtherConstruct","line","keyword","firstWord","misplacedReactionIdentity","isFileImport","parseFileImport","match","DiagnosticCodes","locationOf","origin","unescapeString","isBlankPublicEventOrigin","parseExample","parseEventSource","parseSystem","parseType","isDocumentPlacement","parseModule","parseSeed","parsePurpose","parseIdentity","parsePolicy","parseExposure","parseInstance","data","parseTriggerDeclaration","name","collectInputUses","root","recordAuthoredDocument","modulePattern","describePlacement","word","hint","expected","moduleBodyExpected","featureBodyExpected","feature","innermost","index","start","existing","inFence","startOf","type","attributeText","attributes","parseComplianceMarkers","values","description","validations","child","parseDescription","isFileDirective","parsed","parseValidate","parseComplianceDirective","unescapeIdentifier","policy"],"sources":["../../../../../../Compiler/Parsing/ScreenplayParser.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 { IdentitySyntax } from '../Syntax/IdentitySyntax';\nimport { parseIdentity } from './IdentityParser';\nimport { misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { recordAuthoredDocument } from '../Syntax/SourceOptions';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { describePlacement, documentPlacement, isDocumentPlacement, PlayPlacement } from '../Files/PlayPlacement';\nimport { PersonaSyntax } from '../Syntax/Authorization';\nimport { ConceptSyntax, DomainSyntax, ImportSyntax, TypeSyntax } from '../Syntax/Declarations';\nimport { SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { ApplicationSyntax, FeatureSyntax, FileImportSyntax, ModuleSyntax } from '../Syntax/Structure';\nimport { parseTriggerDeclaration } from './TriggerDataParser';\nimport { pattern } from '../Text/patterns';\nimport { parseComplianceDirective, parseComplianceMarkers } from './ConceptComplianceParser';\nimport { parseType } from './DeclarationParsers';\nimport { ValidateSyntax } from '../Syntax/Commands';\nimport { parseValidate } from './CommandParser';\nimport { parseDescription } from './DescriptionParser';\nimport { FeatureBody, featureBodyExpected } from './FeatureBody';\nimport { isFileImport, parseFileImport } from './FileImportParser';\nimport { isFileDirective } from './FileReferences';\nimport { collectInputUses } from './InputUses';\nimport { firstWord, unescapeIdentifier } from './LineText';\nimport { ModuleBody, moduleBodyExpected, modulePattern, parseModule } from './ModuleBody';\nimport { ParserContext } from './ParserContext';\nimport { PolicySyntax } from '../Syntax/Policies';\nimport { parsePolicy } from './PolicyParser';\nimport { PurposeSyntax } from '../Syntax/Purposes';\nimport { parsePurpose } from './PurposeParser';\nimport { SeedSyntax } from '../Syntax/Seeds';\nimport { parseSeed } from './SeedParser';\nimport { parseSystem } from './OperationParser';\nimport { EventVisibility } from '../Syntax/EventVisibility';\nimport { isBlankPublicEventOrigin } from '../Syntax/PublicEventInvariants';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { SystemSyntax } from '../Syntax/Operations';\nimport { EventSourceSyntax } from '../Syntax/EventSources';\nimport { parseEventSource } from './EventSourceParser';\nimport { parseExposure, parseInstance } from './CompositionParser';\nimport { ExposureSyntax, InstanceContributionsSyntax } from '../Syntax/CompositionSyntax';\nimport { parseExample } from './SpecificationExampleParser';\nimport { locationOf, SourceLine, startOf } from './SourceLine';\n\nconst domainPattern = pattern('^domain\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)$');\nconst importPattern = pattern(`^import\\\\s+([\\\\w.]+)(?:\\\\s+from\\\\s+\"(?<origin>${stringBodyPattern})\")?$`);\nconst conceptPattern = pattern('^concept\\\\s+(\\\\w+)\\\\s*:\\\\s*(\\\\w+)((?:\\\\s+@?\\\\w+)*)$');\nconst enumValuePattern = pattern('^@?[a-z_]\\\\w*$');\nconst personaPattern = pattern('^persona\\\\s+([A-Za-z_]\\\\w*)$');\nconst personaPolicyPattern = pattern('^policy\\\\s+([A-Za-z_]\\\\w*)$');\nconst tabIndentPattern = /^[ ]*\\t/;\nconst primitiveTypes = ['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime'];\n\n// Top-level, module and feature constructs the C# compiler knows that this compiler does not model. They\n// are skipped whole, not reported.\nconst opaqueTopLevel = new Set(['policy', 'authentication', 'seed', 'ui', 'theme', 'trigger', 'layout', 'behavior']);\n\n// What belongs in a module or feature body; at the top level of a whole document it gets a hint saying so.\nconst bodyKeywords = new Set(['slice', 'feature', 'description', 'documentation', 'authorize', 'screen', 'dialog', 'form', 'contribute', 'on', 'uses']);\n\n// Parses one document into its application syntax - the port of the C# ScreenplayParser. The placement says\n// where the document's top level belongs: the application, unless an import placed it in a module or feature.\nexport function parseApplication(context: ParserContext, lines: readonly SourceLine[], placement: PlayPlacement = documentPlacement): ApplicationSyntax {\n context.deferIdentityValidation = true;\n warnOnTabIndentation(context, lines);\n const moduleBody = placement.length === 1 ? new ModuleBody(placement[0]) : undefined;\n const featureBody = placement.length > 1 ? new FeatureBody(placement[placement.length - 1]) : undefined;\n const placedBody = moduleBody ?? featureBody;\n let identity: IdentitySyntax | null = null;\n let domain: DomainSyntax | null = null;\n const imports: ImportSyntax[] = [];\n const fileImports: FileImportSyntax[] = [];\n const concepts: ConceptSyntax[] = [];\n const types: TypeSyntax[] = [];\n const systems: SystemSyntax[] = [];\n const eventSources: EventSourceSyntax[] = [];\n const modules: ModuleSyntax[] = [];\n const personas: PersonaSyntax[] = [];\n const policies: PolicySyntax[] = [];\n const purposes: PurposeSyntax[] = [];\n const seeds: SeedSyntax[] = [];\n const examples: SpecificationExampleSyntax[] = [];\n const declaredTriggers: NonNullable<ApplicationSyntax['declaredTriggers']>[number][] = [];\n const exposures: ExposureSyntax[] = [];\n const instanceContributions: InstanceContributionsSyntax[] = [];\n let sawOtherConstruct = false;\n for (let line = context.reader.peekSignificant(); line !== undefined; line = context.reader.peekSignificant()) {\n context.reader.takeSignificant();\n const keyword = firstWord(line.content);\n if (keyword === 'runs') {\n misplacedReactionIdentity(context, line);\n continue;\n }\n if (keyword === 'domain') {\n context.authoredDeclarations = true;\n domain = parseDomain(context, line, domain, sawOtherConstruct);\n continue;\n }\n // The C# parser asks whether anything was declared before the domain, so an import it rejected,\n // a file import and an unknown construct do not count.\n sawOtherConstruct ||= declaresConstruct(keyword, line, placement);\n context.authoredDeclarations ||= keyword !== 'import' && declaresConstruct(keyword, line, placement);\n if (keyword === 'import' && isFileImport(line.content)) {\n // A top level import belongs to whatever the document's top level is - the application, or the\n // module or feature the document was itself imported into.\n if (placedBody !== undefined) {\n placedBody.tryParse(context, line);\n } else {\n parseFileImport(context, line, fileImports);\n }\n } else if (keyword === 'import') {\n const match = importPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidImportDeclaration, `Invalid import '${line.content}' - expected 'import <Qualified.Name> [from \"<origin>\"]'`, locationOf(line));\n } else {\n const origin = match.groups?.origin === undefined ? null : unescapeString(match.groups.origin);\n if (origin !== null && isBlankPublicEventOrigin(origin)) {\n context.error(DiagnosticCodes.InvalidImportDeclaration, 'An import origin must be a nonblank quoted string', locationOf(line));\n }\n imports.push({ kind: 'ImportSyntax', qualifiedName: match[1], origin, visibility: origin === null ? EventVisibility.Private : EventVisibility.Public, location: locationOf(line) });\n }\n } else if (keyword === 'example') {\n if (placedBody !== undefined) placedBody.tryParse(context, line);\n else examples.push(parseExample(context, line));\n } else if (keyword === 'eventsource') {\n eventSources.push(parseEventSource(context, line));\n } else if (keyword === 'system') {\n systems.push(parseSystem(context, line));\n } else if (keyword === 'concept') {\n concepts.push(parseConcept(context, line));\n } else if (keyword === 'type') {\n types.push(parseType(context, line));\n } else if (keyword === 'module' && !isDocumentPlacement(placement)) {\n parseModuleInPlacedFile(context, line, placement, moduleBody);\n } else if (keyword === 'module') {\n modules.push(parseModule(context, line));\n } else if (keyword === 'persona') {\n personas.push(parsePersona(context, line));\n } else if (keyword === 'seed') {\n seeds.push(parseSeed(context.valueContext, line));\n } else if (keyword === 'purpose' && placedBody !== undefined) {\n placedBody.tryParse(context, line);\n } else if (keyword === 'purpose') {\n purposes.push(parsePurpose(context, line));\n } else if (keyword === 'identity') {\n identity = parseIdentity(context, line, identity);\n } else if (keyword === 'policy') {\n // Legacy policies were opaque: enrich their structure without adding diagnostics.\n policies.push(parsePolicy(context, line));\n } else if (keyword === 'exposure') {\n exposures.push(parseExposure(context, line));\n } else if (keyword === 'instance') {\n instanceContributions.push(parseInstance(context, line));\n } else if (keyword === 'trigger') {\n const data = parseTriggerDeclaration(context, line);\n const name = /^trigger\\s+([A-Za-z_]\\w*)$/.exec(line.content)?.[1];\n if (name !== undefined) declaredTriggers.push({ name, data });\n } else if (opaqueTopLevel.has(keyword)) {\n if (keyword === 'behavior' || keyword === 'layout') collectInputUses(context, line);\n else context.skipOpaqueBlock(line.indent);\n } else if (placedBody?.tryParse(context, line) !== true) {\n reportUnexpectedTopLevel(context, line, placement);\n }\n }\n if (moduleBody !== undefined) {\n modules.unshift(moduleBody.build(context.start, true));\n } else if (featureBody !== undefined) {\n modules.unshift(place(placement, featureBody.build(context.start, true), context.start));\n }\n const root: ApplicationSyntax = { kind: 'ApplicationSyntax', ...(identity === null ? {} : { identity }), sourceOptions: context.sourceOptions, domain, imports, concepts, types, systems, eventSources, examples, modules, personas, policies, purposes, seeds, declaredTriggers, fileImports, ...(exposures.length > 0 ? { exposures } : {}), ...(instanceContributions.length > 0 ? { instanceContributions } : {}), location: context.start };\n if (context.authoredDeclarations) recordAuthoredDocument(root);\n return root;\n}\n\nfunction declaresConstruct(keyword: string, line: SourceLine, placement: PlayPlacement): boolean {\n if (keyword === 'import') {\n return importPattern.test(line.content);\n }\n if (keyword === 'module') {\n return isDocumentPlacement(placement);\n }\n if (keyword === 'identity') return line.content === 'identity';\n return keyword === 'purpose' || keyword === 'example' || keyword === 'exposure' || keyword === 'instance' || keyword === 'eventsource' || keyword === 'system' || keyword === 'concept' || keyword === 'type' || keyword === 'persona' || opaqueTopLevel.has(keyword);\n}\n\nfunction parseModuleInPlacedFile(context: ParserContext, line: SourceLine, placement: PlayPlacement, moduleBody: ModuleBody | undefined): void {\n const name = modulePattern.exec(line.content)?.[1] ?? '';\n\n // Restating the module a file is placed in says nothing new, so its body simply joins the placement.\n if (moduleBody !== undefined && name === placement[0]) {\n context.authoredDeclarations = true;\n moduleBody.parseChildren(context, line);\n return;\n }\n context.error(DiagnosticCodes.ModuleInPlacedFile,\n `This file is imported into ${describePlacement(placement)}, so it cannot declare module '${name}' - import it at the top level of a document instead`, locationOf(line));\n context.skipBlock(line.indent);\n}\n\nfunction reportUnexpectedTopLevel(context: ParserContext, line: SourceLine, placement: PlayPlacement): void {\n const word = firstWord(line.content);\n if (!isDocumentPlacement(placement)) {\n const expected = placement.length === 1 ? moduleBodyExpected : featureBodyExpected;\n context.error(DiagnosticCodes.UnexpectedInPlacedFile,\n `Unexpected '${word}' in a file imported into ${describePlacement(placement)} - expected an application declaration or ${expected}`, locationOf(line));\n } else {\n const hint = bodyKeywords.has(word)\n ? ` - '${word}' belongs in a module or feature; wrap it in one, or import this file from inside one`\n : ' - expected domain, import, concept, type, policy, persona, authentication, identity, module, seed, trigger, behavior, ui profile, theme or layout';\n context.error(DiagnosticCodes.UnknownTopLevelConstruct, `Unexpected '${word}' at the top level${hint}`, locationOf(line));\n }\n context.skipBlock(line.indent);\n}\n\n// Wraps the feature a file is placed in in the features and module around it, each marked as a placement.\nfunction place(placement: PlayPlacement, innermost: FeatureSyntax, start: SourceLocation): ModuleSyntax {\n let feature = innermost;\n for (let index = placement.length - 2; index >= 1; index--) {\n feature = {\n kind: 'FeatureSyntax', name: placement[index], description: null, authorize: null,\n features: [feature], slices: [], fileImports: [], isPlacement: true, location: start,\n };\n }\n return {\n kind: 'ModuleSyntax', name: placement[0], description: null, authorize: null,\n features: [feature], fileImports: [], isPlacement: true, location: start,\n };\n}\n\nfunction parseDomain(context: ParserContext, line: SourceLine, existing: DomainSyntax | null, sawOtherConstruct: boolean): DomainSyntax | null {\n const match = domainPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidDomainDeclaration, `Invalid domain declaration '${line.content}' - expected 'domain <Qualified.Name>'`, locationOf(line));\n return existing;\n }\n if (existing !== null) {\n context.error(DiagnosticCodes.DuplicateDomain, 'The document already declares a domain - a document can have at most one', locationOf(line));\n return existing;\n }\n if (sawOtherConstruct) {\n context.error(DiagnosticCodes.DomainNotFirst, '\\'domain\\' must be declared before any other construct', locationOf(line));\n }\n return { kind: 'DomainSyntax', name: match[1], location: locationOf(line) };\n}\n\nfunction warnOnTabIndentation(context: ParserContext, lines: readonly SourceLine[]): void {\n let inFence = false;\n for (const line of lines) {\n if (line.raw.trimStart().startsWith('```')) {\n inFence = !inFence;\n continue;\n }\n if (!inFence && tabIndentPattern.test(line.raw)) {\n context.warning(DiagnosticCodes.TabIndentation, 'Screenplay is indentation based - use spaces, not tabs', startOf(line));\n }\n }\n}\n\nfunction parseConcept(context: ParserContext, line: SourceLine): ConceptSyntax {\n const match = conceptPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidConceptDeclaration, `Invalid concept declaration '${line.content}' - expected 'concept <Name> : <Type>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ConceptSyntax', name: firstWord(line.content), type: '', attributes: [], values: [], location: locationOf(line) };\n }\n const [, name, type, attributeText] = match;\n const attributes = parseComplianceMarkers(context, line, attributeText);\n if (type !== 'Enum' && !primitiveTypes.includes(type)) {\n context.error(DiagnosticCodes.UnknownPrimitiveType, `Unknown primitive type '${type}' - expected ${primitiveTypes.join(', ')} or Enum`, locationOf(line));\n }\n const values: string[] = [];\n let description: string | null = null;\n const validations: ValidateSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'description' && (type !== 'Enum' || child.content !== 'description' || context.peekChild(child.indent)?.content.startsWith('```') === true)) {\n description = parseDescription(context, child, description, `Concept '${name}'`);\n } else if (isFileDirective(child)) {\n continue;\n } else if (firstWord(child.content) === 'validate') {\n if (type === 'Enum' && child.content === 'validate' && context.peekChild(child.indent) === undefined) {\n context.warning(DiagnosticCodes.ValidateReadAsEnumerationBlock,\n `'validate' in enumeration concept '${name}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,\n locationOf(child));\n }\n const parsed = parseValidate(context, child, 'concept');\n if (parsed !== undefined) validations.push(parsed);\n } else if (parseComplianceDirective(context, child, name, attributes)) {\n // Compliance directives are modeled by their original concept marker.\n } else if (type === 'Enum' && enumValuePattern.test(child.content)) {\n values.push(unescapeIdentifier(child.content));\n } else if (type === 'Enum') {\n context.error(DiagnosticCodes.InvalidEnumerationValue, `Invalid enum value '${child.content}' - expected an identifier`, locationOf(child));\n } else {\n context.error(DiagnosticCodes.UnknownConceptDirective, `Unexpected '${child.content}' in concept body - expected validate, 'file <path>' or '<attribute> reason \"<text>\"'`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return { kind: 'ConceptSyntax', name, type, attributes, values, validations, description, location: locationOf(line) };\n}\n\n// 'persona <Name>' with an optional description and the policies it holds - the port of the C# ParsePersona.\nfunction parsePersona(context: ParserContext, line: SourceLine): PersonaSyntax {\n const name = personaPattern.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid persona declaration '${line.content}' - expected 'persona <Name>'`, locationOf(line));\n }\n let description: string | null = null;\n const policies: string[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'description') {\n description = parseDescription(context, child, description, `Persona '${name}'`);\n } else if (keyword === 'policy') {\n const policy = personaPolicyPattern.exec(child.content);\n if (policy === null) {\n context.error(DiagnosticCodes.InvalidPersonaPolicyReference, `Invalid policy reference '${child.content}' - expected 'policy <Name>'`, locationOf(child));\n } else {\n policies.push(policy[1]);\n }\n } else {\n context.error(DiagnosticCodes.UnknownPersonaDirective, `Unexpected '${keyword}' in persona body - expected description or policy`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return { kind: 'PersonaSyntax', name, description, policies, location: locationOf(line) };\n}\n"],"mappings":"6xDA8CA,MAAMA,EAAgBC,EAAQ,kDAAkD,EAC1EC,EAAgBD,EAAQ,iDAAiDE,EAAkB,MAAM,EACjGC,EAAiBH,EAAQ,qDAAqD,EAC9EI,EAAmBJ,EAAQ,gBAAgB,EAC3CK,EAAiBL,EAAQ,8BAA8B,EACvDM,EAAuBN,EAAQ,6BAA6B,EAC5DO,EAAmB,UACnBC,EAAiB,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,UAAU,EAIhFC,kBAAiB,IAAI,IAAI,CAAC,SAAU,iBAAkB,OAAQ,KAAM,QAAS,UAAW,SAAU,UAAU,CAAC,EAG7GC,kBAAe,IAAI,IAAI,CAAC,QAAS,UAAW,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,IAAA,GAAW,EAAQ7E,EAAQ,UAAU0B,EAAK,MAAM,EAAG,CAC1G1B,EAAQ,OAAO,gBAAgB,EAC/B,IAAM2B,EAAUC,EAAUiD,EAAM,OAAO,EACvC,GAAIlD,IAAY,cACZ,EAAcmD,EAAiB9E,EAAS6E,EAAOF,EAAa,YAAYvB,EAAK,EAAE,OAC5E,GAAIzB,IAAY,SAAU,CAC7B,IAAMyD,EAAS1F,EAAqB,KAAKmF,EAAM,OAAO,EAClDO,IAAW,KACXpF,EAAQ,MAAMiC,EAAgB,8BAA+B,6BAA6B4C,EAAM,QAAQ,8BAA+B3C,EAAW2C,CAAK,CAAC,EAExJ3D,EAAS,KAAKkE,EAAO,EAAE,CAE/B,MACIpF,EAAQ,MAAMiC,EAAgB,wBAAyB,eAAeN,EAAQ,oDAAqDO,EAAW2C,CAAK,CAAC,EACpJ7E,EAAQ,UAAU6E,EAAM,MAAM,CAEtC,CACA,MAAO,CAAE,KAAM,gBAAiB,OAAM,cAAa,WAAU,SAAU3C,EAAWR,CAAI,CAAE,CAC5F"}
|
|
1
|
+
{"version":3,"file":"ScreenplayParser.js","names":["domainPattern","pattern","importPattern","stringBodyPattern","conceptPattern","enumValuePattern","personaPattern","personaPolicyPattern","tabIndentPattern","primitiveTypes","opaqueTopLevel","bodyKeywords","documentPlacement","context","lines","moduleBody","placement","ModuleBody","featureBody","FeatureBody","placedBody","identity","domain","imports","fileImports","concepts","types","systems","eventSources","modules","personas","policies","purposes","seeds","examples","declaredTriggers","exposures","instanceContributions","sawOtherConstruct","line","keyword","firstWord","misplacedReactionIdentity","isFileImport","parseFileImport","match","DiagnosticCodes","locationOf","origin","unescapeString","isBlankPublicEventOrigin","parseExample","parseEventSource","parseSystem","parseType","isDocumentPlacement","parseModule","parseSeed","parsePurpose","parseIdentity","parsePolicy","parseExposure","parseInstance","data","parseTriggerDeclaration","name","collectInputUses","root","recordAuthoredDocument","modulePattern","describePlacement","word","hint","expected","moduleBodyExpected","featureBodyExpected","feature","innermost","index","start","existing","inFence","startOf","type","attributeText","attributes","parseComplianceMarkers","values","description","validations","child","parseDescription","isFileDirective","parsed","parseValidate","parseComplianceDirective","unescapeIdentifier","policy"],"sources":["../../../../../../Compiler/Parsing/ScreenplayParser.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 { IdentitySyntax } from '../Syntax/IdentitySyntax';\nimport { parseIdentity } from './IdentityParser';\nimport { misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { recordAuthoredDocument } from '../Syntax/SourceOptions';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { describePlacement, documentPlacement, isDocumentPlacement, PlayPlacement } from '../Files/PlayPlacement';\nimport { PersonaSyntax } from '../Syntax/Authorization';\nimport { ConceptSyntax, DomainSyntax, ImportSyntax, TypeSyntax } from '../Syntax/Declarations';\nimport { SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { ApplicationSyntax, FeatureSyntax, FileImportSyntax, ModuleSyntax } from '../Syntax/Structure';\nimport { parseTriggerDeclaration } from './TriggerDataParser';\nimport { pattern } from '../Text/patterns';\nimport { parseComplianceDirective, parseComplianceMarkers } from './ConceptComplianceParser';\nimport { parseType } from './DeclarationParsers';\nimport { ValidateSyntax } from '../Syntax/Commands';\nimport { parseValidate } from './CommandParser';\nimport { parseDescription } from './DescriptionParser';\nimport { FeatureBody, featureBodyExpected } from './FeatureBody';\nimport { isFileImport, parseFileImport } from './FileImportParser';\nimport { isFileDirective } from './FileReferences';\nimport { collectInputUses } from './InputUses';\nimport { firstWord, unescapeIdentifier } from './LineText';\nimport { ModuleBody, moduleBodyExpected, modulePattern, parseModule } from './ModuleBody';\nimport { ParserContext } from './ParserContext';\nimport { PolicySyntax } from '../Syntax/Policies';\nimport { parsePolicy } from './PolicyParser';\nimport { PurposeSyntax } from '../Syntax/Purposes';\nimport { parsePurpose } from './PurposeParser';\nimport { SeedSyntax } from '../Syntax/Seeds';\nimport { parseSeed } from './SeedParser';\nimport { parseSystem } from './OperationParser';\nimport { EventVisibility } from '../Syntax/EventVisibility';\nimport { isBlankPublicEventOrigin } from '../Syntax/PublicEventInvariants';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { SystemSyntax } from '../Syntax/Operations';\nimport { EventSourceSyntax } from '../Syntax/EventSources';\nimport { parseEventSource } from './EventSourceParser';\nimport { parseExposure, parseInstance } from './CompositionParser';\nimport { ExposureSyntax, InstanceContributionsSyntax } from '../Syntax/CompositionSyntax';\nimport { parseExample } from './SpecificationExampleParser';\nimport { locationOf, SourceLine, startOf } from './SourceLine';\n\nconst domainPattern = pattern('^domain\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)$');\nconst importPattern = pattern(`^import\\\\s+([\\\\w.]+)(?:\\\\s+from\\\\s+\"(?<origin>${stringBodyPattern})\")?$`);\nconst conceptPattern = pattern('^concept\\\\s+(\\\\w+)\\\\s*:\\\\s*(\\\\w+)((?:\\\\s+@?\\\\w+)*)$');\nconst enumValuePattern = pattern('^@?[a-z_]\\\\w*$');\nconst personaPattern = pattern('^persona\\\\s+([A-Za-z_]\\\\w*)$');\nconst personaPolicyPattern = pattern('^policy\\\\s+([A-Za-z_]\\\\w*)$');\nconst tabIndentPattern = /^[ ]*\\t/;\nconst primitiveTypes = ['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime'];\n\n// Top-level, module and feature constructs the C# compiler knows that this compiler does not model. They\n// are skipped whole, not reported.\nconst opaqueTopLevel = new Set(['policy', 'authentication', 'seed', 'ui', 'theme', 'trigger', 'layout', 'behavior']);\n\n// What belongs in a module or feature body; at the top level of a whole document it gets a hint saying so.\nconst bodyKeywords = new Set(['slice', 'feature', 'description', 'documentation', 'authorize', 'screen', 'dialog', 'form', 'contribute', 'on', 'uses']);\n\n// Parses one document into its application syntax - the port of the C# ScreenplayParser. The placement says\n// where the document's top level belongs: the application, unless an import placed it in a module or feature.\nexport function parseApplication(context: ParserContext, lines: readonly SourceLine[], placement: PlayPlacement = documentPlacement): ApplicationSyntax {\n context.deferIdentityValidation = true;\n warnOnTabIndentation(context, lines);\n const moduleBody = placement.length === 1 ? new ModuleBody(placement[0]) : undefined;\n const featureBody = placement.length > 1 ? new FeatureBody(placement[placement.length - 1]) : undefined;\n const placedBody = moduleBody ?? featureBody;\n let identity: IdentitySyntax | null = null;\n let domain: DomainSyntax | null = null;\n const imports: ImportSyntax[] = [];\n const fileImports: FileImportSyntax[] = [];\n const concepts: ConceptSyntax[] = [];\n const types: TypeSyntax[] = [];\n const systems: SystemSyntax[] = [];\n const eventSources: EventSourceSyntax[] = [];\n const modules: ModuleSyntax[] = [];\n const personas: PersonaSyntax[] = [];\n const policies: PolicySyntax[] = [];\n const purposes: PurposeSyntax[] = [];\n const seeds: SeedSyntax[] = [];\n const examples: SpecificationExampleSyntax[] = [];\n const declaredTriggers: NonNullable<ApplicationSyntax['declaredTriggers']>[number][] = [];\n const exposures: ExposureSyntax[] = [];\n const instanceContributions: InstanceContributionsSyntax[] = [];\n let sawOtherConstruct = false;\n for (let line = context.reader.peekSignificant(); line !== undefined; line = context.reader.peekSignificant()) {\n context.reader.takeSignificant();\n const keyword = firstWord(line.content);\n if (keyword === 'runs') {\n misplacedReactionIdentity(context, line);\n continue;\n }\n if (keyword === 'domain') {\n context.authoredDeclarations = true;\n domain = parseDomain(context, line, domain, sawOtherConstruct);\n continue;\n }\n // The C# parser asks whether anything was declared before the domain, so an import it rejected,\n // a file import and an unknown construct do not count.\n sawOtherConstruct ||= declaresConstruct(keyword, line, placement);\n context.authoredDeclarations ||= keyword !== 'import' && declaresConstruct(keyword, line, placement);\n if (keyword === 'import' && isFileImport(line.content)) {\n // A top level import belongs to whatever the document's top level is - the application, or the\n // module or feature the document was itself imported into.\n if (placedBody !== undefined) {\n placedBody.tryParse(context, line);\n } else {\n parseFileImport(context, line, fileImports);\n }\n } else if (keyword === 'import') {\n const match = importPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidImportDeclaration, `Invalid import '${line.content}' - expected 'import <Qualified.Name> [from \"<origin>\"]'`, locationOf(line));\n } else {\n const origin = match.groups?.origin === undefined ? null : unescapeString(match.groups.origin);\n if (origin !== null && isBlankPublicEventOrigin(origin)) {\n context.error(DiagnosticCodes.InvalidImportDeclaration, 'An import origin must be a nonblank quoted string', locationOf(line));\n }\n imports.push({ kind: 'ImportSyntax', qualifiedName: match[1], origin, visibility: origin === null ? EventVisibility.Private : EventVisibility.Public, location: locationOf(line) });\n }\n } else if (keyword === 'example') {\n if (placedBody !== undefined) placedBody.tryParse(context, line);\n else examples.push(parseExample(context, line));\n } else if (keyword === 'eventsource') {\n eventSources.push(parseEventSource(context, line));\n } else if (keyword === 'system') {\n systems.push(parseSystem(context, line));\n } else if (keyword === 'concept') {\n concepts.push(parseConcept(context, line));\n } else if (keyword === 'type') {\n types.push(parseType(context, line));\n } else if (keyword === 'module' && !isDocumentPlacement(placement)) {\n parseModuleInPlacedFile(context, line, placement, moduleBody);\n } else if (keyword === 'module') {\n modules.push(parseModule(context, line));\n } else if (keyword === 'persona') {\n personas.push(parsePersona(context, line));\n } else if (keyword === 'seed') {\n seeds.push(parseSeed(context.valueContext, line));\n } else if (keyword === 'purpose' && placedBody !== undefined) {\n placedBody.tryParse(context, line);\n } else if (keyword === 'purpose') {\n purposes.push(parsePurpose(context, line));\n } else if (keyword === 'identity') {\n identity = parseIdentity(context, line, identity);\n } else if (keyword === 'policy') {\n // Legacy policies were opaque: enrich their structure without adding diagnostics.\n policies.push(parsePolicy(context, line));\n } else if (keyword === 'exposure') {\n exposures.push(parseExposure(context, line));\n } else if (keyword === 'instance') {\n instanceContributions.push(parseInstance(context, line));\n } else if (keyword === 'trigger') {\n const data = parseTriggerDeclaration(context, line);\n const name = /^trigger\\s+([A-Za-z_]\\w*)$/.exec(line.content)?.[1];\n if (name !== undefined) declaredTriggers.push({ name, data });\n } else if (opaqueTopLevel.has(keyword)) {\n if (keyword === 'behavior' || keyword === 'layout') collectInputUses(context, line);\n else context.skipOpaqueBlock(line.indent);\n } else if (placedBody?.tryParse(context, line) !== true) {\n reportUnexpectedTopLevel(context, line, placement);\n }\n }\n if (moduleBody !== undefined) {\n modules.unshift(moduleBody.build(context.start, true));\n } else if (featureBody !== undefined) {\n modules.unshift(place(placement, featureBody.build(context.start, true), context.start));\n }\n const root: ApplicationSyntax = { kind: 'ApplicationSyntax', ...(identity === null ? {} : { identity }), sourceOptions: context.sourceOptions, domain, imports, concepts, types, systems, eventSources, examples, modules, personas, policies, purposes, seeds, declaredTriggers, fileImports, ...(exposures.length > 0 ? { exposures } : {}), ...(instanceContributions.length > 0 ? { instanceContributions } : {}), location: context.start };\n if (context.authoredDeclarations) recordAuthoredDocument(root);\n return root;\n}\n\nfunction declaresConstruct(keyword: string, line: SourceLine, placement: PlayPlacement): boolean {\n if (keyword === 'import') {\n return importPattern.test(line.content);\n }\n if (keyword === 'module') {\n return isDocumentPlacement(placement);\n }\n if (keyword === 'identity') return line.content === 'identity';\n return keyword === 'purpose' || keyword === 'example' || keyword === 'exposure' || keyword === 'instance' || keyword === 'eventsource' || keyword === 'system' || keyword === 'concept' || keyword === 'type' || keyword === 'persona' || opaqueTopLevel.has(keyword);\n}\n\nfunction parseModuleInPlacedFile(context: ParserContext, line: SourceLine, placement: PlayPlacement, moduleBody: ModuleBody | undefined): void {\n const name = modulePattern.exec(line.content)?.[1] ?? '';\n\n // Restating the module a file is placed in says nothing new, so its body simply joins the placement.\n if (moduleBody !== undefined && name === placement[0]) {\n context.authoredDeclarations = true;\n moduleBody.parseChildren(context, line);\n return;\n }\n context.error(DiagnosticCodes.ModuleInPlacedFile,\n `This file is imported into ${describePlacement(placement)}, so it cannot declare module '${name}' - import it at the top level of a document instead`, locationOf(line));\n context.skipBlock(line.indent);\n}\n\nfunction reportUnexpectedTopLevel(context: ParserContext, line: SourceLine, placement: PlayPlacement): void {\n const word = firstWord(line.content);\n if (!isDocumentPlacement(placement)) {\n const expected = placement.length === 1 ? moduleBodyExpected : featureBodyExpected;\n context.error(DiagnosticCodes.UnexpectedInPlacedFile,\n `Unexpected '${word}' in a file imported into ${describePlacement(placement)} - expected an application declaration or ${expected}`, locationOf(line));\n } else {\n const hint = bodyKeywords.has(word)\n ? ` - '${word}' belongs in a module or feature; wrap it in one, or import this file from inside one`\n : ' - expected domain, import, concept, type, policy, persona, authentication, identity, module, seed, trigger, behavior, ui profile, theme or layout';\n context.error(DiagnosticCodes.UnknownTopLevelConstruct, `Unexpected '${word}' at the top level${hint}`, locationOf(line));\n }\n context.skipBlock(line.indent);\n}\n\n// Wraps the feature a file is placed in in the features and module around it, each marked as a placement.\nfunction place(placement: PlayPlacement, innermost: FeatureSyntax, start: SourceLocation): ModuleSyntax {\n let feature = innermost;\n for (let index = placement.length - 2; index >= 1; index--) {\n feature = {\n kind: 'FeatureSyntax', name: placement[index], description: null, authorize: null,\n features: [feature], slices: [], fileImports: [], isPlacement: true, location: start,\n };\n }\n return {\n kind: 'ModuleSyntax', name: placement[0], description: null, authorize: null,\n features: [feature], fileImports: [], isPlacement: true, location: start,\n };\n}\n\nfunction parseDomain(context: ParserContext, line: SourceLine, existing: DomainSyntax | null, sawOtherConstruct: boolean): DomainSyntax | null {\n const match = domainPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidDomainDeclaration, `Invalid domain declaration '${line.content}' - expected 'domain <Qualified.Name>'`, locationOf(line));\n return existing;\n }\n if (existing !== null) {\n context.error(DiagnosticCodes.DuplicateDomain, 'The document already declares a domain - a document can have at most one', locationOf(line));\n return existing;\n }\n if (sawOtherConstruct) {\n context.error(DiagnosticCodes.DomainNotFirst, '\\'domain\\' must be declared before any other construct', locationOf(line));\n }\n return { kind: 'DomainSyntax', name: match[1], location: locationOf(line) };\n}\n\nfunction warnOnTabIndentation(context: ParserContext, lines: readonly SourceLine[]): void {\n let inFence = false;\n for (const line of lines) {\n if (line.raw.trimStart().startsWith('```')) {\n inFence = !inFence;\n continue;\n }\n if (!inFence && tabIndentPattern.test(line.raw)) {\n context.warning(DiagnosticCodes.TabIndentation, 'Screenplay is indentation based - use spaces, not tabs', startOf(line));\n }\n }\n}\n\nfunction parseConcept(context: ParserContext, line: SourceLine): ConceptSyntax {\n const match = conceptPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidConceptDeclaration, `Invalid concept declaration '${line.content}' - expected 'concept <Name> : <Type>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ConceptSyntax', name: firstWord(line.content), type: '', attributes: [], values: [], location: locationOf(line) };\n }\n const [, name, type, attributeText] = match;\n const attributes = parseComplianceMarkers(context, line, name, attributeText);\n if (type !== 'Enum' && !primitiveTypes.includes(type)) {\n context.error(DiagnosticCodes.UnknownPrimitiveType, `Unknown primitive type '${type}' - expected ${primitiveTypes.join(', ')} or Enum`, locationOf(line));\n }\n const values: string[] = [];\n let description: string | null = null;\n const validations: ValidateSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'description' && (type !== 'Enum' || child.content !== 'description' || context.peekChild(child.indent)?.content.startsWith('```') === true)) {\n description = parseDescription(context, child, description, `Concept '${name}'`);\n } else if (isFileDirective(child)) {\n continue;\n } else if (firstWord(child.content) === 'validate') {\n if (type === 'Enum' && child.content === 'validate' && context.peekChild(child.indent) === undefined) {\n context.warning(DiagnosticCodes.ValidateReadAsEnumerationBlock,\n `'validate' in enumeration concept '${name}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,\n locationOf(child));\n }\n const parsed = parseValidate(context, child, 'concept');\n if (parsed !== undefined) validations.push(parsed);\n } else if (parseComplianceDirective(context, child, name, attributes)) {\n // Compliance directives are modeled by their original concept marker.\n } else if (type === 'Enum' && enumValuePattern.test(child.content)) {\n values.push(unescapeIdentifier(child.content));\n } else if (type === 'Enum') {\n context.error(DiagnosticCodes.InvalidEnumerationValue, `Invalid enum value '${child.content}' - expected an identifier`, locationOf(child));\n } else {\n context.error(DiagnosticCodes.UnknownConceptDirective, `Unexpected '${child.content}' in concept body - expected validate, 'file <path>' or '<attribute> reason \"<text>\"'`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return { kind: 'ConceptSyntax', name, type, attributes, values, validations, description, location: locationOf(line) };\n}\n\n// 'persona <Name>' with an optional description and the policies it holds - the port of the C# ParsePersona.\nfunction parsePersona(context: ParserContext, line: SourceLine): PersonaSyntax {\n const name = personaPattern.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid persona declaration '${line.content}' - expected 'persona <Name>'`, locationOf(line));\n }\n let description: string | null = null;\n const policies: string[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'description') {\n description = parseDescription(context, child, description, `Persona '${name}'`);\n } else if (keyword === 'policy') {\n const policy = personaPolicyPattern.exec(child.content);\n if (policy === null) {\n context.error(DiagnosticCodes.InvalidPersonaPolicyReference, `Invalid policy reference '${child.content}' - expected 'policy <Name>'`, locationOf(child));\n } else {\n policies.push(policy[1]);\n }\n } else {\n context.error(DiagnosticCodes.UnknownPersonaDirective, `Unexpected '${keyword}' in persona body - expected description or policy`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return { kind: 'PersonaSyntax', name, description, policies, location: locationOf(line) };\n}\n"],"mappings":"6xDA8CA,MAAMA,EAAgBC,EAAQ,kDAAkD,EAC1EC,EAAgBD,EAAQ,iDAAiDE,EAAkB,MAAM,EACjGC,EAAiBH,EAAQ,qDAAqD,EAC9EI,EAAmBJ,EAAQ,gBAAgB,EAC3CK,EAAiBL,EAAQ,8BAA8B,EACvDM,EAAuBN,EAAQ,6BAA6B,EAC5DO,EAAmB,UACnBC,EA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,EAAQ,MAAMiC,EAAgB,0BAA2B,gCAAgCP,EAAK,QAAQ,+BAAgCQ,EAAWR,CAAI,CAAC,EAE1J,IAAIiD,EAA6B,KAC3BzD,EAAqB,CAAC,EAC5B,IAAK,IAAI2D,EAAQ7E,EAAQ,UAAU0B,EAAK,MAAM,EAAGmD,IAAU,IAAA,GAAW,EAAQ7E,EAAQ,UAAU0B,EAAK,MAAM,EAAG,CAC1G1B,EAAQ,OAAO,gBAAgB,EAC/B,IAAM2B,EAAUC,EAAUiD,EAAM,OAAO,EACvC,GAAIlD,IAAY,cACZ,EAAcmD,EAAiB9E,EAAS6E,EAAOF,EAAa,YAAYvB,EAAK,EAAE,OAC5E,GAAIzB,IAAY,SAAU,CAC7B,IAAMyD,EAAS1F,EAAqB,KAAKmF,EAAM,OAAO,EAClDO,IAAW,KACXpF,EAAQ,MAAMiC,EAAgB,8BAA+B,6BAA6B4C,EAAM,QAAQ,8BAA+B3C,EAAW2C,CAAK,CAAC,EAExJ3D,EAAS,KAAKkE,EAAO,EAAE,CAE/B,MACIpF,EAAQ,MAAMiC,EAAgB,wBAAyB,eAAeN,EAAQ,oDAAqDO,EAAW2C,CAAK,CAAC,EACpJ7E,EAAQ,UAAU6E,EAAM,MAAM,CAEtC,CACA,MAAO,CAAE,KAAM,gBAAiB,OAAM,cAAa,WAAU,SAAU3C,EAAWR,CAAI,CAAE,CAC5F"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{
|
|
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{nativePattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{parseModeledMappingSource as a}from"./ExpressionParser.js";const o=RegExp(`^for\\s+"(${t})"$`,`u`),s=r(`^[A-Z]\\w*$`),c=r(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`);function parseSeed(t,r){let l=[];if(t=t.valueContext,r.content!==`seed`)return t.error(e.InvalidSeedDeclaration,`Invalid seed declaration '${r.content}' - expected 'seed'`,i(r)),t.skipOpaqueBlock(r.indent),{kind:`SeedSyntax`,groups:l,location:i(r)};for(let u=t.peekChild(r.indent);u!==void 0;u=t.peekChild(r.indent)){t.reader.takeSignificant();let r=o.exec(u.content);if(r===null){t.error(e.InvalidSeedGroup,`Invalid seed group '${u.content}' - expected 'for "<event source id>"'`,i(u)),t.skipOpaqueBlock(u.indent);continue}let d=[];for(let n=t.peekChild(u.indent);n!==void 0;n=t.peekChild(u.indent)){if(t.reader.takeSignificant(),!s.test(n.content)){t.error(e.InvalidSeedEvent,`Invalid seed event '${n.content}' - expected an event type name`,i(n)),t.skipOpaqueBlock(n.indent);continue}let r=[];for(let o=t.peekChild(n.indent);o!==void 0;o=t.peekChild(n.indent)){t.reader.takeSignificant();let n=c.exec(o.content);n===null?t.error(e.InvalidSeedPropertyAssignment,`Invalid property assignment '${o.content}' - expected '<property> = <value>'`,i(o)):r.push({kind:`PropertyMappingSyntax`,property:n[1],source:a(n[2],i(o),t),location:i(o)})}d.push({kind:`SeedEventSyntax`,event:n.content,properties:r,location:i(n)})}l.push({kind:`SeedGroupSyntax`,eventSourceId:n(r[1]),events:d,location:i(u)})}return{kind:`SeedSyntax`,groups:l,location:i(r)}}export{parseSeed};
|
|
2
2
|
//# sourceMappingURL=SeedParser.js.map
|
|
@@ -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{
|
|
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{dependencySources as r}from"../Syntax/DependencySources.js";import{firstWord as i}from"./LineText.js";import{parseDescription as a}from"./DescriptionParser.js";import{parsePurposeReference as o}from"./PurposeParser.js";import{parseDocumentation as s}from"./DocumentationParser.js";import{misplacedReactionIdentity as c}from"./ReactionIdentityParser.js";import{isFileDirective as l}from"./FileReferences.js";import{parseOperation as u}from"./OperationParser.js";import{parseSpecification as d}from"./SpecificationParser.js";import{parseExample as f}from"./SpecificationExampleParser.js";import{sliceTypes as p}from"../Syntax/Structure.js";import{parseEvent as m,parseReadModel as h}from"./DeclarationParsers.js";import{parseCapture as g}from"./CaptureParser.js";import{captureReducer as _}from"./DependencySourceParser.js";import{parseCommand as v}from"./CommandParser.js";import{parseConstraint as y}from"./ConstraintParser.js";import{parseProjection as b}from"./ProjectionParser.js";import{parseQuery as x}from"./QueryParser.js";import{parseReaction as S}from"./ReactionParser.js";import{parseScreen as C}from"./ScreenParser.js";const w=t(`^slice\\s+([A-Za-z]\\w*)\\s+([A-Za-z_]\\w*)$`),T=/* @__PURE__ */ new Set([`reducer`]);function parseSlice(t,E){let D=w.exec(E.content),O=`StateChange`,k=``;D===null?t.error(e.InvalidSliceDeclaration,`Invalid slice declaration '${E.content}' - expected 'slice <Type> <Name>'`,n(E)):(k=D[2],p.includes(D[1])?O=D[1]:t.error(e.UnknownSliceType,`Unknown slice type '${D[1]}' - expected StateChange, StateView, Automation or Translate`,n(E)));let A=t.scope;t.scope=[...A,k];let j=null,M=!1,N=null,P=null,F=[],I=[],L=[],R=[],z=[],B=[],V=[],H=[],U=[],W=[],G=[],K=[],q=[],J=[];for(let r=t.peekChild(E.indent);r!==void 0;r=t.peekChild(E.indent)){if(t.reader.takeSignificant(),l(r))continue;let p=r.content.split(/[ \t]/,1)[0],w=p===`public`||p===`direction`?p:i(r.content);if(w===`description`)N=a(t,r,N,`Slice '${k}'`);else if(w===`documentation`)P=s(t,r,P,`Slice '${k}'`);else if(w===`purpose`)o(t,r,G);else if(w===`operation`)I.push(u(t,r).operation);else if(w===`direction`){let i=/^direction\s+(inbound|outbound)$/.exec(r.content);M||O!==`Translate`||i===null?t.error(e.InvalidSliceDeclaration,`Declare direction inbound or direction outbound once, inside a Translate slice only`,n(r)):j=i[1]===`inbound`?`Inbound`:`Outbound`,M=!0}else w===`event`||w===`public`?F.push(m(t,r)):w===`command`?L.push(v(t,r)):w===`query`?R.push(x(t,r)):w===`projection`?z.push(b(t,r)):w===`capture`?V.push(g(t,r)):w===`runs`?c(t,r):w===`reaction`?B.push(S(t,r)):w===`constraint`?H.push(y(t,r)):w===`example`?W.push(f(t,r)):w===`specification`?U.push(d(t,r)):w===`readmodel`?K.push(h(t,r)):w===`screen`?q.push(C(t,r)):T.has(w)?(J.push(_(t,r)),t.skipOpaqueBlock(r.indent)):(t.warning(e.UnknownSliceDirective,`Unknown construct '${w}' in slice '${k}'`,n(r)),t.skipBlock(r.indent))}t.scope=A;let Y={kind:`SliceSyntax`,type:O,name:k,direction:j,description:N,documentation:P,examples:W,purposes:G,events:F,operations:I,commands:L,queries:R,projections:z,captures:V,reactions:B,constraints:H,specifications:U,readModels:K,screens:q,location:n(E)};return r.set(Y,{reducers:J}),Y}export{parseSlice};
|
|
2
2
|
//# sourceMappingURL=SliceParser.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{locationOf as t}from"./SourceLine.js";import{commentStart as n}from"./SourceLineSplitter.js";import{firstWord as r}from"./LineText.js";import{LineReader as i}from"./LineReader.js";import{exactSourceOptions as a,legacySourceOptions as o}from"../Syntax/SourceOptions.js";import{ParserContext as s}from"./ParserContext.js";import{isClosingCodeFence as c}from"./ImplementationParser.js";function sourceContext(l,u,d,f=!1){let p=[],m=[],h=o,g=!1,_=!1,v=!1,y=/* @__PURE__ */ new Map,b=new s(new i([]),u,d).languages;for(let i of l){let o=i;if(o.number===1&&o.raw.startsWith(``)){let e=o.raw.substring(1),t=e.length-e.trimStart().length,r=n(e.substring(t),f);o={...o,indent:t,contentOffset:1,content:(r<0?e.substring(t):e.substring(t,t+r)).trimEnd()}}if(v)c(o)&&(v=!1),p.push(o);else if(o.content.startsWith("```")&&(["```","```text","```markdown"].includes(o.content)||b.has(o.content.substring(3)))&&(v=!0),!v&&o.indent===0&&r(o.content)===`numbers`){let n=o.content===`numbers exact`?g?e.DuplicateNumericDirective:_?e.LateNumericDirective:void 0:e.InvalidNumericDirective;n===void 0?h=a:(m.push({severity:`error`,code:n,message:`Expected one 'numbers exact' preamble before domain, imports and declarations.`,location:t(o)}),h=Object.freeze({numericMode:`invalid`})),g=!0,p.push({...o,content:``})}else!v&&o.indent>0&&/^numbers(\s+(exact|legacy))?$/.test(o.content)&&y.set(o.number,{severity:`error`,code:e.InvalidNumericDirective,message:`Expected 'numbers exact' only as the document preamble, not inside a body.`,location:t(o)}),_||=o.content.trim().length>0,p.push(o)}let x=new s(new i(g?p:l),u,d);return x.sourceOptions=h,x.nestedNumericDirectives=y,m.forEach(e=>x.error(e.code,e.message,e.location)),x}export{sourceContext};
|
|
2
2
|
//# sourceMappingURL=SourceOptionsParser.js.map
|
|
@@ -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{
|
|
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{parseProperty as i}from"./PropertyLineParser.js";import{parseConcrete as a}from"./SpecificationResponseParser.js";const o=new RegExp(t(`^case\\s+([A-Za-z_]\\w*)(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?$`).source,`du`),s=t(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),c=t(`^case\\.([a-z_]\\w*)$`);function containsCaseReference(e){return/\bcase\.[a-z_]\w*/.test(e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,``))}function parseSpecificationValue(t,n,i,a=!1){if(!t.startsWith(`case.`))return containsCaseReference(t)&&i.error(e.InvalidSpecificationCaseReference,`A case reference fills a whole value position; it cannot occur inside a structured value or expression.`,n),r(t,n,i,a);let o=c.exec(t);return o===null&&i.error(e.InvalidSpecificationCaseReference,`A case reference fills a whole value position: 'case.<parameter>'.`,n),{kind:`CaseValueExpressionSyntax`,parameter:o?.[1]??t.substring(5),location:n}}function parseParameter(t,r){let a=r.content.indexOf(` `)+1,o=a>0?i(t,{...r,content:r.content.substring(a),indent:r.indent+a}):void 0;if(o===void 0||o.isGenerated||o.isIdentifier)return t.error(e.InvalidSpecificationParameter,`Expected 'parameter <name> <Type>', with optional collection and optional modifiers.`,n(r)),t.skipOpaqueBlock(r.indent),null;let s=t.peekChild(r.indent);return s!==void 0&&(t.error(e.InvalidSpecificationParameter,`A parameter has no body or default.`,n(s)),t.skipOpaqueBlock(r.indent)),{kind:`SpecificationParameterSyntax`,name:o.name,type:o.type,location:n(r)}}function parseCase(t,r){let i=o.exec(r.content);if(i===null)return t.error(e.InvalidSpecificationCase,`Expected 'case <Name>' with at most one inline parameter assignment.`,n(r)),t.skipOpaqueBlock(r.indent),null;let c=[],add=(o,s,l)=>{let u=n(l),d={...u,column:u.column+l.content.indexOf(s,l.content.indexOf(`=`)+1)};if(s.startsWith(`case.`)){t.error(e.InvalidSpecificationCaseValue,`A case assigns concrete values, not case references.`,d);return}let f=a(t,s,d,e.InvalidSpecificationCaseValue);f!==null&&c.push({kind:`PropertyMappingSyntax`,property:o,source:f,location:l===r?{...u,column:u.column+i.indices.groups.property[0]}:u})};i.groups?.property!==void 0&&add(i.groups.property,i.groups.value,r);for(let i=t.peekChild(r.indent);i!==void 0;i=t.peekChild(r.indent)){t.reader.takeSignificant();let r=s.exec(i.content);if(r===null){t.error(e.InvalidSpecificationCaseAssignment,`Expected '<parameter> = <concrete value>' in a case.`,n(i)),t.skipOpaqueBlock(i.indent);continue}add(r[1],r[2],i);let a=t.peekChild(i.indent);a!==void 0&&(t.error(e.InvalidSpecificationCaseValue,`A case value must fit on one line.`,n(a)),t.skipOpaqueBlock(i.indent))}return{kind:`SpecificationCaseSyntax`,name:i[1],values:c,location:n(r)}}function caseReferences(e){return Array.isArray(e)?e.flatMap(caseReferences):typeof e!=`object`||!e?[]:`kind`in e&&e.kind===`CaseValueExpressionSyntax`?[e]:Object.values(e).flatMap(caseReferences)}function validateTable(t,n){let r=t.parameters??[],i=t.cases??[];r.length===0!=(i.length===0)&&n.error(e.IncompleteSpecificationTable,`A specification table requires parameters and at least one case.`,t.location),r.forEach((t,i)=>{r.slice(0,i).some(e=>e.name===t.name)&&n.error(e.DuplicateSpecificationParameter,`Parameter '${t.name}' is declared more than once.`,t.location)}),i.forEach((t,a)=>{i.slice(0,a).some(e=>e.name===t.name)&&n.error(e.DuplicateSpecificationCase,`Case '${t.name}' is declared more than once.`,t.location);for(let i of t.values.filter(e=>!r.some(t=>t.name===e.property)))n.error(e.InvalidSpecificationCaseAssignment,`Case '${t.name}' assigns undeclared parameter '${i.property}'.`,i.location);for(let i of r.filter(e=>t.values.filter(t=>t.property===e.name).length!==1))n.error(e.InvalidSpecificationCaseAssignment,`Case '${t.name}' must assign parameter '${i.name}' exactly once.`,t.location)});let a=caseReferences(t);for(let t of a)(i.length===0||!r.some(e=>e.name===t.parameter))&&n.error(e.InvalidSpecificationCaseReference,`Case reference '${t.parameter}' requires a declared parameter in a specification table.`,t.location);for(let t of r.filter(e=>!a.some(t=>t.parameter===e.name)))n.warning(e.UnusedSpecificationParameter,`Parameter '${t.name}' is never referenced.`,t.location);for(let r of caseReferences(t.whenRedelivered))n.error(e.InvalidSpecificationCaseReference,`Case references are not permitted in redelivery locators.`,r.location)}function substituteCase(e,t,n=/* @__PURE__ */ new WeakMap){if(typeof e==`object`&&e&&n.has(e))return n.get(e);if(Array.isArray(e)){let r=e.map(e=>substituteCase(e,t,n));return n.set(e,r),r}if(typeof e!=`object`||!e||!(`kind`in e))return e;if(e.kind===`CaseValueExpressionSyntax`){let n=e.parameter;return t.values.find(e=>e.property===n)?.source??e}let r=Object.fromEntries(Object.entries(e).map(([e,r])=>[e,substituteCase(r,t,n)]));if(e.kind===`SpecificationErrorSyntax`&&`caseValue`in e&&e.caseValue!==void 0){let e=r.caseValue;r.name=e.kind===`LiteralExpressionSyntax`?e.value:null,delete r.caseValue}return n.set(e,r),r}export{caseReferences,containsCaseReference,parseCase,parseParameter,parseSpecificationValue,substituteCase,validateTable};
|
|
2
2
|
//# sourceMappingURL=SpecificationCaseParser.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{dotNetWhitespace as t,nativePattern as n}from"../Text/patterns.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{dotNetWhitespace as t,nativePattern as n}from"../Text/patterns.js";import{locationOf as r}from"./SourceLine.js";import{firstWord as i}from"./LineText.js";import{generatedFixturePattern as a,generatedFixturePrefix as o,parseConcrete as s,parseConcreteMapping as c}from"./SpecificationResponseParser.js";import{caseReferences as l,parseSpecificationValue as u}from"./SpecificationCaseParser.js";import{parseDescription as d}from"./DescriptionParser.js";import{parseSpecificationStream as f,rejectSpecificationRouteChildren as p,specificationStream as m}from"./SpecificationParser.js";const h=n(`^example\\s+([A-Z]\\w*)\\s*:\\s*([A-Z]\\w*(?:\\.\\w+)*)$`.replaceAll(`\\s`,t)),g=n(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`.replaceAll(`\\s`,t));function parseExample(t,n){let i=h.exec(n.content);if(i===null)return t.error(e.InvalidSpecificationExample,`Invalid example declaration '${n.content}' - expected 'example <Name> : <EventOrCommandOrReadModel>'`,r(n)),t.skipOpaqueBlock(n.indent),{kind:`SpecificationExampleSyntax`,name:``,type:``,values:[],generatedValues:[],for:null,description:null,location:r(n)};let a=parseFixtureBody(t,n,void 0,!0,i[1]);for(let n of l(a))t.error(e.InvalidSpecificationCaseReference,`Case references are not permitted in example bodies.`,n.location);return{kind:`SpecificationExampleSyntax`,name:i[1],type:i[2],...a,location:r(n)}}function addInlineValue(t,n,i,a){if(i?.groups?.property===void 0)return;let o=i.groups.property,c=i.groups.value,l=n.content.length-c.length,u=r(n),d=s(t,c,{...u,column:u.column+l},e.InvalidSpecificationValue);d!==null&&a.push({kind:`PropertyMappingSyntax`,property:o,source:d,location:{...u,column:u.column+n.content.lastIndexOf(o,n.content.indexOf(`=`))}})}function addFixtureValue(t,n,r,i=[]){[...n,...i].some(e=>e.property===r.property)?t.error(e.DuplicateSpecificationAssignment,`Property '${r.property}' is assigned more than once in this fixture - assign it only once, inline or indented`,r.location):n.push(r)}function parseFixtureBody(t,n,s,l=!1,h){let _=[],v=[],y=null,b=null,x,S;addInlineValue(t,n,s,_);for(let s=t.peekChild(n.indent);s!==void 0;s=t.peekChild(n.indent)){if(t.reader.takeSignificant(),h!==void 0&&i(s.content)===`description`){b=d(t,s,b,`Example '${h}'`);continue}if(l&&o.test(s.content)){let n=c(t,s,a,e.InvalidGeneratedFixture);n!==null&&(h===void 0?v.push(n):addFixtureValue(t,v,n,_));continue}let n=g.exec(s.content);if(h!==void 0&&n===null&&(i(s.content)===`stream`||s.content.startsWith(`no stream`))){let n=m.exec(s.content);x!==void 0||S!==void 0?(t.error(e.InvalidSpecificationStream,`An event occurrence declares at most one stream or no stream directive.`,r(s)),t.skipOpaqueBlock(s.indent)):s.content===`no stream`?(S={kind:`SpecificationNoStreamSyntax`,location:r(s)},p(t,s)):n===null?(t.error(e.InvalidSpecificationStream,`Expected 'stream Source.Stream', or 'no stream' on an event example.`,r(s)),t.skipOpaqueBlock(s.indent)):x=f(t,s,n)}else if(n!==null)addFixtureValue(t,_,{kind:`PropertyMappingSyntax`,property:n[1],source:u(n[2],r(s),t),location:r(s)},v);else if(i(s.content)===`for`){let n=s.content.substring(3).trim();n.length===0?t.error(e.InvalidSpecificationEventSource,`Invalid event-source assertion 'for' - expected 'for <value>'`,r(s)):y===null?y=u(n,r(s),t):t.error(e.DuplicateSpecificationEventSource,`A specification step can declare its event-source assertion only once`,r(s))}else t.error(e.InvalidSpecificationValue,`Invalid property mapping '${s.content}' - expected '<property> = <value>'`,r(s))}return{values:_,for:y,generatedValues:v,description:b,...x===void 0?{}:{stream:x},...S===void 0?{}:{noStream:S}}}export{addFixtureValue,addInlineValue,parseExample,parseFixtureBody};
|
|
2
2
|
//# sourceMappingURL=SpecificationExampleParser.js.map
|