@cratis/screenplay-language 5.5.0 → 5.5.1

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.
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{validateHandlerContracts as t}from"./CommandHandlerValidator.js";import{misplacedRuleHintForCommand as n}from"./MisplacedRuleHint.js";import{parseCondition as r}from"./ConditionParser.js";import{parseClockOperand as i}from"./ClockOperandParser.js";import{parseCommandStream as a}from"./EventSourceParser.js";import{pattern as o}from"../Text/patterns.js";import{sourceStreamPattern as s}from"../Text/SourceStreamNames.js";import{stringBodyPattern as c,unescapeString as l}from"../Text/StringLiteral.js";import{combineAuthorize as u,parseAuthorize as d}from"./AuthorizeParser.js";import{parseCommandResponse as f,scalarResponsePattern as p}from"./CommandResponseParser.js";import{parseDescription as m}from"./DescriptionParser.js";import{parseDocumentation as h}from"./DocumentationParser.js";import{isCode as g,isFile as _,parseCode as v,parseFile as y,parseHandler as b,parseImplementationWrapper as x}from"./ImplementationParser.js";import{parseMappingSource as S}from"./ExpressionParser.js";import{firstWord as C}from"./LineText.js";import{ParserContext as w}from"./ParserContext.js";import{matchSubject as T,validateMatchOperand as E}from"./MatchOperandValidation.js";import{isReactionIdentityLine as D,misplacedReactionIdentity as O}from"./ReactionIdentityParser.js";import{commandReadSources as k}from"./CommandReadSources.js";import{dependencySources as ee}from"../Syntax/DependencySources.js";import{captureConcurrency as A}from"./DependencySourceParser.js";import{parseReads as j}from"./ReadsParser.js";import{parseProduces as M}from"./ProducesParser.js";import{reportInvalidModifierOrder as N,reportLegacyOptionalSuffix as P,tryParseProperty as F}from"./PropertyLineParser.js";import{locationOf as I}from"./SourceLine.js";import{isFileDirectiveAmongProperties as L}from"./FileReferences.js";const R=o(`^command\\s+([A-Za-z_]\\w*)$`),z=s(`^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$`),B=o(`^calendar\\s+(?:"|from\\s+\\$context\\.)`),V=o(`^calendar\\s+(?:"(${c})"|from\\s+\\$context\\.([A-Za-z_][A-Za-z0-9_]*(?:\\.[A-Za-z_][A-Za-z0-9_]*)*))$`),H=o(`\\bseverity\\s+(\\S+)$`),U=o(`\\bmessage\\s+(?:"(${c})"|(\\$strings\\.\\S*))$`),W=o(`^([\\w.]+)\\s+(.+)$`),G=o(`^(?:(not empty|matches|not contains|contains|starts with|ends with|max|min|rule)(?:\\s+|$)|(length ==|decimals <=|all >=|all >|>=|<=|==|!=|>|<)\\s*)(.*)$`),K=s(`^[A-Za-z_]\\w*$`),q=o(`^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)`),J={max:`Max`,min:`Min`,">":`GreaterThan`,">=":`GreaterThanOrEqual`,"<":`LessThan`,"<=":`LessThanOrEqual`,"==":`Equal`,"!=":`NotEqual`,"length ==":`Length`,"decimals <=":`DecimalPlaces`,matches:`Matches`,contains:`Contains`,"not contains":`NotContains`,"starts with":`StartsWith`,"ends with":`EndsWith`,"all >":`AllGreaterThan`,"all >=":`AllGreaterThanOrEqual`},Y={information:`Information`,warning:`Warning`,error:`Error`},te=/* @__PURE__ */ new Set([`reads`,`concurrency`]),ne=/* @__PURE__ */ new Set([`description`,`documentation`,`handler`,`concurrency`]);function parseCommand(e,t){let n=/* @__PURE__ */ new Set,r=new w(e.reader.fork(),e.path,e.languages);return r.sourceOptions=e.sourceOptions,r.streamCandidates=e.streamCandidates,parseCommandBody(r,t,void 0,n),parseCommandBody(e,t,n)}function parseCommandBody(r,i,o,s){let c=R.exec(i.content)?.[1]??``;c===``&&r.error(e.InvalidCommandDeclaration,`Invalid command declaration '${i.content}' - expected 'command <Name>'`,I(i));let g=[],_=[],v,y=[],x=[],S=[],w=[],T,E=null,P=null,L=null,H=!1,U=null,W=[],G=null,K=[],J=null;for(let t=r.peekChild(i.indent);t!==void 0;t=r.peekChild(i.indent)){r.reader.takeSignificant();let i=C(t.content),s=F(t);if(i===`calendar`&&B.test(t.content)){let n=V.exec(t.content);J!==null||n===null?r.error(e.InvalidCommandCalendar,`A command declares at most one 'calendar "<id>"' or 'calendar from $context.<member>'.`,I(t)):J={kind:`CommandCalendarSyntax`,id:n[1]===void 0?null:l(n[1]),contextMember:n[2]??null,location:I(t)}}else if(s!==void 0&&(ne.has(i)||i===`validate`&&t.content!==`validate csharp`))v=addProperty(r,g,s,c,t,v);else if(i===`returns`){let e=p.exec(t.content);e!==null&&!e[1].startsWith(`@`)&&s!==void 0?o===void 0?(g.push(s),_.push({line:t,candidate:s,response:null})):o.has(s.type.name)?_.push({line:t,candidate:null,response:f(r,t)}):v=addProperty(r,g,s,c,t,v):s===void 0?N(r,t)?r.skipBlock(t.indent):_.push({line:t,candidate:null,response:f(r,t)}):v=addProperty(r,g,s,c,t,v)}else if(i===`stream`&&z.test(t.content)&&s!==void 0&&r.streamCandidates?.hasSource(s.type.name.split(`.`)[0])===!0){let[n,i]=s.type.name.split(`.`),o=r.streamCandidates.hasPropertyType(s.type.name)&&r.streamCandidates.hasUniqueStream(n,i),c=a(r,t,s,o);(G!==null||K.length>0)&&r.error(e.InvalidCommandStream,`A command declares at most one stream route.`,I(t)),o||G!==null?K.push(c):G=c}else if(i===`runs`&&D(t))O(r,t);else if(i===`description`)E=m(r,t,E,`Command '${c}'`);else if(i===`documentation`)P=h(r,t,P,`Command '${c}'`);else if(i===`authorize`){let e=d(r,t);if(!H){let t=L;L=u(L,e,r),H=t!==null&&L===null}}else if(i===`validate`){let e=parseValidate(r,t,`command`,c);e!==void 0&&y.push(e)}else if(i===`produces`){let e=M(r,t,!0);e!==void 0&&x.push(e)}else if(i===`handler`)U=b(r,t),W.push({handler:U,location:I(t)});else if(te.has(i)){let n=i===`reads`?j(r,t):void 0;n!==void 0&&w.push(n),i===`concurrency`&&T===void 0&&(T=A(r,t));let a=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(t.content);a!==null&&S.push({readModel:a[1],alias:a[2]??null}),q.test(t.content)&&r.error(e.OptionalReadsNotSupported,`Optional reads are not yet supported (see #308).`,I(t)),r.skipOpaqueBlock(t.indent)}else s===void 0?(N(r,t),r.error(e.UnknownCommandDirective,`Unexpected '${t.content}' in command body${n(t.content)}`,I(t)),r.skipBlock(t.indent)):v=addProperty(r,g,s,c,t,v)}let Y=new Set(_.flatMap(e=>e.candidate===null?[]:[e.candidate])),X=new Set(g.filter(e=>!Y.has(e)).map(e=>e.name));_.some(e=>e.candidate!==null&&!X.has(e.candidate.type.name)&&e.candidate.type.name!==`returns`)&&X.add(`returns`);for(let e of X)s?.add(e);let Z=null,Q=/* @__PURE__ */ new Set;for(let t of _){let n=t.response;if(t.candidate!==null){if(!X.has(t.candidate.type.name))continue;Q.add(t.candidate),n={kind:`ScalarCommandResponseSyntax`,source:{kind:`PropertyResponseSourceSyntax`,property:t.candidate.type.name,location:t.candidate.type.location},location:I(t.line)}}n!==null&&(Z===null?Z=n:r.error(e.InvalidCommandResponse,`A command declares at most one unconditional response.`,I(t.line)))}t(W,U,x.length>0,r);let $={kind:`CommandSyntax`,name:c,description:E,documentation:P,authorize:L,properties:g.filter(e=>!Q.has(e)),validations:y,produces:x,handler:U,response:Z,stream:G,streamCandidates:K,...J===null?{}:{calendar:J},location:I(i)};return k.set($,S),ee.set($,{reads:w,concurrency:T}),$}function addProperty(t,n,r,i,a,o){return P(t,r.type,a),r.isIdentifier&&o!==void 0&&(t.error(e.DuplicateCommandIdentifier,`Command '${i}' already marks '${o.name}' as identifier - only one property can be the identifier`,r.location),r={...r,isIdentifier:!1}),n.push(r),o??(r.isIdentifier?r:void 0)}function parseValidationFile(e,t,n){let r=y(e,n);return r===void 0?void 0:{kind:`FileValidateSyntax`,file:r,location:I(t)}}function hasValidationOperand(e){let t=W.exec(e.content);return t!==null&&startsWithRuleOperand(t[2])}function startsWithRuleOperand(e){return C(e)===`not`&&C(e.substring(3).trimStart())===`empty`||C(e)===`checksum`||G.test(e)}function isDeclarativePredicate(e){return startsWithRuleOperand(e)&&C(e)!==`rule`}function isValidationFileBody(e,t,n){if(!L(n)||hasValidationOperand(n))return!1;let r=e.reader.fork();r.takeSignificant();let i=r.peekSignificant();return i===void 0||i.indent<=t.indent}function parseValidate(t,n,i,a){if(n.content===`validate`){let o=t.peekChild(n.indent);if(o!==void 0&&isValidationFileBody(t,n,o))return t.reader.takeSignificant(),parseValidationFile(t,n,o);if(o!==void 0&&o.content.startsWith("```")){t.reader.takeSignificant();let e=v(t.valueContext,o);return e===null&&t.skipFencedBody(),{kind:`CodeValidateSyntax`,code:e,location:I(n)}}let s=[],c=[],u;for(let o=t.peekChild(n.indent);o!==void 0;o=t.peekChild(n.indent)){if(t.reader.takeSignificant(),i===`concept`){if(t.sourceOptions.numericMode===`legacy`&&o.content.startsWith("```")){t.skipFencedBody();continue}if(u!==void 0&&o.indent<=u&&(u=void 0),u!==void 0||C(o.content)===`implementation`){t.error(e.InvalidValidationRule,`Invalid validation rule '${o.content}'`,I(o)),u??=o.indent;continue}}if(C(o.content)===`require`){let e=r(i===`concept`?t.valueContext:t,o.content.substring(7).trim(),I(o),!1,t),n=null,a=`Error`,s=!1;for(let e=t.peekChild(o.indent);e!==void 0;e=t.peekChild(o.indent)){t.reader.takeSignificant();let r=U.exec(e.content);r!==null&&r.index===0?n=r[1]===void 0?r[2]:l(r[1]):C(e.content)===`severity`?(s||(a=Y[e.content.substring(8).trim()]??`Error`),s=!0):t.skipOpaqueBlock(e.indent)}e!==null&&c.push({kind:`RequirementSyntax`,condition:e,message:n,severity:a,location:I(o)});continue}let n=parseValidationRule(t,i===`concept`?{...o,content:`value ${o.content}`}:o,i,a);n!==void 0&&s.push(n)}return{kind:`DeclarativeValidateSyntax`,rules:s,requirements:c,location:I(n)}}if(i===`concept`&&C(n.content.substring(8).trimStart())===`checksum`){let e=parseValidationRule(t,{...n,content:`value ${n.content.substring(8).trimStart()}`},i,a);return e===void 0?void 0:{kind:`DeclarativeValidateSyntax`,rules:[e],requirements:[],location:I(n)}}if(n.content===`validate csharp`){let e=v(t.valueContext,{...n,content:`csharp`});return e===null&&t.skipOpaqueBlock(n.indent),{kind:`CodeValidateSyntax`,code:e,location:I(n)}}t.error(e.InvalidValidateDeclaration,`Invalid validate declaration '${n.content}' - expected 'validate' or 'validate csharp'`,I(n)),t.skipBlock(n.indent)}function parseValidationRule(t,n,r,i){let a=C(W.exec(n.content)?.[2]??``)===`checksum`,o=r===`concept`&&!a?t.valueContext:t,{content:s,message:c}=splitMessage(n.content),l=splitSeverity(o,n,s);if(l===void 0)return;let u=W.exec(l.content);if(u===null){o.error(e.InvalidValidationRule,`Invalid validation rule '${n.content}'`,I(n));return}let d=parseRule(o,u[2],n,r===`command`);if(d===void 0)return;d.kind===`Matches`&&d.value!==null&&E(t,d.value,I(n),n.raw,T(t,r,i,u[1]));let f=d.kind===`Rule`?parseRuleImplementation(t,n,r===`command`):{file:null,code:null,implementation:null};return{kind:`ValidationRuleSyntax`,property:u[1],rule:d.kind,value:d.value,message:c,severity:l.severity,...f,location:I(n)}}function parseRuleImplementation(t,n,r){let i=t.peekChild(n.indent);if(i===void 0)return{file:null,code:null,implementation:null};t.reader.takeSignificant();let a=r&&C(i.content)===`implementation`,o=a?x(t,i):{file:_(i)?y(t,i):null,code:!_(i)&&g(t,i)?v(t,i):null,implementation:null};!a&&o.file===null&&o.code===null&&(t.error(e.UnknownRuleImplementationDirective,`Unexpected '${i.content}' in rule implementation - expected 'file <path>' or an inline code block`,I(i)),t.skipBlock(i.indent));for(let i=t.peekChild(n.indent);i!==void 0&&(a||r&&C(i.content)===`implementation`);i=t.peekChild(n.indent))t.reader.takeSignificant(),t.error(a&&C(i.content)===`implementation`?e.InvalidImplementationBlock:e.ConflictingImplementationSources,`A named rule has one implementation wrapper and cannot mix wrapped and direct sources.`,I(i)),g(t,i)?v(t,i):t.skipBlock(i.indent);return o}function splitMessage(e){let t=U.exec(e);if(t===null)return{content:e,message:null};let n=t[1]===void 0?t[2]:l(t[1]);return{content:e.substring(0,t.index).trimEnd(),message:n}}function splitSeverity(t,n,r){let i=H.exec(r);if(i===null)return{content:r,severity:`Error`};let a=Y[i[1]];if(a===void 0)t.error(e.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,I(n));else return{content:r.substring(0,i.index).trimEnd(),severity:a}}const X=/* @__PURE__ */ new Set([`>`,`>=`,`<`,`<=`,`==`,`!=`]);function parseClockComparisonValue(t,n,r){let a=n.split(/\s+/).filter(e=>e.length>0),o=i(t,a,0,I(r));if(o===null)return S(n,I(r),t);if(o.expression!==null){if(o.position===a.length)return o.expression;t.error(e.InvalidValidationRule,`Invalid validation rule '${r.content}'`,I(r))}}function parseRule(t,n,r,i){if(n===`not empty`)return{kind:`NotEmpty`,value:null};if(C(n)===`checksum`){let i=n.substring(8).trim();if(i!==`luhn`&&i!==`mod11`&&i!==`mod97`){t.error(e.InvalidGenerationArgument,`Checksum validation requires luhn, mod11 or mod97.`,I(r));return}return{kind:`Checksum`,value:{kind:`LiteralExpressionSyntax`,value:i,location:I(r)}}}let a=G.exec(n);if(a===null)t.error(e.InvalidValidationRule,`Invalid validation rule '${r.content}'`,I(r));else{if((a[1]??a[2])===`rule`){let n=a[3].trim();if(!K.test(n)){t.error(e.InvalidRuleName,`Invalid rule name '${n}' in '${r.content}' - expected 'rule <Name>' with an identifier`,I(r));return}return{kind:`Rule`,value:{kind:`PathExpressionSyntax`,path:n,location:I(r)}}}return parseOperandRule(t,a,r,i)}}function parseOperandRule(e,t,n,r){let i=t[1]??t[2],a=r&&X.has(i)?parseClockComparisonValue(e,t[3],n):S(t[3],I(n),e);return a===void 0?void 0:{kind:J[i],value:a}}export{isDeclarativePredicate,parseCommand,parseValidate};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{validateHandlerContracts as t}from"./CommandHandlerValidator.js";import{misplacedRuleHintForCommand as n}from"./MisplacedRuleHint.js";import{parseCondition as r}from"./ConditionParser.js";import{parseClockOperand as i}from"./ClockOperandParser.js";import{parseCommandStream as a}from"./EventSourceParser.js";import{pattern as o}from"../Text/patterns.js";import{sourceStreamPattern as s}from"../Text/SourceStreamNames.js";import{stringBodyPattern as c,unescapeString as l}from"../Text/StringLiteral.js";import{combineAuthorize as u,parseAuthorize as d}from"./AuthorizeParser.js";import{parseCommandResponse as f,scalarResponsePattern as p}from"./CommandResponseParser.js";import{parseDescription as m}from"./DescriptionParser.js";import{parseDocumentation as h}from"./DocumentationParser.js";import{isCode as g,isFile as _,parseCode as v,parseFile as y,parseHandler as b,parseImplementationWrapper as x}from"./ImplementationParser.js";import{parseMappingSource as S}from"./ExpressionParser.js";import{firstWord as C}from"./LineText.js";import{ParserContext as w}from"./ParserContext.js";import{matchSubject as T,validateMatchOperand as E}from"./MatchOperandValidation.js";import{isReactionIdentityLine as D,misplacedReactionIdentity as O}from"./ReactionIdentityParser.js";import{commandReadSources as k}from"./CommandReadSources.js";import{dependencySources as A}from"../Syntax/DependencySources.js";import{captureConcurrency as j}from"./DependencySourceParser.js";import{parseReads as M}from"./ReadsParser.js";import{parseProduces as N}from"./ProducesParser.js";import{reportInvalidModifierOrder as P,reportLegacyOptionalSuffix as F,tryParseProperty as I}from"./PropertyLineParser.js";import{locationOf as L}from"./SourceLine.js";import{isFileDirectiveAmongProperties as R}from"./FileReferences.js";const z=o(`^command\\s+([A-Za-z_]\\w*)$`),B=s(`^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$`),V=o(`^calendar\\s+(?:"|from\\s+\\$context\\.)`),H=o(`^calendar\\s+(?:"(${c})"|from\\s+\\$context\\.([A-Za-z_][A-Za-z0-9_]*(?:\\.[A-Za-z_][A-Za-z0-9_]*)*))$`),U=o(`\\bseverity\\s+(\\S+)$`),W=o(`\\bmessage\\s+(?:"(${c})"|(\\$strings\\.\\S*))$`),G=o(`^([\\w.]+)\\s+(.+)$`),K=o(`^(?:(not empty|matches|not contains|contains|starts with|ends with|max|min|rule)(?:\\s+|$)|(length ==|decimals <=|all >=|all >|>=|<=|==|!=|>|<)\\s*)(.*)$`),q=s(`^[A-Za-z_]\\w*$`),J=o(`^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)`),Y={max:`Max`,min:`Min`,">":`GreaterThan`,">=":`GreaterThanOrEqual`,"<":`LessThan`,"<=":`LessThanOrEqual`,"==":`Equal`,"!=":`NotEqual`,"length ==":`Length`,"decimals <=":`DecimalPlaces`,matches:`Matches`,contains:`Contains`,"not contains":`NotContains`,"starts with":`StartsWith`,"ends with":`EndsWith`,"all >":`AllGreaterThan`,"all >=":`AllGreaterThanOrEqual`},X={information:`Information`,warning:`Warning`,error:`Error`},Z=/* @__PURE__ */ new Set([`reads`,`concurrency`]),Q=/* @__PURE__ */ new Set([`description`,`documentation`,`handler`,`concurrency`]);function parseCommand(e,t){let n=/* @__PURE__ */ new Set,r=new w(e.reader.fork(),e.path,e.languages);return r.sourceOptions=e.sourceOptions,r.streamCandidates=e.streamCandidates,parseCommandBody(r,t,void 0,n),parseCommandBody(e,t,n)}function parseCommandBody(t,n,r,i){let a=z.exec(n.content)?.[1]??``;a===``&&t.error(e.InvalidCommandDeclaration,`Invalid command declaration '${n.content}' - expected 'command <Name>'`,L(n));let o=createCommandBodyState(a,r);for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent))t.reader.takeSignificant(),dispatchCommandDirective(t,e,o);return buildCommand(t,n,o,i)}function createCommandBodyState(e,t){return{name:e,responseNames:t,properties:[],responses:[],identifier:void 0,validations:[],produces:[],reads:[],referenceReads:[],concurrency:void 0,description:null,documentation:null,authorize:null,authorizationDepthExceeded:!1,handler:null,handlers:[],stream:null,streamCandidates:[],calendar:null}}const isDirective=e=>t=>t===e,$=[{matches:(e,t)=>e===`calendar`&&V.test(t.content),parse:parseCalendarDirective},{matches:(e,t,n)=>n!==void 0&&(Q.has(e)||e===`validate`&&t.content!==`validate csharp`),parse:addPropertyDirective},{matches:isDirective(`returns`),parse:parseReturnsDirective},{matches:(e,t,n,r)=>e===`stream`&&B.test(t.content)&&n!==void 0&&r.streamCandidates?.hasSource(n.type.name.split(`.`)[0])===!0,parse:parseStreamDirective},{matches:(e,t)=>e===`runs`&&D(t),parse:(e,t)=>{O(e,t)}},{matches:isDirective(`description`),parse:(e,t,n)=>{n.description=m(e,t,n.description,`Command '${n.name}'`)}},{matches:isDirective(`documentation`),parse:(e,t,n)=>{n.documentation=h(e,t,n.documentation,`Command '${n.name}'`)}},{matches:isDirective(`authorize`),parse:parseAuthorizeDirective},{matches:isDirective(`validate`),parse:parseValidateDirective},{matches:isDirective(`produces`),parse:parseProducesDirective},{matches:isDirective(`handler`),parse:(e,t,n)=>{n.handler=b(e,t),n.handlers.push({handler:n.handler,location:L(t)})}},{matches:e=>Z.has(e),parse:parseOpaqueDirective}];function dispatchCommandDirective(t,r,i){let a=C(r.content),o=I(r),s=$.find(e=>e.matches(a,r,o,t));s===void 0?o===void 0?(P(t,r),t.error(e.UnknownCommandDirective,`Unexpected '${r.content}' in command body${n(r.content)}`,L(r)),t.skipBlock(r.indent)):i.identifier=addProperty(t,i.properties,o,i.name,r,i.identifier):s.parse(t,r,i,o)}function addPropertyDirective(e,t,n,r){n.identifier=addProperty(e,n.properties,r,n.name,t,n.identifier)}function parseCalendarDirective(t,n,r){let i=H.exec(n.content);r.calendar!==null||i===null?t.error(e.InvalidCommandCalendar,`A command declares at most one 'calendar "<id>"' or 'calendar from $context.<member>'.`,L(n)):r.calendar={kind:`CommandCalendarSyntax`,id:i[1]===void 0?null:l(i[1]),contextMember:i[2]??null,location:L(n)}}function parseReturnsDirective(e,t,n,r){let i=p.exec(t.content);i!==null&&!i[1].startsWith(`@`)&&r!==void 0?parseScalarReturns(e,t,n,r):r===void 0?P(e,t)?e.skipBlock(t.indent):n.responses.push({line:t,candidate:null,response:f(e,t)}):n.identifier=addProperty(e,n.properties,r,n.name,t,n.identifier)}function parseScalarReturns(e,t,n,r){n.responseNames===void 0?(n.properties.push(r),n.responses.push({line:t,candidate:r,response:null})):n.responseNames.has(r.type.name)?n.responses.push({line:t,candidate:null,response:f(e,t)}):n.identifier=addProperty(e,n.properties,r,n.name,t,n.identifier)}function parseStreamDirective(t,n,r,i){let[o,s]=i.type.name.split(`.`),c=t.streamCandidates.hasPropertyType(i.type.name)&&t.streamCandidates.hasUniqueStream(o,s),l=a(t,n,i,c);(r.stream!==null||r.streamCandidates.length>0)&&t.error(e.InvalidCommandStream,`A command declares at most one stream route.`,L(n)),c||r.stream!==null?r.streamCandidates.push(l):r.stream=l}function parseAuthorizeDirective(e,t,n){let r=d(e,t);if(n.authorizationDepthExceeded)return;let i=n.authorize;n.authorize=u(n.authorize,r,e),n.authorizationDepthExceeded=i!==null&&n.authorize===null}function parseValidateDirective(e,t,n){let r=parseValidate(e,t,`command`,n.name);r!==void 0&&n.validations.push(r)}function parseProducesDirective(e,t,n){let r=N(e,t,!0);r!==void 0&&n.produces.push(r)}function parseOpaqueDirective(t,n,r){let i=C(n.content),a=i===`reads`?M(t,n):void 0;a!==void 0&&r.referenceReads.push(a),i===`concurrency`&&r.concurrency===void 0&&(r.concurrency=j(t,n));let o=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(n.content);o!==null&&r.reads.push({readModel:o[1],alias:o[2]??null}),J.test(n.content)&&t.error(e.OptionalReadsNotSupported,`Optional reads are not yet supported (see #308).`,L(n)),t.skipOpaqueBlock(n.indent)}function resolveResponse(t,n,r){let{properties:i,responses:a}=n,o=new Set(a.flatMap(e=>e.candidate===null?[]:[e.candidate])),s=new Set(i.filter(e=>!o.has(e)).map(e=>e.name));a.some(e=>e.candidate!==null&&!s.has(e.candidate.type.name)&&e.candidate.type.name!==`returns`)&&s.add(`returns`);for(let e of s)r?.add(e);let c=null,l=/* @__PURE__ */ new Set;for(let n of a){let r=n.response;if(n.candidate!==null){if(!s.has(n.candidate.type.name))continue;l.add(n.candidate),r={kind:`ScalarCommandResponseSyntax`,source:{kind:`PropertyResponseSourceSyntax`,property:n.candidate.type.name,location:n.candidate.type.location},location:L(n.line)}}r!==null&&(c===null?c=r:t.error(e.InvalidCommandResponse,`A command declares at most one unconditional response.`,L(n.line)))}return{response:c,removed:l}}function buildCommand(e,n,r,i){let{name:a,properties:o,validations:s,produces:c,reads:l,referenceReads:u,concurrency:d,description:f,documentation:p,authorize:m,handler:h,handlers:g,stream:_,streamCandidates:v,calendar:y}=r,{response:b,removed:x}=resolveResponse(e,r,i);t(g,h,c.length>0,e);let S={kind:`CommandSyntax`,name:a,description:f,documentation:p,authorize:m,properties:o.filter(e=>!x.has(e)),validations:s,produces:c,handler:h,response:b,stream:_,streamCandidates:v,...y===null?{}:{calendar:y},location:L(n)};return k.set(S,l),A.set(S,{reads:u,concurrency:d}),S}function addProperty(t,n,r,i,a,o){return F(t,r.type,a),r.isIdentifier&&o!==void 0&&(t.error(e.DuplicateCommandIdentifier,`Command '${i}' already marks '${o.name}' as identifier - only one property can be the identifier`,r.location),r={...r,isIdentifier:!1}),n.push(r),o??(r.isIdentifier?r:void 0)}function parseValidationFile(e,t,n){let r=y(e,n);return r===void 0?void 0:{kind:`FileValidateSyntax`,file:r,location:L(t)}}function hasValidationOperand(e){let t=G.exec(e.content);return t!==null&&startsWithRuleOperand(t[2])}function startsWithRuleOperand(e){return C(e)===`not`&&C(e.substring(3).trimStart())===`empty`||C(e)===`checksum`||K.test(e)}function isDeclarativePredicate(e){return startsWithRuleOperand(e)&&C(e)!==`rule`}function isValidationFileBody(e,t,n){if(!R(n)||hasValidationOperand(n))return!1;let r=e.reader.fork();r.takeSignificant();let i=r.peekSignificant();return i===void 0||i.indent<=t.indent}function parseValidate(t,n,i,a){if(n.content===`validate`){let o=t.peekChild(n.indent);if(o!==void 0&&isValidationFileBody(t,n,o))return t.reader.takeSignificant(),parseValidationFile(t,n,o);if(o!==void 0&&o.content.startsWith("```")){t.reader.takeSignificant();let e=v(t.valueContext,o);return e===null&&t.skipFencedBody(),{kind:`CodeValidateSyntax`,code:e,location:L(n)}}let s=[],c=[],u;for(let o=t.peekChild(n.indent);o!==void 0;o=t.peekChild(n.indent)){if(t.reader.takeSignificant(),i===`concept`){if(t.sourceOptions.numericMode===`legacy`&&o.content.startsWith("```")){t.skipFencedBody();continue}if(u!==void 0&&o.indent<=u&&(u=void 0),u!==void 0||C(o.content)===`implementation`){t.error(e.InvalidValidationRule,`Invalid validation rule '${o.content}'`,L(o)),u??=o.indent;continue}}if(C(o.content)===`require`){let e=r(i===`concept`?t.valueContext:t,o.content.substring(7).trim(),L(o),!1,t),n=null,a=`Error`,s=!1;for(let e=t.peekChild(o.indent);e!==void 0;e=t.peekChild(o.indent)){t.reader.takeSignificant();let r=W.exec(e.content);r!==null&&r.index===0?n=r[1]===void 0?r[2]:l(r[1]):C(e.content)===`severity`?(s||(a=X[e.content.substring(8).trim()]??`Error`),s=!0):t.skipOpaqueBlock(e.indent)}e!==null&&c.push({kind:`RequirementSyntax`,condition:e,message:n,severity:a,location:L(o)});continue}let n=parseValidationRule(t,i===`concept`?{...o,content:`value ${o.content}`}:o,i,a);n!==void 0&&s.push(n)}return{kind:`DeclarativeValidateSyntax`,rules:s,requirements:c,location:L(n)}}if(i===`concept`&&C(n.content.substring(8).trimStart())===`checksum`){let e=parseValidationRule(t,{...n,content:`value ${n.content.substring(8).trimStart()}`},i,a);return e===void 0?void 0:{kind:`DeclarativeValidateSyntax`,rules:[e],requirements:[],location:L(n)}}if(n.content===`validate csharp`){let e=v(t.valueContext,{...n,content:`csharp`});return e===null&&t.skipOpaqueBlock(n.indent),{kind:`CodeValidateSyntax`,code:e,location:L(n)}}t.error(e.InvalidValidateDeclaration,`Invalid validate declaration '${n.content}' - expected 'validate' or 'validate csharp'`,L(n)),t.skipBlock(n.indent)}function parseValidationRule(t,n,r,i){let a=C(G.exec(n.content)?.[2]??``)===`checksum`,o=r===`concept`&&!a?t.valueContext:t,{content:s,message:c}=splitMessage(n.content),l=splitSeverity(o,n,s);if(l===void 0)return;let u=G.exec(l.content);if(u===null){o.error(e.InvalidValidationRule,`Invalid validation rule '${n.content}'`,L(n));return}let d=parseRule(o,u[2],n,r===`command`);if(d===void 0)return;d.kind===`Matches`&&d.value!==null&&E(t,d.value,L(n),n.raw,T(t,r,i,u[1]));let f=d.kind===`Rule`?parseRuleImplementation(t,n,r===`command`):{file:null,code:null,implementation:null};return{kind:`ValidationRuleSyntax`,property:u[1],rule:d.kind,value:d.value,message:c,severity:l.severity,...f,location:L(n)}}function parseRuleImplementation(t,n,r){let i=t.peekChild(n.indent);if(i===void 0)return{file:null,code:null,implementation:null};t.reader.takeSignificant();let a=r&&C(i.content)===`implementation`,o=a?x(t,i):{file:_(i)?y(t,i):null,code:!_(i)&&g(t,i)?v(t,i):null,implementation:null};!a&&o.file===null&&o.code===null&&(t.error(e.UnknownRuleImplementationDirective,`Unexpected '${i.content}' in rule implementation - expected 'file <path>' or an inline code block`,L(i)),t.skipBlock(i.indent));for(let i=t.peekChild(n.indent);i!==void 0&&(a||r&&C(i.content)===`implementation`);i=t.peekChild(n.indent))t.reader.takeSignificant(),t.error(a&&C(i.content)===`implementation`?e.InvalidImplementationBlock:e.ConflictingImplementationSources,`A named rule has one implementation wrapper and cannot mix wrapped and direct sources.`,L(i)),g(t,i)?v(t,i):t.skipBlock(i.indent);return o}function splitMessage(e){let t=W.exec(e);if(t===null)return{content:e,message:null};let n=t[1]===void 0?t[2]:l(t[1]);return{content:e.substring(0,t.index).trimEnd(),message:n}}function splitSeverity(t,n,r){let i=U.exec(r);if(i===null)return{content:r,severity:`Error`};let a=X[i[1]];if(a===void 0)t.error(e.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,L(n));else return{content:r.substring(0,i.index).trimEnd(),severity:a}}const ee=/* @__PURE__ */ new Set([`>`,`>=`,`<`,`<=`,`==`,`!=`]);function parseClockComparisonValue(t,n,r){let a=n.split(/\s+/).filter(e=>e.length>0),o=i(t,a,0,L(r));if(o===null)return S(n,L(r),t);if(o.expression!==null){if(o.position===a.length)return o.expression;t.error(e.InvalidValidationRule,`Invalid validation rule '${r.content}'`,L(r))}}function parseRule(t,n,r,i){if(n===`not empty`)return{kind:`NotEmpty`,value:null};if(C(n)===`checksum`){let i=n.substring(8).trim();if(i!==`luhn`&&i!==`mod11`&&i!==`mod97`){t.error(e.InvalidGenerationArgument,`Checksum validation requires luhn, mod11 or mod97.`,L(r));return}return{kind:`Checksum`,value:{kind:`LiteralExpressionSyntax`,value:i,location:L(r)}}}let a=K.exec(n);if(a===null)t.error(e.InvalidValidationRule,`Invalid validation rule '${r.content}'`,L(r));else{if((a[1]??a[2])===`rule`){let n=a[3].trim();if(!q.test(n)){t.error(e.InvalidRuleName,`Invalid rule name '${n}' in '${r.content}' - expected 'rule <Name>' with an identifier`,L(r));return}return{kind:`Rule`,value:{kind:`PathExpressionSyntax`,path:n,location:L(r)}}}return parseOperandRule(t,a,r,i)}}function parseOperandRule(e,t,n,r){let i=t[1]??t[2],a=r&&ee.has(i)?parseClockComparisonValue(e,t[3],n):S(t[3],L(n),e);return a===void 0?void 0:{kind:Y[i],value:a}}export{isDeclarativePredicate,parseCommand,parseValidate};
2
2
  //# sourceMappingURL=CommandParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommandParser.js","names":["header","pattern","routeHeader","sourceStreamPattern","calendarPrefix","calendarPattern","stringBodyPattern","severityPattern","messagePattern","rulePattern","operandPattern","ruleNamePattern","optionalReads","operandKinds","severities","opaqueDirectives","propertyShapedDirectives","names","lookahead","ParserContext","context","line","name","DiagnosticCodes","locationOf","properties","responses","identifier","validations","produces","reads","referenceReads","concurrency","description","documentation","authorize","authorizationDepthExceeded","handler","handlers","stream","streamCandidates","calendar","child","keyword","firstWord","asProperty","tryParseProperty","match","unescapeString","scalar","scalarResponsePattern","responseNames","parseCommandResponse","reportInvalidModifierOrder","source","streamName","ambiguous","route","parseCommandStream","isReactionIdentityLine","misplacedReactionIdentity","parseDescription","parseDocumentation","next","parseAuthorize","previous","combineAuthorize","validate","production","parseProduces","parseHandler","reference","parseReads","captureConcurrency","read","misplacedRuleHintForCommand","candidates","entry","property","discoveredNames","response","removed","parsed","validateHandlerContracts","syntax","commandReadSources","dependencySources","reportLegacyOptionalSuffix","commandName","file","parseFile","body","rule","isFileDirectiveAmongProperties","fence","code","parseCode","rules","requirements","wrapperIndent","owner","condition","parseCondition","message","severity","hasSeverity","directive","matched","ownerName","checksum","valueContext","withSeverity","validateMatchOperand","matchSubject","wrapped","commandOwner","parseImplementationWrapper","isFile","isCode","extra","content","text","clockComparisons","tokens","token","clock","parseClockOperand","parseMappingSource","algorithm","operand","clockOperands","operator","value"],"sources":["../../../../../../Compiler/Parsing/CommandParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { validateHandlerContracts } from './CommandHandlerValidator';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { RequirementSyntax } from '../Syntax/Conditions';\nimport { misplacedRuleHintForCommand } from './MisplacedRuleHint';\nimport { parseCondition } from './ConditionParser';\nimport { parseClockOperand } from './ClockOperandParser';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { CommandSyntax, ValidateSyntax, ValidationRuleKind, ValidationRuleSyntax, ValidationSeverity } from '../Syntax/Commands';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { CommandCalendarSyntax } from '../Syntax/Calendar';\nimport { CommandStreamSyntax } from '../Syntax/EventSources';\nimport { parseCommandStream } from './EventSourceParser';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { ProducesSyntax } from '../Syntax/Reactions';\nimport { CommandResponseSyntax } from '../Syntax/Responses';\nimport { pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseCommandResponse, scalarResponsePattern } from './CommandResponseParser';\nimport { parseDescription } from './DescriptionParser';\nimport { parseDocumentation } from './DocumentationParser';\nimport { isCode, isFile, parseCode, parseFile, parseHandler, parseImplementationWrapper } from './ImplementationParser';\nimport { CodeBlockSyntax, FileReferenceSyntax, HandlerSyntax, ImplementationSyntax } from '../Syntax/Implementations';\nimport { parseMappingSource } from './ExpressionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { matchSubject, validateMatchOperand } from './MatchOperandValidation';\nimport { isReactionIdentityLine, misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { commandReadSources } from './CommandReadSources';\nimport { dependencySources, ReadsSyntax, ConcurrencySyntax } from '../Syntax/DependencySources';\nimport { captureConcurrency } from './DependencySourceParser';\nimport { parseReads } from './ReadsParser';\nimport { parseProduces } from './ProducesParser';\nimport { reportInvalidModifierOrder, reportLegacyOptionalSuffix, tryParseProperty } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { isFileDirectiveAmongProperties } from './FileReferences';\n\nconst header = pattern('^command\\\\s+([A-Za-z_]\\\\w*)$');\nconst routeHeader = sourceStreamPattern('^stream\\\\s+[A-Za-z_]\\\\w*\\\\.[A-Za-z_]\\\\w*$');\nconst calendarPrefix = pattern('^calendar\\\\s+(?:\"|from\\\\s+\\\\$context\\\\.)');\nconst calendarPattern = pattern(`^calendar\\\\s+(?:\"(${stringBodyPattern})\"|from\\\\s+\\\\$context\\\\.([A-Za-z_][A-Za-z0-9_]*(?:\\\\.[A-Za-z_][A-Za-z0-9_]*)*))$`);\nconst severityPattern = pattern('\\\\bseverity\\\\s+(\\\\S+)$');\nconst messagePattern = pattern(`\\\\bmessage\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\S*))$`);\nconst rulePattern = pattern('^([\\\\w.]+)\\\\s+(.+)$');\nconst operandPattern = pattern('^(?:(not empty|matches|not contains|contains|starts with|ends with|max|min|rule)(?:\\\\s+|$)|(length ==|decimals <=|all >=|all >|>=|<=|==|!=|>|<)\\\\s*)(.*)$');\nconst ruleNamePattern = sourceStreamPattern('^[A-Za-z_]\\\\w*$');\nconst optionalReads = pattern('^reads\\\\s+[A-Z]\\\\w*\\\\s+optional(?:\\\\s|$)');\n\n// Every operand the pattern matches has a kind, so an operand never goes unrecognized here.\nconst operandKinds: Record<string, ValidationRuleKind> = {\n max: 'Max',\n min: 'Min',\n '>': 'GreaterThan',\n '>=': 'GreaterThanOrEqual',\n '<': 'LessThan',\n '<=': 'LessThanOrEqual',\n '==': 'Equal',\n '!=': 'NotEqual',\n 'length ==': 'Length',\n 'decimals <=': 'DecimalPlaces',\n matches: 'Matches',\n contains: 'Contains',\n 'not contains': 'NotContains',\n 'starts with': 'StartsWith',\n 'ends with': 'EndsWith',\n 'all >': 'AllGreaterThan',\n 'all >=': 'AllGreaterThanOrEqual',\n};\n\nconst severities: Record<string, ValidationSeverity> = { information: 'Information', warning: 'Warning', error: 'Error' };\n\n// Command directives this compiler does not model. They are skipped whole.\nconst opaqueDirectives = new Set(['reads', 'concurrency']);\n\n// The bare directives cannot take a type reference, so a line with property shape is a property whatever\n// keyword it starts with - 'description String' declares a property called description.\nconst propertyShapedDirectives = new Set(['description', 'documentation', 'handler', 'concurrency']);\n\nexport function parseCommand(context: ParserContext, line: SourceLine): CommandSyntax {\n // Properties are leaves, not indentation owners. Resolve ambiguous returns spelling\n // before the committed pass decides whether its deeper lines belong to a response.\n const names = new Set<string>();\n const lookahead = new ParserContext(context.reader.fork(), context.path, context.languages);\n lookahead.sourceOptions = context.sourceOptions;\n lookahead.streamCandidates = context.streamCandidates;\n parseCommandBody(lookahead, line, undefined, names);\n return parseCommandBody(context, line, names);\n}\n\nfunction parseCommandBody(context: ParserContext, line: SourceLine, responseNames?: ReadonlySet<string>, discoveredNames?: Set<string>): CommandSyntax {\n const name = header.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidCommandDeclaration, `Invalid command declaration '${line.content}' - expected 'command <Name>'`, locationOf(line));\n }\n const properties: PropertySyntax[] = [];\n const responses: { line: SourceLine; candidate: PropertySyntax | null; response: CommandResponseSyntax | null }[] = [];\n let identifier: PropertySyntax | undefined;\n const validations: ValidateSyntax[] = [];\n const produces: ProducesSyntax[] = [];\n const reads: { readModel: string; alias: string | null }[] = [];\n const referenceReads: ReadsSyntax[] = [];\n let concurrency: ConcurrencySyntax | undefined;\n let description: string | null = null;\n let documentation: string | null = null;\n let authorize: AuthorizeSyntax | null = null;\n let authorizationDepthExceeded = false;\n let handler: HandlerSyntax | null = null;\n const handlers: { handler: HandlerSyntax | null; location: SourceLocation }[] = [];\n let stream: CommandStreamSyntax | null = null;\n const streamCandidates: CommandStreamSyntax[] = [];\n let calendar: CommandCalendarSyntax | null = null;\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 const asProperty = tryParseProperty(child);\n if (keyword === 'calendar' && calendarPrefix.test(child.content)) {\n const match = calendarPattern.exec(child.content);\n if (calendar !== null || match === null) {\n context.error(DiagnosticCodes.InvalidCommandCalendar, 'A command declares at most one \\'calendar \"<id>\"\\' or \\'calendar from $context.<member>\\'.', locationOf(child));\n } else {\n calendar = { kind: 'CommandCalendarSyntax', id: match[1] === undefined ? null : unescapeString(match[1]), contextMember: match[2] ?? null, location: locationOf(child) };\n }\n } else if (asProperty !== undefined && (propertyShapedDirectives.has(keyword) || (keyword === 'validate' && child.content !== 'validate csharp'))) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else if (keyword === 'returns') {\n const scalar = scalarResponsePattern.exec(child.content);\n if (scalar !== null && !scalar[1].startsWith('@') && asProperty !== undefined) {\n if (responseNames === undefined) {\n properties.push(asProperty);\n responses.push({ line: child, candidate: asProperty, response: null });\n } else if (responseNames.has(asProperty.type.name)) {\n responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n } else {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n }\n } else if (asProperty !== undefined) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else if (reportInvalidModifierOrder(context, child)) {\n context.skipBlock(child.indent);\n } else {\n responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n }\n } else if (keyword === 'stream' && routeHeader.test(child.content) && asProperty !== undefined && context.streamCandidates?.hasSource(asProperty.type.name.split('.')[0]) === true) {\n const [source, streamName] = asProperty.type.name.split('.');\n const ambiguous = context.streamCandidates.hasPropertyType(asProperty.type.name) && context.streamCandidates.hasUniqueStream(source, streamName);\n const route = parseCommandStream(context, child, asProperty, ambiguous);\n if (stream !== null || streamCandidates.length > 0) context.error(DiagnosticCodes.InvalidCommandStream, 'A command declares at most one stream route.', locationOf(child));\n if (ambiguous || stream !== null) streamCandidates.push(route);\n else stream = route;\n } else if (keyword === 'runs' && isReactionIdentityLine(child)) {\n misplacedReactionIdentity(context, child);\n } else if (keyword === 'description') {\n description = parseDescription(context, child, description, `Command '${name}'`);\n } else if (keyword === 'documentation') {\n documentation = parseDocumentation(context, child, documentation, `Command '${name}'`);\n } else if (keyword === 'authorize') {\n const next = parseAuthorize(context, child);\n if (!authorizationDepthExceeded) {\n const previous = authorize;\n authorize = combineAuthorize(authorize, next, context);\n authorizationDepthExceeded = previous !== null && authorize === null;\n }\n } else if (keyword === 'validate') {\n const validate = parseValidate(context, child, 'command', name);\n if (validate !== undefined) {\n validations.push(validate);\n }\n } else if (keyword === 'produces') {\n const production = parseProduces(context, child, true);\n if (production !== undefined) produces.push(production);\n } else if (keyword === 'handler') {\n handler = parseHandler(context, child);\n handlers.push({ handler, location: locationOf(child) });\n } else if (opaqueDirectives.has(keyword)) {\n const reference = keyword === 'reads' ? parseReads(context, child) : undefined;\n if (reference !== undefined) referenceReads.push(reference);\n if (keyword === 'concurrency' && concurrency === undefined) concurrency = captureConcurrency(context, child);\n const read = /^reads\\s+([A-Z]\\w*)(?:\\s+as\\s+([a-z_]\\w*))?(?:\\s+by\\s+([a-z_]\\w*))?$/.exec(child.content);\n if (read !== null) reads.push({ readModel: read[1], alias: read[2] ?? null });\n if (optionalReads.test(child.content)) {\n context.error(DiagnosticCodes.OptionalReadsNotSupported, 'Optional reads are not yet supported (see #308).', locationOf(child));\n }\n context.skipOpaqueBlock(child.indent);\n } else if (asProperty !== undefined) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else {\n reportInvalidModifierOrder(context, child);\n context.error(DiagnosticCodes.UnknownCommandDirective, `Unexpected '${child.content}' in command body${misplacedRuleHintForCommand(child.content)}`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n const candidates = new Set(responses.flatMap(entry => entry.candidate === null ? [] : [entry.candidate]));\n const names = new Set(properties.filter(property => !candidates.has(property)).map(property => property.name));\n if (responses.some(entry => entry.candidate !== null && !names.has(entry.candidate.type.name) && entry.candidate.type.name !== 'returns')) names.add('returns');\n for (const name of names) discoveredNames?.add(name);\n let response: CommandResponseSyntax | null = null;\n const removed = new Set<PropertySyntax>();\n for (const entry of responses) {\n let parsed = entry.response;\n if (entry.candidate !== null) {\n if (!names.has(entry.candidate.type.name)) continue;\n removed.add(entry.candidate);\n parsed = { kind: 'ScalarCommandResponseSyntax', source: { kind: 'PropertyResponseSourceSyntax', property: entry.candidate.type.name, location: entry.candidate.type.location }, location: locationOf(entry.line) };\n }\n if (parsed === null) continue;\n if (response !== null) {\n context.error(DiagnosticCodes.InvalidCommandResponse, 'A command declares at most one unconditional response.', locationOf(entry.line));\n } else {\n response = parsed;\n }\n }\n validateHandlerContracts(handlers, handler, produces.length > 0, context);\n const syntax: CommandSyntax = { kind: 'CommandSyntax', name, description, documentation, authorize, properties: properties.filter(property => !removed.has(property)), validations, produces, handler, response, stream, streamCandidates, ...(calendar === null ? {} : { calendar }), location: locationOf(line) };\n commandReadSources.set(syntax, reads);\n dependencySources.set(syntax, { reads: referenceReads, concurrency });\n return syntax;\n}\n\nfunction addProperty(context: ParserContext, properties: PropertySyntax[], property: PropertySyntax, commandName: string, line: SourceLine, identifier: PropertySyntax | undefined): PropertySyntax | undefined {\n reportLegacyOptionalSuffix(context, property.type, line);\n if (property.isIdentifier && identifier !== undefined) {\n context.error(DiagnosticCodes.DuplicateCommandIdentifier, `Command '${commandName}' already marks '${identifier.name}' as identifier - only one property can be the identifier`, property.location);\n property = { ...property, isIdentifier: false };\n }\n properties.push(property);\n return identifier ?? (property.isIdentifier ? property : undefined);\n}\n\nfunction parseValidationFile(context: ParserContext, header: SourceLine, body: SourceLine): ValidateSyntax | undefined {\n const file = parseFile(context, body);\n return file === undefined ? undefined : { kind: 'FileValidateSyntax', file, location: locationOf(header) };\n}\n\nfunction hasValidationOperand(line: SourceLine): boolean {\n const match = rulePattern.exec(line.content);\n if (match === null) return false;\n return startsWithRuleOperand(match[2]);\n}\n\nfunction startsWithRuleOperand(rule: string): boolean {\n return (firstWord(rule) === 'not' && firstWord(rule.substring('not'.length).trimStart()) === 'empty') ||\n firstWord(rule) === 'checksum' || operandPattern.test(rule);\n}\n\n/** Recognizes a declarative predicate, with any message or severity suffix; a named 'rule <Name>' is not one. */\nexport function isDeclarativePredicate(rule: string): boolean {\n return startsWithRuleOperand(rule) && firstWord(rule) !== 'rule';\n}\n\nfunction isValidationFileBody(context: ParserContext, header: SourceLine, body: SourceLine): boolean {\n if (!isFileDirectiveAmongProperties(body) || hasValidationOperand(body)) return false;\n const lookahead = context.reader.fork();\n lookahead.takeSignificant();\n const next = lookahead.peekSignificant();\n return next === undefined || next.indent <= header.indent;\n}\n\n// Reads a 'validate' block: declarative rules, or code - which is recognized but not modeled.\nexport function parseValidate(context: ParserContext, line: SourceLine, owner: 'command' | 'concept', ownerName: string): ValidateSyntax | undefined {\n if (line.content === 'validate') {\n const fence = context.peekChild(line.indent);\n if (fence !== undefined && isValidationFileBody(context, line, fence)) {\n context.reader.takeSignificant();\n return parseValidationFile(context, line, fence);\n }\n if (fence !== undefined && fence.content.startsWith('```')) {\n context.reader.takeSignificant();\n const code = parseCode(context.valueContext, fence);\n if (code === null) context.skipFencedBody();\n return { kind: 'CodeValidateSyntax', code, location: locationOf(line) };\n }\n const rules: ValidationRuleSyntax[] = [];\n const requirements: RequirementSyntax[] = [];\n let wrapperIndent: number | undefined;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (owner === 'concept') {\n if (context.sourceOptions.numericMode === 'legacy' && child.content.startsWith('```')) { context.skipFencedBody(); continue; }\n if (wrapperIndent !== undefined && child.indent <= wrapperIndent) wrapperIndent = undefined;\n if (wrapperIndent !== undefined || firstWord(child.content) === 'implementation') {\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${child.content}'`, locationOf(child));\n wrapperIndent ??= child.indent;\n continue;\n }\n }\n if (firstWord(child.content) === 'require') {\n // Keep legacy operand enrichment quiet, but never discard the depth refusal.\n const condition = parseCondition(owner === 'concept' ? context.valueContext : context, child.content.substring('require'.length).trim(), locationOf(child), false, context);\n let message: string | null = null;\n let severity: ValidationSeverity = 'Error';\n let hasSeverity = false;\n for (let directive = context.peekChild(child.indent); directive !== undefined; directive = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n const matched = messagePattern.exec(directive.content);\n if (matched !== null && matched.index === 0) message = matched[1] !== undefined ? unescapeString(matched[1]) : matched[2];\n else if (firstWord(directive.content) === 'severity') {\n if (!hasSeverity) severity = severities[directive.content.substring('severity'.length).trim()] ?? 'Error';\n hasSeverity = true;\n } else context.skipOpaqueBlock(directive.indent);\n }\n if (condition !== null) requirements.push({ kind: 'RequirementSyntax', condition, message, severity, location: locationOf(child) });\n continue;\n }\n const rule = parseValidationRule(context, owner === 'concept' ? { ...child, content: `value ${child.content}` } : child, owner, ownerName);\n if (rule !== undefined) {\n rules.push(rule);\n }\n }\n return { kind: 'DeclarativeValidateSyntax', rules, requirements, location: locationOf(line) };\n }\n if (owner === 'concept' && firstWord(line.content.substring('validate'.length).trimStart()) === 'checksum') {\n const ruleLine = { ...line, content: `value ${line.content.substring('validate'.length).trimStart()}` };\n const rule = parseValidationRule(context, ruleLine, owner, ownerName);\n return rule === undefined ? undefined : { kind: 'DeclarativeValidateSyntax', rules: [rule], requirements: [], location: locationOf(line) };\n }\n if (line.content === 'validate csharp') {\n const code = parseCode(context.valueContext, { ...line, content: 'csharp' });\n if (code === null) context.skipOpaqueBlock(line.indent);\n return { kind: 'CodeValidateSyntax', code, location: locationOf(line) };\n }\n context.error(DiagnosticCodes.InvalidValidateDeclaration, `Invalid validate declaration '${line.content}' - expected 'validate' or 'validate csharp'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n}\n\nfunction parseValidationRule(context: ParserContext, line: SourceLine, owner: 'command' | 'concept', ownerName: string): ValidationRuleSyntax | undefined {\n // Checksum is a new declaration, not enrichment of a formerly opaque Legacy rule.\n const checksum = firstWord(rulePattern.exec(line.content)?.[2] ?? '') === 'checksum';\n const valueContext = owner === 'concept' && !checksum ? context.valueContext : context;\n const { content: withSeverity, message } = splitMessage(line.content);\n const severity = splitSeverity(valueContext, line, withSeverity);\n if (severity === undefined) {\n return undefined;\n }\n const match = rulePattern.exec(severity.content);\n if (match === null) {\n valueContext.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n }\n const parsed = parseRule(valueContext, match[2], line, owner === 'command');\n if (parsed === undefined) {\n return undefined;\n }\n if (parsed.kind === 'Matches' && parsed.value !== null) validateMatchOperand(context, parsed.value, locationOf(line), line.raw, matchSubject(context, owner, ownerName, match[1]));\n const source = parsed.kind === 'Rule' ? parseRuleImplementation(context, line, owner === 'command') : { file: null, code: null, implementation: null };\n return {\n kind: 'ValidationRuleSyntax',\n property: match[1],\n rule: parsed.kind,\n value: parsed.value,\n message,\n severity: severity.severity,\n ...source,\n location: locationOf(line),\n };\n}\n\nfunction parseRuleImplementation(context: ParserContext, rule: SourceLine, commandOwner: boolean): { file: FileReferenceSyntax | null; code: CodeBlockSyntax | null; implementation: ImplementationSyntax | null } {\n const body = context.peekChild(rule.indent);\n if (body === undefined) return { file: null, code: null, implementation: null };\n context.reader.takeSignificant();\n const wrapped = commandOwner && firstWord(body.content) === 'implementation';\n const source = wrapped ? parseImplementationWrapper(context, body) : {\n file: isFile(body) ? parseFile(context, body) : null,\n code: !isFile(body) && isCode(context, body) ? parseCode(context, body) : null,\n implementation: null,\n };\n if (!wrapped && source.file === null && source.code === null) {\n context.error(DiagnosticCodes.UnknownRuleImplementationDirective, `Unexpected '${body.content}' in rule implementation - expected 'file <path>' or an inline code block`, locationOf(body));\n context.skipBlock(body.indent);\n }\n for (let extra = context.peekChild(rule.indent); extra !== undefined && (wrapped || (commandOwner && firstWord(extra.content) === 'implementation')); extra = context.peekChild(rule.indent)) {\n context.reader.takeSignificant();\n context.error(wrapped && firstWord(extra.content) === 'implementation' ? DiagnosticCodes.InvalidImplementationBlock : DiagnosticCodes.ConflictingImplementationSources,\n 'A named rule has one implementation wrapper and cannot mix wrapped and direct sources.', locationOf(extra));\n if (isCode(context, extra)) parseCode(context, extra);\n else context.skipBlock(extra.indent);\n }\n return source;\n}\n\nfunction splitMessage(content: string): { content: string; message: string | null } {\n const match = messagePattern.exec(content);\n if (match === null) {\n return { content, message: null };\n }\n const message = match[1] !== undefined ? unescapeString(match[1]) : match[2];\n return { content: content.substring(0, match.index).trimEnd(), message };\n}\n\nfunction splitSeverity(context: ParserContext, line: SourceLine, text: string): { content: string; severity: ValidationSeverity } | undefined {\n const match = severityPattern.exec(text);\n if (match === null) {\n return { content: text, severity: 'Error' };\n }\n const severity = severities[match[1]];\n if (severity === undefined) {\n context.error(DiagnosticCodes.InvalidValidationSeverity, `Unknown validation severity '${match[1]}' - expected information, warning or error`, locationOf(line));\n return undefined;\n }\n return { content: text.substring(0, match.index).trimEnd(), severity };\n}\n\nconst clockComparisons = new Set(['>', '>=', '<', '<=', '==', '!=']);\n\n// The right operand of a comparison rule: a clock offset or 'date of' one (decisions 0106 and 0107), otherwise an ordinary value.\n// Bare 'today' and 'now' stay paths, so a command property of that name still wins in the binder.\nfunction parseClockComparisonValue(context: ParserContext, text: string, line: SourceLine): ExpressionSyntax | null | undefined {\n const tokens = text.split(/\\s+/).filter(token => token.length > 0);\n const clock = parseClockOperand(context, tokens, 0, locationOf(line));\n if (clock === null) return parseMappingSource(text, locationOf(line), context);\n if (clock.expression === null) return undefined;\n if (clock.position === tokens.length) return clock.expression;\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n}\n\n// Only a command property rule may compare with a clock operand (decision 0107, item 1); a concept rule keeps its ordinary value.\nfunction parseRule(context: ParserContext, rule: string, line: SourceLine, clockOperands: boolean): { kind: ValidationRuleKind; value: ExpressionSyntax | null } | undefined {\n if (rule === 'not empty') {\n return { kind: 'NotEmpty', value: null };\n }\n if (firstWord(rule) === 'checksum') {\n const algorithm = rule.substring('checksum'.length).trim();\n if (algorithm !== 'luhn' && algorithm !== 'mod11' && algorithm !== 'mod97') {\n context.error(DiagnosticCodes.InvalidGenerationArgument, 'Checksum validation requires luhn, mod11 or mod97.', locationOf(line));\n return undefined;\n }\n return { kind: 'Checksum', value: { kind: 'LiteralExpressionSyntax', value: algorithm, location: locationOf(line) } };\n }\n const operand = operandPattern.exec(rule);\n if (operand === null) {\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n }\n const operator = operand[1] ?? operand[2];\n if (operator === 'rule') {\n const name = operand[3].trim();\n if (!ruleNamePattern.test(name)) {\n context.error(DiagnosticCodes.InvalidRuleName, `Invalid rule name '${name}' in '${line.content}' - expected 'rule <Name>' with an identifier`, locationOf(line));\n return undefined;\n }\n return { kind: 'Rule', value: { kind: 'PathExpressionSyntax', path: name, location: locationOf(line) } };\n }\n return parseOperandRule(context, operand, line, clockOperands);\n}\n\nfunction parseOperandRule(context: ParserContext, operand: RegExpExecArray, line: SourceLine, clockOperands: boolean): { kind: ValidationRuleKind; value: ExpressionSyntax | null } | undefined {\n const operator = operand[1] ?? operand[2];\n const value = clockOperands && clockComparisons.has(operator)\n ? parseClockComparisonValue(context, operand[3], line)\n : parseMappingSource(operand[3], locationOf(line), context);\n return value === undefined ? undefined : { kind: operandKinds[operator], value };\n}\n"],"mappings":"A,w4DA0CA,MAAMA,EAASC,EAAQ,8BAA8B,EAC/CC,EAAcC,EAAoB,2CAA2C,EAC7EC,EAAiBH,EAAQ,0CAA0C,EACnEI,EAAkBJ,EAAQ,qBAAqBK,EAAkB,iFAAiF,EAClJC,EAAkBN,EAAQ,wBAAwB,EAClDO,EAAiBP,EAAQ,sBAAsBK,EAAkB,yBAAyB,EAC1FG,EAAcR,EAAQ,qBAAqB,EAC3CS,EAAiBT,EAAQ,2JAA2J,EACpLU,EAAkBR,EAAoB,iBAAiB,EACvDS,EAAgBX,EAAQ,0CAA0C,EAGlEY,EAAmD,CACrD,IAAK,MACL,IAAK,MACL,IAAK,cACL,KAAM,qBACN,IAAK,WACL,KAAM,kBACN,KAAM,QACN,KAAM,WACN,YAAa,SACb,cAAe,gBACf,QAAS,UACT,SAAU,WACV,eAAgB,cAChB,cAAe,aACf,YAAa,WACb,QAAS,iBACT,SAAU,uBACd,EAEMC,EAAiD,CAAE,YAAa,cAAe,QAAS,UAAW,MAAO,OAAQ,EAGlHC,mBAAmB,IAAI,IAAI,CAAC,QAAS,aAAa,CAAC,EAInDC,mBAA2B,IAAI,IAAI,CAAC,cAAe,gBAAiB,UAAW,aAAa,CAAC,EAEnG,SAAgB,aAAa,EAAwB,EAAiC,CAGlF,IAAMC,kBAAQ,IAAI,IACZC,EAAY,IAAIC,EAAcC,EAAQ,OAAO,KAAK,EAAGA,EAAQ,KAAMA,EAAQ,SAAS,EAI1F,MAHA,GAAU,cAAgBA,EAAQ,cAClC,EAAU,iBAAmBA,EAAQ,iBACrC,iBAAiBF,E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arPrefix","calendarPattern","stringBodyPattern","severityPattern","messagePattern","rulePattern","operandPattern","ruleNamePattern","optionalReads","operandKinds","severities","opaqueDirectives","propertyShapedDirectives","names","lookahead","ParserContext","context","line","name","DiagnosticCodes","locationOf","state","responseNames","child","discoveredNames","keyword","commandDirectiveRules","property","isReactionIdentityLine","misplacedReactionIdentity","parseDescription","parseDocumentation","parseHandler","firstWord","asProperty","tryParseProperty","rule","candidate","reportInvalidModifierOrder","misplacedRuleHintForCommand","match","unescapeString","scalar","scalarResponsePattern","parseCommandResponse","source","streamName","ambiguous","route","parseCommandStream","next","parseAuthorize","previous","combineAuthorize","validate","production","parseProduces","reference","parseReads","captureConcurrency","read","candidates","responses","entry","properties","response","removed","parsed","validateHandlerContracts","handlers","handler","produces","syntax","calendar","commandReadSources","reads","dependencySources","referenceReads","reportLegacyOptionalSuffix","identifier","commandName","file","parseFile","body","isFileDirectiveAmongProperties","fence","code","parseCode","rules","requirements","wrapperIndent","owner","condition","parseCondition","message","severity","hasSeverity","directive","matched","ownerName","checksum","valueContext","withSeverity","validateMatchOperand","matchSubject","wrapped","commandOwner","parseImplementationWrapper","isFile","isCode","extra","content","text","clockComparisons","tokens","token","clock","parseClockOperand","parseMappingSource","algorithm","operand","clockOperands","operator","value"],"sources":["../../../../../../Compiler/Parsing/CommandParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { validateHandlerContracts } from './CommandHandlerValidator';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { RequirementSyntax } from '../Syntax/Conditions';\nimport { misplacedRuleHintForCommand } from './MisplacedRuleHint';\nimport { parseCondition } from './ConditionParser';\nimport { parseClockOperand } from './ClockOperandParser';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { CommandSyntax, ValidateSyntax, ValidationRuleKind, ValidationRuleSyntax, ValidationSeverity } from '../Syntax/Commands';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { CommandCalendarSyntax } from '../Syntax/Calendar';\nimport { CommandStreamSyntax } from '../Syntax/EventSources';\nimport { parseCommandStream } from './EventSourceParser';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { ProducesSyntax } from '../Syntax/Reactions';\nimport { CommandResponseSyntax } from '../Syntax/Responses';\nimport { pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseCommandResponse, scalarResponsePattern } from './CommandResponseParser';\nimport { parseDescription } from './DescriptionParser';\nimport { parseDocumentation } from './DocumentationParser';\nimport { isCode, isFile, parseCode, parseFile, parseHandler, parseImplementationWrapper } from './ImplementationParser';\nimport { CodeBlockSyntax, FileReferenceSyntax, HandlerSyntax, ImplementationSyntax } from '../Syntax/Implementations';\nimport { parseMappingSource } from './ExpressionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { matchSubject, validateMatchOperand } from './MatchOperandValidation';\nimport { isReactionIdentityLine, misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { commandReadSources } from './CommandReadSources';\nimport { dependencySources, ReadsSyntax, ConcurrencySyntax } from '../Syntax/DependencySources';\nimport { captureConcurrency } from './DependencySourceParser';\nimport { parseReads } from './ReadsParser';\nimport { parseProduces } from './ProducesParser';\nimport { reportInvalidModifierOrder, reportLegacyOptionalSuffix, tryParseProperty } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { isFileDirectiveAmongProperties } from './FileReferences';\n\nconst header = pattern('^command\\\\s+([A-Za-z_]\\\\w*)$');\nconst routeHeader = sourceStreamPattern('^stream\\\\s+[A-Za-z_]\\\\w*\\\\.[A-Za-z_]\\\\w*$');\nconst calendarPrefix = pattern('^calendar\\\\s+(?:\"|from\\\\s+\\\\$context\\\\.)');\nconst calendarPattern = pattern(`^calendar\\\\s+(?:\"(${stringBodyPattern})\"|from\\\\s+\\\\$context\\\\.([A-Za-z_][A-Za-z0-9_]*(?:\\\\.[A-Za-z_][A-Za-z0-9_]*)*))$`);\nconst severityPattern = pattern('\\\\bseverity\\\\s+(\\\\S+)$');\nconst messagePattern = pattern(`\\\\bmessage\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\S*))$`);\nconst rulePattern = pattern('^([\\\\w.]+)\\\\s+(.+)$');\nconst operandPattern = pattern('^(?:(not empty|matches|not contains|contains|starts with|ends with|max|min|rule)(?:\\\\s+|$)|(length ==|decimals <=|all >=|all >|>=|<=|==|!=|>|<)\\\\s*)(.*)$');\nconst ruleNamePattern = sourceStreamPattern('^[A-Za-z_]\\\\w*$');\nconst optionalReads = pattern('^reads\\\\s+[A-Z]\\\\w*\\\\s+optional(?:\\\\s|$)');\n\n// Every operand the pattern matches has a kind, so an operand never goes unrecognized here.\nconst operandKinds: Record<string, ValidationRuleKind> = {\n max: 'Max',\n min: 'Min',\n '>': 'GreaterThan',\n '>=': 'GreaterThanOrEqual',\n '<': 'LessThan',\n '<=': 'LessThanOrEqual',\n '==': 'Equal',\n '!=': 'NotEqual',\n 'length ==': 'Length',\n 'decimals <=': 'DecimalPlaces',\n matches: 'Matches',\n contains: 'Contains',\n 'not contains': 'NotContains',\n 'starts with': 'StartsWith',\n 'ends with': 'EndsWith',\n 'all >': 'AllGreaterThan',\n 'all >=': 'AllGreaterThanOrEqual',\n};\n\nconst severities: Record<string, ValidationSeverity> = { information: 'Information', warning: 'Warning', error: 'Error' };\n\n// Command directives this compiler does not model. They are skipped whole.\nconst opaqueDirectives = new Set(['reads', 'concurrency']);\n\n// The bare directives cannot take a type reference, so a line with property shape is a property whatever\n// keyword it starts with - 'description String' declares a property called description.\nconst propertyShapedDirectives = new Set(['description', 'documentation', 'handler', 'concurrency']);\n\nexport function parseCommand(context: ParserContext, line: SourceLine): CommandSyntax {\n // Properties are leaves, not indentation owners. Resolve ambiguous returns spelling\n // before the committed pass decides whether its deeper lines belong to a response.\n const names = new Set<string>();\n const lookahead = new ParserContext(context.reader.fork(), context.path, context.languages);\n lookahead.sourceOptions = context.sourceOptions;\n lookahead.streamCandidates = context.streamCandidates;\n parseCommandBody(lookahead, line, undefined, names);\n return parseCommandBody(context, line, names);\n}\n\nfunction parseCommandBody(context: ParserContext, line: SourceLine, responseNames?: ReadonlySet<string>, discoveredNames?: Set<string>): CommandSyntax {\n const name = header.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidCommandDeclaration, `Invalid command declaration '${line.content}' - expected 'command <Name>'`, locationOf(line));\n }\n const state = createCommandBodyState(name, responseNames);\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n dispatchCommandDirective(context, child, state);\n }\n return buildCommand(context, line, state, discoveredNames);\n}\n\n// What the command body loop gathers while it reads the directives of one command.\ninterface CommandBodyState {\n readonly name: string;\n readonly responseNames: ReadonlySet<string> | undefined;\n readonly properties: PropertySyntax[];\n readonly responses: { line: SourceLine; candidate: PropertySyntax | null; response: CommandResponseSyntax | null }[];\n identifier: PropertySyntax | undefined;\n readonly validations: ValidateSyntax[];\n readonly produces: ProducesSyntax[];\n readonly reads: { readModel: string; alias: string | null }[];\n readonly referenceReads: ReadsSyntax[];\n concurrency: ConcurrencySyntax | undefined;\n description: string | null;\n documentation: string | null;\n authorize: AuthorizeSyntax | null;\n authorizationDepthExceeded: boolean;\n handler: HandlerSyntax | null;\n readonly handlers: { handler: HandlerSyntax | null; location: SourceLocation }[];\n stream: CommandStreamSyntax | null;\n readonly streamCandidates: CommandStreamSyntax[];\n calendar: CommandCalendarSyntax | null;\n}\n\n// A command body rule: whether it takes a line - by keyword and, where the keyword alone cannot decide, by the line - and what to do with it.\ninterface CommandDirectiveRule {\n readonly matches: (keyword: string, line: SourceLine, property: PropertySyntax | undefined, context: ParserContext) => boolean;\n readonly parse: (context: ParserContext, line: SourceLine, state: CommandBodyState, property: PropertySyntax | undefined) => void;\n}\n\nfunction createCommandBodyState(name: string, responseNames: ReadonlySet<string> | undefined): CommandBodyState {\n return {\n name, responseNames, properties: [], responses: [], identifier: undefined, validations: [], produces: [], reads: [], referenceReads: [],\n concurrency: undefined, description: null, documentation: null, authorize: null, authorizationDepthExceeded: false, handler: null,\n handlers: [], stream: null, streamCandidates: [], calendar: null\n };\n}\n\nconst isDirective = (name: string) => (keyword: string): boolean => keyword === name;\n\n// The command body rules in the order they are tried: the first one that takes the line handles it, so a keyword with a property shaped rule keeps it\n// ahead of its directive rule. A line no rule takes is a property, or an unexpected directive.\nconst commandDirectiveRules: readonly CommandDirectiveRule[] = [\n { matches: (keyword, line) => keyword === 'calendar' && calendarPrefix.test(line.content), parse: parseCalendarDirective },\n { matches: (keyword, line, property) => property !== undefined && (propertyShapedDirectives.has(keyword) || (keyword === 'validate' && line.content !== 'validate csharp')), parse: addPropertyDirective },\n { matches: isDirective('returns'), parse: parseReturnsDirective },\n { matches: (keyword, line, property, context) => keyword === 'stream' && routeHeader.test(line.content) && property !== undefined && context.streamCandidates?.hasSource(property.type.name.split('.')[0]) === true, parse: parseStreamDirective },\n { matches: (keyword, line) => keyword === 'runs' && isReactionIdentityLine(line), parse: (context, line) => { misplacedReactionIdentity(context, line); } },\n { matches: isDirective('description'), parse: (context, line, state) => { state.description = parseDescription(context, line, state.description, `Command '${state.name}'`); } },\n { matches: isDirective('documentation'), parse: (context, line, state) => { state.documentation = parseDocumentation(context, line, state.documentation, `Command '${state.name}'`); } },\n { matches: isDirective('authorize'), parse: parseAuthorizeDirective },\n { matches: isDirective('validate'), parse: parseValidateDirective },\n { matches: isDirective('produces'), parse: parseProducesDirective },\n { matches: isDirective('handler'), parse: (context, line, state) => { state.handler = parseHandler(context, line); state.handlers.push({ handler: state.handler, location: locationOf(line) }); } },\n { matches: keyword => opaqueDirectives.has(keyword), parse: parseOpaqueDirective }\n];\n\nfunction dispatchCommandDirective(context: ParserContext, child: SourceLine, state: CommandBodyState): void {\n const keyword = firstWord(child.content);\n const asProperty = tryParseProperty(child);\n const rule = commandDirectiveRules.find(candidate => candidate.matches(keyword, child, asProperty, context));\n if (rule !== undefined) {\n rule.parse(context, child, state, asProperty);\n } else if (asProperty !== undefined) {\n state.identifier = addProperty(context, state.properties, asProperty, state.name, child, state.identifier);\n } else {\n reportInvalidModifierOrder(context, child);\n context.error(DiagnosticCodes.UnknownCommandDirective, `Unexpected '${child.content}' in command body${misplacedRuleHintForCommand(child.content)}`, locationOf(child));\n context.skipBlock(child.indent);\n }\n}\n\nfunction addPropertyDirective(context: ParserContext, child: SourceLine, state: CommandBodyState, property: PropertySyntax | undefined): void {\n state.identifier = addProperty(context, state.properties, property!, state.name, child, state.identifier);\n}\n\nfunction parseCalendarDirective(context: ParserContext, child: SourceLine, state: CommandBodyState): void {\n const match = calendarPattern.exec(child.content);\n if (state.calendar !== null || match === null) {\n context.error(DiagnosticCodes.InvalidCommandCalendar, 'A command declares at most one \\'calendar \"<id>\"\\' or \\'calendar from $context.<member>\\'.', locationOf(child));\n } else {\n state.calendar = { kind: 'CommandCalendarSyntax', id: match[1] === undefined ? null : unescapeString(match[1]), contextMember: match[2] ?? null, location: locationOf(child) };\n }\n}\n\nfunction parseReturnsDirective(context: ParserContext, child: SourceLine, state: CommandBodyState, property: PropertySyntax | undefined): void {\n const scalar = scalarResponsePattern.exec(child.content);\n if (scalar !== null && !scalar[1].startsWith('@') && property !== undefined) {\n parseScalarReturns(context, child, state, property);\n } else if (property !== undefined) {\n state.identifier = addProperty(context, state.properties, property, state.name, child, state.identifier);\n } else if (reportInvalidModifierOrder(context, child)) {\n context.skipBlock(child.indent);\n } else {\n state.responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n }\n}\n\nfunction parseScalarReturns(context: ParserContext, child: SourceLine, state: CommandBodyState, property: PropertySyntax): void {\n if (state.responseNames === undefined) {\n state.properties.push(property);\n state.responses.push({ line: child, candidate: property, response: null });\n } else if (state.responseNames.has(property.type.name)) {\n state.responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n } else {\n state.identifier = addProperty(context, state.properties, property, state.name, child, state.identifier);\n }\n}\n\nfunction parseStreamDirective(context: ParserContext, child: SourceLine, state: CommandBodyState, property: PropertySyntax | undefined): void {\n const [source, streamName] = property!.type.name.split('.');\n const ambiguous = context.streamCandidates!.hasPropertyType(property!.type.name) && context.streamCandidates!.hasUniqueStream(source, streamName);\n const route = parseCommandStream(context, child, property!, ambiguous);\n if (state.stream !== null || state.streamCandidates.length > 0) context.error(DiagnosticCodes.InvalidCommandStream, 'A command declares at most one stream route.', locationOf(child));\n if (ambiguous || state.stream !== null) state.streamCandidates.push(route);\n else state.stream = route;\n}\n\nfunction parseAuthorizeDirective(context: ParserContext, child: SourceLine, state: CommandBodyState): void {\n const next = parseAuthorize(context, child);\n if (state.authorizationDepthExceeded) return;\n const previous = state.authorize;\n state.authorize = combineAuthorize(state.authorize, next, context);\n state.authorizationDepthExceeded = previous !== null && state.authorize === null;\n}\n\nfunction parseValidateDirective(context: ParserContext, child: SourceLine, state: CommandBodyState): void {\n const validate = parseValidate(context, child, 'command', state.name);\n if (validate !== undefined) state.validations.push(validate);\n}\n\nfunction parseProducesDirective(context: ParserContext, child: SourceLine, state: CommandBodyState): void {\n const production = parseProduces(context, child, true);\n if (production !== undefined) state.produces.push(production);\n}\n\nfunction parseOpaqueDirective(context: ParserContext, child: SourceLine, state: CommandBodyState): void {\n const keyword = firstWord(child.content);\n const reference = keyword === 'reads' ? parseReads(context, child) : undefined;\n if (reference !== undefined) state.referenceReads.push(reference);\n if (keyword === 'concurrency' && state.concurrency === undefined) state.concurrency = captureConcurrency(context, child);\n const read = /^reads\\s+([A-Z]\\w*)(?:\\s+as\\s+([a-z_]\\w*))?(?:\\s+by\\s+([a-z_]\\w*))?$/.exec(child.content);\n if (read !== null) state.reads.push({ readModel: read[1], alias: read[2] ?? null });\n if (optionalReads.test(child.content)) {\n context.error(DiagnosticCodes.OptionalReadsNotSupported, 'Optional reads are not yet supported (see #308).', locationOf(child));\n }\n context.skipOpaqueBlock(child.indent);\n}\n\n// Settles which 'returns' lines are the response and which are properties named like one, and the one response a command may declare.\nfunction resolveResponse(context: ParserContext, state: CommandBodyState, discoveredNames: Set<string> | undefined): { response: CommandResponseSyntax | null; removed: Set<PropertySyntax> } {\n const { properties, responses } = state;\n const candidates = new Set(responses.flatMap(entry => entry.candidate === null ? [] : [entry.candidate]));\n const names = new Set(properties.filter(property => !candidates.has(property)).map(property => property.name));\n if (responses.some(entry => entry.candidate !== null && !names.has(entry.candidate.type.name) && entry.candidate.type.name !== 'returns')) names.add('returns');\n for (const name of names) discoveredNames?.add(name);\n let response: CommandResponseSyntax | null = null;\n const removed = new Set<PropertySyntax>();\n for (const entry of responses) {\n let parsed = entry.response;\n if (entry.candidate !== null) {\n if (!names.has(entry.candidate.type.name)) continue;\n removed.add(entry.candidate);\n parsed = { kind: 'ScalarCommandResponseSyntax', source: { kind: 'PropertyResponseSourceSyntax', property: entry.candidate.type.name, location: entry.candidate.type.location }, location: locationOf(entry.line) };\n }\n if (parsed === null) continue;\n if (response !== null) {\n context.error(DiagnosticCodes.InvalidCommandResponse, 'A command declares at most one unconditional response.', locationOf(entry.line));\n } else {\n response = parsed;\n }\n }\n return { response, removed };\n}\n\nfunction buildCommand(context: ParserContext, line: SourceLine, state: CommandBodyState, discoveredNames: Set<string> | undefined): CommandSyntax {\n const { name, properties, validations, produces, reads, referenceReads, concurrency, description, documentation, authorize, handler, handlers, stream, streamCandidates, calendar } = state;\n const { response, removed } = resolveResponse(context, state, discoveredNames);\n validateHandlerContracts(handlers, handler, produces.length > 0, context);\n const syntax: CommandSyntax = { kind: 'CommandSyntax', name, description, documentation, authorize, properties: properties.filter(property => !removed.has(property)), validations, produces, handler, response, stream, streamCandidates, ...(calendar === null ? {} : { calendar }), location: locationOf(line) };\n commandReadSources.set(syntax, reads);\n dependencySources.set(syntax, { reads: referenceReads, concurrency });\n return syntax;\n}\n\nfunction addProperty(context: ParserContext, properties: PropertySyntax[], property: PropertySyntax, commandName: string, line: SourceLine, identifier: PropertySyntax | undefined): PropertySyntax | undefined {\n reportLegacyOptionalSuffix(context, property.type, line);\n if (property.isIdentifier && identifier !== undefined) {\n context.error(DiagnosticCodes.DuplicateCommandIdentifier, `Command '${commandName}' already marks '${identifier.name}' as identifier - only one property can be the identifier`, property.location);\n property = { ...property, isIdentifier: false };\n }\n properties.push(property);\n return identifier ?? (property.isIdentifier ? property : undefined);\n}\n\nfunction parseValidationFile(context: ParserContext, header: SourceLine, body: SourceLine): ValidateSyntax | undefined {\n const file = parseFile(context, body);\n return file === undefined ? undefined : { kind: 'FileValidateSyntax', file, location: locationOf(header) };\n}\n\nfunction hasValidationOperand(line: SourceLine): boolean {\n const match = rulePattern.exec(line.content);\n if (match === null) return false;\n return startsWithRuleOperand(match[2]);\n}\n\nfunction startsWithRuleOperand(rule: string): boolean {\n return (firstWord(rule) === 'not' && firstWord(rule.substring('not'.length).trimStart()) === 'empty') ||\n firstWord(rule) === 'checksum' || operandPattern.test(rule);\n}\n\n/** Recognizes a declarative predicate, with any message or severity suffix; a named 'rule <Name>' is not one. */\nexport function isDeclarativePredicate(rule: string): boolean {\n return startsWithRuleOperand(rule) && firstWord(rule) !== 'rule';\n}\n\nfunction isValidationFileBody(context: ParserContext, header: SourceLine, body: SourceLine): boolean {\n if (!isFileDirectiveAmongProperties(body) || hasValidationOperand(body)) return false;\n const lookahead = context.reader.fork();\n lookahead.takeSignificant();\n const next = lookahead.peekSignificant();\n return next === undefined || next.indent <= header.indent;\n}\n\n// Reads a 'validate' block: declarative rules, or code - which is recognized but not modeled.\nexport function parseValidate(context: ParserContext, line: SourceLine, owner: 'command' | 'concept', ownerName: string): ValidateSyntax | undefined {\n if (line.content === 'validate') {\n const fence = context.peekChild(line.indent);\n if (fence !== undefined && isValidationFileBody(context, line, fence)) {\n context.reader.takeSignificant();\n return parseValidationFile(context, line, fence);\n }\n if (fence !== undefined && fence.content.startsWith('```')) {\n context.reader.takeSignificant();\n const code = parseCode(context.valueContext, fence);\n if (code === null) context.skipFencedBody();\n return { kind: 'CodeValidateSyntax', code, location: locationOf(line) };\n }\n const rules: ValidationRuleSyntax[] = [];\n const requirements: RequirementSyntax[] = [];\n let wrapperIndent: number | undefined;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (owner === 'concept') {\n if (context.sourceOptions.numericMode === 'legacy' && child.content.startsWith('```')) { context.skipFencedBody(); continue; }\n if (wrapperIndent !== undefined && child.indent <= wrapperIndent) wrapperIndent = undefined;\n if (wrapperIndent !== undefined || firstWord(child.content) === 'implementation') {\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${child.content}'`, locationOf(child));\n wrapperIndent ??= child.indent;\n continue;\n }\n }\n if (firstWord(child.content) === 'require') {\n // Keep legacy operand enrichment quiet, but never discard the depth refusal.\n const condition = parseCondition(owner === 'concept' ? context.valueContext : context, child.content.substring('require'.length).trim(), locationOf(child), false, context);\n let message: string | null = null;\n let severity: ValidationSeverity = 'Error';\n let hasSeverity = false;\n for (let directive = context.peekChild(child.indent); directive !== undefined; directive = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n const matched = messagePattern.exec(directive.content);\n if (matched !== null && matched.index === 0) message = matched[1] !== undefined ? unescapeString(matched[1]) : matched[2];\n else if (firstWord(directive.content) === 'severity') {\n if (!hasSeverity) severity = severities[directive.content.substring('severity'.length).trim()] ?? 'Error';\n hasSeverity = true;\n } else context.skipOpaqueBlock(directive.indent);\n }\n if (condition !== null) requirements.push({ kind: 'RequirementSyntax', condition, message, severity, location: locationOf(child) });\n continue;\n }\n const rule = parseValidationRule(context, owner === 'concept' ? { ...child, content: `value ${child.content}` } : child, owner, ownerName);\n if (rule !== undefined) {\n rules.push(rule);\n }\n }\n return { kind: 'DeclarativeValidateSyntax', rules, requirements, location: locationOf(line) };\n }\n if (owner === 'concept' && firstWord(line.content.substring('validate'.length).trimStart()) === 'checksum') {\n const ruleLine = { ...line, content: `value ${line.content.substring('validate'.length).trimStart()}` };\n const rule = parseValidationRule(context, ruleLine, owner, ownerName);\n return rule === undefined ? undefined : { kind: 'DeclarativeValidateSyntax', rules: [rule], requirements: [], location: locationOf(line) };\n }\n if (line.content === 'validate csharp') {\n const code = parseCode(context.valueContext, { ...line, content: 'csharp' });\n if (code === null) context.skipOpaqueBlock(line.indent);\n return { kind: 'CodeValidateSyntax', code, location: locationOf(line) };\n }\n context.error(DiagnosticCodes.InvalidValidateDeclaration, `Invalid validate declaration '${line.content}' - expected 'validate' or 'validate csharp'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n}\n\nfunction parseValidationRule(context: ParserContext, line: SourceLine, owner: 'command' | 'concept', ownerName: string): ValidationRuleSyntax | undefined {\n // Checksum is a new declaration, not enrichment of a formerly opaque Legacy rule.\n const checksum = firstWord(rulePattern.exec(line.content)?.[2] ?? '') === 'checksum';\n const valueContext = owner === 'concept' && !checksum ? context.valueContext : context;\n const { content: withSeverity, message } = splitMessage(line.content);\n const severity = splitSeverity(valueContext, line, withSeverity);\n if (severity === undefined) {\n return undefined;\n }\n const match = rulePattern.exec(severity.content);\n if (match === null) {\n valueContext.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n }\n const parsed = parseRule(valueContext, match[2], line, owner === 'command');\n if (parsed === undefined) {\n return undefined;\n }\n if (parsed.kind === 'Matches' && parsed.value !== null) validateMatchOperand(context, parsed.value, locationOf(line), line.raw, matchSubject(context, owner, ownerName, match[1]));\n const source = parsed.kind === 'Rule' ? parseRuleImplementation(context, line, owner === 'command') : { file: null, code: null, implementation: null };\n return {\n kind: 'ValidationRuleSyntax',\n property: match[1],\n rule: parsed.kind,\n value: parsed.value,\n message,\n severity: severity.severity,\n ...source,\n location: locationOf(line),\n };\n}\n\nfunction parseRuleImplementation(context: ParserContext, rule: SourceLine, commandOwner: boolean): { file: FileReferenceSyntax | null; code: CodeBlockSyntax | null; implementation: ImplementationSyntax | null } {\n const body = context.peekChild(rule.indent);\n if (body === undefined) return { file: null, code: null, implementation: null };\n context.reader.takeSignificant();\n const wrapped = commandOwner && firstWord(body.content) === 'implementation';\n const source = wrapped ? parseImplementationWrapper(context, body) : {\n file: isFile(body) ? parseFile(context, body) : null,\n code: !isFile(body) && isCode(context, body) ? parseCode(context, body) : null,\n implementation: null,\n };\n if (!wrapped && source.file === null && source.code === null) {\n context.error(DiagnosticCodes.UnknownRuleImplementationDirective, `Unexpected '${body.content}' in rule implementation - expected 'file <path>' or an inline code block`, locationOf(body));\n context.skipBlock(body.indent);\n }\n for (let extra = context.peekChild(rule.indent); extra !== undefined && (wrapped || (commandOwner && firstWord(extra.content) === 'implementation')); extra = context.peekChild(rule.indent)) {\n context.reader.takeSignificant();\n context.error(wrapped && firstWord(extra.content) === 'implementation' ? DiagnosticCodes.InvalidImplementationBlock : DiagnosticCodes.ConflictingImplementationSources,\n 'A named rule has one implementation wrapper and cannot mix wrapped and direct sources.', locationOf(extra));\n if (isCode(context, extra)) parseCode(context, extra);\n else context.skipBlock(extra.indent);\n }\n return source;\n}\n\nfunction splitMessage(content: string): { content: string; message: string | null } {\n const match = messagePattern.exec(content);\n if (match === null) {\n return { content, message: null };\n }\n const message = match[1] !== undefined ? unescapeString(match[1]) : match[2];\n return { content: content.substring(0, match.index).trimEnd(), message };\n}\n\nfunction splitSeverity(context: ParserContext, line: SourceLine, text: string): { content: string; severity: ValidationSeverity } | undefined {\n const match = severityPattern.exec(text);\n if (match === null) {\n return { content: text, severity: 'Error' };\n }\n const severity = severities[match[1]];\n if (severity === undefined) {\n context.error(DiagnosticCodes.InvalidValidationSeverity, `Unknown validation severity '${match[1]}' - expected information, warning or error`, locationOf(line));\n return undefined;\n }\n return { content: text.substring(0, match.index).trimEnd(), severity };\n}\n\nconst clockComparisons = new Set(['>', '>=', '<', '<=', '==', '!=']);\n\n// The right operand of a comparison rule: a clock offset or 'date of' one (decisions 0106 and 0107), otherwise an ordinary value.\n// Bare 'today' and 'now' stay paths, so a command property of that name still wins in the binder.\nfunction parseClockComparisonValue(context: ParserContext, text: string, line: SourceLine): ExpressionSyntax | null | undefined {\n const tokens = text.split(/\\s+/).filter(token => token.length > 0);\n const clock = parseClockOperand(context, tokens, 0, locationOf(line));\n if (clock === null) return parseMappingSource(text, locationOf(line), context);\n if (clock.expression === null) return undefined;\n if (clock.position === tokens.length) return clock.expression;\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n}\n\n// Only a command property rule may compare with a clock operand (decision 0107, item 1); a concept rule keeps its ordinary value.\nfunction parseRule(context: ParserContext, rule: string, line: SourceLine, clockOperands: boolean): { kind: ValidationRuleKind; value: ExpressionSyntax | null } | undefined {\n if (rule === 'not empty') {\n return { kind: 'NotEmpty', value: null };\n }\n if (firstWord(rule) === 'checksum') {\n const algorithm = rule.substring('checksum'.length).trim();\n if (algorithm !== 'luhn' && algorithm !== 'mod11' && algorithm !== 'mod97') {\n context.error(DiagnosticCodes.InvalidGenerationArgument, 'Checksum validation requires luhn, mod11 or mod97.', locationOf(line));\n return undefined;\n }\n return { kind: 'Checksum', value: { kind: 'LiteralExpressionSyntax', value: algorithm, location: locationOf(line) } };\n }\n const operand = operandPattern.exec(rule);\n if (operand === null) {\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n }\n const operator = operand[1] ?? operand[2];\n if (operator === 'rule') {\n const name = operand[3].trim();\n if (!ruleNamePattern.test(name)) {\n context.error(DiagnosticCodes.InvalidRuleName, `Invalid rule name '${name}' in '${line.content}' - expected 'rule <Name>' with an identifier`, locationOf(line));\n return undefined;\n }\n return { kind: 'Rule', value: { kind: 'PathExpressionSyntax', path: name, location: locationOf(line) } };\n }\n return parseOperandRule(context, operand, line, clockOperands);\n}\n\nfunction parseOperandRule(context: ParserContext, operand: RegExpExecArray, line: SourceLine, clockOperands: boolean): { kind: ValidationRuleKind; value: ExpressionSyntax | null } | undefined {\n const operator = operand[1] ?? operand[2];\n const value = clockOperands && clockComparisons.has(operator)\n ? parseClockComparisonValue(context, operand[3], line)\n : parseMappingSource(operand[3], locationOf(line), context);\n return value === undefined ? undefined : { kind: operandKinds[operator], value };\n}\n"],"mappings":"A,u4DA0CA,MAAMA,EAASC,EAAQ,8BAA8B,EAC/CC,EAAcC,EAAoB,2CAA2C,EAC7EC,EAAiBH,EAAQ,0CAA0C,EACnEI,EAAkBJ,EAAQ,qBAAqBK,EAAkB,iFAAiF,EAClJC,EAAkBN,EAAQ,wBAAwB,EAClDO,EAAiBP,EAAQ,sBAAsBK,EAAkB,yBAAyB,EAC1FG,EAAcR,EAAQ,qBAAqB,EAC3CS,EAAiBT,EAAQ,2JAA2J,EACpLU,EAAkBR,EAAoB,iBAAiB,EACvDS,EAAgBX,EAAQ,0CAA0C,EAGlEY,EAAmD,CACrD,IAAK,MACL,IAAK,MACL,IAAK,cACL,KAAM,qBACN,IAAK,WACL,KAAM,kBACN,KAAM,QACN,KAAM,WACN,YAAa,SACb,cAAe,gBACf,QAAS,UACT,SAAU,WACV,eAAgB,cAChB,cAAe,aACf,YAAa,WACb,QAAS,iBACT,SAAU,uBACd,EAEMC,EAAiD,CAAE,YAAa,cAAe,QAAS,UAAW,MAAO,OAAQ,EAGlHC,kBAAmB,IAAI,IAAI,CAAC,QAAS,aAAa,CAAC,EAInDC,kBAA2B,IAAI,IAAI,CAAC,cAAe,gBAAiB,UAAW,aAAa,CAAC,EAEnG,SAAgB,aAAa,EAAwB,EAAiC,CAGlF,IAAMC,kBAAQ,IAAI,IACZC,EAAY,IAAIC,EAAcC,EAAQ,OAAO,KAAK,EAAGA,EAAQ,KAAMA,EAAQ,SAAS,EAI1F,MAHA,GAAU,cAAgBA,EAAQ,cAClC,EAAU,iBAAmBA,EAAQ,iBACrC,iBA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AAiB,sBAAsBD,EAAK,QAAQD,EAAK,QAAQ,+CAAgDG,EAAWH,CAAI,CAAC,EAC/J,MACJ,CACA,MAAO,CAAE,KAAM,OAAQ,MAAO,CAAE,KAAM,uBAAwB,KAAMC,EAAM,SAAUE,EAAWH,CAAI,CAAE,CAAE,CAC3G,CACA,OAAO,iBAAiBD,EAASwG,EAASvG,EAAMwG,CAAa,CAD7D,CAEJ,CAEA,SAAS,iBAAiB,EAAwB,EAA0B,EAAkB,EAAkG,CAC5L,IAAMC,EAAWF,EAAQ,IAAMA,EAAQ,GACjCG,EAAQF,GAAiBR,GAAiB,IAAIS,CAAQ,EACtD,0BAA0B1G,EAASwG,EAAQ,GAAIvG,CAAI,EACnDqG,EAAmBE,EAAQ,GAAIpG,EAAWH,CAAI,EAAGD,CAAO,EAC9D,OAAO2G,IAAU,IAAA,GAAY,IAAA,GAAY,CAAE,KAAMlH,EAAaiH,GAAW,OAAM,CACnF,C"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{EnumerationMembers as e}from"./EnumerationMembers.js";import{misplacedRuleHintForConcept as t}from"./MisplacedRuleHint.js";import{parseGeneration as n}from"./GenerationParser.js";import{parseIdentity as r}from"./IdentityParser.js";import{parseApplicationContext as i}from"./ApplicationContextParser.js";import{misplacedReactionIdentity as a}from"./ReactionIdentityParser.js";import{DiagnosticCodes as o}from"../Diagnostics/DiagnosticCodes.js";import{recordAuthoredDocument as s}from"../Syntax/SourceOptions.js";import{describePlacement as c,documentPlacement as l,isDocumentPlacement as u}from"../Files/PlayPlacement.js";import{parseTriggerDeclaration as d}from"./TriggerDataParser.js";import{pattern as f}from"../Text/patterns.js";import{parseComplianceDirective as p,parseComplianceMarkers as m}from"./ConceptComplianceParser.js";import{parseType as h}from"./DeclarationParsers.js";import{parseValidate as g}from"./CommandParser.js";import{parseDescription as _}from"./DescriptionParser.js";import{FeatureBody as v,featureBodyExpected as y}from"./FeatureBody.js";import{isFileImport as b,parseFileImport as x}from"./FileImportParser.js";import{isFileDirective as S}from"./FileReferences.js";import{collectInputUses as ee}from"./InputUses.js";import{firstWord as C,unescapeIdentifier as w}from"./LineText.js";import{ModuleBody as te,moduleBodyExpected as T,modulePattern as E,parseModule as ne}from"./ModuleBody.js";import{parsePolicy as re}from"./PolicyParser.js";import{parsePurpose as ie}from"./PurposeParser.js";import{parseSeed as ae}from"./SeedParser.js";import{parseSystem as D}from"./OperationParser.js";import{parseStateMachine as oe}from"./StateMachineParser.js";import{parseWorkflow as se}from"./WorkflowParser.js";import{isBlankPublicEventOrigin as ce}from"../Syntax/PublicEventInvariants.js";import{stringBodyPattern as O,unescapeString as k}from"../Text/StringLiteral.js";import{parseCanvasPair as A}from"./CanvasPlacement.js";import{parseEventSource as le}from"./EventSourceParser.js";import{parseExposure as ue,parseInstance as de}from"./CompositionParser.js";import{parseExample as fe}from"./SpecificationExampleParser.js";import{parseUiProfile as pe}from"./UiProfileLegacyLayout.js";import{locationOf as j,startOf as M}from"./SourceLine.js";const N=f(`^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`),P=f(`^time\\s+zone\\s+(configurable\\s+default\\s+)?"(${O})"$`),F=f(`^import\\s+([\\w.]+)(?:\\s+from\\s+"(?<origin>${O})")?$`),I=f(`^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$`),L=f(`^@?[a-z_]\\w*$`),R=f(`^persona\\s+([A-Za-z_]\\w*)$`),z=f(`^policy\\s+([A-Za-z_]\\w*)$`),B=f(`^goal\\s+"(${O})"$`),V=f(`^sticky\\s+note\\s+on\\s+(personas|eventsources|givencontexts|seeddata)$`),H=f(`^colour\\s+(yellow|pink|green|blue)$`),U=/^[ ]*\t/,W=[`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`],G=/* @__PURE__ */ new Set([`policy`,`authentication`,`onboarding`,`seed`,`ui`,`theme`,`trigger`,`layout`,`behavior`,`sample`]),K=/* @__PURE__ */ new Set([`slice`,`feature`,`description`,`documentation`,`authorize`,`screen`,`dialog`,`form`,`contribute`,`on`,`uses`]);function parseApplication(e,t,n=l){e.deferIdentityValidation=!0,warnOnTabIndentation(e,t);let c=n.length===1?new te(n[0]):void 0,f=n.length>1?new v(n[n.length-1]):void 0,p=c??f,m=null,g=null,_=null,y=!1,S=null,w=null,T=!1,E=!1,O=null,A=[],M=[],N=[],I=[],L=[],R=[],z=[],B=[],V=[],H=[],U=[],W=[],K=[],q=[],J=[],Y=[],X=[],Z=[],Q=!1;for(let t=e.reader.peekSignificant();t!==void 0;t=e.reader.peekSignificant()){e.reader.takeSignificant();let s=C(t.content);if(s===`command`&&/^command\s+reads(?:\s|$)/.test(t.content))E||!u(n)||!/^command\s+reads\s+protected$/.test(t.content)?e.error(o.InvalidCommandReadsDeclaration,`Declare 'command reads protected' once at the application root.`,j(t)):S=`Protected`,E=!0;else if(s===`time`&&/^time\s+zone(?:\s|$)/.test(t.content)){let r=P.exec(t.content);e.skipBlock(t.indent),T||!u(n)||r===null?e.error(o.InvalidTimeZoneDeclaration,`Declare 'time zone "<id>"' or 'time zone configurable default "<id>"' once at the application root.`,j(t)):w={kind:`TimeZoneSyntax`,id:k(r[2]),configurable:r[1]!==void 0,location:j(t)},T=!0}else if(s===`reaction`)y||!u(n)||!/^reaction\s+batches\s+atomic$/.test(t.content)?e.error(o.InvalidReactionBatchesDeclaration,`Declare 'reaction batches atomic' once at the application root.`,j(t)):_=`Atomic`,y=!0;else if(s===`runs`)a(e,t);else if(s===`domain`)e.authoredDeclarations=!0,O=parseDomain(e,t,O,Q);else if(Q||=declaresConstruct(s,t,n),e.authoredDeclarations||=s!==`import`&&declaresConstruct(s,t,n),s===`import`&&b(t.content))p===void 0?x(e,t,M):p.tryParse(e,t);else if(s===`import`){let n=F.exec(t.content);if(n===null)e.error(o.InvalidImportDeclaration,`Invalid import '${t.content}' - expected 'import <Qualified.Name> [from "<origin>"]'`,j(t));else{let r=n.groups?.origin===void 0?null:k(n.groups.origin);r!==null&&ce(r)&&e.error(o.InvalidImportDeclaration,`An import origin must be a nonblank quoted string`,j(t)),A.push({kind:`ImportSyntax`,qualifiedName:n[1],origin:r,visibility:r===null?`Private`:`Public`,location:j(t)})}}else if(s===`example`)p===void 0?J.push(fe(e,t)):p.tryParse(e,t);else if(s===`eventsource`)B.push(le(e,t));else if(s===`system`)L.push(D(e,t));else if(s===`statemachine`)R.push(oe(e,t));else if(s===`workflow`)z.push(se(e,t));else if(s===`concept`)N.push(parseConcept(e,t));else if(s===`type`)I.push(h(e,t));else if(s===`module`&&!u(n))parseModuleInPlacedFile(e,t,n,c);else if(s===`module`)V.push(ne(e,t));else if(s===`persona`)H.push(parsePersona(e,t));else if(s===`sticky`){let n=parseStickyNote(e,t);n!==null&&U.push(n)}else if(s===`seed`)q.push(ae(e.valueContext,t));else if(s===`purpose`&&p!==void 0)p.tryParse(e,t);else if(s===`purpose`)K.push(ie(e,t));else if(s===`context`)g=i(e,t,g,n);else if(s===`identity`)m=r(e,t,m);else if(s===`policy`){let n=re(e,t);W.some(e=>e.name===n.name)&&e.error(o.DuplicateDeclaration,`Duplicate declaration of policy '${n.name}' - policy names must be unique`,n.location),W.push(n)}else if(s===`exposure`)X.push(ue(e,t));else if(s===`instance`)Z.push(de(e,t));else if(s===`trigger`){let n=d(e,t),r=/^trigger\s+([A-Za-z_]\w*)$/.exec(t.content)?.[1];r!==void 0&&Y.push({name:r,data:n})}else G.has(s)?s===`behavior`||s===`layout`?ee(e,t):s===`ui`?pe(e,t):e.skipOpaqueBlock(t.indent):p?.tryParse(e,t)!==!0&&reportUnexpectedTopLevel(e,t,n)}c===void 0?f!==void 0&&V.unshift(place(n,f.build(e.start,!0),e.start)):V.unshift(c.build(e.start,!0));let $={kind:`ApplicationSyntax`,...S===null?{}:{commandReadMode:S},...w===null?{}:{timeZone:w},...g===null?{}:{context:g},..._===null?{}:{reactionProductionMode:_},...m===null?{}:{identity:m},sourceOptions:e.sourceOptions,domain:O,imports:A,concepts:N,types:I,systems:L,...R.length>0?{stateMachines:R}:{},...z.length>0?{workflows:z}:{},eventSources:B,examples:J,modules:V,personas:H,policies:W,purposes:K,seeds:q,declaredTriggers:Y,fileImports:M,...X.length>0?{exposures:X}:{},...U.length>0?{stickyNotes:U}:{},...Z.length>0?{instanceContributions:Z}:{},location:e.start};return e.authoredDeclarations&&s($),$}function declaresConstruct(e,t,n){return e===`import`?F.test(t.content):e===`module`?u(n):e===`identity`?t.content===`identity`:e===`context`?t.content===`context`:e===`purpose`||e===`example`||e===`exposure`||e===`instance`||e===`eventsource`||e===`system`||e===`statemachine`||e===`workflow`||e===`concept`||e===`type`||e===`persona`||e===`sticky`||G.has(e)}function parseModuleInPlacedFile(e,t,n,r){let i=E.exec(t.content)?.[1]??``;r!==void 0&&i===n[0]?(e.authoredDeclarations=!0,r.parseChildren(e,t)):(e.error(o.ModuleInPlacedFile,`This file is imported into ${c(n)}, so it cannot declare module '${i}' - import it at the top level of a document instead`,j(t)),e.skipBlock(t.indent))}function reportUnexpectedTopLevel(e,t,n){let r=C(t.content);if(u(n)){let n=K.has(r)?` - '${r}' belongs in a module or feature; wrap it in one, or import this file from inside one`:` - expected domain, import, concept, type, policy, persona, sticky note, authentication, onboarding, identity, context, module, seed, trigger, behavior, ui profile, theme, sample data or layout`;e.error(o.UnknownTopLevelConstruct,`Unexpected '${r}' at the top level${n}`,j(t))}else{let i=n.length===1?T:y;e.error(o.UnexpectedInPlacedFile,`Unexpected '${r}' in a file imported into ${c(n)} - expected an application declaration or ${i}`,j(t))}e.skipBlock(t.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(e,t,n,r){let i=N.exec(t.content);return i===null?(e.error(o.InvalidDomainDeclaration,`Invalid domain declaration '${t.content}' - expected 'domain <Qualified.Name>'`,j(t)),n):n===null?(r&&e.error(o.DomainNotFirst,`'domain' must be declared before any other construct`,j(t)),{kind:`DomainSyntax`,name:i[1],location:j(t)}):(e.error(o.DuplicateDomain,`The document already declares a domain - a document can have at most one`,j(t)),n)}function warnOnTabIndentation(e,t){let n=!1;for(let r of t)r.raw.trimStart().startsWith("```")?n=!n:!n&&U.test(r.raw)&&e.warning(o.TabIndentation,`Screenplay is indentation based - use spaces, not tabs`,M(r))}function parseConcept(r,i){let a=I.exec(i.content);if(a===null)return r.error(o.InvalidConceptDeclaration,`Invalid concept declaration '${i.content}' - expected 'concept <Name> : <Type>'`,j(i)),r.skipBlock(i.indent),{kind:`ConceptSyntax`,name:C(i.content),type:``,attributes:[],values:[],location:j(i)};let[,s,c,l]=a,u=m(r,i,s,l);c!==`Enum`&&!W.includes(c)&&r.error(o.UnknownPrimitiveType,`Unknown primitive type '${c}' - expected ${W.join(`, `)} or Enum`,j(i));let d=[],f=new e,h=null,v=!1,y=null,b=[];for(let e=r.peekChild(i.indent);e!==void 0;e=r.peekChild(i.indent)){r.reader.takeSignificant();let i=c===`Enum`?f.tryNumbered(r,e):void 0;if(i!==void 0)d.push(i);else if(C(e.content)===`description`&&(c!==`Enum`||e.content!==`description`||r.peekChild(e.indent)?.content.startsWith("```")===!0))y=_(r,e,y,`Concept '${s}'`);else if(S(e))continue;else if(C(e.content)===`validate`){c===`Enum`&&e.content===`validate`&&r.peekChild(e.indent)===void 0&&r.warning(o.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${s}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,j(e));let t=g(r,e,`concept`,s);t!==void 0&&b.push(t)}else if(C(e.content)===`generate`&&(c!==`Enum`||e.content!==`generate`)){v&&r.error(o.DuplicateGeneration,`Concept '${s}' declares generation more than once.`,j(e));let t=n(r,e,c);v||(h=t),v=!0}else p(r,e,s,u)||(c===`Enum`&&L.test(e.content)?d.push(w(e.content)):c===`Enum`?r.error(o.InvalidEnumerationValue,`Invalid enum value '${e.content}' - expected an identifier`,j(e)):(r.error(o.UnknownConceptDirective,`Unexpected '${e.content}' in concept body - expected validate, generate, 'file <path>' or '<attribute> reason "<text>"'${t(e.content)}`,j(e)),r.skipBlock(e.indent)))}let x=f.finish(r,i,d.length);return{kind:`ConceptSyntax`,name:s,type:c,attributes:u,values:d,validations:b,description:y,...h===null?{}:{generation:h},...x===void 0?{}:{valueNumbers:x},location:j(i)}}function parsePersona(e,t){let n=R.exec(t.content)?.[1]??``;n===``&&e.error(o.InvalidPersonaDeclaration,`Invalid persona declaration '${t.content}' - expected 'persona <Name>'`,j(t));let r=null,i=[],a=[],s=null,c=null;for(let l=e.peekChild(t.indent);l!==void 0;l=e.peekChild(t.indent)){e.reader.takeSignificant();let t=C(l.content);if(t===`description`)r=_(e,l,r,`Persona '${n}'`);else if(t===`goal`){let t=B.exec(l.content);t===null?e.error(o.InvalidPersonaDeclaration,`Invalid goal '${l.content}' - expected 'goal "<text>"'`,j(l)):a.push(k(t[1]))}else if(t===`position`)s=A(e,l,`position`,`x`,`y`,s,!0)??s;else if(t===`size`)c=A(e,l,`size`,`width`,`height`,c,!1)??c;else if(t===`policy`){let t=z.exec(l.content);t===null?e.error(o.InvalidPersonaPolicyReference,`Invalid policy reference '${l.content}' - expected 'policy <Name>'`,j(l)):i.push(t[1])}else e.error(o.UnknownPersonaDirective,`Unexpected '${t}' in persona body - expected description, goal, policy, position or size`,j(l)),e.skipBlock(l.indent)}return{kind:`PersonaSyntax`,name:n,description:r,policies:i,...a.length>0?{goals:a}:{},...s===null?{}:{x:s[0],y:s[1]},...c===null?{}:{width:c[0],height:c[1]},location:j(t)}}function parseStickyNote(e,t){let n=V.exec(t.content);if(n===null)return e.error(o.InvalidPersonaDeclaration,`Invalid sticky note declaration '${t.content}' - expected 'sticky note on personas', 'sticky note on eventsources', 'sticky note on givencontexts' or 'sticky note on seeddata'`,j(t)),e.skipBlock(t.indent),null;let r=null,i=null,a=null,s=null;for(let n=e.peekChild(t.indent);n!==void 0;n=e.peekChild(t.indent)){e.reader.takeSignificant();let t=C(n.content);if(t===`description`)r=_(e,n,r,`A sticky note`);else if(t===`colour`){let t=H.exec(n.content);t===null?e.error(o.InvalidPersonaDeclaration,`Invalid colour '${n.content}' - expected 'colour yellow', 'colour pink', 'colour green' or 'colour blue'`,j(n)):i=t[1]}else t===`position`?a=A(e,n,`position`,`x`,`y`,a,!0)??a:t===`size`?s=A(e,n,`size`,`width`,`height`,s,!1)??s:(e.error(o.UnknownPersonaDirective,`Unexpected '${t}' in sticky note body - expected description, colour, position or size`,j(n)),e.skipBlock(n.indent))}return r===null||a===null?(e.error(o.InvalidPersonaDeclaration,`A sticky note needs a description (the text on it) and a position`,j(t)),null):{kind:`StickyNoteSyntax`,canvas:n[1],text:r,colour:i,x:a[0],y:a[1],width:s===null?null:s[0],height:s===null?null:s[1],location:j(t)}}export{parseApplication};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{EnumerationMembers as e}from"./EnumerationMembers.js";import{misplacedRuleHintForConcept as t}from"./MisplacedRuleHint.js";import{parseGeneration as n}from"./GenerationParser.js";import{parseIdentity as r}from"./IdentityParser.js";import{parseApplicationContext as i}from"./ApplicationContextParser.js";import{misplacedReactionIdentity as a}from"./ReactionIdentityParser.js";import{DiagnosticCodes as o}from"../Diagnostics/DiagnosticCodes.js";import{recordAuthoredDocument as s}from"../Syntax/SourceOptions.js";import{describePlacement as c,documentPlacement as l,isDocumentPlacement as u}from"../Files/PlayPlacement.js";import{parseTriggerDeclaration as d}from"./TriggerDataParser.js";import{pattern as f}from"../Text/patterns.js";import{parseComplianceDirective as p,parseComplianceMarkers as m}from"./ConceptComplianceParser.js";import{parseType as h}from"./DeclarationParsers.js";import{parseValidate as g}from"./CommandParser.js";import{parseDescription as _}from"./DescriptionParser.js";import{FeatureBody as v,featureBodyExpected as y}from"./FeatureBody.js";import{isFileImport as b,parseFileImport as x}from"./FileImportParser.js";import{isFileDirective as S}from"./FileReferences.js";import{collectInputUses as C}from"./InputUses.js";import{firstWord as w,unescapeIdentifier as T}from"./LineText.js";import{ModuleBody as E,moduleBodyExpected as D,modulePattern as O,parseModule as k}from"./ModuleBody.js";import{parsePolicy as A}from"./PolicyParser.js";import{parsePurpose as ee}from"./PurposeParser.js";import{parseSeed as te}from"./SeedParser.js";import{parseSystem as j}from"./OperationParser.js";import{parseStateMachine as M}from"./StateMachineParser.js";import{parseWorkflow as N}from"./WorkflowParser.js";import{isBlankPublicEventOrigin as ne}from"../Syntax/PublicEventInvariants.js";import{stringBodyPattern as P,unescapeString as F}from"../Text/StringLiteral.js";import{parseCanvasPair as I}from"./CanvasPlacement.js";import{parseEventSource as L}from"./EventSourceParser.js";import{parseExposure as R,parseInstance as z}from"./CompositionParser.js";import{parseExample as B}from"./SpecificationExampleParser.js";import{parseUiProfile as V}from"./UiProfileLegacyLayout.js";import{locationOf as H,startOf as U}from"./SourceLine.js";const W=f(`^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`),G=f(`^time\\s+zone\\s+(configurable\\s+default\\s+)?"(${P})"$`),K=f(`^import\\s+([\\w.]+)(?:\\s+from\\s+"(?<origin>${P})")?$`),q=f(`^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$`),J=f(`^@?[a-z_]\\w*$`),Y=f(`^persona\\s+([A-Za-z_]\\w*)$`),X=f(`^policy\\s+([A-Za-z_]\\w*)$`),Z=f(`^goal\\s+"(${P})"$`),re=f(`^sticky\\s+note\\s+on\\s+(personas|eventsources|givencontexts|seeddata)$`),ie=f(`^colour\\s+(yellow|pink|green|blue)$`),ae=/^[ ]*\t/,Q=[`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`],$=/* @__PURE__ */ new Set([`policy`,`authentication`,`onboarding`,`seed`,`ui`,`theme`,`trigger`,`layout`,`behavior`,`sample`]),oe=/* @__PURE__ */ new Set([`slice`,`feature`,`description`,`documentation`,`authorize`,`screen`,`dialog`,`form`,`contribute`,`on`,`uses`]);function parseApplication(e,t,n=l){e.deferIdentityValidation=!0,warnOnTabIndentation(e,t);let r=createRootState(n);for(let t=e.reader.peekSignificant();t!==void 0;t=e.reader.peekSignificant())e.reader.takeSignificant(),dispatchRoot(e,t,r);return buildApplication(e,r)}function createRootState(e){let t=e.length===1?new E(e[0]):void 0,n=e.length>1?new v(e[e.length-1]):void 0;return{placement:e,moduleBody:t,featureBody:n,placedBody:t??n,identity:null,applicationContext:null,reactionProductionMode:null,sawReactionBatches:!1,commandReadMode:null,timeZone:null,sawTimeZone:!1,sawCommandReads:!1,domain:null,sawOtherConstruct:!1,imports:[],fileImports:[],concepts:[],types:[],systems:[],stateMachines:[],workflows:[],eventSources:[],modules:[],personas:[],stickyNotes:[],policies:[],purposes:[],seeds:[],examples:[],declaredTriggers:[],exposures:[],instanceContributions:[]}}const isKeyword=e=>t=>t===e,se=[{matches:(e,t)=>e===`command`&&/^command\s+reads(?:\s|$)/.test(t.content),parse:parseRootCommandReads},{matches:(e,t)=>e===`time`&&/^time\s+zone(?:\s|$)/.test(t.content),parse:parseRootTimeZone},{matches:isKeyword(`reaction`),parse:parseRootReactionBatches},{matches:isKeyword(`runs`),parse:(e,t)=>{a(e,t)}},{matches:isKeyword(`domain`),parse:parseRootDomain}],ce=[{matches:(e,t)=>e===`import`&&b(t.content),parse:parseRootFileImport},{matches:isKeyword(`import`),parse:parseRootImport},{matches:isKeyword(`example`),parse:parseRootExample},{matches:isKeyword(`eventsource`),parse:(e,t,n)=>{n.eventSources.push(L(e,t))}},{matches:isKeyword(`system`),parse:(e,t,n)=>{n.systems.push(j(e,t))}},{matches:isKeyword(`statemachine`),parse:(e,t,n)=>{n.stateMachines.push(M(e,t))}},{matches:isKeyword(`workflow`),parse:(e,t,n)=>{n.workflows.push(N(e,t))}},{matches:isKeyword(`concept`),parse:(e,t,n)=>{n.concepts.push(parseConcept(e,t))}},{matches:isKeyword(`type`),parse:(e,t,n)=>{n.types.push(h(e,t))}},{matches:(e,t,n)=>e===`module`&&!u(n.placement),parse:(e,t,n)=>parseModuleInPlacedFile(e,t,n.placement,n.moduleBody)},{matches:isKeyword(`module`),parse:(e,t,n)=>{n.modules.push(k(e,t))}},{matches:isKeyword(`persona`),parse:(e,t,n)=>{n.personas.push(parsePersona(e,t))}},{matches:isKeyword(`sticky`),parse:parseRootStickyNote},{matches:isKeyword(`seed`),parse:(e,t,n)=>{n.seeds.push(te(e.valueContext,t))}},{matches:(e,t,n)=>e===`purpose`&&n.placedBody!==void 0,parse:(e,t,n)=>{n.placedBody?.tryParse(e,t)}},{matches:isKeyword(`purpose`),parse:(e,t,n)=>{n.purposes.push(ee(e,t))}},{matches:isKeyword(`context`),parse:(e,t,n)=>{n.applicationContext=i(e,t,n.applicationContext,n.placement)}},{matches:isKeyword(`identity`),parse:(e,t,n)=>{n.identity=r(e,t,n.identity)}},{matches:isKeyword(`policy`),parse:parseRootPolicy},{matches:isKeyword(`exposure`),parse:(e,t,n)=>{n.exposures.push(R(e,t))}},{matches:isKeyword(`instance`),parse:(e,t,n)=>{n.instanceContributions.push(z(e,t))}},{matches:isKeyword(`trigger`),parse:parseRootTrigger},{matches:e=>$.has(e),parse:parseRootOpaque}];function dispatchRoot(e,t,n){let r=w(t.content),i=se.find(e=>e.matches(r,t,n));if(i!==void 0){i.parse(e,t,n);return}n.sawOtherConstruct||=declaresConstruct(r,t,n.placement),e.authoredDeclarations||=r!==`import`&&declaresConstruct(r,t,n.placement);let a=ce.find(e=>e.matches(r,t,n));a===void 0?n.placedBody?.tryParse(e,t)!==!0&&reportUnexpectedTopLevel(e,t,n.placement):a.parse(e,t,n)}function isRepeatedOrMisplaced(e,t){return e||!u(t.placement)}function parseRootCommandReads(e,t,n){isRepeatedOrMisplaced(n.sawCommandReads,n)||!/^command\s+reads\s+protected$/.test(t.content)?e.error(o.InvalidCommandReadsDeclaration,`Declare 'command reads protected' once at the application root.`,H(t)):n.commandReadMode=`Protected`,n.sawCommandReads=!0}function parseRootTimeZone(e,t,n){let r=G.exec(t.content);e.skipBlock(t.indent),isRepeatedOrMisplaced(n.sawTimeZone,n)||r===null?e.error(o.InvalidTimeZoneDeclaration,`Declare 'time zone "<id>"' or 'time zone configurable default "<id>"' once at the application root.`,H(t)):n.timeZone={kind:`TimeZoneSyntax`,id:F(r[2]),configurable:r[1]!==void 0,location:H(t)},n.sawTimeZone=!0}function parseRootReactionBatches(e,t,n){isRepeatedOrMisplaced(n.sawReactionBatches,n)||!/^reaction\s+batches\s+atomic$/.test(t.content)?e.error(o.InvalidReactionBatchesDeclaration,`Declare 'reaction batches atomic' once at the application root.`,H(t)):n.reactionProductionMode=`Atomic`,n.sawReactionBatches=!0}function parseRootDomain(e,t,n){e.authoredDeclarations=!0,n.domain=parseDomain(e,t,n.domain,n.sawOtherConstruct)}function parseRootFileImport(e,t,n){n.placedBody===void 0?x(e,t,n.fileImports):n.placedBody.tryParse(e,t)}function parseRootImport(e,t,n){let r=K.exec(t.content);if(r===null){e.error(o.InvalidImportDeclaration,`Invalid import '${t.content}' - expected 'import <Qualified.Name> [from "<origin>"]'`,H(t));return}let i=r.groups?.origin===void 0?null:F(r.groups.origin);i!==null&&ne(i)&&e.error(o.InvalidImportDeclaration,`An import origin must be a nonblank quoted string`,H(t)),n.imports.push({kind:`ImportSyntax`,qualifiedName:r[1],origin:i,visibility:i===null?`Private`:`Public`,location:H(t)})}function parseRootExample(e,t,n){n.placedBody===void 0?n.examples.push(B(e,t)):n.placedBody.tryParse(e,t)}function parseRootStickyNote(e,t,n){let r=parseStickyNote(e,t);r!==null&&n.stickyNotes.push(r)}function parseRootPolicy(e,t,n){let r=A(e,t);n.policies.some(e=>e.name===r.name)&&e.error(o.DuplicateDeclaration,`Duplicate declaration of policy '${r.name}' - policy names must be unique`,r.location),n.policies.push(r)}function parseRootTrigger(e,t,n){let r=d(e,t),i=/^trigger\s+([A-Za-z_]\w*)$/.exec(t.content)?.[1];i!==void 0&&n.declaredTriggers.push({name:i,data:r})}function parseRootOpaque(e,t){let n=w(t.content);n===`behavior`||n===`layout`?C(e,t):n===`ui`?V(e,t):e.skipOpaqueBlock(t.indent)}function presentOnly(e,t){return t===null?{}:{[e]:t}}function nonEmptyOnly(e,t){return t.length>0?{[e]:t}:{}}function buildApplication(e,t){let{placement:n,moduleBody:r,featureBody:i,modules:a}=t;r===void 0?i!==void 0&&a.unshift(place(n,i.build(e.start,!0),e.start)):a.unshift(r.build(e.start,!0));let{commandReadMode:o,timeZone:c,applicationContext:l,reactionProductionMode:u,identity:d,domain:f,imports:p,concepts:m,types:h,systems:g,stateMachines:_,workflows:v,eventSources:y,examples:b,personas:x,policies:S,purposes:C,seeds:w,declaredTriggers:T,fileImports:E,exposures:D,stickyNotes:O,instanceContributions:k}=t,A={kind:`ApplicationSyntax`,...presentOnly(`commandReadMode`,o),...presentOnly(`timeZone`,c),...presentOnly(`context`,l),...presentOnly(`reactionProductionMode`,u),...presentOnly(`identity`,d),sourceOptions:e.sourceOptions,domain:f,imports:p,concepts:m,types:h,systems:g,...nonEmptyOnly(`stateMachines`,_),...nonEmptyOnly(`workflows`,v),eventSources:y,examples:b,modules:a,personas:x,policies:S,purposes:C,seeds:w,declaredTriggers:T,fileImports:E,...nonEmptyOnly(`exposures`,D),...nonEmptyOnly(`stickyNotes`,O),...nonEmptyOnly(`instanceContributions`,k),location:e.start};return e.authoredDeclarations&&s(A),A}function declaresConstruct(e,t,n){return e===`import`?K.test(t.content):e===`module`?u(n):e===`identity`?t.content===`identity`:e===`context`?t.content===`context`:e===`purpose`||e===`example`||e===`exposure`||e===`instance`||e===`eventsource`||e===`system`||e===`statemachine`||e===`workflow`||e===`concept`||e===`type`||e===`persona`||e===`sticky`||$.has(e)}function parseModuleInPlacedFile(e,t,n,r){let i=O.exec(t.content)?.[1]??``;r!==void 0&&i===n[0]?(e.authoredDeclarations=!0,r.parseChildren(e,t)):(e.error(o.ModuleInPlacedFile,`This file is imported into ${c(n)}, so it cannot declare module '${i}' - import it at the top level of a document instead`,H(t)),e.skipBlock(t.indent))}function reportUnexpectedTopLevel(e,t,n){let r=w(t.content);if(u(n)){let n=oe.has(r)?` - '${r}' belongs in a module or feature; wrap it in one, or import this file from inside one`:` - expected domain, import, concept, type, policy, persona, sticky note, authentication, onboarding, identity, context, module, seed, trigger, behavior, ui profile, theme, sample data or layout`;e.error(o.UnknownTopLevelConstruct,`Unexpected '${r}' at the top level${n}`,H(t))}else{let i=n.length===1?D:y;e.error(o.UnexpectedInPlacedFile,`Unexpected '${r}' in a file imported into ${c(n)} - expected an application declaration or ${i}`,H(t))}e.skipBlock(t.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(e,t,n,r){let i=W.exec(t.content);return i===null?(e.error(o.InvalidDomainDeclaration,`Invalid domain declaration '${t.content}' - expected 'domain <Qualified.Name>'`,H(t)),n):n===null?(r&&e.error(o.DomainNotFirst,`'domain' must be declared before any other construct`,H(t)),{kind:`DomainSyntax`,name:i[1],location:H(t)}):(e.error(o.DuplicateDomain,`The document already declares a domain - a document can have at most one`,H(t)),n)}function warnOnTabIndentation(e,t){let n=!1;for(let r of t)r.raw.trimStart().startsWith("```")?n=!n:!n&&ae.test(r.raw)&&e.warning(o.TabIndentation,`Screenplay is indentation based - use spaces, not tabs`,U(r))}function parseConcept(r,i){let a=q.exec(i.content);if(a===null)return r.error(o.InvalidConceptDeclaration,`Invalid concept declaration '${i.content}' - expected 'concept <Name> : <Type>'`,H(i)),r.skipBlock(i.indent),{kind:`ConceptSyntax`,name:w(i.content),type:``,attributes:[],values:[],location:H(i)};let[,s,c,l]=a,u=m(r,i,s,l);c!==`Enum`&&!Q.includes(c)&&r.error(o.UnknownPrimitiveType,`Unknown primitive type '${c}' - expected ${Q.join(`, `)} or Enum`,H(i));let d=[],f=new e,h=null,v=!1,y=null,b=[];for(let e=r.peekChild(i.indent);e!==void 0;e=r.peekChild(i.indent)){r.reader.takeSignificant();let i=c===`Enum`?f.tryNumbered(r,e):void 0;if(i!==void 0)d.push(i);else if(w(e.content)===`description`&&(c!==`Enum`||e.content!==`description`||r.peekChild(e.indent)?.content.startsWith("```")===!0))y=_(r,e,y,`Concept '${s}'`);else if(S(e))continue;else if(w(e.content)===`validate`){c===`Enum`&&e.content===`validate`&&r.peekChild(e.indent)===void 0&&r.warning(o.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${s}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,H(e));let t=g(r,e,`concept`,s);t!==void 0&&b.push(t)}else if(w(e.content)===`generate`&&(c!==`Enum`||e.content!==`generate`)){v&&r.error(o.DuplicateGeneration,`Concept '${s}' declares generation more than once.`,H(e));let t=n(r,e,c);v||(h=t),v=!0}else p(r,e,s,u)||(c===`Enum`&&J.test(e.content)?d.push(T(e.content)):c===`Enum`?r.error(o.InvalidEnumerationValue,`Invalid enum value '${e.content}' - expected an identifier`,H(e)):(r.error(o.UnknownConceptDirective,`Unexpected '${e.content}' in concept body - expected validate, generate, 'file <path>' or '<attribute> reason "<text>"'${t(e.content)}`,H(e)),r.skipBlock(e.indent)))}let x=f.finish(r,i,d.length);return{kind:`ConceptSyntax`,name:s,type:c,attributes:u,values:d,validations:b,description:y,...h===null?{}:{generation:h},...x===void 0?{}:{valueNumbers:x},location:H(i)}}function parsePersona(e,t){let n=Y.exec(t.content)?.[1]??``;n===``&&e.error(o.InvalidPersonaDeclaration,`Invalid persona declaration '${t.content}' - expected 'persona <Name>'`,H(t));let r=null,i=[],a=[],s=null,c=null;for(let l=e.peekChild(t.indent);l!==void 0;l=e.peekChild(t.indent)){e.reader.takeSignificant();let t=w(l.content);if(t===`description`)r=_(e,l,r,`Persona '${n}'`);else if(t===`goal`){let t=Z.exec(l.content);t===null?e.error(o.InvalidPersonaDeclaration,`Invalid goal '${l.content}' - expected 'goal "<text>"'`,H(l)):a.push(F(t[1]))}else if(t===`position`)s=I(e,l,`position`,`x`,`y`,s,!0)??s;else if(t===`size`)c=I(e,l,`size`,`width`,`height`,c,!1)??c;else if(t===`policy`){let t=X.exec(l.content);t===null?e.error(o.InvalidPersonaPolicyReference,`Invalid policy reference '${l.content}' - expected 'policy <Name>'`,H(l)):i.push(t[1])}else e.error(o.UnknownPersonaDirective,`Unexpected '${t}' in persona body - expected description, goal, policy, position or size`,H(l)),e.skipBlock(l.indent)}return{kind:`PersonaSyntax`,name:n,description:r,policies:i,...a.length>0?{goals:a}:{},...s===null?{}:{x:s[0],y:s[1]},...c===null?{}:{width:c[0],height:c[1]},location:H(t)}}function parseStickyNote(e,t){let n=re.exec(t.content);if(n===null)return e.error(o.InvalidPersonaDeclaration,`Invalid sticky note declaration '${t.content}' - expected 'sticky note on personas', 'sticky note on eventsources', 'sticky note on givencontexts' or 'sticky note on seeddata'`,H(t)),e.skipBlock(t.indent),null;let r=null,i=null,a=null,s=null;for(let n=e.peekChild(t.indent);n!==void 0;n=e.peekChild(t.indent)){e.reader.takeSignificant();let t=w(n.content);if(t===`description`)r=_(e,n,r,`A sticky note`);else if(t===`colour`){let t=ie.exec(n.content);t===null?e.error(o.InvalidPersonaDeclaration,`Invalid colour '${n.content}' - expected 'colour yellow', 'colour pink', 'colour green' or 'colour blue'`,H(n)):i=t[1]}else t===`position`?a=I(e,n,`position`,`x`,`y`,a,!0)??a:t===`size`?s=I(e,n,`size`,`width`,`height`,s,!1)??s:(e.error(o.UnknownPersonaDirective,`Unexpected '${t}' in sticky note body - expected description, colour, position or size`,H(n)),e.skipBlock(n.indent))}return r===null||a===null?(e.error(o.InvalidPersonaDeclaration,`A sticky note needs a description (the text on it) and a position`,H(t)),null):{kind:`StickyNoteSyntax`,canvas:n[1],text:r,colour:i,x:a[0],y:a[1],width:s===null?null:s[0],height:s===null?null:s[1],location:H(t)}}export{parseApplication};
