@cratis/screenplay-language 4.207.0 → 4.208.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CommandParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/MatchOperandValidation.js +1 -1
- package/dist/bundles/compiler/Parsing/MatchOperandValidation.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{dependencySources as a}from"../Syntax/DependencySources.js";import{parseMappingSource as o}from"./ExpressionParser.js";import{isPendingHandler as s,validateHandlerOccurrences as c}from"./CommandHandlerValidator.js";import{firstWord as l}from"./LineText.js";import{reportInvalidModifierOrder as u,reportLegacyOptionalSuffix as d,tryParseProperty as f}from"./PropertyLineParser.js";import{combineAuthorize as p,parseAuthorize as m}from"./AuthorizeParser.js";import{parseDescription as h}from"./DescriptionParser.js";import{parseDocumentation as g}from"./DocumentationParser.js";import{parseCondition as _}from"./ConditionParser.js";import{ParserContext as v}from"./ParserContext.js";import{isReactionIdentityLine as y,misplacedReactionIdentity as b}from"./ReactionIdentityParser.js";import{sourceStreamPattern as x}from"../Text/SourceStreamNames.js";import{parseCommandStream as S}from"./EventSourceParser.js";import{isCode as C,isFile as w,parseCode as T,parseFile as E,parseHandler as D,parseImplementationWrapper as O}from"./ImplementationParser.js";import{parseCommandResponse as k,scalarResponsePattern as A}from"./CommandResponseParser.js";import{validateMatchOperand as j}from"./MatchOperandValidation.js";import{commandReadSources as M}from"./CommandReadSources.js";import{captureConcurrency as N}from"./DependencySourceParser.js";import{parseReads as P}from"./ReadsParser.js";import{parseProduces as F}from"./ProducesParser.js";const I=r(`^command\\s+([A-Za-z_]\\w*)$`),L=x(`^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$`),R=r(`\\bseverity\\s+(\\S+)$`),z=r(`\\bmessage\\s+(?:"(${t})"|(\\$strings\\.\\S*))$`),B=r(`^([\\w.]+)\\s+(.+)$`),V=r(`^(not empty|length ==|all >=|all >|matches|not contains|contains|starts with|ends with|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$`),H=x(`^[A-Za-z_]\\w*$`),U=r(`^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)`),W={max:`Max`,min:`Min`,">":`GreaterThan`,">=":`GreaterThanOrEqual`,"<":`LessThan`,"<=":`LessThanOrEqual`,"==":`Equal`,"!=":`NotEqual`,"length ==":`Length`,matches:`Matches`,contains:`Contains`,"not contains":`NotContains`,"starts with":`StartsWith`,"ends with":`EndsWith`,"all >":`AllGreaterThan`,"all >=":`AllGreaterThanOrEqual`},G={information:`Information`,warning:`Warning`,error:`Error`},K=/* @__PURE__ */ new Set([`reads`,`concurrency`]),q=/* @__PURE__ */ new Set([`description`,`documentation`,`handler`,`concurrency`]);function parseCommand(e,t){let n=/* @__PURE__ */ new Set,r=new v(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,o){let d=I.exec(n.content)?.[1]??``;d===``&&t.error(e.InvalidCommandDeclaration,`Invalid command declaration '${n.content}' - expected 'command <Name>'`,i(n));let _=[],v=[],x,C=[],w=[],T=[],E=[],O,j=null,R=null,z=null,B=null,V=[],H=null,W=[];for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent)){t.reader.takeSignificant();let n=l(a.content),o=f(a);if(o!==void 0&&(q.has(n)||n===`validate`&&a.content!==`validate csharp`))x=addProperty(t,_,o,d,a,x);else if(n===`returns`){let e=A.exec(a.content);e!==null&&!e[1].startsWith(`@`)&&o!==void 0?r===void 0?(_.push(o),v.push({line:a,candidate:o,response:null})):r.has(o.type.name)?v.push({line:a,candidate:null,response:k(t,a)}):x=addProperty(t,_,o,d,a,x):o===void 0?u(t,a)?t.skipBlock(a.indent):v.push({line:a,candidate:null,response:k(t,a)}):x=addProperty(t,_,o,d,a,x)}else if(n===`stream`&&L.test(a.content)&&o!==void 0&&t.streamCandidates?.hasSource(o.type.name.split(`.`)[0])===!0){let[n,r]=o.type.name.split(`.`),s=t.streamCandidates.hasPropertyType(o.type.name)&&t.streamCandidates.hasUniqueStream(n,r),c=S(t,a,o,s);(H!==null||W.length>0)&&t.error(e.InvalidCommandStream,`A command declares at most one stream route.`,i(a)),s||H!==null?W.push(c):H=c}else if(n===`runs`&&y(a))b(t,a);else if(n===`description`)j=h(t,a,j,`Command '${d}'`);else if(n===`documentation`)R=g(t,a,R,`Command '${d}'`);else if(n===`authorize`)z=p(z,m(t,a));else if(n===`validate`){let e=parseValidate(t,a,`command`);e!==void 0&&C.push(e)}else if(n===`produces`){let e=F(t,a,!0);e!==void 0&&w.push(e)}else if(n===`handler`)B=D(t,a),V.push({handler:B,location:i(a)});else if(K.has(n)){let r=n===`reads`?P(t,a):void 0;r!==void 0&&E.push(r),n===`concurrency`&&O===void 0&&(O=N(t,a));let o=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(a.content);o!==null&&T.push({readModel:o[1],alias:o[2]??null}),U.test(a.content)&&t.error(e.OptionalReadsNotSupported,`Optional reads are not yet supported (see #308).`,i(a)),t.skipOpaqueBlock(a.indent)}else o===void 0?(u(t,a),t.error(e.UnknownCommandDirective,`Unexpected '${a.content}' in command body`,i(a)),t.skipBlock(a.indent)):x=addProperty(t,_,o,d,a,x)}let G=new Set(v.flatMap(e=>e.candidate===null?[]:[e.candidate])),J=new Set(_.filter(e=>!G.has(e)).map(e=>e.name));v.some(e=>e.candidate!==null&&!J.has(e.candidate.type.name)&&e.candidate.type.name!==`returns`)&&J.add(`returns`);for(let e of J)o?.add(e);let Y=null,X=/* @__PURE__ */ new Set;for(let n of v){let r=n.response;if(n.candidate!==null){if(!J.has(n.candidate.type.name))continue;X.add(n.candidate),r={kind:`ScalarCommandResponseSyntax`,source:{kind:`PropertyResponseSourceSyntax`,property:n.candidate.type.name,location:n.candidate.type.location},location:i(n.line)}}r!==null&&(Y===null?Y=r:t.error(e.InvalidCommandResponse,`A command declares at most one unconditional response.`,i(n.line)))}c(V,t),B!==null&&!s(B)&&w.length>0&&t.error(e.CommandWithProducesAndHandler,`Command '${d}' cannot declare both 'produces' and 'handler'`,i(n));let Z={kind:`CommandSyntax`,name:d,description:j,documentation:R,authorize:z,properties:_.filter(e=>!X.has(e)),validations:C,produces:w,handler:B,response:Y,stream:H,streamCandidates:W,location:i(n)};return M.set(Z,T),a.set(Z,{reads:E,concurrency:O}),Z}function addProperty(t,n,r,i,a,o){return d(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 parseValidate(t,r,a){if(r.content===`validate`){let o=t.peekChild(r.indent);if(o!==void 0&&o.content.startsWith("```")){t.reader.takeSignificant();let e=T(t.valueContext,o);return e===null&&t.skipFencedBody(),{kind:`CodeValidateSyntax`,code:e,location:i(r)}}let s=[],c=[],u;for(let o=t.peekChild(r.indent);o!==void 0;o=t.peekChild(r.indent)){if(t.reader.takeSignificant(),a===`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||l(o.content)===`implementation`){t.error(e.InvalidValidationRule,`Invalid validation rule '${o.content}'`,i(o)),u??=o.indent;continue}}if(l(o.content)===`require`){let e=_(a===`concept`?t.valueContext:t,o.content.substring(7).trim(),i(o)),r=null,s=`Error`,u=!1;for(let e=t.peekChild(o.indent);e!==void 0;e=t.peekChild(o.indent)){t.reader.takeSignificant();let i=z.exec(e.content);i!==null&&i.index===0?r=i[1]===void 0?i[2]:n(i[1]):l(e.content)===`severity`?(u||(s=G[e.content.substring(8).trim()]??`Error`),u=!0):t.skipOpaqueBlock(e.indent)}e!==null&&c.push({kind:`RequirementSyntax`,condition:e,message:r,severity:s,location:i(o)});continue}let r=parseValidationRule(t,a===`concept`?{...o,content:`value ${o.content}`}:o,a);r!==void 0&&s.push(r)}return{kind:`DeclarativeValidateSyntax`,rules:s,requirements:c,location:i(r)}}if(a===`concept`&&l(r.content.substring(8).trimStart())===`checksum`){let e=parseValidationRule(t,{...r,content:`value ${r.content.substring(8).trimStart()}`},a);return e===void 0?void 0:{kind:`DeclarativeValidateSyntax`,rules:[e],requirements:[],location:i(r)}}if(r.content===`validate csharp`){let e=T(t.valueContext,{...r,content:`csharp`});return e===null&&t.skipOpaqueBlock(r.indent),{kind:`CodeValidateSyntax`,code:e,location:i(r)}}t.error(e.InvalidValidateDeclaration,`Invalid validate declaration '${r.content}' - expected 'validate' or 'validate csharp'`,i(r)),t.skipBlock(r.indent)}function parseValidationRule(t,n,r){let a=l(B.exec(n.content)?.[2]??``)===`checksum`,o=r===`concept`&&!a?t.valueContext:t,{content:s,message:c}=splitMessage(n.content),u=splitSeverity(o,n,s);if(u===void 0)return;let d=B.exec(u.content);if(d===null){o.error(e.InvalidValidationRule,`Invalid validation rule '${n.content}'`,i(n));return}let f=parseRule(o,d[2],n);if(f===void 0)return;f.kind===`Matches`&&f.value!==null&&j(t,f.value,i(n),n.raw);let p=f.kind===`Rule`?parseRuleImplementation(t,n,r===`command`):{file:null,code:null,implementation:null};return{kind:`ValidationRuleSyntax`,property:d[1],rule:f.kind,value:f.value,message:c,severity:u.severity,...p,location:i(n)}}function parseRuleImplementation(t,n,r){let a=t.peekChild(n.indent);if(a===void 0)return{file:null,code:null,implementation:null};t.reader.takeSignificant();let o=r&&l(a.content)===`implementation`,s=o?O(t,a):{file:w(a)?E(t,a):null,code:!w(a)&&C(t,a)?T(t,a):null,implementation:null};!o&&s.file===null&&s.code===null&&(t.error(e.UnknownRuleImplementationDirective,`Unexpected '${a.content}' in rule implementation - expected 'file <path>' or an inline code block`,i(a)),t.skipBlock(a.indent));for(let a=t.peekChild(n.indent);a!==void 0&&(o||r&&l(a.content)===`implementation`);a=t.peekChild(n.indent))t.reader.takeSignificant(),t.error(o&&l(a.content)===`implementation`?e.InvalidImplementationBlock:e.ConflictingImplementationSources,`A named rule has one implementation wrapper and cannot mix wrapped and direct sources.`,i(a)),C(t,a)?T(t,a):t.skipBlock(a.indent);return s}function splitMessage(e){let t=z.exec(e);if(t===null)return{content:e,message:null};let r=t[1]===void 0?t[2]:n(t[1]);return{content:e.substring(0,t.index).trimEnd(),message:r}}function splitSeverity(t,n,r){let a=R.exec(r);if(a===null)return{content:r,severity:`Error`};let o=G[a[1]];if(o===void 0)t.error(e.InvalidValidationSeverity,`Unknown validation severity '${a[1]}' - expected information, warning or error`,i(n));else return{content:r.substring(0,a.index).trimEnd(),severity:o}}function parseRule(t,n,r){if(n===`not empty`)return{kind:`NotEmpty`,value:null};if(l(n)===`checksum`){let a=n.substring(8).trim();if(a!==`luhn`&&a!==`mod11`&&a!==`mod97`){t.error(e.InvalidGenerationArgument,`Checksum validation requires luhn, mod11 or mod97.`,i(r));return}return{kind:`Checksum`,value:{kind:`LiteralExpressionSyntax`,value:a,location:i(r)}}}let a=V.exec(n);if(a===null)t.error(e.InvalidValidationRule,`Invalid validation rule '${r.content}'`,i(r));else{if(a[1]===`rule`){let n=a[2].trim();if(!H.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{kind:W[a[1]],value:o(a[2],i(r),t)}}}export{parseCommand,parseValidate};
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{dependencySources as a}from"../Syntax/DependencySources.js";import{parseMappingSource as o}from"./ExpressionParser.js";import{isPendingHandler as s,validateHandlerOccurrences as c}from"./CommandHandlerValidator.js";import{firstWord as l}from"./LineText.js";import{reportInvalidModifierOrder as u,reportLegacyOptionalSuffix as d,tryParseProperty as f}from"./PropertyLineParser.js";import{combineAuthorize as p,parseAuthorize as m}from"./AuthorizeParser.js";import{parseDescription as h}from"./DescriptionParser.js";import{parseDocumentation as g}from"./DocumentationParser.js";import{parseCondition as _}from"./ConditionParser.js";import{ParserContext as v}from"./ParserContext.js";import{isReactionIdentityLine as y,misplacedReactionIdentity as b}from"./ReactionIdentityParser.js";import{sourceStreamPattern as x}from"../Text/SourceStreamNames.js";import{parseCommandStream as S}from"./EventSourceParser.js";import{isCode as C,isFile as w,parseCode as T,parseFile as E,parseHandler as D,parseImplementationWrapper as O}from"./ImplementationParser.js";import{parseCommandResponse as k,scalarResponsePattern as A}from"./CommandResponseParser.js";import{matchSubject as j,validateMatchOperand as M}from"./MatchOperandValidation.js";import{commandReadSources as N}from"./CommandReadSources.js";import{captureConcurrency as P}from"./DependencySourceParser.js";import{parseReads as F}from"./ReadsParser.js";import{parseProduces as I}from"./ProducesParser.js";const L=r(`^command\\s+([A-Za-z_]\\w*)$`),R=x(`^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$`),z=r(`\\bseverity\\s+(\\S+)$`),B=r(`\\bmessage\\s+(?:"(${t})"|(\\$strings\\.\\S*))$`),V=r(`^([\\w.]+)\\s+(.+)$`),H=r(`^(not empty|length ==|all >=|all >|matches|not contains|contains|starts with|ends with|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$`),U=x(`^[A-Za-z_]\\w*$`),W=r(`^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)`),G={max:`Max`,min:`Min`,">":`GreaterThan`,">=":`GreaterThanOrEqual`,"<":`LessThan`,"<=":`LessThanOrEqual`,"==":`Equal`,"!=":`NotEqual`,"length ==":`Length`,matches:`Matches`,contains:`Contains`,"not contains":`NotContains`,"starts with":`StartsWith`,"ends with":`EndsWith`,"all >":`AllGreaterThan`,"all >=":`AllGreaterThanOrEqual`},K={information:`Information`,warning:`Warning`,error:`Error`},q=/* @__PURE__ */ new Set([`reads`,`concurrency`]),J=/* @__PURE__ */ new Set([`description`,`documentation`,`handler`,`concurrency`]);function parseCommand(e,t){let n=/* @__PURE__ */ new Set,r=new v(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,o){let d=L.exec(n.content)?.[1]??``;d===``&&t.error(e.InvalidCommandDeclaration,`Invalid command declaration '${n.content}' - expected 'command <Name>'`,i(n));let _=[],v=[],x,C=[],w=[],T=[],E=[],O,j=null,M=null,z=null,B=null,V=[],H=null,U=[];for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent)){t.reader.takeSignificant();let n=l(a.content),o=f(a);if(o!==void 0&&(J.has(n)||n===`validate`&&a.content!==`validate csharp`))x=addProperty(t,_,o,d,a,x);else if(n===`returns`){let e=A.exec(a.content);e!==null&&!e[1].startsWith(`@`)&&o!==void 0?r===void 0?(_.push(o),v.push({line:a,candidate:o,response:null})):r.has(o.type.name)?v.push({line:a,candidate:null,response:k(t,a)}):x=addProperty(t,_,o,d,a,x):o===void 0?u(t,a)?t.skipBlock(a.indent):v.push({line:a,candidate:null,response:k(t,a)}):x=addProperty(t,_,o,d,a,x)}else if(n===`stream`&&R.test(a.content)&&o!==void 0&&t.streamCandidates?.hasSource(o.type.name.split(`.`)[0])===!0){let[n,r]=o.type.name.split(`.`),s=t.streamCandidates.hasPropertyType(o.type.name)&&t.streamCandidates.hasUniqueStream(n,r),c=S(t,a,o,s);(H!==null||U.length>0)&&t.error(e.InvalidCommandStream,`A command declares at most one stream route.`,i(a)),s||H!==null?U.push(c):H=c}else if(n===`runs`&&y(a))b(t,a);else if(n===`description`)j=h(t,a,j,`Command '${d}'`);else if(n===`documentation`)M=g(t,a,M,`Command '${d}'`);else if(n===`authorize`)z=p(z,m(t,a));else if(n===`validate`){let e=parseValidate(t,a,`command`,d);e!==void 0&&C.push(e)}else if(n===`produces`){let e=I(t,a,!0);e!==void 0&&w.push(e)}else if(n===`handler`)B=D(t,a),V.push({handler:B,location:i(a)});else if(q.has(n)){let r=n===`reads`?F(t,a):void 0;r!==void 0&&E.push(r),n===`concurrency`&&O===void 0&&(O=P(t,a));let o=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(a.content);o!==null&&T.push({readModel:o[1],alias:o[2]??null}),W.test(a.content)&&t.error(e.OptionalReadsNotSupported,`Optional reads are not yet supported (see #308).`,i(a)),t.skipOpaqueBlock(a.indent)}else o===void 0?(u(t,a),t.error(e.UnknownCommandDirective,`Unexpected '${a.content}' in command body`,i(a)),t.skipBlock(a.indent)):x=addProperty(t,_,o,d,a,x)}let G=new Set(v.flatMap(e=>e.candidate===null?[]:[e.candidate])),K=new Set(_.filter(e=>!G.has(e)).map(e=>e.name));v.some(e=>e.candidate!==null&&!K.has(e.candidate.type.name)&&e.candidate.type.name!==`returns`)&&K.add(`returns`);for(let e of K)o?.add(e);let Y=null,X=/* @__PURE__ */ new Set;for(let n of v){let r=n.response;if(n.candidate!==null){if(!K.has(n.candidate.type.name))continue;X.add(n.candidate),r={kind:`ScalarCommandResponseSyntax`,source:{kind:`PropertyResponseSourceSyntax`,property:n.candidate.type.name,location:n.candidate.type.location},location:i(n.line)}}r!==null&&(Y===null?Y=r:t.error(e.InvalidCommandResponse,`A command declares at most one unconditional response.`,i(n.line)))}c(V,t),B!==null&&!s(B)&&w.length>0&&t.error(e.CommandWithProducesAndHandler,`Command '${d}' cannot declare both 'produces' and 'handler'`,i(n));let Z={kind:`CommandSyntax`,name:d,description:j,documentation:M,authorize:z,properties:_.filter(e=>!X.has(e)),validations:C,produces:w,handler:B,response:Y,stream:H,streamCandidates:U,location:i(n)};return N.set(Z,T),a.set(Z,{reads:E,concurrency:O}),Z}function addProperty(t,n,r,i,a,o){return d(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 parseValidate(t,r,a,o){if(r.content===`validate`){let s=t.peekChild(r.indent);if(s!==void 0&&s.content.startsWith("```")){t.reader.takeSignificant();let e=T(t.valueContext,s);return e===null&&t.skipFencedBody(),{kind:`CodeValidateSyntax`,code:e,location:i(r)}}let c=[],u=[],d;for(let s=t.peekChild(r.indent);s!==void 0;s=t.peekChild(r.indent)){if(t.reader.takeSignificant(),a===`concept`){if(t.sourceOptions.numericMode===`legacy`&&s.content.startsWith("```")){t.skipFencedBody();continue}if(d!==void 0&&s.indent<=d&&(d=void 0),d!==void 0||l(s.content)===`implementation`){t.error(e.InvalidValidationRule,`Invalid validation rule '${s.content}'`,i(s)),d??=s.indent;continue}}if(l(s.content)===`require`){let e=_(a===`concept`?t.valueContext:t,s.content.substring(7).trim(),i(s)),r=null,o=`Error`,c=!1;for(let e=t.peekChild(s.indent);e!==void 0;e=t.peekChild(s.indent)){t.reader.takeSignificant();let i=B.exec(e.content);i!==null&&i.index===0?r=i[1]===void 0?i[2]:n(i[1]):l(e.content)===`severity`?(c||(o=K[e.content.substring(8).trim()]??`Error`),c=!0):t.skipOpaqueBlock(e.indent)}e!==null&&u.push({kind:`RequirementSyntax`,condition:e,message:r,severity:o,location:i(s)});continue}let r=parseValidationRule(t,a===`concept`?{...s,content:`value ${s.content}`}:s,a,o);r!==void 0&&c.push(r)}return{kind:`DeclarativeValidateSyntax`,rules:c,requirements:u,location:i(r)}}if(a===`concept`&&l(r.content.substring(8).trimStart())===`checksum`){let e=parseValidationRule(t,{...r,content:`value ${r.content.substring(8).trimStart()}`},a,o);return e===void 0?void 0:{kind:`DeclarativeValidateSyntax`,rules:[e],requirements:[],location:i(r)}}if(r.content===`validate csharp`){let e=T(t.valueContext,{...r,content:`csharp`});return e===null&&t.skipOpaqueBlock(r.indent),{kind:`CodeValidateSyntax`,code:e,location:i(r)}}t.error(e.InvalidValidateDeclaration,`Invalid validate declaration '${r.content}' - expected 'validate' or 'validate csharp'`,i(r)),t.skipBlock(r.indent)}function parseValidationRule(t,n,r,a){let o=l(V.exec(n.content)?.[2]??``)===`checksum`,s=r===`concept`&&!o?t.valueContext:t,{content:c,message:u}=splitMessage(n.content),d=splitSeverity(s,n,c);if(d===void 0)return;let f=V.exec(d.content);if(f===null){s.error(e.InvalidValidationRule,`Invalid validation rule '${n.content}'`,i(n));return}let p=parseRule(s,f[2],n);if(p===void 0)return;p.kind===`Matches`&&p.value!==null&&M(t,p.value,i(n),n.raw,j(t,r,a,f[1]));let m=p.kind===`Rule`?parseRuleImplementation(t,n,r===`command`):{file:null,code:null,implementation:null};return{kind:`ValidationRuleSyntax`,property:f[1],rule:p.kind,value:p.value,message:u,severity:d.severity,...m,location:i(n)}}function parseRuleImplementation(t,n,r){let a=t.peekChild(n.indent);if(a===void 0)return{file:null,code:null,implementation:null};t.reader.takeSignificant();let o=r&&l(a.content)===`implementation`,s=o?O(t,a):{file:w(a)?E(t,a):null,code:!w(a)&&C(t,a)?T(t,a):null,implementation:null};!o&&s.file===null&&s.code===null&&(t.error(e.UnknownRuleImplementationDirective,`Unexpected '${a.content}' in rule implementation - expected 'file <path>' or an inline code block`,i(a)),t.skipBlock(a.indent));for(let a=t.peekChild(n.indent);a!==void 0&&(o||r&&l(a.content)===`implementation`);a=t.peekChild(n.indent))t.reader.takeSignificant(),t.error(o&&l(a.content)===`implementation`?e.InvalidImplementationBlock:e.ConflictingImplementationSources,`A named rule has one implementation wrapper and cannot mix wrapped and direct sources.`,i(a)),C(t,a)?T(t,a):t.skipBlock(a.indent);return s}function splitMessage(e){let t=B.exec(e);if(t===null)return{content:e,message:null};let r=t[1]===void 0?t[2]:n(t[1]);return{content:e.substring(0,t.index).trimEnd(),message:r}}function splitSeverity(t,n,r){let a=z.exec(r);if(a===null)return{content:r,severity:`Error`};let o=K[a[1]];if(o===void 0)t.error(e.InvalidValidationSeverity,`Unknown validation severity '${a[1]}' - expected information, warning or error`,i(n));else return{content:r.substring(0,a.index).trimEnd(),severity:o}}function parseRule(t,n,r){if(n===`not empty`)return{kind:`NotEmpty`,value:null};if(l(n)===`checksum`){let a=n.substring(8).trim();if(a!==`luhn`&&a!==`mod11`&&a!==`mod97`){t.error(e.InvalidGenerationArgument,`Checksum validation requires luhn, mod11 or mod97.`,i(r));return}return{kind:`Checksum`,value:{kind:`LiteralExpressionSyntax`,value:a,location:i(r)}}}let a=H.exec(n);if(a===null)t.error(e.InvalidValidationRule,`Invalid validation rule '${r.content}'`,i(r));else{if(a[1]===`rule`){let n=a[2].trim();if(!U.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{kind:G[a[1]],value:o(a[2],i(r),t)}}}export{parseCommand,parseValidate};
|
|
2
2
|
//# sourceMappingURL=CommandParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandParser.js","names":["header","pattern","routeHeader","sourceStreamPattern","severityPattern","messagePattern","stringBodyPattern","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","handler","handlers","stream","streamCandidates","child","keyword","firstWord","asProperty","tryParseProperty","scalar","scalarResponsePattern","responseNames","parseCommandResponse","reportInvalidModifierOrder","source","streamName","ambiguous","route","parseCommandStream","isReactionIdentityLine","misplacedReactionIdentity","parseDescription","parseDocumentation","combineAuthorize","parseAuthorize","validate","production","parseProduces","parseHandler","reference","parseReads","captureConcurrency","read","candidates","entry","property","discoveredNames","response","removed","parsed","validateHandlerOccurrences","isPendingHandler","syntax","commandReadSources","dependencySources","reportLegacyOptionalSuffix","commandName","fence","code","parseCode","rules","requirements","wrapperIndent","owner","condition","parseCondition","message","severity","hasSeverity","directive","matched","unescapeString","rule","checksum","valueContext","withSeverity","match","validateMatchOperand","body","wrapped","commandOwner","parseImplementationWrapper","isFile","parseFile","isCode","extra","content","text","algorithm","operand","parseMappingSource"],"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 { isPendingHandler, validateHandlerOccurrences } from './CommandHandlerValidator';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { RequirementSyntax } from '../Syntax/Conditions';\nimport { parseCondition } from './ConditionParser';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { CommandSyntax, ValidateSyntax, ValidationRuleKind, ValidationRuleSyntax, ValidationSeverity } from '../Syntax/Commands';\nimport { PropertySyntax } from '../Syntax/Declarations';\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 { 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';\n\nconst header = pattern('^command\\\\s+([A-Za-z_]\\\\w*)$');\nconst routeHeader = sourceStreamPattern('^stream\\\\s+[A-Za-z_]\\\\w*\\\\.[A-Za-z_]\\\\w*$');\nconst severityPattern = pattern('\\\\bseverity\\\\s+(\\\\S+)$');\nconst messagePattern = pattern(`\\\\bmessage\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\S*))$`);\nconst rulePattern = pattern('^([\\\\w.]+)\\\\s+(.+)$');\nconst operandPattern = pattern('^(not empty|length ==|all >=|all >|matches|not contains|contains|starts with|ends with|max|min|rule|>=|<=|==|!=|>|<)\\\\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 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 handler: HandlerSyntax | null = null;\n const handlers: { handler: HandlerSyntax | null; location: SourceLocation }[] = [];\n let stream: CommandStreamSyntax | null = null;\n const streamCandidates: CommandStreamSyntax[] = [];\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 (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 authorize = combineAuthorize(authorize, parseAuthorize(context, child));\n } else if (keyword === 'validate') {\n const validate = parseValidate(context, child, 'command');\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`, 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 validateHandlerOccurrences(handlers, context);\n if (handler !== null && !isPendingHandler(handler) && produces.length > 0) {\n context.error(DiagnosticCodes.CommandWithProducesAndHandler, `Command '${name}' cannot declare both 'produces' and 'handler'`, locationOf(line));\n }\n const syntax: CommandSyntax = { kind: 'CommandSyntax', name, description, documentation, authorize, properties: properties.filter(property => !removed.has(property)), validations, produces, handler, response, stream, streamCandidates, 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\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'): ValidateSyntax | undefined {\n if (line.content === 'validate') {\n const fence = context.peekChild(line.indent);\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 const condition = parseCondition(owner === 'concept' ? context.valueContext : context, child.content.substring('require'.length).trim(), locationOf(child));\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);\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);\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'): 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);\n if (parsed === undefined) {\n return undefined;\n }\n if (parsed.kind === 'Matches' && parsed.value !== null) validateMatchOperand(context, parsed.value, locationOf(line), line.raw);\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\nfunction parseRule(context: ParserContext, rule: string, line: SourceLine): { 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 if (operand[1] === 'rule') {\n const name = operand[2].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 { kind: operandKinds[operand[1]], value: parseMappingSource(operand[2], locationOf(line), context) };\n}\n"],"mappings":"usDAsCA,MAAMA,EAASC,EAAQ,8BAA8B,EAC/CC,EAAcC,EAAoB,2CAA2C,EAC7EC,EAAkBH,EAAQ,wBAAwB,EAClDI,EAAiBJ,EAAQ,sBAAsBK,EAAkB,yBAAyB,EAC1FC,EAAcN,EAAQ,qBAAqB,EAC3CO,EAAiBP,EAAQ,+HAA+H,EACxJQ,EAAkBN,EAAoB,iBAAiB,EACvDO,EAAgBT,EAAQ,0CAA0C,EAGlEU,EAAmD,CACrD,IAAK,MACL,IAAK,MACL,IAAK,cACL,KAAM,qBACN,IAAK,WACL,KAAM,kBACN,KAAM,QACN,KAAM,WACN,YAAa,SACb,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,IA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AmBD,EAAQ,GAAI3F,EAAWH,CAAI,EAAGD,CAAO,CAAE,CAD1G,CAEJ"}
|
|
1
|
+
{"version":3,"file":"CommandParser.js","names":["header","pattern","routeHeader","sourceStreamPattern","severityPattern","messagePattern","stringBodyPattern","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","handler","handlers","stream","streamCandidates","child","keyword","firstWord","asProperty","tryParseProperty","scalar","scalarResponsePattern","responseNames","parseCommandResponse","reportInvalidModifierOrder","source","streamName","ambiguous","route","parseCommandStream","isReactionIdentityLine","misplacedReactionIdentity","parseDescription","parseDocumentation","combineAuthorize","parseAuthorize","validate","production","parseProduces","parseHandler","reference","parseReads","captureConcurrency","read","candidates","entry","property","discoveredNames","response","removed","parsed","validateHandlerOccurrences","isPendingHandler","syntax","commandReadSources","dependencySources","reportLegacyOptionalSuffix","commandName","fence","code","parseCode","rules","requirements","wrapperIndent","owner","condition","parseCondition","message","severity","hasSeverity","directive","matched","unescapeString","rule","ownerName","checksum","valueContext","withSeverity","match","validateMatchOperand","matchSubject","body","wrapped","commandOwner","parseImplementationWrapper","isFile","parseFile","isCode","extra","content","text","algorithm","operand","parseMappingSource"],"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 { isPendingHandler, validateHandlerOccurrences } from './CommandHandlerValidator';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { RequirementSyntax } from '../Syntax/Conditions';\nimport { parseCondition } from './ConditionParser';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { CommandSyntax, ValidateSyntax, ValidationRuleKind, ValidationRuleSyntax, ValidationSeverity } from '../Syntax/Commands';\nimport { PropertySyntax } from '../Syntax/Declarations';\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';\n\nconst header = pattern('^command\\\\s+([A-Za-z_]\\\\w*)$');\nconst routeHeader = sourceStreamPattern('^stream\\\\s+[A-Za-z_]\\\\w*\\\\.[A-Za-z_]\\\\w*$');\nconst severityPattern = pattern('\\\\bseverity\\\\s+(\\\\S+)$');\nconst messagePattern = pattern(`\\\\bmessage\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\S*))$`);\nconst rulePattern = pattern('^([\\\\w.]+)\\\\s+(.+)$');\nconst operandPattern = pattern('^(not empty|length ==|all >=|all >|matches|not contains|contains|starts with|ends with|max|min|rule|>=|<=|==|!=|>|<)\\\\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 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 handler: HandlerSyntax | null = null;\n const handlers: { handler: HandlerSyntax | null; location: SourceLocation }[] = [];\n let stream: CommandStreamSyntax | null = null;\n const streamCandidates: CommandStreamSyntax[] = [];\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 (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 authorize = combineAuthorize(authorize, parseAuthorize(context, child));\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`, 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 validateHandlerOccurrences(handlers, context);\n if (handler !== null && !isPendingHandler(handler) && produces.length > 0) {\n context.error(DiagnosticCodes.CommandWithProducesAndHandler, `Command '${name}' cannot declare both 'produces' and 'handler'`, locationOf(line));\n }\n const syntax: CommandSyntax = { kind: 'CommandSyntax', name, description, documentation, authorize, properties: properties.filter(property => !removed.has(property)), validations, produces, handler, response, stream, streamCandidates, 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\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 && 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 const condition = parseCondition(owner === 'concept' ? context.valueContext : context, child.content.substring('require'.length).trim(), locationOf(child));\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);\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\nfunction parseRule(context: ParserContext, rule: string, line: SourceLine): { 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 if (operand[1] === 'rule') {\n const name = operand[2].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 { kind: operandKinds[operand[1]], value: parseMappingSource(operand[2], locationOf(line), context) };\n}\n"],"mappings":"ytDAsCA,MAAMA,EAASC,EAAQ,8BAA8B,EAC/CC,EAAcC,EAAoB,2CAA2C,EAC7EC,EAAkBH,EAAQ,wBAAwB,EAClDI,EAAiBJ,EAAQ,sBAAsBK,EAAkB,yBAAyB,EAC1FC,EAAcN,EAAQ,qBAAqB,EAC3CO,EAAiBP,EAAQ,+HAA+H,EACxJQ,EAAkBN,EAAoB,iBAAiB,EACvDO,EAAgBT,EAAQ,0CAA0C,EAGlEU,EAAmD,CACrD,IAAK,MACL,IAAK,MACL,IAAK,cACL,KAAM,qBACN,IAAK,WACL,KAAM,kBACN,KAAM,QACN,KAAM,WACN,YAAa,SACb,QAAS,UACT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MAGtH,IAAIgG,EAAQ,KAAO,OAAQ,CACvB,IAAM/F,EAAO+F,EAAQ,EAAE,CAAC,KAAK,EAC7B,GAAI,CAAC1G,EAAgB,KAAKW,CAAI,EAAG,CAC7BF,EAAQ,MAAMG,EAAgB,gBAAiB,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,MAAO,CAAE,KAAMR,EAAawG,EAAQ,IAAK,MAAOC,EAAmBD,EAAQ,GAAI7F,EAAWH,CAAI,EAAGD,CAAO,CAAE,CAD1G,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{emailMatchPattern as t,validateMatchPattern as n}from"./PortableMatchPattern.js";import{checkPortableMatchPattern as r}from"./checkPortableMatchPattern.js";function validateMatchOperand(i,a,o,s){if(a.kind===`PathExpressionSyntax`&&a.path!==`email`){i.error(e.UnknownMatchPattern,`Named match pattern '${a.path}' is not defined; use 'email' or a quoted portable regular expression.`,o);return}let
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{emailMatchPattern as t,validateMatchPattern as n}from"./PortableMatchPattern.js";import{checkPortableMatchPattern as r}from"./checkPortableMatchPattern.js";function matchSubject(e,t,n,r){return t===`command`?{owner:{kind:`declaration`,value:{kind:`command`,path:[...e.scope,n]}},property:r}:{owner:{kind:`declaration`,value:{kind:`concept`,path:[n]}}}}function matchArguments(e,t,n){return{subject:e.owner,...e.property===void 0?{}:{property:{kind:`text`,value:e.property}},pattern:{kind:`text`,value:t},...n===void 0?{}:{offset:{kind:`index`,value:n}}}}function validateMatchOperand(i,a,o,s,c){if(a.kind===`PathExpressionSyntax`&&a.path!==`email`){i.error(e.UnknownMatchPattern,`Named match pattern '${a.path}' is not defined; use 'email' or a quoted portable regular expression.`,o);return}let l=a.kind===`LiteralExpressionSyntax`&&typeof a.value==`string`?a.value:a.kind===`PathExpressionSyntax`?t:void 0;if(l===void 0)return;let u=r(l);if(u.replacement!==void 0){i.warning(e.DeprecatedStudioTextRulePattern,u.description,o,matchArguments(c,l));return}let d=n(l);if(d===void 0)return;let f=`${d.construct} at offset ${d.offset}. ${d.suggestion??``}`.trimEnd();i.error(d.invalid?e.InvalidMatchPattern:e.PatternOutsidePortableMatchDialect,`Match pattern: ${f}`,patternLocation(s,o,d.offset),matchArguments(c,l,d.offset))}function patternLocation(e,t,n){let r=e.indexOf(`"`,t.column-1);if(r<0)return t;let i=r+1;for(let t=0;t<n&&i<e.length;t++,i++)e[i]===`\\`&&`\\"nrt`.includes(e[i+1]??`\0`)&&i++;return{...t,column:i+1}}export{matchSubject,validateMatchOperand};
|
|
2
2
|
//# sourceMappingURL=MatchOperandValidation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MatchOperandValidation.js","names":["
|
|
1
|
+
{"version":3,"file":"MatchOperandValidation.js","names":["owner","context","name","subject","pattern","offset","value","DiagnosticCodes","location","emailMatchPattern","check","checkPortableMatchPattern","issue","validateMatchPattern","description","raw","quote","decoded","patternOffset"],"sources":["../../../../../../Compiler/Parsing/MatchOperandValidation.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 { DiagnosticArgument } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticArgumentKind } from '../Diagnostics/DiagnosticArgumentKind';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { ParserContext } from './ParserContext';\nimport { checkPortableMatchPattern } from './checkPortableMatchPattern';\nimport { emailMatchPattern, validateMatchPattern } from './PortableMatchPattern';\n\nexport interface MatchSubject {\n readonly owner: DiagnosticArgument;\n readonly property?: string;\n}\n\n// The command (module, features, slice, command) or concept that owns a match rule, as the C# binder names it.\nexport function matchSubject(context: ParserContext, owner: 'command' | 'concept', name: string, property: string): MatchSubject {\n return owner === 'command'\n ? { owner: { kind: DiagnosticArgumentKind.Declaration, value: { kind: 'command', path: [...context.scope, name] } }, property }\n : { owner: { kind: DiagnosticArgumentKind.Declaration, value: { kind: 'concept', path: [name] } } };\n}\n\nfunction matchArguments(subject: MatchSubject, pattern: string, offset?: number): Readonly<Record<string, DiagnosticArgument>> {\n return {\n subject: subject.owner,\n ...(subject.property === undefined ? {} : { property: { kind: DiagnosticArgumentKind.Text, value: subject.property } }),\n pattern: { kind: DiagnosticArgumentKind.Text, value: pattern },\n ...(offset === undefined ? {} : { offset: { kind: DiagnosticArgumentKind.Index, value: offset } }),\n };\n}\n\nexport function validateMatchOperand(context: ParserContext, value: ExpressionSyntax, location: SourceLocation, raw: string, subject: MatchSubject): void {\n if (value.kind === 'PathExpressionSyntax' && value.path !== 'email') {\n context.error(DiagnosticCodes.UnknownMatchPattern, `Named match pattern '${value.path}' is not defined; use 'email' or a quoted portable regular expression.`, location);\n return;\n }\n const pattern = value.kind === 'LiteralExpressionSyntax' && typeof value.value === 'string' ? value.value : value.kind === 'PathExpressionSyntax' ? emailMatchPattern : undefined;\n if (pattern === undefined) return;\n const check = checkPortableMatchPattern(pattern);\n if (check.replacement !== undefined) {\n context.warning(DiagnosticCodes.DeprecatedStudioTextRulePattern, check.description, location, matchArguments(subject, pattern));\n return;\n }\n const issue = validateMatchPattern(pattern);\n if (issue === undefined) return;\n const description = `${issue.construct} at offset ${issue.offset}. ${issue.suggestion ?? ''}`.trimEnd();\n context.error(issue.invalid ? DiagnosticCodes.InvalidMatchPattern : DiagnosticCodes.PatternOutsidePortableMatchDialect, `Match pattern: ${description}`, patternLocation(raw, location, issue.offset), matchArguments(subject, pattern, issue.offset));\n}\n\nfunction patternLocation(raw: string, location: SourceLocation, patternOffset: number): SourceLocation {\n const quote = raw.indexOf('\"', location.column - 1);\n if (quote < 0) return location;\n let offset = quote + 1;\n for (let decoded = 0; decoded < patternOffset && offset < raw.length; decoded++, offset++) {\n if (raw[offset] === '\\\\' && '\\\\\"nrt'.includes(raw[offset + 1] ?? '\\0')) offset++;\n }\n return { ...location, column: offset + 1 };\n}\n"],"mappings":"4RAkBA,SAAgB,aAAa,EAAwB,EAA8B,EAAc,EAAgC,CAC7H,OAAOA,IAAU,UACX,CAAE,MAAO,CAAE,KAAA,cAA0C,MAAO,CAAE,KAAM,UAAW,KAAM,CAAC,GAAGC,EAAQ,MAAOC,CAAI,CAAE,CAAE,EAAG,UAAS,EAC5H,CAAE,MAAO,CAAE,KAAA,cAA0C,MAAO,CAAE,KAAM,UAAW,KAAM,CAACA,CAAI,CAAE,CAAE,CAAE,CAC1G,CAEA,SAAS,eAAe,EAAuB,EAAiB,EAA+D,CAC3H,MAAO,CACH,QAASC,EAAQ,MACjB,GAAIA,EAAQ,WAAa,IAAA,GAAY,CAAC,EAAI,CAAE,SAAU,CAAE,KAAA,OAAmC,MAAOA,EAAQ,QAAS,CAAE,EACrH,QAAS,CAAE,KAAA,OAAmC,MAAOC,CAAQ,EAC7D,GAAIC,IAAW,IAAA,GAAY,CAAC,EAAI,CAAE,OAAQ,CAAE,KAAA,QAAoC,MAAOA,CAAO,CAAE,CACpG,CACJ,CAEA,SAAgB,qBAAqB,EAAwB,EAAyB,EAA0B,EAAa,EAA6B,CACtJ,GAAIC,EAAM,OAAS,wBAA0BA,EAAM,OAAS,QAAS,CACjEL,EAAQ,MAAMM,EAAgB,oBAAqB,wBAAwBD,EAAM,KAAK,wEAAyEE,CAAQ,EACvK,MACJ,CACA,IAAMJ,EAAUE,EAAM,OAAS,2BAA6B,OAAOA,EAAM,OAAU,SAAWA,EAAM,MAAQA,EAAM,OAAS,uBAAyBG,EAAoB,IAAA,GACxK,GAAIL,IAAY,IAAA,GAAW,OAC3B,IAAMM,EAAQC,EAA0BP,CAAO,EAC/C,GAAIM,EAAM,cAAgB,IAAA,GAAW,CACjCT,EAAQ,QAAQM,EAAgB,gCAAiCG,EAAM,YAAaF,EAAU,eAAeL,EAASC,CAAO,CAAC,EAC9H,MACJ,CACA,IAAMQ,EAAQC,EAAqBT,CAAO,EAC1C,GAAIQ,IAAU,IAAA,GAAW,OACzB,IAAME,EAAc,GAAGF,EAAM,UAAU,aAAaA,EAAM,OAAO,IAAIA,EAAM,YAAc,KAAK,QAAQ,EACtGX,EAAQ,MAAMW,EAAM,QAAUL,EAAgB,oBAAsBA,EAAgB,mCAAoC,kBAAkBO,IAAe,gBAAgBC,EAAKP,EAAUI,EAAM,MAAM,EAAG,eAAeT,EAASC,EAASQ,EAAM,MAAM,CAAC,CACzP,CAEA,SAAS,gBAAgB,EAAa,EAA0B,EAAuC,CACnG,IAAMI,EAAQD,EAAI,QAAQ,IAAKP,EAAS,OAAS,CAAC,EAClD,GAAIQ,EAAQ,EAAG,OAAOR,EACtB,IAAIH,EAASW,EAAQ,EACrB,IAAK,IAAIC,EAAU,EAAGA,EAAUC,GAAiBb,EAASU,EAAI,OAAQ,IAAW,IACzEA,EAAIV,KAAY,MAAQ,SAAS,SAASU,EAAIV,EAAS,IAAM,IAAI,GAAG,IAE5E,MAAO,CAAE,GAAGG,EAAU,OAAQH,EAAS,CAAE,CAC7C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{locationOf as i,startOf as a}from"./SourceLine.js";import{parseComplianceDirective as o,parseComplianceMarkers as s}from"./ConceptComplianceParser.js";import{firstWord as c,unescapeIdentifier as l}from"./LineText.js";import{describePlacement as u,documentPlacement as d,isDocumentPlacement as f}from"../Files/PlayPlacement.js";import{parseDescription as p}from"./DescriptionParser.js";import{parsePurpose as m}from"./PurposeParser.js";import{isFileImport as h,parseFileImport as g}from"./FileImportParser.js";import{recordAuthoredDocument as _}from"../Syntax/SourceOptions.js";import{collectInputUses as v}from"./InputUses.js";import{misplacedReactionIdentity as y}from"./ReactionIdentityParser.js";import{parseEventSource as b}from"./EventSourceParser.js";import{isFileDirective as x}from"./FileReferences.js";import{parseSystem as S}from"./OperationParser.js";import{parseExample as C}from"./SpecificationExampleParser.js";import{isBlankPublicEventOrigin as ee}from"../Syntax/PublicEventInvariants.js";import{parseType as w}from"./DeclarationParsers.js";import{parseValidate as T}from"./CommandParser.js";import{parseTriggerDeclaration as te}from"./TriggerDataParser.js";import{FeatureBody as E,featureBodyExpected as D}from"./FeatureBody.js";import{ModuleBody as ne,moduleBodyExpected as O,modulePattern as k,parseModule as re}from"./ModuleBody.js";import{EnumerationMembers as A}from"./EnumerationMembers.js";import{parseGeneration as j}from"./GenerationParser.js";import{parseIdentity as M}from"./IdentityParser.js";import{parsePolicy as N}from"./PolicyParser.js";import{parseSeed as P}from"./SeedParser.js";import{parseExposure as F,parseInstance as I}from"./CompositionParser.js";import{parseUiProfile as L}from"./UiProfileLegacyLayout.js";const R=r(`^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`),z=r(`^import\\s+([\\w.]+)(?:\\s+from\\s+"(?<origin>${t})")?$`),B=r(`^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$`),V=r(`^@?[a-z_]\\w*$`),H=r(`^persona\\s+([A-Za-z_]\\w*)$`),U=r(`^policy\\s+([A-Za-z_]\\w*)$`),W=/^[ ]*\t/,G=[`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`],K=/* @__PURE__ */ new Set([`policy`,`authentication`,`seed`,`ui`,`theme`,`trigger`,`layout`,`behavior`,`sample`]),q=/* @__PURE__ */ new Set([`slice`,`feature`,`description`,`documentation`,`authorize`,`screen`,`dialog`,`form`,`contribute`,`on`,`uses`]);function parseApplication(t,r,a=d){t.deferIdentityValidation=!0,warnOnTabIndentation(t,r);let o=a.length===1?new ne(a[0]):void 0,s=a.length>1?new E(a[a.length-1]):void 0,l=o??s,u=null,p=null,x=!1,T=null,D=!1,O=null,k=[],A=[],j=[],R=[],B=[],V=[],H=[],U=[],W=[],G=[],q=[],J=[],Y=[],X=[],Z=[],Q=!1;for(let r=t.reader.peekSignificant();r!==void 0;r=t.reader.peekSignificant()){t.reader.takeSignificant();let s=c(r.content);if(s===`command`&&/^command\s+reads(?:\s|$)/.test(r.content))D||!f(a)||!/^command\s+reads\s+protected$/.test(r.content)?t.error(e.InvalidCommandReadsDeclaration,`Declare 'command reads protected' once at the application root.`,i(r)):T=`Protected`,D=!0;else if(s===`reaction`)x||!f(a)||!/^reaction\s+batches\s+atomic$/.test(r.content)?t.error(e.InvalidReactionBatchesDeclaration,`Declare 'reaction batches atomic' once at the application root.`,i(r)):p=`Atomic`,x=!0;else if(s===`runs`)y(t,r);else if(s===`domain`)t.authoredDeclarations=!0,O=parseDomain(t,r,O,Q);else if(Q||=declaresConstruct(s,r,a),t.authoredDeclarations||=s!==`import`&&declaresConstruct(s,r,a),s===`import`&&h(r.content))l===void 0?g(t,r,A):l.tryParse(t,r);else if(s===`import`){let a=z.exec(r.content);if(a===null)t.error(e.InvalidImportDeclaration,`Invalid import '${r.content}' - expected 'import <Qualified.Name> [from "<origin>"]'`,i(r));else{let o=a.groups?.origin===void 0?null:n(a.groups.origin);o!==null&&ee(o)&&t.error(e.InvalidImportDeclaration,`An import origin must be a nonblank quoted string`,i(r)),k.push({kind:`ImportSyntax`,qualifiedName:a[1],origin:o,visibility:o===null?`Private`:`Public`,location:i(r)})}}else if(s===`example`)l===void 0?J.push(C(t,r)):l.tryParse(t,r);else if(s===`eventsource`)V.push(b(t,r));else if(s===`system`)B.push(S(t,r));else if(s===`concept`)j.push(parseConcept(t,r));else if(s===`type`)R.push(w(t,r));else if(s===`module`&&!f(a))parseModuleInPlacedFile(t,r,a,o);else if(s===`module`)H.push(re(t,r));else if(s===`persona`)U.push(parsePersona(t,r));else if(s===`seed`)q.push(P(t.valueContext,r));else if(s===`purpose`&&l!==void 0)l.tryParse(t,r);else if(s===`purpose`)G.push(m(t,r));else if(s===`identity`)u=M(t,r,u);else if(s===`policy`)W.push(N(t,r));else if(s===`exposure`)X.push(F(t,r));else if(s===`instance`)Z.push(I(t,r));else if(s===`trigger`){let e=te(t,r),n=/^trigger\s+([A-Za-z_]\w*)$/.exec(r.content)?.[1];n!==void 0&&Y.push({name:n,data:e})}else K.has(s)?s===`behavior`||s===`layout`?v(t,r):s===`ui`?L(t,r):t.skipOpaqueBlock(r.indent):l?.tryParse(t,r)!==!0&&reportUnexpectedTopLevel(t,r,a)}o===void 0?s!==void 0&&H.unshift(place(a,s.build(t.start,!0),t.start)):H.unshift(o.build(t.start,!0));let $={kind:`ApplicationSyntax`,...T===null?{}:{commandReadMode:T},...p===null?{}:{reactionProductionMode:p},...u===null?{}:{identity:u},sourceOptions:t.sourceOptions,domain:O,imports:k,concepts:j,types:R,systems:B,eventSources:V,examples:J,modules:H,personas:U,policies:W,purposes:G,seeds:q,declaredTriggers:Y,fileImports:A,...X.length>0?{exposures:X}:{},...Z.length>0?{instanceContributions:Z}:{},location:t.start};return t.authoredDeclarations&&_($),$}function declaresConstruct(e,t,n){return e===`import`?z.test(t.content):e===`module`?f(n):e===`identity`?t.content===`identity`:e===`purpose`||e===`example`||e===`exposure`||e===`instance`||e===`eventsource`||e===`system`||e===`concept`||e===`type`||e===`persona`||K.has(e)}function parseModuleInPlacedFile(t,n,r,a){let o=k.exec(n.content)?.[1]??``;a!==void 0&&o===r[0]?(t.authoredDeclarations=!0,a.parseChildren(t,n)):(t.error(e.ModuleInPlacedFile,`This file is imported into ${u(r)}, so it cannot declare module '${o}' - import it at the top level of a document instead`,i(n)),t.skipBlock(n.indent))}function reportUnexpectedTopLevel(t,n,r){let a=c(n.content);if(f(r)){let r=q.has(a)?` - '${a}' belongs in a module or feature; wrap it in one, or import this file from inside one`:` - expected domain, import, concept, type, policy, persona, authentication, identity, module, seed, trigger, behavior, ui profile, theme, sample data or layout`;t.error(e.UnknownTopLevelConstruct,`Unexpected '${a}' at the top level${r}`,i(n))}else{let o=r.length===1?O:D;t.error(e.UnexpectedInPlacedFile,`Unexpected '${a}' in a file imported into ${u(r)} - expected an application declaration or ${o}`,i(n))}t.skipBlock(n.indent)}function place(e,t,n){let r=t;for(let t=e.length-2;t>=1;t--)r={kind:`FeatureSyntax`,name:e[t],description:null,authorize:null,features:[r],slices:[],fileImports:[],isPlacement:!0,location:n};return{kind:`ModuleSyntax`,name:e[0],description:null,authorize:null,features:[r],fileImports:[],isPlacement:!0,location:n}}function parseDomain(t,n,r,a){let o=R.exec(n.content);return o===null?(t.error(e.InvalidDomainDeclaration,`Invalid domain declaration '${n.content}' - expected 'domain <Qualified.Name>'`,i(n)),r):r===null?(a&&t.error(e.DomainNotFirst,`'domain' must be declared before any other construct`,i(n)),{kind:`DomainSyntax`,name:o[1],location:i(n)}):(t.error(e.DuplicateDomain,`The document already declares a domain - a document can have at most one`,i(n)),r)}function warnOnTabIndentation(t,n){let r=!1;for(let i of n)i.raw.trimStart().startsWith("```")?r=!r:!r&&W.test(i.raw)&&t.warning(e.TabIndentation,`Screenplay is indentation based - use spaces, not tabs`,a(i))}function parseConcept(t,n){let r=B.exec(n.content);if(r===null)return t.error(e.InvalidConceptDeclaration,`Invalid concept declaration '${n.content}' - expected 'concept <Name> : <Type>'`,i(n)),t.skipBlock(n.indent),{kind:`ConceptSyntax`,name:c(n.content),type:``,attributes:[],values:[],location:i(n)};let[,a,u,d]=r,f=s(t,n,a,d);u!==`Enum`&&!G.includes(u)&&t.error(e.UnknownPrimitiveType,`Unknown primitive type '${u}' - expected ${G.join(`, `)} or Enum`,i(n));let m=[],h=new A,g=null,_=!1,v=null,y=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=u===`Enum`?h.tryNumbered(t,r):void 0;if(n!==void 0)m.push(n);else if(c(r.content)===`description`&&(u!==`Enum`||r.content!==`description`||t.peekChild(r.indent)?.content.startsWith("```")===!0))v=p(t,r,v,`Concept '${a}'`);else if(x(r))continue;else if(c(r.content)===`validate`){u===`Enum`&&r.content===`validate`&&t.peekChild(r.indent)===void 0&&t.warning(e.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${a}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,i(r));let n=T(t,r,`concept`);n!==void 0&&y.push(n)}else if(c(r.content)===`generate`&&(u!==`Enum`||r.content!==`generate`)){_&&t.error(e.DuplicateGeneration,`Concept '${a}' declares generation more than once.`,i(r));let n=j(t,r,u);_||(g=n),_=!0}else o(t,r,a,f)||(u===`Enum`&&V.test(r.content)?m.push(l(r.content)):u===`Enum`?t.error(e.InvalidEnumerationValue,`Invalid enum value '${r.content}' - expected an identifier`,i(r)):(t.error(e.UnknownConceptDirective,`Unexpected '${r.content}' in concept body - expected validate, generate, 'file <path>' or '<attribute> reason "<text>"'`,i(r)),t.skipBlock(r.indent)))}let b=h.finish(t,n,m.length);return{kind:`ConceptSyntax`,name:a,type:u,attributes:f,values:m,validations:y,description:v,...g===null?{}:{generation:g},...b===void 0?{}:{valueNumbers:b},location:i(n)}}function parsePersona(t,n){let r=H.exec(n.content)?.[1]??``;r===``&&t.error(e.InvalidPersonaDeclaration,`Invalid persona declaration '${n.content}' - expected 'persona <Name>'`,i(n));let a=null,o=[];for(let s=t.peekChild(n.indent);s!==void 0;s=t.peekChild(n.indent)){t.reader.takeSignificant();let n=c(s.content);if(n===`description`)a=p(t,s,a,`Persona '${r}'`);else if(n===`policy`){let n=U.exec(s.content);n===null?t.error(e.InvalidPersonaPolicyReference,`Invalid policy reference '${s.content}' - expected 'policy <Name>'`,i(s)):o.push(n[1])}else t.error(e.UnknownPersonaDirective,`Unexpected '${n}' in persona body - expected description or policy`,i(s)),t.skipBlock(s.indent)}return{kind:`PersonaSyntax`,name:r,description:a,policies:o,location:i(n)}}export{parseApplication};
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{locationOf as i,startOf as a}from"./SourceLine.js";import{parseComplianceDirective as o,parseComplianceMarkers as s}from"./ConceptComplianceParser.js";import{firstWord as c,unescapeIdentifier as l}from"./LineText.js";import{describePlacement as u,documentPlacement as d,isDocumentPlacement as f}from"../Files/PlayPlacement.js";import{parseDescription as p}from"./DescriptionParser.js";import{parsePurpose as m}from"./PurposeParser.js";import{isFileImport as h,parseFileImport as g}from"./FileImportParser.js";import{recordAuthoredDocument as _}from"../Syntax/SourceOptions.js";import{collectInputUses as v}from"./InputUses.js";import{misplacedReactionIdentity as y}from"./ReactionIdentityParser.js";import{parseEventSource as b}from"./EventSourceParser.js";import{isFileDirective as x}from"./FileReferences.js";import{parseSystem as S}from"./OperationParser.js";import{parseExample as C}from"./SpecificationExampleParser.js";import{isBlankPublicEventOrigin as ee}from"../Syntax/PublicEventInvariants.js";import{parseType as w}from"./DeclarationParsers.js";import{parseValidate as T}from"./CommandParser.js";import{parseTriggerDeclaration as te}from"./TriggerDataParser.js";import{FeatureBody as E,featureBodyExpected as D}from"./FeatureBody.js";import{ModuleBody as ne,moduleBodyExpected as O,modulePattern as k,parseModule as re}from"./ModuleBody.js";import{EnumerationMembers as A}from"./EnumerationMembers.js";import{parseGeneration as j}from"./GenerationParser.js";import{parseIdentity as M}from"./IdentityParser.js";import{parsePolicy as N}from"./PolicyParser.js";import{parseSeed as P}from"./SeedParser.js";import{parseExposure as F,parseInstance as I}from"./CompositionParser.js";import{parseUiProfile as L}from"./UiProfileLegacyLayout.js";const R=r(`^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`),z=r(`^import\\s+([\\w.]+)(?:\\s+from\\s+"(?<origin>${t})")?$`),B=r(`^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$`),V=r(`^@?[a-z_]\\w*$`),H=r(`^persona\\s+([A-Za-z_]\\w*)$`),U=r(`^policy\\s+([A-Za-z_]\\w*)$`),W=/^[ ]*\t/,G=[`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`],K=/* @__PURE__ */ new Set([`policy`,`authentication`,`seed`,`ui`,`theme`,`trigger`,`layout`,`behavior`,`sample`]),q=/* @__PURE__ */ new Set([`slice`,`feature`,`description`,`documentation`,`authorize`,`screen`,`dialog`,`form`,`contribute`,`on`,`uses`]);function parseApplication(t,r,a=d){t.deferIdentityValidation=!0,warnOnTabIndentation(t,r);let o=a.length===1?new ne(a[0]):void 0,s=a.length>1?new E(a[a.length-1]):void 0,l=o??s,u=null,p=null,x=!1,T=null,D=!1,O=null,k=[],A=[],j=[],R=[],B=[],V=[],H=[],U=[],W=[],G=[],q=[],J=[],Y=[],X=[],Z=[],Q=!1;for(let r=t.reader.peekSignificant();r!==void 0;r=t.reader.peekSignificant()){t.reader.takeSignificant();let s=c(r.content);if(s===`command`&&/^command\s+reads(?:\s|$)/.test(r.content))D||!f(a)||!/^command\s+reads\s+protected$/.test(r.content)?t.error(e.InvalidCommandReadsDeclaration,`Declare 'command reads protected' once at the application root.`,i(r)):T=`Protected`,D=!0;else if(s===`reaction`)x||!f(a)||!/^reaction\s+batches\s+atomic$/.test(r.content)?t.error(e.InvalidReactionBatchesDeclaration,`Declare 'reaction batches atomic' once at the application root.`,i(r)):p=`Atomic`,x=!0;else if(s===`runs`)y(t,r);else if(s===`domain`)t.authoredDeclarations=!0,O=parseDomain(t,r,O,Q);else if(Q||=declaresConstruct(s,r,a),t.authoredDeclarations||=s!==`import`&&declaresConstruct(s,r,a),s===`import`&&h(r.content))l===void 0?g(t,r,A):l.tryParse(t,r);else if(s===`import`){let a=z.exec(r.content);if(a===null)t.error(e.InvalidImportDeclaration,`Invalid import '${r.content}' - expected 'import <Qualified.Name> [from "<origin>"]'`,i(r));else{let o=a.groups?.origin===void 0?null:n(a.groups.origin);o!==null&&ee(o)&&t.error(e.InvalidImportDeclaration,`An import origin must be a nonblank quoted string`,i(r)),k.push({kind:`ImportSyntax`,qualifiedName:a[1],origin:o,visibility:o===null?`Private`:`Public`,location:i(r)})}}else if(s===`example`)l===void 0?J.push(C(t,r)):l.tryParse(t,r);else if(s===`eventsource`)V.push(b(t,r));else if(s===`system`)B.push(S(t,r));else if(s===`concept`)j.push(parseConcept(t,r));else if(s===`type`)R.push(w(t,r));else if(s===`module`&&!f(a))parseModuleInPlacedFile(t,r,a,o);else if(s===`module`)H.push(re(t,r));else if(s===`persona`)U.push(parsePersona(t,r));else if(s===`seed`)q.push(P(t.valueContext,r));else if(s===`purpose`&&l!==void 0)l.tryParse(t,r);else if(s===`purpose`)G.push(m(t,r));else if(s===`identity`)u=M(t,r,u);else if(s===`policy`)W.push(N(t,r));else if(s===`exposure`)X.push(F(t,r));else if(s===`instance`)Z.push(I(t,r));else if(s===`trigger`){let e=te(t,r),n=/^trigger\s+([A-Za-z_]\w*)$/.exec(r.content)?.[1];n!==void 0&&Y.push({name:n,data:e})}else K.has(s)?s===`behavior`||s===`layout`?v(t,r):s===`ui`?L(t,r):t.skipOpaqueBlock(r.indent):l?.tryParse(t,r)!==!0&&reportUnexpectedTopLevel(t,r,a)}o===void 0?s!==void 0&&H.unshift(place(a,s.build(t.start,!0),t.start)):H.unshift(o.build(t.start,!0));let $={kind:`ApplicationSyntax`,...T===null?{}:{commandReadMode:T},...p===null?{}:{reactionProductionMode:p},...u===null?{}:{identity:u},sourceOptions:t.sourceOptions,domain:O,imports:k,concepts:j,types:R,systems:B,eventSources:V,examples:J,modules:H,personas:U,policies:W,purposes:G,seeds:q,declaredTriggers:Y,fileImports:A,...X.length>0?{exposures:X}:{},...Z.length>0?{instanceContributions:Z}:{},location:t.start};return t.authoredDeclarations&&_($),$}function declaresConstruct(e,t,n){return e===`import`?z.test(t.content):e===`module`?f(n):e===`identity`?t.content===`identity`:e===`purpose`||e===`example`||e===`exposure`||e===`instance`||e===`eventsource`||e===`system`||e===`concept`||e===`type`||e===`persona`||K.has(e)}function parseModuleInPlacedFile(t,n,r,a){let o=k.exec(n.content)?.[1]??``;a!==void 0&&o===r[0]?(t.authoredDeclarations=!0,a.parseChildren(t,n)):(t.error(e.ModuleInPlacedFile,`This file is imported into ${u(r)}, so it cannot declare module '${o}' - import it at the top level of a document instead`,i(n)),t.skipBlock(n.indent))}function reportUnexpectedTopLevel(t,n,r){let a=c(n.content);if(f(r)){let r=q.has(a)?` - '${a}' belongs in a module or feature; wrap it in one, or import this file from inside one`:` - expected domain, import, concept, type, policy, persona, authentication, identity, module, seed, trigger, behavior, ui profile, theme, sample data or layout`;t.error(e.UnknownTopLevelConstruct,`Unexpected '${a}' at the top level${r}`,i(n))}else{let o=r.length===1?O:D;t.error(e.UnexpectedInPlacedFile,`Unexpected '${a}' in a file imported into ${u(r)} - expected an application declaration or ${o}`,i(n))}t.skipBlock(n.indent)}function place(e,t,n){let r=t;for(let t=e.length-2;t>=1;t--)r={kind:`FeatureSyntax`,name:e[t],description:null,authorize:null,features:[r],slices:[],fileImports:[],isPlacement:!0,location:n};return{kind:`ModuleSyntax`,name:e[0],description:null,authorize:null,features:[r],fileImports:[],isPlacement:!0,location:n}}function parseDomain(t,n,r,a){let o=R.exec(n.content);return o===null?(t.error(e.InvalidDomainDeclaration,`Invalid domain declaration '${n.content}' - expected 'domain <Qualified.Name>'`,i(n)),r):r===null?(a&&t.error(e.DomainNotFirst,`'domain' must be declared before any other construct`,i(n)),{kind:`DomainSyntax`,name:o[1],location:i(n)}):(t.error(e.DuplicateDomain,`The document already declares a domain - a document can have at most one`,i(n)),r)}function warnOnTabIndentation(t,n){let r=!1;for(let i of n)i.raw.trimStart().startsWith("```")?r=!r:!r&&W.test(i.raw)&&t.warning(e.TabIndentation,`Screenplay is indentation based - use spaces, not tabs`,a(i))}function parseConcept(t,n){let r=B.exec(n.content);if(r===null)return t.error(e.InvalidConceptDeclaration,`Invalid concept declaration '${n.content}' - expected 'concept <Name> : <Type>'`,i(n)),t.skipBlock(n.indent),{kind:`ConceptSyntax`,name:c(n.content),type:``,attributes:[],values:[],location:i(n)};let[,a,u,d]=r,f=s(t,n,a,d);u!==`Enum`&&!G.includes(u)&&t.error(e.UnknownPrimitiveType,`Unknown primitive type '${u}' - expected ${G.join(`, `)} or Enum`,i(n));let m=[],h=new A,g=null,_=!1,v=null,y=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=u===`Enum`?h.tryNumbered(t,r):void 0;if(n!==void 0)m.push(n);else if(c(r.content)===`description`&&(u!==`Enum`||r.content!==`description`||t.peekChild(r.indent)?.content.startsWith("```")===!0))v=p(t,r,v,`Concept '${a}'`);else if(x(r))continue;else if(c(r.content)===`validate`){u===`Enum`&&r.content===`validate`&&t.peekChild(r.indent)===void 0&&t.warning(e.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${a}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,i(r));let n=T(t,r,`concept`,a);n!==void 0&&y.push(n)}else if(c(r.content)===`generate`&&(u!==`Enum`||r.content!==`generate`)){_&&t.error(e.DuplicateGeneration,`Concept '${a}' declares generation more than once.`,i(r));let n=j(t,r,u);_||(g=n),_=!0}else o(t,r,a,f)||(u===`Enum`&&V.test(r.content)?m.push(l(r.content)):u===`Enum`?t.error(e.InvalidEnumerationValue,`Invalid enum value '${r.content}' - expected an identifier`,i(r)):(t.error(e.UnknownConceptDirective,`Unexpected '${r.content}' in concept body - expected validate, generate, 'file <path>' or '<attribute> reason "<text>"'`,i(r)),t.skipBlock(r.indent)))}let b=h.finish(t,n,m.length);return{kind:`ConceptSyntax`,name:a,type:u,attributes:f,values:m,validations:y,description:v,...g===null?{}:{generation:g},...b===void 0?{}:{valueNumbers:b},location:i(n)}}function parsePersona(t,n){let r=H.exec(n.content)?.[1]??``;r===``&&t.error(e.InvalidPersonaDeclaration,`Invalid persona declaration '${n.content}' - expected 'persona <Name>'`,i(n));let a=null,o=[];for(let s=t.peekChild(n.indent);s!==void 0;s=t.peekChild(n.indent)){t.reader.takeSignificant();let n=c(s.content);if(n===`description`)a=p(t,s,a,`Persona '${r}'`);else if(n===`policy`){let n=U.exec(s.content);n===null?t.error(e.InvalidPersonaPolicyReference,`Invalid policy reference '${s.content}' - expected 'policy <Name>'`,i(s)):o.push(n[1])}else t.error(e.UnknownPersonaDirective,`Unexpected '${n}' in persona body - expected description or policy`,i(s)),t.skipBlock(s.indent)}return{kind:`PersonaSyntax`,name:r,description:a,policies:o,location:i(n)}}export{parseApplication};
|
|
2
2
|
//# sourceMappingURL=ScreenplayParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScreenplayParser.js","names":["domainPattern","pattern","importPattern","stringBodyPattern","conceptPattern","enumValuePattern","personaPattern","personaPolicyPattern","tabIndentPattern","primitiveTypes","opaqueTopLevel","bodyKeywords","documentPlacement","context","lines","moduleBody","placement","ModuleBody","featureBody","FeatureBody","placedBody","identity","reactionProductionMode","sawReactionBatches","commandReadMode","sawCommandReads","domain","imports","fileImports","concepts","types","systems","eventSources","modules","personas","policies","purposes","seeds","examples","declaredTriggers","exposures","instanceContributions","sawOtherConstruct","line","keyword","firstWord","isDocumentPlacement","DiagnosticCodes","locationOf","misplacedReactionIdentity","isFileImport","parseFileImport","match","origin","unescapeString","isBlankPublicEventOrigin","parseExample","parseEventSource","parseSystem","parseType","parseModule","parseSeed","parsePurpose","parseIdentity","parsePolicy","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","valueNumbers","policy"],"sources":["../../../../../../Compiler/Parsing/ScreenplayParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { CommandReadMode } from '../Syntax/CommandReadMode';\nimport { ReactionProductionMode } from '../Syntax/ReactionProductionMode';\nimport { EnumerationMembers } from './EnumerationMembers';\nimport { GenerationSyntax } from '../Syntax/GenerationSyntax';\nimport { parseGeneration } from './GenerationParser';\nimport { IdentitySyntax } from '../Syntax/IdentitySyntax';\nimport { parseIdentity } from './IdentityParser';\nimport { misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { recordAuthoredDocument } from '../Syntax/SourceOptions';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { describePlacement, documentPlacement, isDocumentPlacement, PlayPlacement } from '../Files/PlayPlacement';\nimport { PersonaSyntax } from '../Syntax/Authorization';\nimport { ConceptSyntax, DomainSyntax, ImportSyntax, TypeSyntax } from '../Syntax/Declarations';\nimport { SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { ApplicationSyntax, FeatureSyntax, FileImportSyntax, ModuleSyntax } from '../Syntax/Structure';\nimport { parseTriggerDeclaration } from './TriggerDataParser';\nimport { pattern } from '../Text/patterns';\nimport { parseComplianceDirective, parseComplianceMarkers } from './ConceptComplianceParser';\nimport { parseType } from './DeclarationParsers';\nimport { ValidateSyntax } from '../Syntax/Commands';\nimport { parseValidate } from './CommandParser';\nimport { parseDescription } from './DescriptionParser';\nimport { FeatureBody, featureBodyExpected } from './FeatureBody';\nimport { isFileImport, parseFileImport } from './FileImportParser';\nimport { isFileDirective } from './FileReferences';\nimport { collectInputUses } from './InputUses';\nimport { firstWord, unescapeIdentifier } from './LineText';\nimport { ModuleBody, moduleBodyExpected, modulePattern, parseModule } from './ModuleBody';\nimport { ParserContext } from './ParserContext';\nimport { PolicySyntax } from '../Syntax/Policies';\nimport { parsePolicy } from './PolicyParser';\nimport { PurposeSyntax } from '../Syntax/Purposes';\nimport { parsePurpose } from './PurposeParser';\nimport { SeedSyntax } from '../Syntax/Seeds';\nimport { parseSeed } from './SeedParser';\nimport { parseSystem } from './OperationParser';\nimport { EventVisibility } from '../Syntax/EventVisibility';\nimport { isBlankPublicEventOrigin } from '../Syntax/PublicEventInvariants';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { SystemSyntax } from '../Syntax/Operations';\nimport { EventSourceSyntax } from '../Syntax/EventSources';\nimport { parseEventSource } from './EventSourceParser';\nimport { parseExposure, parseInstance } from './CompositionParser';\nimport { ExposureSyntax, InstanceContributionsSyntax } from '../Syntax/CompositionSyntax';\nimport { parseExample } from './SpecificationExampleParser';\nimport { parseUiProfile } from './UiProfileLegacyLayout';\nimport { locationOf, SourceLine, startOf } from './SourceLine';\n\nconst domainPattern = pattern('^domain\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)$');\nconst importPattern = pattern(`^import\\\\s+([\\\\w.]+)(?:\\\\s+from\\\\s+\"(?<origin>${stringBodyPattern})\")?$`);\nconst conceptPattern = pattern('^concept\\\\s+(\\\\w+)\\\\s*:\\\\s*(\\\\w+)((?:\\\\s+@?\\\\w+)*)$');\nconst enumValuePattern = pattern('^@?[a-z_]\\\\w*$');\nconst personaPattern = pattern('^persona\\\\s+([A-Za-z_]\\\\w*)$');\nconst personaPolicyPattern = pattern('^policy\\\\s+([A-Za-z_]\\\\w*)$');\nconst tabIndentPattern = /^[ ]*\\t/;\nconst primitiveTypes = ['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime'];\n\n// Top-level, module and feature constructs the C# compiler knows that this compiler does not model. They\n// are skipped whole, not reported.\nconst opaqueTopLevel = new Set(['policy', 'authentication', 'seed', 'ui', 'theme', 'trigger', 'layout', 'behavior', '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 reactionProductionMode: ReactionProductionMode | null = null;\n let sawReactionBatches = false;\n let commandReadMode: CommandReadMode | null = null;\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 eventSources: EventSourceSyntax[] = [];\n const modules: ModuleSyntax[] = [];\n const personas: PersonaSyntax[] = [];\n const policies: PolicySyntax[] = [];\n const purposes: PurposeSyntax[] = [];\n const seeds: SeedSyntax[] = [];\n const examples: SpecificationExampleSyntax[] = [];\n const declaredTriggers: NonNullable<ApplicationSyntax['declaredTriggers']>[number][] = [];\n const exposures: ExposureSyntax[] = [];\n const instanceContributions: InstanceContributionsSyntax[] = [];\n let sawOtherConstruct = false;\n for (let line = context.reader.peekSignificant(); line !== undefined; line = context.reader.peekSignificant()) {\n context.reader.takeSignificant();\n const keyword = firstWord(line.content);\n if (keyword === '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 === '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 === 'concept') {\n concepts.push(parseConcept(context, line));\n } else if (keyword === 'type') {\n types.push(parseType(context, line));\n } else if (keyword === 'module' && !isDocumentPlacement(placement)) {\n parseModuleInPlacedFile(context, line, placement, moduleBody);\n } else if (keyword === 'module') {\n modules.push(parseModule(context, line));\n } else if (keyword === 'persona') {\n personas.push(parsePersona(context, line));\n } else if (keyword === 'seed') {\n seeds.push(parseSeed(context.valueContext, line));\n } else if (keyword === 'purpose' && placedBody !== undefined) {\n placedBody.tryParse(context, line);\n } else if (keyword === 'purpose') {\n purposes.push(parsePurpose(context, line));\n } else if (keyword === 'identity') {\n identity = parseIdentity(context, line, identity);\n } else if (keyword === 'policy') {\n // Legacy policies were opaque: enrich their structure without adding diagnostics.\n policies.push(parsePolicy(context, line));\n } else if (keyword === 'exposure') {\n exposures.push(parseExposure(context, line));\n } else if (keyword === 'instance') {\n instanceContributions.push(parseInstance(context, line));\n } else if (keyword === 'trigger') {\n const data = parseTriggerDeclaration(context, line);\n const name = /^trigger\\s+([A-Za-z_]\\w*)$/.exec(line.content)?.[1];\n if (name !== undefined) declaredTriggers.push({ name, data });\n } else if (opaqueTopLevel.has(keyword)) {\n if (keyword === 'behavior' || keyword === 'layout') collectInputUses(context, line);\n else 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 }), ...(reactionProductionMode === null ? {} : { reactionProductionMode }), ...(identity === null ? {} : { identity }), sourceOptions: context.sourceOptions, domain, imports, concepts, types, systems, eventSources, examples, modules, personas, policies, purposes, seeds, declaredTriggers, fileImports, ...(exposures.length > 0 ? { exposures } : {}), ...(instanceContributions.length > 0 ? { instanceContributions } : {}), location: context.start };\n if (context.authoredDeclarations) recordAuthoredDocument(root);\n return root;\n}\n\nfunction declaresConstruct(keyword: string, line: SourceLine, placement: PlayPlacement): boolean {\n if (keyword === 'import') {\n return importPattern.test(line.content);\n }\n if (keyword === 'module') {\n return isDocumentPlacement(placement);\n }\n if (keyword === 'identity') return line.content === 'identity';\n return keyword === 'purpose' || keyword === 'example' || keyword === 'exposure' || keyword === 'instance' || keyword === 'eventsource' || keyword === 'system' || keyword === 'concept' || keyword === 'type' || keyword === 'persona' || opaqueTopLevel.has(keyword);\n}\n\nfunction parseModuleInPlacedFile(context: ParserContext, line: SourceLine, placement: PlayPlacement, moduleBody: ModuleBody | undefined): void {\n const name = modulePattern.exec(line.content)?.[1] ?? '';\n\n // Restating the module a file is placed in says nothing new, so its body simply joins the placement.\n if (moduleBody !== undefined && name === placement[0]) {\n context.authoredDeclarations = true;\n moduleBody.parseChildren(context, line);\n return;\n }\n context.error(DiagnosticCodes.ModuleInPlacedFile,\n `This file is imported into ${describePlacement(placement)}, so it cannot declare module '${name}' - import it at the top level of a document instead`, locationOf(line));\n context.skipBlock(line.indent);\n}\n\nfunction reportUnexpectedTopLevel(context: ParserContext, line: SourceLine, placement: PlayPlacement): void {\n const word = firstWord(line.content);\n if (!isDocumentPlacement(placement)) {\n const expected = placement.length === 1 ? moduleBodyExpected : featureBodyExpected;\n context.error(DiagnosticCodes.UnexpectedInPlacedFile,\n `Unexpected '${word}' in a file imported into ${describePlacement(placement)} - expected an application declaration or ${expected}`, locationOf(line));\n } else {\n const hint = bodyKeywords.has(word)\n ? ` - '${word}' belongs in a module or feature; wrap it in one, or import this file from inside one`\n : ' - expected domain, import, concept, type, policy, persona, authentication, identity, module, seed, trigger, behavior, ui profile, theme, 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');\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>\"'`, 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 for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'description') {\n description = parseDescription(context, child, description, `Persona '${name}'`);\n } else if (keyword === 'policy') {\n const policy = personaPolicyPattern.exec(child.content);\n if (policy === null) {\n context.error(DiagnosticCodes.InvalidPersonaPolicyReference, `Invalid policy reference '${child.content}' - expected 'policy <Name>'`, locationOf(child));\n } else {\n policies.push(policy[1]);\n }\n } else {\n context.error(DiagnosticCodes.UnknownPersonaDirective, `Unexpected '${keyword}' in persona body - expected description or policy`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return { kind: 'PersonaSyntax', name, description, policies, location: locationOf(line) };\n}\n"],"mappings":"k9DAoDA,MAAMA,EAAgBC,EAAQ,kDAAkD,EAC1EC,EAAgBD,EAAQ,iDAAiDE,EAAkB,MAAM,EACjGC,EAAiBH,EAAQ,qDAAqD,EAC9EI,EAAmBJ,EAAQ,gBAAgB,EAC3CK,EAAiBL,EAAQ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AiC,CAC3E,IAAM0B,EAAO/D,EAAe,KAAKqC,EAAK,OAAO,CAAC,GAAG,IAAM,GACnD0B,IAAS,IACTxD,EAAQ,MAAMkC,EAAgB,0BAA2B,gCAAgCJ,EAAK,QAAQ,+BAAgCK,EAAWL,CAAI,CAAC,EAE1J,IAAIsD,EAA6B,KAC3B9D,EAAqB,CAAC,EAC5B,IAAK,IAAIgE,EAAQtF,EAAQ,UAAU8B,EAAK,MAAM,EAAGwD,IAAU,IAAA,GAAW,EAAQtF,EAAQ,UAAU8B,EAAK,MAAM,EAAG,CAC1G9B,EAAQ,OAAO,gBAAgB,EAC/B,IAAM+B,EAAUC,EAAUsD,EAAM,OAAO,EACvC,GAAIvD,IAAY,cACZ,EAAcyD,EAAiBxF,EAASsF,EAAOF,EAAa,YAAY5B,EAAK,EAAE,OAC5E,GAAIzB,IAAY,SAAU,CAC7B,IAAMiE,EAAStG,EAAqB,KAAK4F,EAAM,OAAO,EAClDU,IAAW,KACXhG,EAAQ,MAAMkC,EAAgB,8BAA+B,6BAA6BoD,EAAM,QAAQ,8BAA+BnD,EAAWmD,CAAK,CAAC,EAExJhE,EAAS,KAAK0E,EAAO,EAAE,CAE/B,MACIhG,EAAQ,MAAMkC,EAAgB,wBAAyB,eAAeH,EAAQ,oDAAqDI,EAAWmD,CAAK,CAAC,EACpJtF,EAAQ,UAAUsF,EAAM,MAAM,CAEtC,CACA,MAAO,CAAE,KAAM,gBAAiB,OAAM,cAAa,WAAU,SAAUnD,EAAWL,CAAI,CAAE,CAC5F"}
|
|
1
|
+
{"version":3,"file":"ScreenplayParser.js","names":["domainPattern","pattern","importPattern","stringBodyPattern","conceptPattern","enumValuePattern","personaPattern","personaPolicyPattern","tabIndentPattern","primitiveTypes","opaqueTopLevel","bodyKeywords","documentPlacement","context","lines","moduleBody","placement","ModuleBody","featureBody","FeatureBody","placedBody","identity","reactionProductionMode","sawReactionBatches","commandReadMode","sawCommandReads","domain","imports","fileImports","concepts","types","systems","eventSources","modules","personas","policies","purposes","seeds","examples","declaredTriggers","exposures","instanceContributions","sawOtherConstruct","line","keyword","firstWord","isDocumentPlacement","DiagnosticCodes","locationOf","misplacedReactionIdentity","isFileImport","parseFileImport","match","origin","unescapeString","isBlankPublicEventOrigin","parseExample","parseEventSource","parseSystem","parseType","parseModule","parseSeed","parsePurpose","parseIdentity","parsePolicy","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","valueNumbers","policy"],"sources":["../../../../../../Compiler/Parsing/ScreenplayParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { CommandReadMode } from '../Syntax/CommandReadMode';\nimport { ReactionProductionMode } from '../Syntax/ReactionProductionMode';\nimport { EnumerationMembers } from './EnumerationMembers';\nimport { GenerationSyntax } from '../Syntax/GenerationSyntax';\nimport { parseGeneration } from './GenerationParser';\nimport { IdentitySyntax } from '../Syntax/IdentitySyntax';\nimport { parseIdentity } from './IdentityParser';\nimport { misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { recordAuthoredDocument } from '../Syntax/SourceOptions';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { describePlacement, documentPlacement, isDocumentPlacement, PlayPlacement } from '../Files/PlayPlacement';\nimport { PersonaSyntax } from '../Syntax/Authorization';\nimport { ConceptSyntax, DomainSyntax, ImportSyntax, TypeSyntax } from '../Syntax/Declarations';\nimport { SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { ApplicationSyntax, FeatureSyntax, FileImportSyntax, ModuleSyntax } from '../Syntax/Structure';\nimport { parseTriggerDeclaration } from './TriggerDataParser';\nimport { pattern } from '../Text/patterns';\nimport { parseComplianceDirective, parseComplianceMarkers } from './ConceptComplianceParser';\nimport { parseType } from './DeclarationParsers';\nimport { ValidateSyntax } from '../Syntax/Commands';\nimport { parseValidate } from './CommandParser';\nimport { parseDescription } from './DescriptionParser';\nimport { FeatureBody, featureBodyExpected } from './FeatureBody';\nimport { isFileImport, parseFileImport } from './FileImportParser';\nimport { isFileDirective } from './FileReferences';\nimport { collectInputUses } from './InputUses';\nimport { firstWord, unescapeIdentifier } from './LineText';\nimport { ModuleBody, moduleBodyExpected, modulePattern, parseModule } from './ModuleBody';\nimport { ParserContext } from './ParserContext';\nimport { PolicySyntax } from '../Syntax/Policies';\nimport { parsePolicy } from './PolicyParser';\nimport { PurposeSyntax } from '../Syntax/Purposes';\nimport { parsePurpose } from './PurposeParser';\nimport { SeedSyntax } from '../Syntax/Seeds';\nimport { parseSeed } from './SeedParser';\nimport { parseSystem } from './OperationParser';\nimport { EventVisibility } from '../Syntax/EventVisibility';\nimport { isBlankPublicEventOrigin } from '../Syntax/PublicEventInvariants';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { SystemSyntax } from '../Syntax/Operations';\nimport { EventSourceSyntax } from '../Syntax/EventSources';\nimport { parseEventSource } from './EventSourceParser';\nimport { parseExposure, parseInstance } from './CompositionParser';\nimport { ExposureSyntax, InstanceContributionsSyntax } from '../Syntax/CompositionSyntax';\nimport { parseExample } from './SpecificationExampleParser';\nimport { parseUiProfile } from './UiProfileLegacyLayout';\nimport { locationOf, SourceLine, startOf } from './SourceLine';\n\nconst domainPattern = pattern('^domain\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)$');\nconst importPattern = pattern(`^import\\\\s+([\\\\w.]+)(?:\\\\s+from\\\\s+\"(?<origin>${stringBodyPattern})\")?$`);\nconst conceptPattern = pattern('^concept\\\\s+(\\\\w+)\\\\s*:\\\\s*(\\\\w+)((?:\\\\s+@?\\\\w+)*)$');\nconst enumValuePattern = pattern('^@?[a-z_]\\\\w*$');\nconst personaPattern = pattern('^persona\\\\s+([A-Za-z_]\\\\w*)$');\nconst personaPolicyPattern = pattern('^policy\\\\s+([A-Za-z_]\\\\w*)$');\nconst tabIndentPattern = /^[ ]*\\t/;\nconst primitiveTypes = ['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime'];\n\n// Top-level, module and feature constructs the C# compiler knows that this compiler does not model. They\n// are skipped whole, not reported.\nconst opaqueTopLevel = new Set(['policy', 'authentication', 'seed', 'ui', 'theme', 'trigger', 'layout', 'behavior', '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 reactionProductionMode: ReactionProductionMode | null = null;\n let sawReactionBatches = false;\n let commandReadMode: CommandReadMode | null = null;\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 eventSources: EventSourceSyntax[] = [];\n const modules: ModuleSyntax[] = [];\n const personas: PersonaSyntax[] = [];\n const policies: PolicySyntax[] = [];\n const purposes: PurposeSyntax[] = [];\n const seeds: SeedSyntax[] = [];\n const examples: SpecificationExampleSyntax[] = [];\n const declaredTriggers: NonNullable<ApplicationSyntax['declaredTriggers']>[number][] = [];\n const exposures: ExposureSyntax[] = [];\n const instanceContributions: InstanceContributionsSyntax[] = [];\n let sawOtherConstruct = false;\n for (let line = context.reader.peekSignificant(); line !== undefined; line = context.reader.peekSignificant()) {\n context.reader.takeSignificant();\n const keyword = firstWord(line.content);\n if (keyword === '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 === '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 === 'concept') {\n concepts.push(parseConcept(context, line));\n } else if (keyword === 'type') {\n types.push(parseType(context, line));\n } else if (keyword === 'module' && !isDocumentPlacement(placement)) {\n parseModuleInPlacedFile(context, line, placement, moduleBody);\n } else if (keyword === 'module') {\n modules.push(parseModule(context, line));\n } else if (keyword === 'persona') {\n personas.push(parsePersona(context, line));\n } else if (keyword === 'seed') {\n seeds.push(parseSeed(context.valueContext, line));\n } else if (keyword === 'purpose' && placedBody !== undefined) {\n placedBody.tryParse(context, line);\n } else if (keyword === 'purpose') {\n purposes.push(parsePurpose(context, line));\n } else if (keyword === 'identity') {\n identity = parseIdentity(context, line, identity);\n } else if (keyword === 'policy') {\n // Legacy policies were opaque: enrich their structure without adding diagnostics.\n policies.push(parsePolicy(context, line));\n } else if (keyword === 'exposure') {\n exposures.push(parseExposure(context, line));\n } else if (keyword === 'instance') {\n instanceContributions.push(parseInstance(context, line));\n } else if (keyword === 'trigger') {\n const data = parseTriggerDeclaration(context, line);\n const name = /^trigger\\s+([A-Za-z_]\\w*)$/.exec(line.content)?.[1];\n if (name !== undefined) declaredTriggers.push({ name, data });\n } else if (opaqueTopLevel.has(keyword)) {\n if (keyword === 'behavior' || keyword === 'layout') collectInputUses(context, line);\n else 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 }), ...(reactionProductionMode === null ? {} : { reactionProductionMode }), ...(identity === null ? {} : { identity }), sourceOptions: context.sourceOptions, domain, imports, concepts, types, systems, eventSources, examples, modules, personas, policies, purposes, seeds, declaredTriggers, fileImports, ...(exposures.length > 0 ? { exposures } : {}), ...(instanceContributions.length > 0 ? { instanceContributions } : {}), location: context.start };\n if (context.authoredDeclarations) recordAuthoredDocument(root);\n return root;\n}\n\nfunction declaresConstruct(keyword: string, line: SourceLine, placement: PlayPlacement): boolean {\n if (keyword === 'import') {\n return importPattern.test(line.content);\n }\n if (keyword === 'module') {\n return isDocumentPlacement(placement);\n }\n if (keyword === 'identity') return line.content === 'identity';\n return keyword === 'purpose' || keyword === 'example' || keyword === 'exposure' || keyword === 'instance' || keyword === 'eventsource' || keyword === 'system' || keyword === 'concept' || keyword === 'type' || keyword === 'persona' || opaqueTopLevel.has(keyword);\n}\n\nfunction parseModuleInPlacedFile(context: ParserContext, line: SourceLine, placement: PlayPlacement, moduleBody: ModuleBody | undefined): void {\n const name = modulePattern.exec(line.content)?.[1] ?? '';\n\n // Restating the module a file is placed in says nothing new, so its body simply joins the placement.\n if (moduleBody !== undefined && name === placement[0]) {\n context.authoredDeclarations = true;\n moduleBody.parseChildren(context, line);\n return;\n }\n context.error(DiagnosticCodes.ModuleInPlacedFile,\n `This file is imported into ${describePlacement(placement)}, so it cannot declare module '${name}' - import it at the top level of a document instead`, locationOf(line));\n context.skipBlock(line.indent);\n}\n\nfunction reportUnexpectedTopLevel(context: ParserContext, line: SourceLine, placement: PlayPlacement): void {\n const word = firstWord(line.content);\n if (!isDocumentPlacement(placement)) {\n const expected = placement.length === 1 ? moduleBodyExpected : featureBodyExpected;\n context.error(DiagnosticCodes.UnexpectedInPlacedFile,\n `Unexpected '${word}' in a file imported into ${describePlacement(placement)} - expected an application declaration or ${expected}`, locationOf(line));\n } else {\n const hint = bodyKeywords.has(word)\n ? ` - '${word}' belongs in a module or feature; wrap it in one, or import this file from inside one`\n : ' - expected domain, import, concept, type, policy, persona, authentication, identity, module, seed, trigger, behavior, ui profile, theme, 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>\"'`, 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 for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'description') {\n description = parseDescription(context, child, description, `Persona '${name}'`);\n } else if (keyword === 'policy') {\n const policy = personaPolicyPattern.exec(child.content);\n if (policy === null) {\n context.error(DiagnosticCodes.InvalidPersonaPolicyReference, `Invalid policy reference '${child.content}' - expected 'policy <Name>'`, locationOf(child));\n } else {\n policies.push(policy[1]);\n }\n } else {\n context.error(DiagnosticCodes.UnknownPersonaDirective, `Unexpected '${keyword}' in persona body - expected description or policy`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return { kind: 'PersonaSyntax', name, description, policies, location: locationOf(line) };\n}\n"],"mappings":"k9DAoDA,MAAMA,EAAgBC,EAAQ,kDAAkD,EAC1EC,EAAgBD,EAAQ,iDAAiDE,EAAkB,MAAM,EACjGC,EAAiBH,EAAQ,qDAAqD,EAC9EI,EAAmBJ,EAAQ,gBAAgB,EAC3CK,EAAiBL,EAAQ,8BAA8B,EACvDM,EAAuBN,EAAQ,6BAA6B,EAC5DO,EAAmB,UACnBC,EAAiB,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,UAAU,EAIhFC,kBAAiB,IAAI,IAAI,CAAC,SAAU,iBAAkB,OAAQ,KAAM,QAAS,UAAW,SAAU,WAAY,QAAQ,CAAC,EAGvHC,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,EAC7BG,EAAkC,KAClCC,EAAwD,KACxDC,EAAqB,GACrBC,EAA0C,KAC1CC,EAAkB,GAClBC,EAA8B,KAC5BC,EAA0B,CAAC,EAC3BC,EAAkC,CAAC,EACnCC,EAA4B,CAAC,EAC7BC,EAAsB,CAAC,EACvBC,EAA0B,CAAC,EAC3BC,EAAoC,CAAC,EACrCC,EAA0B,CAAC,EAC3B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