2
2
  //# sourceMappingURL=ScreenplayParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScreenplayParser.js","names":["domainPattern","pattern","timeZonePattern","stringBodyPattern","importPattern","conceptPattern","enumValuePattern","personaPattern","personaPolicyPattern","personaGoalPattern","stickyNotePattern","stickyNoteColourPattern","tabIndentPattern","primitiveTypes","opaqueTopLevel","bodyKeywords","documentPlacement","context","lines","moduleBody","placement","ModuleBody","featureBody","FeatureBody","placedBody","identity","applicationContext","reactionProductionMode","sawReactionBatches","commandReadMode","timeZone","sawTimeZone","sawCommandReads","domain","imports","fileImports","concepts","types","systems","stateMachines","workflows","eventSources","modules","personas","stickyNotes","policies","purposes","seeds","examples","declaredTriggers","exposures","instanceContributions","sawOtherConstruct","line","keyword","firstWord","isDocumentPlacement","DiagnosticCodes","locationOf","match","unescapeString","misplacedReactionIdentity","isFileImport","parseFileImport","origin","isBlankPublicEventOrigin","parseExample","parseEventSource","parseSystem","parseStateMachine","parseWorkflow","parseType","parseModule","stickyNote","parseSeed","parsePurpose","parseApplicationContext","parseIdentity","policy","parsePolicy","previous","parseExposure","parseInstance","data","parseTriggerDeclaration","name","collectInputUses","parseUiProfile","root","recordAuthoredDocument","modulePattern","describePlacement","word","hint","expected","moduleBodyExpected","featureBodyExpected","feature","innermost","index","start","existing","inFence","startOf","type","attributeText","attributes","parseComplianceMarkers","values","members","EnumerationMembers","generation","declaredGeneration","description","validations","child","memberName","parseDescription","isFileDirective","parsed","parseValidate","parseGeneration","parseComplianceDirective","unescapeIdentifier","misplacedRuleHintForConcept","valueNumbers","goals","position","size","goal","parseCanvasPair","canvasMatch","text","colour"],"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 { CommandReadMode } from '../Syntax/CommandReadMode';\nimport { ReactionProductionMode } from '../Syntax/ReactionProductionMode';\nimport { EnumerationMembers } from './EnumerationMembers';\nimport { GenerationSyntax } from '../Syntax/GenerationSyntax';\nimport { misplacedRuleHintForConcept } from './MisplacedRuleHint';\nimport { parseGeneration } from './GenerationParser';\nimport { IdentitySyntax } from '../Syntax/IdentitySyntax';\nimport { parseIdentity } from './IdentityParser';\nimport { parseApplicationContext } from './ApplicationContextParser';\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, StickyNoteSyntax } from '../Syntax/Authorization';\nimport { ConceptSyntax, DomainSyntax, ImportSyntax, TypeSyntax } from '../Syntax/Declarations';\nimport { SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { TimeZoneSyntax } from '../Syntax/Calendar';\nimport { ApplicationContextSyntax, 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 { parseStateMachine } from './StateMachineParser';\nimport { parseWorkflow } from './WorkflowParser';\nimport { StateMachineSyntax, WorkflowSyntax } from '../Syntax/Lifecycles';\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 { parseCanvasPair } from './CanvasPlacement';\nimport { parseEventSource } from './EventSourceParser';\nimport { parseExposure, parseInstance } from './CompositionParser';\nimport { ExposureSyntax, InstanceContributionsSyntax } from '../Syntax/CompositionSyntax';\nimport { parseExample } from './SpecificationExampleParser';\nimport { parseUiProfile } from './UiProfileLegacyLayout';\nimport { locationOf, SourceLine, startOf } from './SourceLine';\n\nconst domainPattern = pattern('^domain\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)$');\nconst timeZonePattern = pattern(`^time\\\\s+zone\\\\s+(configurable\\\\s+default\\\\s+)?\"(${stringBodyPattern})\"$`);\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 personaGoalPattern = pattern(`^goal\\\\s+\"(${stringBodyPattern})\"$`);\nconst stickyNotePattern = pattern('^sticky\\\\s+note\\\\s+on\\\\s+(personas|eventsources|givencontexts|seeddata)$');\nconst stickyNoteColourPattern = pattern('^colour\\\\s+(yellow|pink|green|blue)$');\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', 'onboarding', 'seed', 'ui', 'theme', 'trigger', 'layout', 'behavior', 'sample']);\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 applicationContext: ApplicationContextSyntax | null = null;\n let reactionProductionMode: ReactionProductionMode | null = null;\n let sawReactionBatches = false;\n let commandReadMode: CommandReadMode | null = null;\n let timeZone: TimeZoneSyntax | null = null;\n let sawTimeZone = false;\n let sawCommandReads = false;\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 stateMachines: StateMachineSyntax[] = [];\n const workflows: WorkflowSyntax[] = [];\n const eventSources: EventSourceSyntax[] = [];\n const modules: ModuleSyntax[] = [];\n const personas: PersonaSyntax[] = [];\n const stickyNotes: StickyNoteSyntax[] = [];\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 === 'command' && /^command\\s+reads(?:\\s|$)/.test(line.content)) {\n if (sawCommandReads || !isDocumentPlacement(placement) || !/^command\\s+reads\\s+protected$/.test(line.content)) {\n context.error(DiagnosticCodes.InvalidCommandReadsDeclaration, \"Declare 'command reads protected' once at the application root.\", locationOf(line));\n } else {\n commandReadMode = CommandReadMode.Protected;\n }\n sawCommandReads = true;\n continue;\n }\n if (keyword === 'time' && /^time\\s+zone(?:\\s|$)/.test(line.content)) {\n const match = timeZonePattern.exec(line.content);\n context.skipBlock(line.indent);\n if (sawTimeZone || !isDocumentPlacement(placement) || match === null) {\n context.error(DiagnosticCodes.InvalidTimeZoneDeclaration, \"Declare 'time zone \\\"<id>\\\"' or 'time zone configurable default \\\"<id>\\\"' once at the application root.\", locationOf(line));\n } else {\n timeZone = { kind: 'TimeZoneSyntax', id: unescapeString(match[2]), configurable: match[1] !== undefined, location: locationOf(line) };\n }\n sawTimeZone = true;\n continue;\n }\n if (keyword === 'reaction') {\n if (sawReactionBatches || !isDocumentPlacement(placement) || !/^reaction\\s+batches\\s+atomic$/.test(line.content)) {\n context.error(DiagnosticCodes.InvalidReactionBatchesDeclaration, \"Declare 'reaction batches atomic' once at the application root.\", locationOf(line));\n } else {\n reactionProductionMode = ReactionProductionMode.Atomic;\n }\n sawReactionBatches = true;\n continue;\n }\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 === 'statemachine') {\n stateMachines.push(parseStateMachine(context, line));\n } else if (keyword === 'workflow') {\n workflows.push(parseWorkflow(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 === 'sticky') {\n const stickyNote = parseStickyNote(context, line);\n if (stickyNote !== null) stickyNotes.push(stickyNote);\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 === 'context') {\n applicationContext = parseApplicationContext(context, line, applicationContext, placement);\n } else if (keyword === 'identity') {\n identity = parseIdentity(context, line, identity);\n } else if (keyword === 'policy') {\n const policy = parsePolicy(context, line);\n if (policies.some(previous => previous.name === policy.name)) {\n context.error(DiagnosticCodes.DuplicateDeclaration, `Duplicate declaration of policy '${policy.name}' - policy names must be unique`, policy.location);\n }\n policies.push(policy);\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 if (keyword === 'ui') parseUiProfile(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', ...(commandReadMode === null ? {} : { commandReadMode }), ...(timeZone === null ? {} : { timeZone }), ...(applicationContext === null ? {} : { context: applicationContext }), ...(reactionProductionMode === null ? {} : { reactionProductionMode }), ...(identity === null ? {} : { identity }), sourceOptions: context.sourceOptions, domain, imports, concepts, types, systems, ...(stateMachines.length > 0 ? { stateMachines } : {}), ...(workflows.length > 0 ? { workflows } : {}), eventSources, examples, modules, personas, policies, purposes, seeds, declaredTriggers, fileImports, ...(exposures.length > 0 ? { exposures } : {}), ...(stickyNotes.length > 0 ? { stickyNotes } : {}), ...(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 if (keyword === 'context') return line.content === 'context';\n return keyword === 'purpose' || keyword === 'example' || keyword === 'exposure' || keyword === 'instance' || keyword === 'eventsource' || keyword === 'system' || keyword === 'statemachine' || keyword === 'workflow' || keyword === 'concept' || keyword === 'type' || keyword === 'persona' || keyword === 'sticky' || 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, sticky note, authentication, onboarding, identity, context, module, seed, trigger, behavior, ui profile, theme, sample data 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 const members = new EnumerationMembers();\n let generation: GenerationSyntax | null = null;\n let declaredGeneration = false;\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 const memberName = type === 'Enum' ? members.tryNumbered(context, child) : undefined;\n if (memberName !== undefined) {\n values.push(memberName);\n } else 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', name);\n if (parsed !== undefined) validations.push(parsed);\n } else if (firstWord(child.content) === 'generate' && !(type === 'Enum' && child.content === 'generate')) {\n if (declaredGeneration) context.error(DiagnosticCodes.DuplicateGeneration, `Concept '${name}' declares generation more than once.`, locationOf(child));\n const parsed = parseGeneration(context, child, type);\n if (!declaredGeneration) generation = parsed;\n declaredGeneration = true;\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, generate, 'file <path>' or '<attribute> reason \"<text>\"'${misplacedRuleHintForConcept(child.content)}`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n const valueNumbers = members.finish(context, line, values.length);\n return { kind: 'ConceptSyntax', name, type, attributes, values, validations, description, ...(generation === null ? {} : { generation }), ...(valueNumbers === undefined ? {} : { valueNumbers }), 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 const goals: string[] = [];\n let position: readonly [number, number] | null = null;\n let size: readonly [number, number] | null = null;\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 === 'goal') {\n const goal = personaGoalPattern.exec(child.content);\n if (goal === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid goal '${child.content}' - expected 'goal \"<text>\"'`, locationOf(child));\n } else {\n goals.push(unescapeString(goal[1]));\n }\n } else if (keyword === 'position') {\n position = parseCanvasPair(context, child, 'position', 'x', 'y', position, true) ?? position;\n } else if (keyword === 'size') {\n size = parseCanvasPair(context, child, 'size', 'width', 'height', size, false) ?? size;\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, goal, policy, position or size`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return {\n kind: 'PersonaSyntax', name, description, policies,\n ...(goals.length > 0 ? { goals } : {}),\n ...(position === null ? {} : { x: position[0], y: position[1] }),\n ...(size === null ? {} : { width: size[0], height: size[1] }),\n location: locationOf(line),\n };\n}\n\n// 'sticky note on <canvas>' with the text it carries, an optional colour and where it sits on that canvas - the port of the C# ParseStickyNote.\nfunction parseStickyNote(context: ParserContext, line: SourceLine): StickyNoteSyntax | null {\n const canvasMatch = stickyNotePattern.exec(line.content);\n if (canvasMatch === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid sticky note declaration '${line.content}' - expected 'sticky note on personas', 'sticky note on eventsources', 'sticky note on givencontexts' or 'sticky note on seeddata'`, locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n let text: string | null = null;\n let colour: string | null = null;\n let position: readonly [number, number] | null = null;\n let size: readonly [number, number] | null = null;\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 text = parseDescription(context, child, text, 'A sticky note');\n } else if (keyword === 'colour') {\n const match = stickyNoteColourPattern.exec(child.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid colour '${child.content}' - expected 'colour yellow', 'colour pink', 'colour green' or 'colour blue'`, locationOf(child));\n } else {\n colour = match[1];\n }\n } else if (keyword === 'position') {\n position = parseCanvasPair(context, child, 'position', 'x', 'y', position, true) ?? position;\n } else if (keyword === 'size') {\n size = parseCanvasPair(context, child, 'size', 'width', 'height', size, false) ?? size;\n } else {\n context.error(DiagnosticCodes.UnknownPersonaDirective, `Unexpected '${keyword}' in sticky note body - expected description, colour, position or size`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n if (text === null || position === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, 'A sticky note needs a description (the text on it) and a position', locationOf(line));\n return null;\n }\n return { kind: 'StickyNoteSyntax', canvas: canvasMatch[1] as StickyNoteSyntax['canvas'], text, colour, x: position[0], y: position[1], width: size === null ? null : size[0], height: size === null ? null : size[1], location: locationOf(line) };\n}\n\n"],"mappings":"A,gxEA2DA,MAAMA,EAAgBC,EAAQ,kDAAkD,EAC1EC,EAAkBD,EAAQ,oDAAoDE,EAAkB,IAAI,EACpGC,EAAgBH,EAAQ,iDAAiDE,EAAkB,MAAM,EACjGE,EAAiBJ,EAAQ,qDAAqD,EAC9EK,EAAmBL,EAAQ,gBAAgB,EAC3CM,EAAiBN,EAAQ,8BAA8B,EACvDO,EAAuBP,EAAQ,6BAA6B,EAC5DQ,EAAqBR,EAAQ,cAAcE,EAAkB,IAAI,EACjEO,EAAoBT,EAAQ,0EAA0E,EACtGU,EAA0BV,EAAQ,sCAAsC,EACxEW,EAAmB,UACnBC,EAAiB,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,UAAU,EAIhFC,kBAAiB,IAAI,IAAI,CAAC,SAAU,iBAAkB,aAAc,OAAQ,KAAM,QAAS,UAAW,SAAU,WAAY,QAAQ,CAAC,EAGrIC,kBAAe,IAAI,IAAI,CAAC,QAAS,UAAW,cAAe,gBAAiB,YAAa,SAAU,SAAU,OAAQ,aAAc,KAAM,MAAM,CAAC,EAItJ,SAAgB,iBAAiB,EAAwB,EAA8B,EAA2BC,EAAsC,CACpJ,EAAQ,wBAA0B,GAClC,qBAAqBC,EAASC,CAAK,EACnC,IAAMC,EAAaC,EAAU,SAAW,EAAI,IAAIC,GAAWD,EAAU,EAAE,EAAI,IAAA,GACrEE,EAAcF,EAAU,OAAS,EAAI,IAAIG,EAAYH,EAAUA,EAAU,OAAS,EAAE,EAAI,IAAA,GACxFI,EAAaL,GAAcG,EAC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,EAAGJ,EAAS,GAAI,EAAGA,EAAS,GAAI,MAAOC,IAAS,KAAO,KAAOA,EAAK,GAAI,OAAQA,IAAS,KAAO,KAAOA,EAAK,GAAI,SAAUtE,EAAWL,CAAI,CAAE,CACrP,C"}
1
+ {"version":3,"file":"ScreenplayParser.js","names":["domainPattern","pattern","timeZonePattern","stringBodyPattern","importPattern","conceptPattern","enumValuePattern","personaPattern","personaPolicyPattern","personaGoalPattern","stickyNotePattern","stickyNoteColourPattern","tabIndentPattern","primitiveTypes","opaqueTopLevel","bodyKeywords","documentPlacement","context","lines","state","placement","line","moduleBody","ModuleBody","featureBody","FeatureBody","keyword","name","preambleRules","misplacedReactionIdentity","bodyRules","isFileImport","parseEventSource","parseSystem","parseStateMachine","parseWorkflow","parseType","isDocumentPlacement","parseModule","parseSeed","parsePurpose","parseApplicationContext","parseIdentity","parseExposure","parseInstance","firstWord","preamble","rule","candidate","alreadyDeclared","DiagnosticCodes","locationOf","match","unescapeString","parseFileImport","origin","isBlankPublicEventOrigin","parseExample","stickyNote","policy","parsePolicy","previous","data","parseTriggerDeclaration","collectInputUses","parseUiProfile","value","key","values","modules","root","commandReadMode","timeZone","applicationContext","reactionProductionMode","identity","stateMachines","workflows","exposures","stickyNotes","instanceContributions","recordAuthoredDocument","modulePattern","describePlacement","word","hint","expected","moduleBodyExpected","featureBodyExpected","feature","innermost","index","start","existing","sawOtherConstruct","inFence","startOf","type","attributeText","attributes","parseComplianceMarkers","members","EnumerationMembers","generation","declaredGeneration","description","validations","child","memberName","parseDescription","isFileDirective","parsed","parseValidate","parseGeneration","parseComplianceDirective","unescapeIdentifier","misplacedRuleHintForConcept","valueNumbers","policies","goals","position","size","goal","parseCanvasPair","canvasMatch","text","colour"],"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 { CommandReadMode } from '../Syntax/CommandReadMode';\nimport { ReactionProductionMode } from '../Syntax/ReactionProductionMode';\nimport { EnumerationMembers } from './EnumerationMembers';\nimport { GenerationSyntax } from '../Syntax/GenerationSyntax';\nimport { misplacedRuleHintForConcept } from './MisplacedRuleHint';\nimport { parseGeneration } from './GenerationParser';\nimport { IdentitySyntax } from '../Syntax/IdentitySyntax';\nimport { parseIdentity } from './IdentityParser';\nimport { parseApplicationContext } from './ApplicationContextParser';\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, StickyNoteSyntax } from '../Syntax/Authorization';\nimport { ConceptSyntax, DomainSyntax, ImportSyntax, TypeSyntax } from '../Syntax/Declarations';\nimport { SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { TimeZoneSyntax } from '../Syntax/Calendar';\nimport { ApplicationContextSyntax, 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 { parseStateMachine } from './StateMachineParser';\nimport { parseWorkflow } from './WorkflowParser';\nimport { StateMachineSyntax, WorkflowSyntax } from '../Syntax/Lifecycles';\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 { parseCanvasPair } from './CanvasPlacement';\nimport { parseEventSource } from './EventSourceParser';\nimport { parseExposure, parseInstance } from './CompositionParser';\nimport { ExposureSyntax, InstanceContributionsSyntax } from '../Syntax/CompositionSyntax';\nimport { parseExample } from './SpecificationExampleParser';\nimport { parseUiProfile } from './UiProfileLegacyLayout';\nimport { locationOf, SourceLine, startOf } from './SourceLine';\n\nconst domainPattern = pattern('^domain\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)$');\nconst timeZonePattern = pattern(`^time\\\\s+zone\\\\s+(configurable\\\\s+default\\\\s+)?\"(${stringBodyPattern})\"$`);\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 personaGoalPattern = pattern(`^goal\\\\s+\"(${stringBodyPattern})\"$`);\nconst stickyNotePattern = pattern('^sticky\\\\s+note\\\\s+on\\\\s+(personas|eventsources|givencontexts|seeddata)$');\nconst stickyNoteColourPattern = pattern('^colour\\\\s+(yellow|pink|green|blue)$');\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', 'onboarding', 'seed', 'ui', 'theme', 'trigger', 'layout', 'behavior', 'sample']);\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 state = createRootState(placement);\n for (let line = context.reader.peekSignificant(); line !== undefined; line = context.reader.peekSignificant()) {\n context.reader.takeSignificant();\n dispatchRoot(context, line, state);\n }\n return buildApplication(context, state);\n}\n\n// What the root loop gathers while it reads the lines of a document.\ninterface RootState {\n readonly placement: PlayPlacement;\n readonly moduleBody: ModuleBody | undefined;\n readonly featureBody: FeatureBody | undefined;\n readonly placedBody: ModuleBody | FeatureBody | undefined;\n identity: IdentitySyntax | null;\n applicationContext: ApplicationContextSyntax | null;\n reactionProductionMode: ReactionProductionMode | null;\n sawReactionBatches: boolean;\n commandReadMode: CommandReadMode | null;\n timeZone: TimeZoneSyntax | null;\n sawTimeZone: boolean;\n sawCommandReads: boolean;\n domain: DomainSyntax | null;\n sawOtherConstruct: boolean;\n readonly imports: ImportSyntax[];\n readonly fileImports: FileImportSyntax[];\n readonly concepts: ConceptSyntax[];\n readonly types: TypeSyntax[];\n readonly systems: SystemSyntax[];\n readonly stateMachines: StateMachineSyntax[];\n readonly workflows: WorkflowSyntax[];\n readonly eventSources: EventSourceSyntax[];\n readonly modules: ModuleSyntax[];\n readonly personas: PersonaSyntax[];\n readonly stickyNotes: StickyNoteSyntax[];\n readonly policies: PolicySyntax[];\n readonly purposes: PurposeSyntax[];\n readonly seeds: SeedSyntax[];\n readonly examples: SpecificationExampleSyntax[];\n readonly declaredTriggers: NonNullable<ApplicationSyntax['declaredTriggers']>[number][];\n readonly exposures: ExposureSyntax[];\n readonly instanceContributions: InstanceContributionsSyntax[];\n}\n\ninterface RootRule {\n readonly matches: (keyword: string, line: SourceLine, state: RootState) => boolean;\n readonly parse: (context: ParserContext, line: SourceLine, state: RootState) => void;\n}\n\nfunction createRootState(placement: PlayPlacement): RootState {\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 return {\n placement, moduleBody, featureBody, placedBody: moduleBody ?? featureBody,\n identity: null, applicationContext: null, reactionProductionMode: null, sawReactionBatches: false, commandReadMode: null,\n timeZone: null, sawTimeZone: false, sawCommandReads: false, domain: null, sawOtherConstruct: false,\n imports: [], fileImports: [], concepts: [], types: [], systems: [], stateMachines: [], workflows: [], eventSources: [], modules: [],\n personas: [], stickyNotes: [], policies: [], purposes: [], seeds: [], examples: [], declaredTriggers: [], exposures: [], instanceContributions: []\n };\n}\n\nconst isKeyword = (name: string) => (keyword: string): boolean => keyword === name;\n\n// The directives that open a document, tried before the bookkeeping that counts a construct as declared.\nconst preambleRules: readonly RootRule[] = [\n { matches: (keyword, line) => keyword === 'command' && /^command\\s+reads(?:\\s|$)/.test(line.content), parse: parseRootCommandReads },\n { matches: (keyword, line) => keyword === 'time' && /^time\\s+zone(?:\\s|$)/.test(line.content), parse: parseRootTimeZone },\n { matches: isKeyword('reaction'), parse: parseRootReactionBatches },\n { matches: isKeyword('runs'), parse: (context, line) => { misplacedReactionIdentity(context, line); } },\n { matches: isKeyword('domain'), parse: parseRootDomain }\n];\n\n// The rest of the root constructs in the order they are tried; a line none of them takes goes to the placed body, then to the unexpected top level report.\nconst bodyRules: readonly RootRule[] = [\n { matches: (keyword, line) => keyword === 'import' && isFileImport(line.content), parse: parseRootFileImport },\n { matches: isKeyword('import'), parse: parseRootImport },\n { matches: isKeyword('example'), parse: parseRootExample },\n { matches: isKeyword('eventsource'), parse: (context, line, state) => { state.eventSources.push(parseEventSource(context, line)); } },\n { matches: isKeyword('system'), parse: (context, line, state) => { state.systems.push(parseSystem(context, line)); } },\n { matches: isKeyword('statemachine'), parse: (context, line, state) => { state.stateMachines.push(parseStateMachine(context, line)); } },\n { matches: isKeyword('workflow'), parse: (context, line, state) => { state.workflows.push(parseWorkflow(context, line)); } },\n { matches: isKeyword('concept'), parse: (context, line, state) => { state.concepts.push(parseConcept(context, line)); } },\n { matches: isKeyword('type'), parse: (context, line, state) => { state.types.push(parseType(context, line)); } },\n { matches: (keyword, _, state) => keyword === 'module' && !isDocumentPlacement(state.placement), parse: (context, line, state) => parseModuleInPlacedFile(context, line, state.placement, state.moduleBody) },\n { matches: isKeyword('module'), parse: (context, line, state) => { state.modules.push(parseModule(context, line)); } },\n { matches: isKeyword('persona'), parse: (context, line, state) => { state.personas.push(parsePersona(context, line)); } },\n { matches: isKeyword('sticky'), parse: parseRootStickyNote },\n { matches: isKeyword('seed'), parse: (context, line, state) => { state.seeds.push(parseSeed(context.valueContext, line)); } },\n { matches: (keyword, _, state) => keyword === 'purpose' && state.placedBody !== undefined, parse: (context, line, state) => { state.placedBody?.tryParse(context, line); } },\n { matches: isKeyword('purpose'), parse: (context, line, state) => { state.purposes.push(parsePurpose(context, line)); } },\n { matches: isKeyword('context'), parse: (context, line, state) => { state.applicationContext = parseApplicationContext(context, line, state.applicationContext, state.placement); } },\n { matches: isKeyword('identity'), parse: (context, line, state) => { state.identity = parseIdentity(context, line, state.identity); } },\n { matches: isKeyword('policy'), parse: parseRootPolicy },\n { matches: isKeyword('exposure'), parse: (context, line, state) => { state.exposures.push(parseExposure(context, line)); } },\n { matches: isKeyword('instance'), parse: (context, line, state) => { state.instanceContributions.push(parseInstance(context, line)); } },\n { matches: isKeyword('trigger'), parse: parseRootTrigger },\n { matches: keyword => opaqueTopLevel.has(keyword), parse: parseRootOpaque }\n];\n\nfunction dispatchRoot(context: ParserContext, line: SourceLine, state: RootState): void {\n const keyword = firstWord(line.content);\n const preamble = preambleRules.find(rule => rule.matches(keyword, line, state));\n if (preamble !== undefined) {\n preamble.parse(context, line, state);\n return;\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 state.sawOtherConstruct ||= declaresConstruct(keyword, line, state.placement);\n context.authoredDeclarations ||= keyword !== 'import' && declaresConstruct(keyword, line, state.placement);\n const rule = bodyRules.find(candidate => candidate.matches(keyword, line, state));\n if (rule !== undefined) {\n rule.parse(context, line, state);\n } else if (state.placedBody?.tryParse(context, line) !== true) {\n reportUnexpectedTopLevel(context, line, state.placement);\n }\n}\n\nfunction isRepeatedOrMisplaced(alreadyDeclared: boolean, state: RootState): boolean {\n return alreadyDeclared || !isDocumentPlacement(state.placement);\n}\n\nfunction parseRootCommandReads(context: ParserContext, line: SourceLine, state: RootState): void {\n if (isRepeatedOrMisplaced(state.sawCommandReads, state) || !/^command\\s+reads\\s+protected$/.test(line.content)) {\n context.error(DiagnosticCodes.InvalidCommandReadsDeclaration, \"Declare 'command reads protected' once at the application root.\", locationOf(line));\n } else {\n state.commandReadMode = CommandReadMode.Protected;\n }\n state.sawCommandReads = true;\n}\n\nfunction parseRootTimeZone(context: ParserContext, line: SourceLine, state: RootState): void {\n const match = timeZonePattern.exec(line.content);\n context.skipBlock(line.indent);\n if (isRepeatedOrMisplaced(state.sawTimeZone, state) || match === null) {\n context.error(DiagnosticCodes.InvalidTimeZoneDeclaration, \"Declare 'time zone \\\"<id>\\\"' or 'time zone configurable default \\\"<id>\\\"' once at the application root.\", locationOf(line));\n } else {\n state.timeZone = { kind: 'TimeZoneSyntax', id: unescapeString(match[2]), configurable: match[1] !== undefined, location: locationOf(line) };\n }\n state.sawTimeZone = true;\n}\n\nfunction parseRootReactionBatches(context: ParserContext, line: SourceLine, state: RootState): void {\n if (isRepeatedOrMisplaced(state.sawReactionBatches, state) || !/^reaction\\s+batches\\s+atomic$/.test(line.content)) {\n context.error(DiagnosticCodes.InvalidReactionBatchesDeclaration, \"Declare 'reaction batches atomic' once at the application root.\", locationOf(line));\n } else {\n state.reactionProductionMode = ReactionProductionMode.Atomic;\n }\n state.sawReactionBatches = true;\n}\n\nfunction parseRootDomain(context: ParserContext, line: SourceLine, state: RootState): void {\n context.authoredDeclarations = true;\n state.domain = parseDomain(context, line, state.domain, state.sawOtherConstruct);\n}\n\nfunction parseRootFileImport(context: ParserContext, line: SourceLine, state: RootState): void {\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 (state.placedBody !== undefined) {\n state.placedBody.tryParse(context, line);\n } else {\n parseFileImport(context, line, state.fileImports);\n }\n}\n\nfunction parseRootImport(context: ParserContext, line: SourceLine, state: RootState): void {\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 return;\n }\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 state.imports.push({ kind: 'ImportSyntax', qualifiedName: match[1], origin, visibility: origin === null ? EventVisibility.Private : EventVisibility.Public, location: locationOf(line) });\n}\n\nfunction parseRootExample(context: ParserContext, line: SourceLine, state: RootState): void {\n if (state.placedBody !== undefined) state.placedBody.tryParse(context, line);\n else state.examples.push(parseExample(context, line));\n}\n\nfunction parseRootStickyNote(context: ParserContext, line: SourceLine, state: RootState): void {\n const stickyNote = parseStickyNote(context, line);\n if (stickyNote !== null) state.stickyNotes.push(stickyNote);\n}\n\nfunction parseRootPolicy(context: ParserContext, line: SourceLine, state: RootState): void {\n const policy = parsePolicy(context, line);\n if (state.policies.some(previous => previous.name === policy.name)) {\n context.error(DiagnosticCodes.DuplicateDeclaration, `Duplicate declaration of policy '${policy.name}' - policy names must be unique`, policy.location);\n }\n state.policies.push(policy);\n}\n\nfunction parseRootTrigger(context: ParserContext, line: SourceLine, state: RootState): void {\n const data = parseTriggerDeclaration(context, line);\n const name = /^trigger\\s+([A-Za-z_]\\w*)$/.exec(line.content)?.[1];\n if (name !== undefined) state.declaredTriggers.push({ name, data });\n}\n\nfunction parseRootOpaque(context: ParserContext, line: SourceLine): void {\n const keyword = firstWord(line.content);\n if (keyword === 'behavior' || keyword === 'layout') collectInputUses(context, line);\n else if (keyword === 'ui') parseUiProfile(context, line);\n else context.skipOpaqueBlock(line.indent);\n}\n\n// A property the syntax only carries when it was declared.\nfunction presentOnly<K extends string, V>(key: K, value: V | null): { [P in K]?: V } {\n return (value === null ? {} : { [key]: value }) as { [P in K]?: V };\n}\n\n// A list the syntax only carries when something was declared in it.\nfunction nonEmptyOnly<K extends string, V>(key: K, values: V[]): { [P in K]?: V[] } {\n return (values.length > 0 ? { [key]: values } : {}) as { [P in K]?: V[] };\n}\n\nfunction buildApplication(context: ParserContext, state: RootState): ApplicationSyntax {\n const { placement, moduleBody, featureBody, modules } = state;\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 { commandReadMode, timeZone, applicationContext, reactionProductionMode, identity, domain, imports, concepts, types, systems, stateMachines, workflows, eventSources, examples, personas, policies, purposes, seeds, declaredTriggers, fileImports, exposures, stickyNotes, instanceContributions } = state;\n const root: ApplicationSyntax = { kind: 'ApplicationSyntax', ...presentOnly('commandReadMode', commandReadMode), ...presentOnly('timeZone', timeZone), ...presentOnly('context', applicationContext), ...presentOnly('reactionProductionMode', reactionProductionMode), ...presentOnly('identity', identity), sourceOptions: context.sourceOptions, domain, imports, concepts, types, systems, ...nonEmptyOnly('stateMachines', stateMachines), ...nonEmptyOnly('workflows', workflows), eventSources, examples, modules, personas, policies, purposes, seeds, declaredTriggers, fileImports, ...nonEmptyOnly('exposures', exposures), ...nonEmptyOnly('stickyNotes', stickyNotes), ...nonEmptyOnly('instanceContributions', 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 if (keyword === 'context') return line.content === 'context';\n return keyword === 'purpose' || keyword === 'example' || keyword === 'exposure' || keyword === 'instance' || keyword === 'eventsource' || keyword === 'system' || keyword === 'statemachine' || keyword === 'workflow' || keyword === 'concept' || keyword === 'type' || keyword === 'persona' || keyword === 'sticky' || 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, sticky note, authentication, onboarding, identity, context, module, seed, trigger, behavior, ui profile, theme, sample data 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 const members = new EnumerationMembers();\n let generation: GenerationSyntax | null = null;\n let declaredGeneration = false;\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 const memberName = type === 'Enum' ? members.tryNumbered(context, child) : undefined;\n if (memberName !== undefined) {\n values.push(memberName);\n } else 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', name);\n if (parsed !== undefined) validations.push(parsed);\n } else if (firstWord(child.content) === 'generate' && !(type === 'Enum' && child.content === 'generate')) {\n if (declaredGeneration) context.error(DiagnosticCodes.DuplicateGeneration, `Concept '${name}' declares generation more than once.`, locationOf(child));\n const parsed = parseGeneration(context, child, type);\n if (!declaredGeneration) generation = parsed;\n declaredGeneration = true;\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, generate, 'file <path>' or '<attribute> reason \"<text>\"'${misplacedRuleHintForConcept(child.content)}`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n const valueNumbers = members.finish(context, line, values.length);\n return { kind: 'ConceptSyntax', name, type, attributes, values, validations, description, ...(generation === null ? {} : { generation }), ...(valueNumbers === undefined ? {} : { valueNumbers }), 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 const goals: string[] = [];\n let position: readonly [number, number] | null = null;\n let size: readonly [number, number] | null = null;\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 === 'goal') {\n const goal = personaGoalPattern.exec(child.content);\n if (goal === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid goal '${child.content}' - expected 'goal \"<text>\"'`, locationOf(child));\n } else {\n goals.push(unescapeString(goal[1]));\n }\n } else if (keyword === 'position') {\n position = parseCanvasPair(context, child, 'position', 'x', 'y', position, true) ?? position;\n } else if (keyword === 'size') {\n size = parseCanvasPair(context, child, 'size', 'width', 'height', size, false) ?? size;\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, goal, policy, position or size`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return {\n kind: 'PersonaSyntax', name, description, policies,\n ...(goals.length > 0 ? { goals } : {}),\n ...(position === null ? {} : { x: position[0], y: position[1] }),\n ...(size === null ? {} : { width: size[0], height: size[1] }),\n location: locationOf(line),\n };\n}\n\n// 'sticky note on <canvas>' with the text it carries, an optional colour and where it sits on that canvas - the port of the C# ParseStickyNote.\nfunction parseStickyNote(context: ParserContext, line: SourceLine): StickyNoteSyntax | null {\n const canvasMatch = stickyNotePattern.exec(line.content);\n if (canvasMatch === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid sticky note declaration '${line.content}' - expected 'sticky note on personas', 'sticky note on eventsources', 'sticky note on givencontexts' or 'sticky note on seeddata'`, locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n let text: string | null = null;\n let colour: string | null = null;\n let position: readonly [number, number] | null = null;\n let size: readonly [number, number] | null = null;\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 text = parseDescription(context, child, text, 'A sticky note');\n } else if (keyword === 'colour') {\n const match = stickyNoteColourPattern.exec(child.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid colour '${child.content}' - expected 'colour yellow', 'colour pink', 'colour green' or 'colour blue'`, locationOf(child));\n } else {\n colour = match[1];\n }\n } else if (keyword === 'position') {\n position = parseCanvasPair(context, child, 'position', 'x', 'y', position, true) ?? position;\n } else if (keyword === 'size') {\n size = parseCanvasPair(context, child, 'size', 'width', 'height', size, false) ?? size;\n } else {\n context.error(DiagnosticCodes.UnknownPersonaDirective, `Unexpected '${keyword}' in sticky note body - expected description, colour, position or size`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n if (text === null || position === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, 'A sticky note needs a description (the text on it) and a position', locationOf(line));\n return null;\n }\n return { kind: 'StickyNoteSyntax', canvas: canvasMatch[1] as StickyNoteSyntax['canvas'], text, colour, x: position[0], y: position[1], width: size === null ? null : size[0], height: size === null ? null : size[1], location: locationOf(line) };\n}\n\n"],"mappings":"A,qwEA2DA,MAAMA,EAAgBC,EAAQ,kDAAkD,EAC1EC,EAAkBD,EAAQ,oDAAoDE,EAAkB,IAAI,EACpGC,EAAgBH,EAAQ,iDAAiDE,EAAkB,MAAM,EACjGE,EAAiBJ,EAAQ,qDAAqD,EAC9EK,EAAmBL,EAAQ,gBAAgB,EAC3CM,EAAiBN,EAAQ,8BAA8B,EACvDO,EAAuBP,EAAQ,6BAA6B,EAC5DQ,EAAqBR,EAAQ,cAAcE,EAAkB,IAAI,EACjEO,GAAoBT,EAAQ,0EAA0E,EACtGU,GAA0BV,EAAQ,sCAAsC,EACxEW,GAAmB,UACnBC,EAAiB,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,UAAU,EAIhFC,kBAAiB,IAAI,IAAI,CAAC,SAAU,iBAAkB,aAAc,OAAQ,KAAM,QAAS,UAAW,SAAU,WAAY,QAAQ,CAAC,EAGrIC,mBAAe,IAAI,IAAI,CAAC,QAAS,UAAW,cAAe,gBAAiB,YAAa,SAAU,SAAU,OAAQ,aAAc,KAAM,MAAM,CAAC,EAItJ,SAAgB,iBAAiB,EAAwB,EAA8B,EAA2BC,EAAsC,CACpJ,EAAQ,wBAA0B,GAClC,qBAAqBC,EAASC,CA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B,EAAQzC,GAAwB,KAAKgG,EAAM,OAAO,EACpDvD,IAAU,KACVnC,EAAQ,MAAMiC,EAAgB,0BAA2B,mBAAmByD,EAAM,QAAQ,8EAA+ExD,EAAWwD,CAAK,CAAC,EAE1L,EAASvD,EAAM,EAEvB,MAAW1B,IAAY,WACnB,EAAWiG,EAAgB1G,EAAS0F,EAAO,WAAY,IAAK,IAAKa,EAAU,EAAI,GAAKA,EAC7E9F,IAAY,OACnB,EAAOiG,EAAgB1G,EAAS0F,EAAO,OAAQ,QAAS,SAAUc,EAAM,EAAK,GAAKA,GAElFxG,EAAQ,MAAMiC,EAAgB,wBAAyB,eAAexB,EAAQ,wEAAyEyB,EAAWwD,CAAK,CAAC,EACxK1F,EAAQ,UAAU0F,EAAM,MAAM,EAEtC,CAKA,OAJIkB,IAAS,MAAQL,IAAa,MAC9BvG,EAAQ,MAAMiC,EAAgB,0BAA2B,oEAAqEC,EAAW9B,CAAI,CAAC,EACvI,MAEJ,CAAE,KAAM,mBAAoB,OAAQuG,EAAY,GAAkC,OAAM,SAAQ,EAAGJ,EAAS,GAAI,EAAGA,EAAS,GAAI,MAAOC,IAAS,KAAO,KAAOA,EAAK,GAAI,OAAQA,IAAS,KAAO,KAAOA,EAAK,GAAI,SAAUtE,EAAW9B,CAAI,CAAE,CACrP,C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/screenplay-language",
3
- "version": "5.5.0",
3
+ "version": "5.5.1",
4
4
  "description": "Monaco language service for the Cratis Screenplay DSL — syntax highlighting, IntelliSense, hover and diagnostics for .play files",
5
5
  "keywords": [
6
6
  "cratis",