@cratis/screenplay-language 4.239.0 → 4.240.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";const r=t(`^(position|size)\\s+(-?\\d+)\\s+(-?\\d+)$`);function parseCanvasPair(t,i,a,o,s,c,l){let u=r.exec(i.content),d=u===null?NaN:Number.parseInt(u[2],10),f=u===null?NaN:Number.parseInt(u[3],10);return u!==null&&u[1]===a&&Number.isSafeInteger(d)&&Number.isSafeInteger(f)&&d>=-2147483648&&d<=2147483647&&f>=-2147483648&&f<=2147483647&&(l||d>=0&&f>=0)?c===null?[d,f]:(t.error(e.InvalidPersonaDeclaration,`The ${a} is already declared - at most one is allowed`,n(i)),null):(t.error(e.InvalidPersonaDeclaration,`Invalid ${a} '${i.content}' - expected '${a} <${o}> <${s}>' with whole numbers${l?``:` that are not negative`}`,n(i)),null)}export{parseCanvasPair};
2
+ //# sourceMappingURL=CanvasPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CanvasPlacement.js","names":["canvasPairPattern","pattern","match","line","firstValue","secondValue","keyword","allowNegative","existing","context","DiagnosticCodes","locationOf","first","second"],"sources":["../../../../../../Compiler/Parsing/CanvasPlacement.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 { pattern } from '../Text/patterns';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst canvasPairPattern = pattern('^(position|size)\\\\s+(-?\\\\d+)\\\\s+(-?\\\\d+)$');\n\n// 'position <x> <y>' or 'size <width> <height>' - two whole numbers in canvas units; a second line is a mistake.\nexport function parseCanvasPair(context: ParserContext, line: SourceLine, keyword: string, first: string, second: string, existing: readonly [number, number] | null, allowNegative: boolean): readonly [number, number] | null {\n const match = canvasPairPattern.exec(line.content);\n const firstValue = match === null ? Number.NaN : Number.parseInt(match[2], 10);\n const secondValue = match === null ? Number.NaN : Number.parseInt(match[3], 10);\n const valid = match !== null && match[1] === keyword && Number.isSafeInteger(firstValue) && Number.isSafeInteger(secondValue)\n && firstValue >= -2147483648 && firstValue <= 2147483647 && secondValue >= -2147483648 && secondValue <= 2147483647\n && (allowNegative || (firstValue >= 0 && secondValue >= 0));\n if (!valid) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid ${keyword} '${line.content}' - expected '${keyword} <${first}> <${second}>' with whole numbers${allowNegative ? '' : ' that are not negative'}`, locationOf(line));\n return null;\n }\n if (existing !== null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `The ${keyword} is already declared - at most one is allowed`, locationOf(line));\n return null;\n }\n return [firstValue, secondValue];\n}\n"],"mappings":"oNAQA,MAAMA,EAAoBC,EAAQ,2CAA2C,EAG7E,SAAgB,gBAAgB,EAAwB,EAAkB,EAAiB,EAAe,EAAgB,EAA4C,EAA0D,CAC5N,IAAMC,EAAQF,EAAkB,KAAKG,EAAK,OAAO,EAC3CC,EAAaF,IAAU,KAAO,IAAa,OAAO,SAASA,EAAM,GAAI,EAAE,EACvEG,EAAcH,IAAU,KAAO,IAAa,OAAO,SAASA,EAAM,GAAI,EAAE,EAY9E,OAXcA,IAAU,MAAQA,EAAM,KAAOI,GAAW,OAAO,cAAcF,CAAU,GAAK,OAAO,cAAcC,CAAW,GACrHD,GAAc,aAAeA,GAAc,YAAcC,GAAe,aAAeA,GAAe,aACrGE,GAAkBH,GAAc,GAAKC,GAAe,GAKxDG,IAAa,KAIV,CAACJ,EAAYC,CAAW,GAH3BI,EAAQ,MAAMC,EAAgB,0BAA2B,OAAOJ,EAAQ,+CAAgDK,EAAWR,CAAI,CAAC,EACjI,OALPM,EAAQ,MAAMC,EAAgB,0BAA2B,WAAWJ,EAAQ,IAAIH,EAAK,QAAQ,gBAAgBG,EAAQ,IAAIM,EAAM,KAAKC,EAAO,uBAAuBN,EAAgB,GAAK,2BAA4BI,EAAWR,CAAI,CAAC,EAC5N,KAOf"}
@@ -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{parseMappingSource as a}from"./ExpressionParser.js";import{firstWord as o}from"./LineText.js";import{parseTypeRef as s,reportLegacyOptionalSuffix as c}from"./PropertyLineParser.js";import{parseDescription as l}from"./DescriptionParser.js";import{sourceStreamPattern as u}from"../Text/SourceStreamNames.js";const d=r(`^id\\s+"(${t})"$`),f=u(`^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$`),p=u(`^eventsource\\s+([A-Za-z_]\\w*)$`),m=u(`^stream\\s+([A-Za-z_]\\w*)$`);function parseEventSource(e,t){let n=p.exec(t.content)?.[1]??``;n===``&&invalid(e,t,`Expected 'eventsource <Name>'.`);let r=[],a=null,s=null,c=null;for(let i=e.peekChild(t.indent);i!==void 0;i=e.peekChild(t.indent))switch(e.reader.takeSignificant(),o(i.content)){case`stream`:r.push(parseEventStream(e,i));break;case`identifier`:a=parseType(e,i,`identifier`,a);break;case`description`:s=l(e,i,s,`Event source '${n}'`,!0);break;case`id`:c=parsePin(e,i,n,c);break;default:invalid(e,i,`An event source accepts description, id, identifier and stream declarations.`),e.skipBlock(i.indent)}return{kind:`EventSourceSyntax`,name:n,streams:r,identifier:a,description:s,id:c,location:i(t)}}function parseEventStream(e,t){let n=m.exec(t.content)?.[1]??``;n===``&&invalid(e,t,`Expected 'stream <Name>'.`);let r=null,a=[],s=!1,c={},u=null,d=null;for(let f=e.peekChild(t.indent);f!==void 0;f=e.peekChild(t.indent))switch(e.reader.takeSignificant(),o(f.content)){case`streamId`:s?(invalid(e,f,`Declare either one 'streamId <Type>' or one streamId part block.`),e.skipBlock(f.indent)):f.content===`streamId`?(s=!0,c.streamId=i(f),a=parseStreamIdParts(e,f)):(r=parseType(e,f,`streamId`,r),s=r!==null);break;case`description`:u=l(e,f,u,`Stream '${n}'`,!0);break;case`id`:d=parsePin(e,f,n,d);break;default:invalid(e,f,`A stream accepts description, id and streamId declarations.`),e.skipBlock(f.indent)}return{kind:`EventStreamSyntax`,name:n,streamId:r,streamIdParts:a,description:u,id:d,directiveLocations:c,location:i(t)}}function parseType(t,n,r,a){let o=f.exec(n.content);return o===null||a!==null?invalid(t,n,`Declare at most one '${r} <Type>'.`):(a=s(o[2],{...i(n),column:n.indent+1+n.content.indexOf(o[2],r.length)}),c(t,a,n)),rejectChildren(t,n,e.InvalidEventSourceDeclaration),a}function parsePin(t,r,a,o){let s=d.exec(r.content),c=s===null?null:n(s[1]);return c===null||c.trim()===``||o!==null?invalid(t,r,`Declare at most one nonempty rename-only 'id "<old-name>"'.`):(o=c,c===a&&t.information(e.RedundantSourceStreamId,`The rename pin repeats the current name; omit it for a new declaration.`,i(r))),rejectChildren(t,r,e.InvalidEventSourceDeclaration),o}function parseCommandStream(t,n,r,o){let[s,c]=r.type.name.split(`.`),l={kind:`CommandStreamSyntax`,eventSource:s,stream:c,streamId:null,streamIdParts:[],propertyCandidate:null,referenceLocation:r.type.location,referenceLength:r.type.name.length,location:i(n)};if(o)return t.error(e.AmbiguousCommandStream,`'${n.content}' has both a property type and a stream route interpretation; neither is selected.`,i(n)),{...l,propertyCandidate:r};let u=null,d=[],f=!1,p={};for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){if(t.reader.takeSignificant(),r.content===`streamId`){u!==null||f?(t.error(e.InvalidCommandStream,`Declare either one 'streamId = <source>' mapping or one streamId part block.`,i(r)),t.skipBlock(r.indent)):(f=!0,p.streamId=i(r),d=parseRouteParts(t,r,e.InvalidCommandStream));continue}let n=/^streamId\s*=\s*(.+)$/.exec(r.content);if(n===null||u!==null||f)t.error(e.InvalidCommandStream,`Declare either one 'streamId = <source>' mapping or one streamId part block.`,i(r)),t.skipBlock(r.indent);else{let o={...i(r),column:r.indent+1+r.content.indexOf(n[1],r.content.indexOf(`=`)+1)};u={kind:`PropertyMappingSyntax`,property:`streamId`,source:a(n[1],o,t),location:i(r)},rejectChildren(t,r,e.InvalidCommandStream)}}return{...l,streamId:u,streamIdParts:d,directiveLocations:p}}function parseStreamIdParts(t,n){let r=[],a=u(`^([A-Za-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$`);for(let o=t.peekChild(n.indent);o!==void 0;o=t.peekChild(n.indent)){t.reader.takeSignificant();let n=a.exec(o.content);if(n===null){invalid(t,o,`Expected '<part> <Type>' without modifiers in a streamId part block.`),t.skipBlock(o.indent);continue}let l=s(n[2],{...i(o),column:o.indent+1+o.content.indexOf(n[2],n[1].length)});c(t,l,o),r.push({kind:`EventStreamIdPartSyntax`,name:n[1],type:l,location:i(o)}),rejectChildren(t,o,e.InvalidEventSourceDeclaration)}return r.length===0&&invalid(t,n,`A streamId part block cannot be empty.`),r}function parseRouteParts(e,t,n){let r=[],o=u(`^([A-Za-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$`);for(let s=e.peekChild(t.indent);s!==void 0;s=e.peekChild(t.indent)){e.reader.takeSignificant();let t=o.exec(s.content);if(t===null){e.error(n,`Expected '<part> = <source>' in a streamId part block.`,i(s)),e.skipBlock(s.indent);continue}let c={...i(s),column:s.indent+1+s.content.indexOf(t[2],s.content.indexOf(`=`)+1)};r.push({kind:`PropertyMappingSyntax`,property:t[1],source:a(t[2],c,e),location:i(s)}),rejectChildren(e,s,n)}return r.length===0&&e.error(n,`A streamId part block cannot be empty.`,i(t)),r}function rejectChildren(e,t,n){let r=e.peekChild(t.indent);r!==void 0&&(e.error(n,`This directive cannot have children.`,i(r)),e.skipBlock(t.indent))}function invalid(t,n,r){t.error(e.InvalidEventSourceDeclaration,r,i(n))}export{parseCommandStream,parseEventSource,parseRouteParts};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{parseMappingSource as a}from"./ExpressionParser.js";import{firstWord as o}from"./LineText.js";import{parseTypeRef as s,reportLegacyOptionalSuffix as c}from"./PropertyLineParser.js";import{parseDescription as l}from"./DescriptionParser.js";import{sourceStreamPattern as u}from"../Text/SourceStreamNames.js";import{parseCanvasPair as d}from"./CanvasPlacement.js";const f=r(`^id\\s+"(${t})"$`),p=u(`^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$`),m=u(`^eventsource\\s+([A-Za-z_]\\w*)$`),h=u(`^stream\\s+([A-Za-z_]\\w*)$`);function parseEventSource(e,t){let n=m.exec(t.content)?.[1]??``;n===``&&invalid(e,t,`Expected 'eventsource <Name>'.`);let r=[],a=null,s=null,c=null,u=null;for(let i=e.peekChild(t.indent);i!==void 0;i=e.peekChild(t.indent))switch(e.reader.takeSignificant(),o(i.content)){case`position`:u=d(e,i,`position`,`x`,`y`,u,!0)??u;break;case`stream`:r.push(parseEventStream(e,i));break;case`identifier`:a=parseType(e,i,`identifier`,a);break;case`description`:s=l(e,i,s,`Event source '${n}'`,!0);break;case`id`:c=parsePin(e,i,n,c);break;default:invalid(e,i,`An event source accepts description, id, identifier, position and stream declarations.`),e.skipBlock(i.indent)}return{kind:`EventSourceSyntax`,name:n,streams:r,identifier:a,description:s,id:c,...u===null?{}:{x:u[0],y:u[1]},location:i(t)}}function parseEventStream(e,t){let n=h.exec(t.content)?.[1]??``;n===``&&invalid(e,t,`Expected 'stream <Name>'.`);let r=null,a=[],s=!1,c={},u=null,d=null;for(let f=e.peekChild(t.indent);f!==void 0;f=e.peekChild(t.indent))switch(e.reader.takeSignificant(),o(f.content)){case`streamId`:s?(invalid(e,f,`Declare either one 'streamId <Type>' or one streamId part block.`),e.skipBlock(f.indent)):f.content===`streamId`?(s=!0,c.streamId=i(f),a=parseStreamIdParts(e,f)):(r=parseType(e,f,`streamId`,r),s=r!==null);break;case`description`:u=l(e,f,u,`Stream '${n}'`,!0);break;case`id`:d=parsePin(e,f,n,d);break;default:invalid(e,f,`A stream accepts description, id and streamId declarations.`),e.skipBlock(f.indent)}return{kind:`EventStreamSyntax`,name:n,streamId:r,streamIdParts:a,description:u,id:d,directiveLocations:c,location:i(t)}}function parseType(t,n,r,a){let o=p.exec(n.content);return o===null||a!==null?invalid(t,n,`Declare at most one '${r} <Type>'.`):(a=s(o[2],{...i(n),column:n.indent+1+n.content.indexOf(o[2],r.length)}),c(t,a,n)),rejectChildren(t,n,e.InvalidEventSourceDeclaration),a}function parsePin(t,r,a,o){let s=f.exec(r.content),c=s===null?null:n(s[1]);return c===null||c.trim()===``||o!==null?invalid(t,r,`Declare at most one nonempty rename-only 'id "<old-name>"'.`):(o=c,c===a&&t.information(e.RedundantSourceStreamId,`The rename pin repeats the current name; omit it for a new declaration.`,i(r))),rejectChildren(t,r,e.InvalidEventSourceDeclaration),o}function parseCommandStream(t,n,r,o){let[s,c]=r.type.name.split(`.`),l={kind:`CommandStreamSyntax`,eventSource:s,stream:c,streamId:null,streamIdParts:[],propertyCandidate:null,referenceLocation:r.type.location,referenceLength:r.type.name.length,location:i(n)};if(o)return t.error(e.AmbiguousCommandStream,`'${n.content}' has both a property type and a stream route interpretation; neither is selected.`,i(n)),{...l,propertyCandidate:r};let u=null,d=[],f=!1,p={};for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){if(t.reader.takeSignificant(),r.content===`streamId`){u!==null||f?(t.error(e.InvalidCommandStream,`Declare either one 'streamId = <source>' mapping or one streamId part block.`,i(r)),t.skipBlock(r.indent)):(f=!0,p.streamId=i(r),d=parseRouteParts(t,r,e.InvalidCommandStream));continue}let n=/^streamId\s*=\s*(.+)$/.exec(r.content);if(n===null||u!==null||f)t.error(e.InvalidCommandStream,`Declare either one 'streamId = <source>' mapping or one streamId part block.`,i(r)),t.skipBlock(r.indent);else{let o={...i(r),column:r.indent+1+r.content.indexOf(n[1],r.content.indexOf(`=`)+1)};u={kind:`PropertyMappingSyntax`,property:`streamId`,source:a(n[1],o,t),location:i(r)},rejectChildren(t,r,e.InvalidCommandStream)}}return{...l,streamId:u,streamIdParts:d,directiveLocations:p}}function parseStreamIdParts(t,n){let r=[],a=u(`^([A-Za-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$`);for(let o=t.peekChild(n.indent);o!==void 0;o=t.peekChild(n.indent)){t.reader.takeSignificant();let n=a.exec(o.content);if(n===null){invalid(t,o,`Expected '<part> <Type>' without modifiers in a streamId part block.`),t.skipBlock(o.indent);continue}let l=s(n[2],{...i(o),column:o.indent+1+o.content.indexOf(n[2],n[1].length)});c(t,l,o),r.push({kind:`EventStreamIdPartSyntax`,name:n[1],type:l,location:i(o)}),rejectChildren(t,o,e.InvalidEventSourceDeclaration)}return r.length===0&&invalid(t,n,`A streamId part block cannot be empty.`),r}function parseRouteParts(e,t,n){let r=[],o=u(`^([A-Za-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$`);for(let s=e.peekChild(t.indent);s!==void 0;s=e.peekChild(t.indent)){e.reader.takeSignificant();let t=o.exec(s.content);if(t===null){e.error(n,`Expected '<part> = <source>' in a streamId part block.`,i(s)),e.skipBlock(s.indent);continue}let c={...i(s),column:s.indent+1+s.content.indexOf(t[2],s.content.indexOf(`=`)+1)};r.push({kind:`PropertyMappingSyntax`,property:t[1],source:a(t[2],c,e),location:i(s)}),rejectChildren(e,s,n)}return r.length===0&&e.error(n,`A streamId part block cannot be empty.`,i(t)),r}function rejectChildren(e,t,n){let r=e.peekChild(t.indent);r!==void 0&&(e.error(n,`This directive cannot have children.`,i(r)),e.skipBlock(t.indent))}function invalid(t,n,r){t.error(e.InvalidEventSourceDeclaration,r,i(n))}export{parseCommandStream,parseEventSource,parseRouteParts};
2
2
  //# sourceMappingURL=EventSourceParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EventSourceParser.js","names":["pinPattern","pattern","stringBodyPattern","typeDirective","sourceStreamPattern","sourceHeader","streamHeader","name","header","context","streams","identifier","description","id","child","firstWord","parseDescription","locationOf","streamId","streamIdParts","declared","directiveLocations","match","line","previous","keyword","parseTypeRef","reportLegacyOptionalSuffix","DiagnosticCodes","value","unescapeString","eventSource","stream","candidate","route","ambiguous","block","location","parseMappingSource","parts","declaration","type","mapping","code","message"],"sources":["../../../../../../Compiler/Parsing/EventSourceParser.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 { TypeRefSyntax, PropertySyntax } from '../Syntax/Declarations';\nimport { CommandStreamSyntax, EventSourceSyntax, EventStreamSyntax, EventStreamIdPartSyntax } from '../Syntax/EventSources';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { parseDescription } from './DescriptionParser';\nimport { parseMappingSource } from './ExpressionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parseTypeRef, reportLegacyOptionalSuffix } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst pinPattern = pattern(`^id\\\\s+\"(${stringBodyPattern})\"$`);\nconst typeDirective = sourceStreamPattern('^(identifier|streamId)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)$');\nconst sourceHeader = sourceStreamPattern('^eventsource\\\\s+([A-Za-z_]\\\\w*)$');\nconst streamHeader = sourceStreamPattern('^stream\\\\s+([A-Za-z_]\\\\w*)$');\n\nexport function parseEventSource(context: ParserContext, header: SourceLine): EventSourceSyntax {\n const name = sourceHeader.exec(header.content)?.[1] ?? '';\n if (name === '') invalid(context, header, \"Expected 'eventsource <Name>'.\");\n const streams: EventStreamSyntax[] = [];\n let identifier: TypeRefSyntax | null = null;\n let description: string | null = null;\n let id: string | null = null;\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(child.content)) {\n case 'stream': streams.push(parseEventStream(context, child)); break;\n case 'identifier': identifier = parseType(context, child, 'identifier', identifier); break;\n case 'description': description = parseDescription(context, child, description, `Event source '${name}'`, true); break;\n case 'id': id = parsePin(context, child, name, id); break;\n default: invalid(context, child, 'An event source accepts description, id, identifier and stream declarations.'); context.skipBlock(child.indent); break;\n }\n }\n return { kind: 'EventSourceSyntax', name, streams, identifier, description, id, location: locationOf(header) };\n}\n\nfunction parseEventStream(context: ParserContext, header: SourceLine): EventStreamSyntax {\n const name = streamHeader.exec(header.content)?.[1] ?? '';\n if (name === '') invalid(context, header, \"Expected 'stream <Name>'.\");\n let streamId: TypeRefSyntax | null = null;\n let streamIdParts: EventStreamIdPartSyntax[] = [];\n let declared = false;\n const directiveLocations: Record<string, ReturnType<typeof locationOf>> = {};\n let description: string | null = null;\n let id: string | null = null;\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(child.content)) {\n case 'streamId':\n if (declared) {\n invalid(context, child, \"Declare either one 'streamId <Type>' or one streamId part block.\");\n context.skipBlock(child.indent);\n } else if (child.content === 'streamId') {\n declared = true;\n directiveLocations.streamId = locationOf(child);\n streamIdParts = parseStreamIdParts(context, child);\n } else {\n streamId = parseType(context, child, 'streamId', streamId);\n declared = streamId !== null;\n }\n break;\n case 'description': description = parseDescription(context, child, description, `Stream '${name}'`, true); break;\n case 'id': id = parsePin(context, child, name, id); break;\n default: invalid(context, child, 'A stream accepts description, id and streamId declarations.'); context.skipBlock(child.indent); break;\n }\n }\n return { kind: 'EventStreamSyntax', name, streamId, streamIdParts, description, id, directiveLocations, location: locationOf(header) };\n}\n\nfunction parseType(context: ParserContext, line: SourceLine, keyword: string, previous: TypeRefSyntax | null): TypeRefSyntax | null {\n const match = typeDirective.exec(line.content);\n if (match === null || previous !== null) invalid(context, line, `Declare at most one '${keyword} <Type>'.`);\n else {\n previous = parseTypeRef(match[2], { ...locationOf(line), column: line.indent + 1 + line.content.indexOf(match[2], keyword.length) });\n reportLegacyOptionalSuffix(context, previous, line);\n }\n rejectChildren(context, line, DiagnosticCodes.InvalidEventSourceDeclaration);\n return previous;\n}\n\nfunction parsePin(context: ParserContext, line: SourceLine, name: string, previous: string | null): string | null {\n const match = pinPattern.exec(line.content);\n const value = match === null ? null : unescapeString(match[1]);\n if (value === null || value.trim() === '' || previous !== null) invalid(context, line, 'Declare at most one nonempty rename-only \\'id \"<old-name>\"\\'.');\n else {\n previous = value;\n if (value === name) context.information(DiagnosticCodes.RedundantSourceStreamId, 'The rename pin repeats the current name; omit it for a new declaration.', locationOf(line));\n }\n rejectChildren(context, line, DiagnosticCodes.InvalidEventSourceDeclaration);\n return previous;\n}\n\nexport function parseCommandStream(context: ParserContext, header: SourceLine, candidate: PropertySyntax, ambiguous: boolean): CommandStreamSyntax {\n const [eventSource, stream] = candidate.type.name.split('.');\n const route: CommandStreamSyntax = { kind: 'CommandStreamSyntax', eventSource, stream, streamId: null, streamIdParts: [], propertyCandidate: null, referenceLocation: candidate.type.location, referenceLength: candidate.type.name.length, location: locationOf(header) };\n if (ambiguous) {\n context.error(DiagnosticCodes.AmbiguousCommandStream, `'${header.content}' has both a property type and a stream route interpretation; neither is selected.`, locationOf(header));\n // Ordinary properties are leaves; preserve deeper legacy command members in this case.\n return { ...route, propertyCandidate: candidate };\n }\n let streamId: PropertyMappingSyntax | null = null;\n let streamIdParts: PropertyMappingSyntax[] = [];\n let block = false;\n const directiveLocations: Record<string, ReturnType<typeof locationOf>> = {};\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'streamId') {\n if (streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidCommandStream, \"Declare either one 'streamId = <source>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n } else {\n block = true;\n directiveLocations.streamId = locationOf(child);\n streamIdParts = parseRouteParts(context, child, DiagnosticCodes.InvalidCommandStream);\n }\n continue;\n }\n const match = /^streamId\\s*=\\s*(.+)$/.exec(child.content);\n if (match === null || streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidCommandStream, \"Declare either one 'streamId = <source>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n } else {\n const location = { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(match[1], child.content.indexOf('=') + 1) };\n streamId = { kind: 'PropertyMappingSyntax', property: 'streamId', source: parseMappingSource(match[1], location, context), location: locationOf(child) };\n rejectChildren(context, child, DiagnosticCodes.InvalidCommandStream);\n }\n }\n return { ...route, streamId, streamIdParts, directiveLocations };\n}\n\nfunction parseStreamIdParts(context: ParserContext, header: SourceLine): EventStreamIdPartSyntax[] {\n const parts: EventStreamIdPartSyntax[] = [];\n const declaration = sourceStreamPattern('^([A-Za-z_]\\\\w*)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)$');\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const match = declaration.exec(child.content);\n if (match === null) {\n invalid(context, child, \"Expected '<part> <Type>' without modifiers in a streamId part block.\");\n context.skipBlock(child.indent);\n continue;\n }\n const type = parseTypeRef(match[2], { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(match[2], match[1].length) });\n reportLegacyOptionalSuffix(context, type, child);\n parts.push({ kind: 'EventStreamIdPartSyntax', name: match[1], type, location: locationOf(child) });\n rejectChildren(context, child, DiagnosticCodes.InvalidEventSourceDeclaration);\n }\n if (parts.length === 0) invalid(context, header, 'A streamId part block cannot be empty.');\n return parts;\n}\n\nexport function parseRouteParts(context: ParserContext, header: SourceLine, code: string): PropertyMappingSyntax[] {\n const parts: PropertyMappingSyntax[] = [];\n const mapping = sourceStreamPattern('^([A-Za-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const match = mapping.exec(child.content);\n if (match === null) {\n context.error(code, \"Expected '<part> = <source>' in a streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const location = { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(match[2], child.content.indexOf('=') + 1) };\n parts.push({ kind: 'PropertyMappingSyntax', property: match[1], source: parseMappingSource(match[2], location, context), location: locationOf(child) });\n rejectChildren(context, child, code);\n }\n if (parts.length === 0) context.error(code, 'A streamId part block cannot be empty.', locationOf(header));\n return parts;\n}\n\nfunction rejectChildren(context: ParserContext, line: SourceLine, code: string): void {\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(code, 'This directive cannot have children.', locationOf(child));\n context.skipBlock(line.indent);\n }\n}\n\nfunction invalid(context: ParserContext, line: SourceLine, message: string): void { context.error(DiagnosticCodes.InvalidEventSourceDeclaration, message, locationOf(line)); }\n"],"mappings":"8lBAiBA,MAAMA,EAAaC,EAAQ,YAAYC,EAAkB,IAAI,EACvDC,EAAgBC,EAAoB,sEAAsE,EAC1GC,EAAeD,EAAoB,kCAAkC,EACrEE,EAAeF,EAAoB,6BAA6B,EAEtE,SAAgB,iBAAiB,EAAwB,EAAuC,CAC5F,IAAMG,EAAOF,EAAa,KAAKG,EAAO,OAAO,CAAC,GAAG,IAAM,GACnDD,IAAS,IAAI,QAAQE,EAASD,EAAQ,gCAAgC,EAC1E,IAAME,EAA+B,CAAC,E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StreamPattern","sourceHeader","streamHeader","name","header","context","streams","identifier","description","id","position","child","firstWord","parseCanvasPair","parseDescription","locationOf","streamId","streamIdParts","declared","directiveLocations","match","line","previous","keyword","parseTypeRef","reportLegacyOptionalSuffix","DiagnosticCodes","value","unescapeString","eventSource","stream","candidate","route","ambiguous","block","location","parseMappingSource","parts","declaration","type","mapping","code","message"],"sources":["../../../../../../Compiler/Parsing/EventSourceParser.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 { TypeRefSyntax, PropertySyntax } from '../Syntax/Declarations';\nimport { CommandStreamSyntax, EventSourceSyntax, EventStreamSyntax, EventStreamIdPartSyntax } from '../Syntax/EventSources';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { parseCanvasPair } from './CanvasPlacement';\nimport { parseDescription } from './DescriptionParser';\nimport { parseMappingSource } from './ExpressionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parseTypeRef, reportLegacyOptionalSuffix } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst pinPattern = pattern(`^id\\\\s+\"(${stringBodyPattern})\"$`);\nconst typeDirective = sourceStreamPattern('^(identifier|streamId)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)$');\nconst sourceHeader = sourceStreamPattern('^eventsource\\\\s+([A-Za-z_]\\\\w*)$');\nconst streamHeader = sourceStreamPattern('^stream\\\\s+([A-Za-z_]\\\\w*)$');\n\nexport function parseEventSource(context: ParserContext, header: SourceLine): EventSourceSyntax {\n const name = sourceHeader.exec(header.content)?.[1] ?? '';\n if (name === '') invalid(context, header, \"Expected 'eventsource <Name>'.\");\n const streams: EventStreamSyntax[] = [];\n let identifier: TypeRefSyntax | null = null;\n let description: string | null = null;\n let id: string | null = null;\n let position: readonly [number, number] | null = null;\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(child.content)) {\n case 'position': position = parseCanvasPair(context, child, 'position', 'x', 'y', position, true) ?? position; break;\n case 'stream': streams.push(parseEventStream(context, child)); break;\n case 'identifier': identifier = parseType(context, child, 'identifier', identifier); break;\n case 'description': description = parseDescription(context, child, description, `Event source '${name}'`, true); break;\n case 'id': id = parsePin(context, child, name, id); break;\n default: invalid(context, child, 'An event source accepts description, id, identifier, position and stream declarations.'); context.skipBlock(child.indent); break;\n }\n }\n return { kind: 'EventSourceSyntax', name, streams, identifier, description, id, ...(position === null ? {} : { x: position[0], y: position[1] }), location: locationOf(header) };\n}\n\nfunction parseEventStream(context: ParserContext, header: SourceLine): EventStreamSyntax {\n const name = streamHeader.exec(header.content)?.[1] ?? '';\n if (name === '') invalid(context, header, \"Expected 'stream <Name>'.\");\n let streamId: TypeRefSyntax | null = null;\n let streamIdParts: EventStreamIdPartSyntax[] = [];\n let declared = false;\n const directiveLocations: Record<string, ReturnType<typeof locationOf>> = {};\n let description: string | null = null;\n let id: string | null = null;\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(child.content)) {\n case 'streamId':\n if (declared) {\n invalid(context, child, \"Declare either one 'streamId <Type>' or one streamId part block.\");\n context.skipBlock(child.indent);\n } else if (child.content === 'streamId') {\n declared = true;\n directiveLocations.streamId = locationOf(child);\n streamIdParts = parseStreamIdParts(context, child);\n } else {\n streamId = parseType(context, child, 'streamId', streamId);\n declared = streamId !== null;\n }\n break;\n case 'description': description = parseDescription(context, child, description, `Stream '${name}'`, true); break;\n case 'id': id = parsePin(context, child, name, id); break;\n default: invalid(context, child, 'A stream accepts description, id and streamId declarations.'); context.skipBlock(child.indent); break;\n }\n }\n return { kind: 'EventStreamSyntax', name, streamId, streamIdParts, description, id, directiveLocations, location: locationOf(header) };\n}\n\nfunction parseType(context: ParserContext, line: SourceLine, keyword: string, previous: TypeRefSyntax | null): TypeRefSyntax | null {\n const match = typeDirective.exec(line.content);\n if (match === null || previous !== null) invalid(context, line, `Declare at most one '${keyword} <Type>'.`);\n else {\n previous = parseTypeRef(match[2], { ...locationOf(line), column: line.indent + 1 + line.content.indexOf(match[2], keyword.length) });\n reportLegacyOptionalSuffix(context, previous, line);\n }\n rejectChildren(context, line, DiagnosticCodes.InvalidEventSourceDeclaration);\n return previous;\n}\n\nfunction parsePin(context: ParserContext, line: SourceLine, name: string, previous: string | null): string | null {\n const match = pinPattern.exec(line.content);\n const value = match === null ? null : unescapeString(match[1]);\n if (value === null || value.trim() === '' || previous !== null) invalid(context, line, 'Declare at most one nonempty rename-only \\'id \"<old-name>\"\\'.');\n else {\n previous = value;\n if (value === name) context.information(DiagnosticCodes.RedundantSourceStreamId, 'The rename pin repeats the current name; omit it for a new declaration.', locationOf(line));\n }\n rejectChildren(context, line, DiagnosticCodes.InvalidEventSourceDeclaration);\n return previous;\n}\n\nexport function parseCommandStream(context: ParserContext, header: SourceLine, candidate: PropertySyntax, ambiguous: boolean): CommandStreamSyntax {\n const [eventSource, stream] = candidate.type.name.split('.');\n const route: CommandStreamSyntax = { kind: 'CommandStreamSyntax', eventSource, stream, streamId: null, streamIdParts: [], propertyCandidate: null, referenceLocation: candidate.type.location, referenceLength: candidate.type.name.length, location: locationOf(header) };\n if (ambiguous) {\n context.error(DiagnosticCodes.AmbiguousCommandStream, `'${header.content}' has both a property type and a stream route interpretation; neither is selected.`, locationOf(header));\n // Ordinary properties are leaves; preserve deeper legacy command members in this case.\n return { ...route, propertyCandidate: candidate };\n }\n let streamId: PropertyMappingSyntax | null = null;\n let streamIdParts: PropertyMappingSyntax[] = [];\n let block = false;\n const directiveLocations: Record<string, ReturnType<typeof locationOf>> = {};\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'streamId') {\n if (streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidCommandStream, \"Declare either one 'streamId = <source>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n } else {\n block = true;\n directiveLocations.streamId = locationOf(child);\n streamIdParts = parseRouteParts(context, child, DiagnosticCodes.InvalidCommandStream);\n }\n continue;\n }\n const match = /^streamId\\s*=\\s*(.+)$/.exec(child.content);\n if (match === null || streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidCommandStream, \"Declare either one 'streamId = <source>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n } else {\n const location = { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(match[1], child.content.indexOf('=') + 1) };\n streamId = { kind: 'PropertyMappingSyntax', property: 'streamId', source: parseMappingSource(match[1], location, context), location: locationOf(child) };\n rejectChildren(context, child, DiagnosticCodes.InvalidCommandStream);\n }\n }\n return { ...route, streamId, streamIdParts, directiveLocations };\n}\n\nfunction parseStreamIdParts(context: ParserContext, header: SourceLine): EventStreamIdPartSyntax[] {\n const parts: EventStreamIdPartSyntax[] = [];\n const declaration = sourceStreamPattern('^([A-Za-z_]\\\\w*)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)$');\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const match = declaration.exec(child.content);\n if (match === null) {\n invalid(context, child, \"Expected '<part> <Type>' without modifiers in a streamId part block.\");\n context.skipBlock(child.indent);\n continue;\n }\n const type = parseTypeRef(match[2], { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(match[2], match[1].length) });\n reportLegacyOptionalSuffix(context, type, child);\n parts.push({ kind: 'EventStreamIdPartSyntax', name: match[1], type, location: locationOf(child) });\n rejectChildren(context, child, DiagnosticCodes.InvalidEventSourceDeclaration);\n }\n if (parts.length === 0) invalid(context, header, 'A streamId part block cannot be empty.');\n return parts;\n}\n\nexport function parseRouteParts(context: ParserContext, header: SourceLine, code: string): PropertyMappingSyntax[] {\n const parts: PropertyMappingSyntax[] = [];\n const mapping = sourceStreamPattern('^([A-Za-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const match = mapping.exec(child.content);\n if (match === null) {\n context.error(code, \"Expected '<part> = <source>' in a streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const location = { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(match[2], child.content.indexOf('=') + 1) };\n parts.push({ kind: 'PropertyMappingSyntax', property: match[1], source: parseMappingSource(match[2], location, context), location: locationOf(child) });\n rejectChildren(context, child, code);\n }\n if (parts.length === 0) context.error(code, 'A streamId part block cannot be empty.', locationOf(header));\n return parts;\n}\n\nfunction rejectChildren(context: ParserContext, line: SourceLine, code: string): void {\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(code, 'This directive cannot have children.', locationOf(child));\n context.skipBlock(line.indent);\n }\n}\n\nfunction invalid(context: ParserContext, line: SourceLine, message: string): void { context.error(DiagnosticCodes.InvalidEventSourceDeclaration, message, locationOf(line)); }\n"],"mappings":"qpBAkBA,MAAMA,EAAaC,EAAQ,YAAYC,EAAkB,IAAI,EACvDC,EAAgBC,EAAoB,sEAAsE,EAC1GC,EAAeD,EAAoB,kCAAkC,EACrEE,EAAeF,EAAoB,6BAA6B,EAEtE,SAAgB,iBAAiB,EAAwB,EAAuC,CAC5F,IAAMG,EAAOF,EAAa,KAAKG,EAAO,OAAO,CAAC,GAAG,IAAM,GACnDD,IAAS,IAAI,QAAQE,EAASD,EAAQ,gCAAgC,EAC1E,IAAME,EAA+B,CAAC,EAClCC,EAAmC,KACnCC,EAA6B,KAC7BC,EAAoB,KACpBC,EAA6C,KACjD,IAAK,IAAIC,EAAQ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B,EAAgB,8BAA+BgB,EAAS3B,EAAWM,CAAI,CAAC,CAAG"}
@@ -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 ee}from"./SpecificationExampleParser.js";import{isBlankPublicEventOrigin as te}from"../Syntax/PublicEventInvariants.js";import{parseType as ne}from"./DeclarationParsers.js";import{parseValidate as C}from"./CommandParser.js";import{parseTriggerDeclaration as w}from"./TriggerDataParser.js";import{FeatureBody as T,featureBodyExpected as E}from"./FeatureBody.js";import{ModuleBody as D,moduleBodyExpected as O,modulePattern as k,parseModule as A}from"./ModuleBody.js";import{EnumerationMembers as j}from"./EnumerationMembers.js";import{parseGeneration as M}from"./GenerationParser.js";import{parseIdentity as N}from"./IdentityParser.js";import{parsePolicy as P}from"./PolicyParser.js";import{parseSeed as F}from"./SeedParser.js";import{parseExposure as I,parseInstance as re}from"./CompositionParser.js";import{parseUiProfile as ie}from"./UiProfileLegacyLayout.js";const L=r(`^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`),R=r(`^import\\s+([\\w.]+)(?:\\s+from\\s+"(?<origin>${t})")?$`),z=r(`^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$`),B=r(`^@?[a-z_]\\w*$`),V=r(`^persona\\s+([A-Za-z_]\\w*)$`),H=r(`^policy\\s+([A-Za-z_]\\w*)$`),U=r(`^goal\\s+"(${t})"$`),W=r(`^sticky\\s+note\\s+on\\s+personas$`),G=r(`^colour\\s+(yellow|pink|green|blue)$`),K=r(`^(position|size)\\s+(-?\\d+)\\s+(-?\\d+)$`),q=/^[ ]*\t/,J=[`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`],Y=/* @__PURE__ */ new Set([`policy`,`authentication`,`seed`,`ui`,`theme`,`trigger`,`layout`,`behavior`,`sample`]),X=/* @__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 D(a[0]):void 0,s=a.length>1?new T(a[a.length-1]):void 0,l=o??s,u=null,p=null,x=!1,C=null,E=!1,O=null,k=[],j=[],M=[],L=[],z=[],B=[],V=[],H=[],U=[],W=[],G=[],K=[],q=[],J=[],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))E||!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)):C=`Protected`,E=!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,j):l.tryParse(t,r);else if(s===`import`){let a=R.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&&te(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?q.push(ee(t,r)):l.tryParse(t,r);else if(s===`eventsource`)B.push(b(t,r));else if(s===`system`)z.push(S(t,r));else if(s===`concept`)M.push(parseConcept(t,r));else if(s===`type`)L.push(ne(t,r));else if(s===`module`&&!f(a))parseModuleInPlacedFile(t,r,a,o);else if(s===`module`)V.push(A(t,r));else if(s===`persona`)H.push(parsePersona(t,r));else if(s===`sticky`){let e=parseStickyNote(t,r);e!==null&&U.push(e)}else if(s===`seed`)K.push(F(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=N(t,r,u);else if(s===`policy`){let n=P(t,r);W.some(e=>e.name===n.name)&&t.error(e.DuplicateDeclaration,`Duplicate declaration of policy '${n.name}' - policy names must be unique`,n.location),W.push(n)}else if(s===`exposure`)X.push(I(t,r));else if(s===`instance`)Z.push(re(t,r));else if(s===`trigger`){let e=w(t,r),n=/^trigger\s+([A-Za-z_]\w*)$/.exec(r.content)?.[1];n!==void 0&&J.push({name:n,data:e})}else Y.has(s)?s===`behavior`||s===`layout`?v(t,r):s===`ui`?ie(t,r):t.skipOpaqueBlock(r.indent):l?.tryParse(t,r)!==!0&&reportUnexpectedTopLevel(t,r,a)}o===void 0?s!==void 0&&V.unshift(place(a,s.build(t.start,!0),t.start)):V.unshift(o.build(t.start,!0));let $={kind:`ApplicationSyntax`,...C===null?{}:{commandReadMode:C},...p===null?{}:{reactionProductionMode:p},...u===null?{}:{identity:u},sourceOptions:t.sourceOptions,domain:O,imports:k,concepts:M,types:L,systems:z,eventSources:B,examples:q,modules:V,personas:H,policies:W,purposes:G,seeds:K,declaredTriggers:J,fileImports:j,...X.length>0?{exposures:X}:{},...U.length>0?{stickyNotes:U}:{},...Z.length>0?{instanceContributions:Z}:{},location:t.start};return t.authoredDeclarations&&_($),$}function declaresConstruct(e,t,n){return e===`import`?R.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`||e===`sticky`||Y.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=X.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, sticky note on personas, 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:E;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=L.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&&q.test(i.raw)&&t.warning(e.TabIndentation,`Screenplay is indentation based - use spaces, not tabs`,a(i))}function parseConcept(t,n){let r=z.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`&&!J.includes(u)&&t.error(e.UnknownPrimitiveType,`Unknown primitive type '${u}' - expected ${J.join(`, `)} or Enum`,i(n));let m=[],h=new j,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=C(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=M(t,r,u);_||(g=n),_=!0}else o(t,r,a,f)||(u===`Enum`&&B.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,r){let a=V.exec(r.content)?.[1]??``;a===``&&t.error(e.InvalidPersonaDeclaration,`Invalid persona declaration '${r.content}' - expected 'persona <Name>'`,i(r));let o=null,s=[],l=[],u=null,d=null;for(let f=t.peekChild(r.indent);f!==void 0;f=t.peekChild(r.indent)){t.reader.takeSignificant();let r=c(f.content);if(r===`description`)o=p(t,f,o,`Persona '${a}'`);else if(r===`goal`){let r=U.exec(f.content);r===null?t.error(e.InvalidPersonaDeclaration,`Invalid goal '${f.content}' - expected 'goal "<text>"'`,i(f)):l.push(n(r[1]))}else if(r===`position`)u=parseCanvasPair(t,f,`position`,`x`,`y`,u,!0)??u;else if(r===`size`)d=parseCanvasPair(t,f,`size`,`width`,`height`,d,!1)??d;else if(r===`policy`){let n=H.exec(f.content);n===null?t.error(e.InvalidPersonaPolicyReference,`Invalid policy reference '${f.content}' - expected 'policy <Name>'`,i(f)):s.push(n[1])}else t.error(e.UnknownPersonaDirective,`Unexpected '${r}' in persona body - expected description, goal, policy, position or size`,i(f)),t.skipBlock(f.indent)}return{kind:`PersonaSyntax`,name:a,description:o,policies:s,...l.length>0?{goals:l}:{},...u===null?{}:{x:u[0],y:u[1]},...d===null?{}:{width:d[0],height:d[1]},location:i(r)}}function parseStickyNote(t,n){if(!W.test(n.content))return t.error(e.InvalidPersonaDeclaration,`Invalid sticky note declaration '${n.content}' - expected 'sticky note on personas'`,i(n)),t.skipBlock(n.indent),null;let r=null,a=null,o=null,s=null;for(let l=t.peekChild(n.indent);l!==void 0;l=t.peekChild(n.indent)){t.reader.takeSignificant();let n=c(l.content);if(n===`description`)r=p(t,l,r,`A sticky note`);else if(n===`colour`){let n=G.exec(l.content);n===null?t.error(e.InvalidPersonaDeclaration,`Invalid colour '${l.content}' - expected 'colour yellow', 'colour pink', 'colour green' or 'colour blue'`,i(l)):a=n[1]}else n===`position`?o=parseCanvasPair(t,l,`position`,`x`,`y`,o,!0)??o:n===`size`?s=parseCanvasPair(t,l,`size`,`width`,`height`,s,!1)??s:(t.error(e.UnknownPersonaDirective,`Unexpected '${n}' in sticky note body - expected description, colour, position or size`,i(l)),t.skipBlock(l.indent))}return r===null||o===null?(t.error(e.InvalidPersonaDeclaration,`A sticky note needs a description (the text on it) and a position`,i(n)),null):{kind:`StickyNoteSyntax`,text:r,colour:a,x:o[0],y:o[1],width:s===null?null:s[0],height:s===null?null:s[1],location:i(n)}}function parseCanvasPair(t,n,r,a,o,s,c){let l=K.exec(n.content),u=l===null?NaN:Number.parseInt(l[2],10),d=l===null?NaN:Number.parseInt(l[3],10);return l!==null&&l[1]===r&&Number.isSafeInteger(u)&&Number.isSafeInteger(d)&&u>=-2147483648&&u<=2147483647&&d>=-2147483648&&d<=2147483647&&(c||u>=0&&d>=0)?s===null?[u,d]:(t.error(e.InvalidPersonaDeclaration,`The ${r} is already declared - at most one is allowed`,i(n)),null):(t.error(e.InvalidPersonaDeclaration,`Invalid ${r} '${n.content}' - expected '${r} <${a}> <${o}>' with whole numbers${c?``:` that are not negative`}`,i(n)),null)}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{parseCanvasPair as b}from"./CanvasPlacement.js";import{parseEventSource as x}from"./EventSourceParser.js";import{isFileDirective as S}from"./FileReferences.js";import{parseSystem as C}from"./OperationParser.js";import{parseExample as w}from"./SpecificationExampleParser.js";import{isBlankPublicEventOrigin as ee}from"../Syntax/PublicEventInvariants.js";import{parseType as te}from"./DeclarationParsers.js";import{parseValidate as T}from"./CommandParser.js";import{parseTriggerDeclaration as E}from"./TriggerDataParser.js";import{FeatureBody as D,featureBodyExpected as O}from"./FeatureBody.js";import{ModuleBody as k,moduleBodyExpected as A,modulePattern as j,parseModule as M}from"./ModuleBody.js";import{EnumerationMembers as N}from"./EnumerationMembers.js";import{parseGeneration as P}from"./GenerationParser.js";import{parseIdentity as F}from"./IdentityParser.js";import{parsePolicy as ne}from"./PolicyParser.js";import{parseSeed as re}from"./SeedParser.js";import{parseExposure as ie,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=r(`^goal\\s+"(${t})"$`),G=r(`^sticky\\s+note\\s+on\\s+(personas|eventsources|givencontexts|seeddata)$`),K=r(`^colour\\s+(yellow|pink|green|blue)$`),q=/^[ ]*\t/,J=[`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`],Y=/* @__PURE__ */ new Set([`policy`,`authentication`,`seed`,`ui`,`theme`,`trigger`,`layout`,`behavior`,`sample`]),X=/* @__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 k(a[0]):void 0,s=a.length>1?new D(a[a.length-1]):void 0,l=o??s,u=null,p=null,b=!1,S=null,T=!1,O=null,A=[],j=[],N=[],P=[],R=[],B=[],V=[],H=[],U=[],W=[],G=[],K=[],q=[],J=[],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))T||!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)):S=`Protected`,T=!0;else if(s===`reaction`)b||!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`,b=!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,j):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)),A.push({kind:`ImportSyntax`,qualifiedName:a[1],origin:o,visibility:o===null?`Private`:`Public`,location:i(r)})}}else if(s===`example`)l===void 0?q.push(w(t,r)):l.tryParse(t,r);else if(s===`eventsource`)B.push(x(t,r));else if(s===`system`)R.push(C(t,r));else if(s===`concept`)N.push(parseConcept(t,r));else if(s===`type`)P.push(te(t,r));else if(s===`module`&&!f(a))parseModuleInPlacedFile(t,r,a,o);else if(s===`module`)V.push(M(t,r));else if(s===`persona`)H.push(parsePersona(t,r));else if(s===`sticky`){let e=parseStickyNote(t,r);e!==null&&U.push(e)}else if(s===`seed`)K.push(re(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=F(t,r,u);else if(s===`policy`){let n=ne(t,r);W.some(e=>e.name===n.name)&&t.error(e.DuplicateDeclaration,`Duplicate declaration of policy '${n.name}' - policy names must be unique`,n.location),W.push(n)}else if(s===`exposure`)X.push(ie(t,r));else if(s===`instance`)Z.push(I(t,r));else if(s===`trigger`){let e=E(t,r),n=/^trigger\s+([A-Za-z_]\w*)$/.exec(r.content)?.[1];n!==void 0&&J.push({name:n,data:e})}else Y.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&&V.unshift(place(a,s.build(t.start,!0),t.start)):V.unshift(o.build(t.start,!0));let $={kind:`ApplicationSyntax`,...S===null?{}:{commandReadMode:S},...p===null?{}:{reactionProductionMode:p},...u===null?{}:{identity:u},sourceOptions:t.sourceOptions,domain:O,imports:A,concepts:N,types:P,systems:R,eventSources:B,examples:q,modules:V,personas:H,policies:W,purposes:G,seeds:K,declaredTriggers:J,fileImports:j,...X.length>0?{exposures:X}:{},...U.length>0?{stickyNotes:U}:{},...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`||e===`sticky`||Y.has(e)}function parseModuleInPlacedFile(t,n,r,a){let o=j.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=X.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, sticky note, 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?A:O;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&&q.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`&&!J.includes(u)&&t.error(e.UnknownPrimitiveType,`Unknown primitive type '${u}' - expected ${J.join(`, `)} or Enum`,i(n));let m=[],h=new N,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(S(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=P(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,r){let a=H.exec(r.content)?.[1]??``;a===``&&t.error(e.InvalidPersonaDeclaration,`Invalid persona declaration '${r.content}' - expected 'persona <Name>'`,i(r));let o=null,s=[],l=[],u=null,d=null;for(let f=t.peekChild(r.indent);f!==void 0;f=t.peekChild(r.indent)){t.reader.takeSignificant();let r=c(f.content);if(r===`description`)o=p(t,f,o,`Persona '${a}'`);else if(r===`goal`){let r=W.exec(f.content);r===null?t.error(e.InvalidPersonaDeclaration,`Invalid goal '${f.content}' - expected 'goal "<text>"'`,i(f)):l.push(n(r[1]))}else if(r===`position`)u=b(t,f,`position`,`x`,`y`,u,!0)??u;else if(r===`size`)d=b(t,f,`size`,`width`,`height`,d,!1)??d;else if(r===`policy`){let n=U.exec(f.content);n===null?t.error(e.InvalidPersonaPolicyReference,`Invalid policy reference '${f.content}' - expected 'policy <Name>'`,i(f)):s.push(n[1])}else t.error(e.UnknownPersonaDirective,`Unexpected '${r}' in persona body - expected description, goal, policy, position or size`,i(f)),t.skipBlock(f.indent)}return{kind:`PersonaSyntax`,name:a,description:o,policies:s,...l.length>0?{goals:l}:{},...u===null?{}:{x:u[0],y:u[1]},...d===null?{}:{width:d[0],height:d[1]},location:i(r)}}function parseStickyNote(t,n){let r=G.exec(n.content);if(r===null)return t.error(e.InvalidPersonaDeclaration,`Invalid sticky note declaration '${n.content}' - expected 'sticky note on personas', 'sticky note on eventsources', 'sticky note on givencontexts' or 'sticky note on seeddata'`,i(n)),t.skipBlock(n.indent),null;let a=null,o=null,s=null,l=null;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=c(r.content);if(n===`description`)a=p(t,r,a,`A sticky note`);else if(n===`colour`){let n=K.exec(r.content);n===null?t.error(e.InvalidPersonaDeclaration,`Invalid colour '${r.content}' - expected 'colour yellow', 'colour pink', 'colour green' or 'colour blue'`,i(r)):o=n[1]}else n===`position`?s=b(t,r,`position`,`x`,`y`,s,!0)??s:n===`size`?l=b(t,r,`size`,`width`,`height`,l,!1)??l:(t.error(e.UnknownPersonaDirective,`Unexpected '${n}' in sticky note body - expected description, colour, position or size`,i(r)),t.skipBlock(r.indent))}return a===null||s===null?(t.error(e.InvalidPersonaDeclaration,`A sticky note needs a description (the text on it) and a position`,i(n)),null):{kind:`StickyNoteSyntax`,canvas:r[1],text:a,colour:o,x:s[0],y:s[1],width:l===null?null:l[0],height:l===null?null:l[1],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","personaGoalPattern","stickyNotePattern","stickyNoteColourPattern","canvasPairPattern","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","stickyNotes","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","stickyNote","parseSeed","parsePurpose","parseIdentity","policy","parsePolicy","previous","parseExposure","parseInstance","data","parseTriggerDeclaration","name","collectInputUses","parseUiProfile","root","recordAuthoredDocument","modulePattern","describePlacement","word","hint","expected","moduleBodyExpected","featureBodyExpected","feature","innermost","index","start","existing","inFence","startOf","type","attributeText","attributes","parseComplianceMarkers","values","members","EnumerationMembers","generation","declaredGeneration","description","validations","child","memberName","parseDescription","isFileDirective","parsed","parseValidate","parseGeneration","parseComplianceDirective","unescapeIdentifier","valueNumbers","goals","position","size","goal","text","colour","firstValue","secondValue","allowNegative","first","second"],"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, StickyNoteSyntax } 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 personaGoalPattern = pattern(`^goal\\\\s+\"(${stringBodyPattern})\"$`);\nconst stickyNotePattern = pattern('^sticky\\\\s+note\\\\s+on\\\\s+personas$');\nconst stickyNoteColourPattern = pattern('^colour\\\\s+(yellow|pink|green|blue)$');\nconst canvasPairPattern = pattern('^(position|size)\\\\s+(-?\\\\d+)\\\\s+(-?\\\\d+)$');\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 stickyNotes: StickyNoteSyntax[] = [];\n const policies: PolicySyntax[] = [];\n const purposes: PurposeSyntax[] = [];\n const seeds: SeedSyntax[] = [];\n const examples: SpecificationExampleSyntax[] = [];\n const declaredTriggers: NonNullable<ApplicationSyntax['declaredTriggers']>[number][] = [];\n const exposures: ExposureSyntax[] = [];\n const instanceContributions: InstanceContributionsSyntax[] = [];\n let sawOtherConstruct = false;\n for (let line = context.reader.peekSignificant(); line !== undefined; line = context.reader.peekSignificant()) {\n context.reader.takeSignificant();\n const keyword = firstWord(line.content);\n if (keyword === 'command' && /^command\\s+reads(?:\\s|$)/.test(line.content)) {\n if (sawCommandReads || !isDocumentPlacement(placement) || !/^command\\s+reads\\s+protected$/.test(line.content)) {\n context.error(DiagnosticCodes.InvalidCommandReadsDeclaration, \"Declare 'command reads protected' once at the application root.\", locationOf(line));\n } else {\n commandReadMode = CommandReadMode.Protected;\n }\n sawCommandReads = true;\n continue;\n }\n if (keyword === '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 === 'sticky') {\n const stickyNote = parseStickyNote(context, line);\n if (stickyNote !== null) stickyNotes.push(stickyNote);\n } else if (keyword === 'seed') {\n seeds.push(parseSeed(context.valueContext, line));\n } else if (keyword === 'purpose' && placedBody !== undefined) {\n placedBody.tryParse(context, line);\n } else if (keyword === 'purpose') {\n purposes.push(parsePurpose(context, line));\n } else if (keyword === 'identity') {\n identity = parseIdentity(context, line, identity);\n } else if (keyword === 'policy') {\n const policy = parsePolicy(context, line);\n if (policies.some(previous => previous.name === policy.name)) {\n context.error(DiagnosticCodes.DuplicateDeclaration, `Duplicate declaration of policy '${policy.name}' - policy names must be unique`, policy.location);\n }\n policies.push(policy);\n } else if (keyword === 'exposure') {\n exposures.push(parseExposure(context, line));\n } else if (keyword === 'instance') {\n instanceContributions.push(parseInstance(context, line));\n } else if (keyword === 'trigger') {\n const data = parseTriggerDeclaration(context, line);\n const name = /^trigger\\s+([A-Za-z_]\\w*)$/.exec(line.content)?.[1];\n if (name !== undefined) declaredTriggers.push({ name, data });\n } else if (opaqueTopLevel.has(keyword)) {\n if (keyword === 'behavior' || keyword === 'layout') collectInputUses(context, line);\n else if (keyword === 'ui') parseUiProfile(context, line);\n else context.skipOpaqueBlock(line.indent);\n } else if (placedBody?.tryParse(context, line) !== true) {\n reportUnexpectedTopLevel(context, line, placement);\n }\n }\n if (moduleBody !== undefined) {\n modules.unshift(moduleBody.build(context.start, true));\n } else if (featureBody !== undefined) {\n modules.unshift(place(placement, featureBody.build(context.start, true), context.start));\n }\n const root: ApplicationSyntax = { kind: 'ApplicationSyntax', ...(commandReadMode === null ? {} : { commandReadMode }), ...(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 } : {}), ...(stickyNotes.length > 0 ? { stickyNotes } : {}), ...(instanceContributions.length > 0 ? { instanceContributions } : {}), location: context.start };\n if (context.authoredDeclarations) recordAuthoredDocument(root);\n return root;\n}\n\nfunction declaresConstruct(keyword: string, line: SourceLine, placement: PlayPlacement): boolean {\n if (keyword === 'import') {\n return importPattern.test(line.content);\n }\n if (keyword === 'module') {\n return isDocumentPlacement(placement);\n }\n if (keyword === 'identity') return line.content === 'identity';\n return keyword === 'purpose' || keyword === 'example' || keyword === 'exposure' || keyword === 'instance' || keyword === 'eventsource' || keyword === 'system' || keyword === 'concept' || keyword === 'type' || keyword === 'persona' || keyword === 'sticky' || opaqueTopLevel.has(keyword);\n}\n\nfunction parseModuleInPlacedFile(context: ParserContext, line: SourceLine, placement: PlayPlacement, moduleBody: ModuleBody | undefined): void {\n const name = modulePattern.exec(line.content)?.[1] ?? '';\n\n // Restating the module a file is placed in says nothing new, so its body simply joins the placement.\n if (moduleBody !== undefined && name === placement[0]) {\n context.authoredDeclarations = true;\n moduleBody.parseChildren(context, line);\n return;\n }\n context.error(DiagnosticCodes.ModuleInPlacedFile,\n `This file is imported into ${describePlacement(placement)}, so it cannot declare module '${name}' - import it at the top level of a document instead`, locationOf(line));\n context.skipBlock(line.indent);\n}\n\nfunction reportUnexpectedTopLevel(context: ParserContext, line: SourceLine, placement: PlayPlacement): void {\n const word = firstWord(line.content);\n if (!isDocumentPlacement(placement)) {\n const expected = placement.length === 1 ? moduleBodyExpected : featureBodyExpected;\n context.error(DiagnosticCodes.UnexpectedInPlacedFile,\n `Unexpected '${word}' in a file imported into ${describePlacement(placement)} - expected an application declaration or ${expected}`, locationOf(line));\n } else {\n const hint = bodyKeywords.has(word)\n ? ` - '${word}' belongs in a module or feature; wrap it in one, or import this file from inside one`\n : ' - expected domain, import, concept, type, policy, persona, sticky note on personas, 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 const goals: string[] = [];\n let position: readonly [number, number] | null = null;\n let size: readonly [number, number] | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'description') {\n description = parseDescription(context, child, description, `Persona '${name}'`);\n } else if (keyword === 'goal') {\n const goal = personaGoalPattern.exec(child.content);\n if (goal === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid goal '${child.content}' - expected 'goal \"<text>\"'`, locationOf(child));\n } else {\n goals.push(unescapeString(goal[1]));\n }\n } else if (keyword === 'position') {\n position = parseCanvasPair(context, child, 'position', 'x', 'y', position, true) ?? position;\n } else if (keyword === 'size') {\n size = parseCanvasPair(context, child, 'size', 'width', 'height', size, false) ?? size;\n } else if (keyword === 'policy') {\n const policy = personaPolicyPattern.exec(child.content);\n if (policy === null) {\n context.error(DiagnosticCodes.InvalidPersonaPolicyReference, `Invalid policy reference '${child.content}' - expected 'policy <Name>'`, locationOf(child));\n } else {\n policies.push(policy[1]);\n }\n } else {\n context.error(DiagnosticCodes.UnknownPersonaDirective, `Unexpected '${keyword}' in persona body - expected description, goal, policy, position or size`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return {\n kind: 'PersonaSyntax', name, description, policies,\n ...(goals.length > 0 ? { goals } : {}),\n ...(position === null ? {} : { x: position[0], y: position[1] }),\n ...(size === null ? {} : { width: size[0], height: size[1] }),\n location: locationOf(line),\n };\n}\n\n// 'sticky note on personas' with the text it carries, an optional colour and where it sits on the personas canvas - the port of the C# ParseStickyNote.\nfunction parseStickyNote(context: ParserContext, line: SourceLine): StickyNoteSyntax | null {\n if (!stickyNotePattern.test(line.content)) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid sticky note declaration '${line.content}' - expected 'sticky note on personas'`, locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n let text: string | null = null;\n let colour: string | null = null;\n let position: readonly [number, number] | null = null;\n let size: readonly [number, number] | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'description') {\n text = parseDescription(context, child, text, 'A sticky note');\n } else if (keyword === 'colour') {\n const match = stickyNoteColourPattern.exec(child.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid colour '${child.content}' - expected 'colour yellow', 'colour pink', 'colour green' or 'colour blue'`, locationOf(child));\n } else {\n colour = match[1];\n }\n } else if (keyword === 'position') {\n position = parseCanvasPair(context, child, 'position', 'x', 'y', position, true) ?? position;\n } else if (keyword === 'size') {\n size = parseCanvasPair(context, child, 'size', 'width', 'height', size, false) ?? size;\n } else {\n context.error(DiagnosticCodes.UnknownPersonaDirective, `Unexpected '${keyword}' in sticky note body - expected description, colour, position or size`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n if (text === null || position === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, 'A sticky note needs a description (the text on it) and a position', locationOf(line));\n return null;\n }\n return { kind: 'StickyNoteSyntax', text, colour, x: position[0], y: position[1], width: size === null ? null : size[0], height: size === null ? null : size[1], location: locationOf(line) };\n}\n\n// 'position <x> <y>' or 'size <width> <height>' - two whole numbers in canvas units; a second line is a mistake.\nfunction parseCanvasPair(context: ParserContext, line: SourceLine, keyword: string, first: string, second: string, existing: readonly [number, number] | null, allowNegative: boolean): readonly [number, number] | null {\n const match = canvasPairPattern.exec(line.content);\n const firstValue = match === null ? Number.NaN : Number.parseInt(match[2], 10);\n const secondValue = match === null ? Number.NaN : Number.parseInt(match[3], 10);\n const valid = match !== null && match[1] === keyword && Number.isSafeInteger(firstValue) && Number.isSafeInteger(secondValue)\n && firstValue >= -2147483648 && firstValue <= 2147483647 && secondValue >= -2147483648 && secondValue <= 2147483647\n && (allowNegative || (firstValue >= 0 && secondValue >= 0));\n if (!valid) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid ${keyword} '${line.content}' - expected '${keyword} <${first}> <${second}>' with whole numbers${allowNegative ? '' : ' that are not negative'}`, locationOf(line));\n return null;\n }\n if (existing !== null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `The ${keyword} is already declared - at most one is allowed`, locationOf(line));\n return null;\n }\n return [firstValue, secondValue];\n}\n"],"mappings":"m9DAoDA,MAAMA,EAAgBC,EAAQ,kDAAkD,EAC1EC,EAAgBD,EAAQ,iDAAiDE,EAAkB,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,SAAS,gBAAgB,EAAwB,EAAkB,EAAiB,EAAe,EAAgB,EAA4C,EAA0D,CACrN,IAAMS,EAAQ9C,EAAkB,KAAKqC,EAAK,OAAO,EAC3C2E,EAAalE,IAAU,KAAO,IAAa,OAAO,SAASA,EAAM,GAAI,EAAE,EACvEmE,EAAcnE,IAAU,KAAO,IAAa,OAAO,SAASA,EAAM,GAAI,EAAE,EAY9E,OAXcA,IAAU,MAAQA,EAAM,KAAOR,GAAW,OAAO,cAAc0E,CAAU,GAAK,OAAO,cAAcC,CAAW,GACrHD,GAAc,aAAeA,GAAc,YAAcC,GAAe,aAAeA,GAAe,aACrGC,GAAkBF,GAAc,GAAKC,GAAe,GAKxD/B,IAAa,KAIV,CAAC8B,EAAYC,CAAW,GAH3B3G,EAAQ,MAAMmC,EAAgB,0BAA2B,OAAOH,EAAQ,+CAAgDI,EAAWL,CAAI,CAAC,EACjI,OALP/B,EAAQ,MAAMmC,EAAgB,0BAA2B,WAAWH,EAAQ,IAAID,EAAK,QAAQ,gBAAgBC,EAAQ,IAAI6E,EAAM,KAAKC,EAAO,uBAAuBF,EAAgB,GAAK,2BAA4BxE,EAAWL,CAAI,CAAC,EAC5N,KAOf"}
1
+ {"version":3,"file":"ScreenplayParser.js","names":["domainPattern","pattern","importPattern","stringBodyPattern","conceptPattern","enumValuePattern","personaPattern","personaPolicyPattern","personaGoalPattern","stickyNotePattern","stickyNoteColourPattern","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","stickyNotes","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","stickyNote","parseSeed","parsePurpose","parseIdentity","policy","parsePolicy","previous","parseExposure","parseInstance","data","parseTriggerDeclaration","name","collectInputUses","parseUiProfile","root","recordAuthoredDocument","modulePattern","describePlacement","word","hint","expected","moduleBodyExpected","featureBodyExpected","feature","innermost","index","start","existing","inFence","startOf","type","attributeText","attributes","parseComplianceMarkers","values","members","EnumerationMembers","generation","declaredGeneration","description","validations","child","memberName","parseDescription","isFileDirective","parsed","parseValidate","parseGeneration","parseComplianceDirective","unescapeIdentifier","valueNumbers","goals","position","size","goal","parseCanvasPair","canvasMatch","text","colour"],"sources":["../../../../../../Compiler/Parsing/ScreenplayParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { CommandReadMode } from '../Syntax/CommandReadMode';\nimport { ReactionProductionMode } from '../Syntax/ReactionProductionMode';\nimport { EnumerationMembers } from './EnumerationMembers';\nimport { GenerationSyntax } from '../Syntax/GenerationSyntax';\nimport { 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, StickyNoteSyntax } 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 { parseCanvasPair } from './CanvasPlacement';\nimport { parseEventSource } from './EventSourceParser';\nimport { parseExposure, parseInstance } from './CompositionParser';\nimport { ExposureSyntax, InstanceContributionsSyntax } from '../Syntax/CompositionSyntax';\nimport { parseExample } from './SpecificationExampleParser';\nimport { parseUiProfile } from './UiProfileLegacyLayout';\nimport { locationOf, SourceLine, startOf } from './SourceLine';\n\nconst domainPattern = pattern('^domain\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)$');\nconst importPattern = pattern(`^import\\\\s+([\\\\w.]+)(?:\\\\s+from\\\\s+\"(?<origin>${stringBodyPattern})\")?$`);\nconst conceptPattern = pattern('^concept\\\\s+(\\\\w+)\\\\s*:\\\\s*(\\\\w+)((?:\\\\s+@?\\\\w+)*)$');\nconst enumValuePattern = pattern('^@?[a-z_]\\\\w*$');\nconst personaPattern = pattern('^persona\\\\s+([A-Za-z_]\\\\w*)$');\nconst personaPolicyPattern = pattern('^policy\\\\s+([A-Za-z_]\\\\w*)$');\nconst personaGoalPattern = pattern(`^goal\\\\s+\"(${stringBodyPattern})\"$`);\nconst stickyNotePattern = pattern('^sticky\\\\s+note\\\\s+on\\\\s+(personas|eventsources|givencontexts|seeddata)$');\nconst stickyNoteColourPattern = pattern('^colour\\\\s+(yellow|pink|green|blue)$');\nconst tabIndentPattern = /^[ ]*\\t/;\nconst primitiveTypes = ['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime'];\n\n// Top-level, module and feature constructs the C# compiler knows that this compiler does not model. They\n// are skipped whole, not reported.\nconst opaqueTopLevel = new Set(['policy', 'authentication', '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 stickyNotes: StickyNoteSyntax[] = [];\n const policies: PolicySyntax[] = [];\n const purposes: PurposeSyntax[] = [];\n const seeds: SeedSyntax[] = [];\n const examples: SpecificationExampleSyntax[] = [];\n const declaredTriggers: NonNullable<ApplicationSyntax['declaredTriggers']>[number][] = [];\n const exposures: ExposureSyntax[] = [];\n const instanceContributions: InstanceContributionsSyntax[] = [];\n let sawOtherConstruct = false;\n for (let line = context.reader.peekSignificant(); line !== undefined; line = context.reader.peekSignificant()) {\n context.reader.takeSignificant();\n const keyword = firstWord(line.content);\n if (keyword === 'command' && /^command\\s+reads(?:\\s|$)/.test(line.content)) {\n if (sawCommandReads || !isDocumentPlacement(placement) || !/^command\\s+reads\\s+protected$/.test(line.content)) {\n context.error(DiagnosticCodes.InvalidCommandReadsDeclaration, \"Declare 'command reads protected' once at the application root.\", locationOf(line));\n } else {\n commandReadMode = CommandReadMode.Protected;\n }\n sawCommandReads = true;\n continue;\n }\n if (keyword === '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 === 'sticky') {\n const stickyNote = parseStickyNote(context, line);\n if (stickyNote !== null) stickyNotes.push(stickyNote);\n } else if (keyword === 'seed') {\n seeds.push(parseSeed(context.valueContext, line));\n } else if (keyword === 'purpose' && placedBody !== undefined) {\n placedBody.tryParse(context, line);\n } else if (keyword === 'purpose') {\n purposes.push(parsePurpose(context, line));\n } else if (keyword === 'identity') {\n identity = parseIdentity(context, line, identity);\n } else if (keyword === 'policy') {\n const policy = parsePolicy(context, line);\n if (policies.some(previous => previous.name === policy.name)) {\n context.error(DiagnosticCodes.DuplicateDeclaration, `Duplicate declaration of policy '${policy.name}' - policy names must be unique`, policy.location);\n }\n policies.push(policy);\n } else if (keyword === 'exposure') {\n exposures.push(parseExposure(context, line));\n } else if (keyword === 'instance') {\n instanceContributions.push(parseInstance(context, line));\n } else if (keyword === 'trigger') {\n const data = parseTriggerDeclaration(context, line);\n const name = /^trigger\\s+([A-Za-z_]\\w*)$/.exec(line.content)?.[1];\n if (name !== undefined) declaredTriggers.push({ name, data });\n } else if (opaqueTopLevel.has(keyword)) {\n if (keyword === 'behavior' || keyword === 'layout') collectInputUses(context, line);\n else if (keyword === 'ui') parseUiProfile(context, line);\n else context.skipOpaqueBlock(line.indent);\n } else if (placedBody?.tryParse(context, line) !== true) {\n reportUnexpectedTopLevel(context, line, placement);\n }\n }\n if (moduleBody !== undefined) {\n modules.unshift(moduleBody.build(context.start, true));\n } else if (featureBody !== undefined) {\n modules.unshift(place(placement, featureBody.build(context.start, true), context.start));\n }\n const root: ApplicationSyntax = { kind: 'ApplicationSyntax', ...(commandReadMode === null ? {} : { commandReadMode }), ...(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 } : {}), ...(stickyNotes.length > 0 ? { stickyNotes } : {}), ...(instanceContributions.length > 0 ? { instanceContributions } : {}), location: context.start };\n if (context.authoredDeclarations) recordAuthoredDocument(root);\n return root;\n}\n\nfunction declaresConstruct(keyword: string, line: SourceLine, placement: PlayPlacement): boolean {\n if (keyword === 'import') {\n return importPattern.test(line.content);\n }\n if (keyword === 'module') {\n return isDocumentPlacement(placement);\n }\n if (keyword === 'identity') return line.content === 'identity';\n return keyword === 'purpose' || keyword === 'example' || keyword === 'exposure' || keyword === 'instance' || keyword === 'eventsource' || keyword === 'system' || keyword === 'concept' || keyword === 'type' || keyword === 'persona' || keyword === 'sticky' || opaqueTopLevel.has(keyword);\n}\n\nfunction parseModuleInPlacedFile(context: ParserContext, line: SourceLine, placement: PlayPlacement, moduleBody: ModuleBody | undefined): void {\n const name = modulePattern.exec(line.content)?.[1] ?? '';\n\n // Restating the module a file is placed in says nothing new, so its body simply joins the placement.\n if (moduleBody !== undefined && name === placement[0]) {\n context.authoredDeclarations = true;\n moduleBody.parseChildren(context, line);\n return;\n }\n context.error(DiagnosticCodes.ModuleInPlacedFile,\n `This file is imported into ${describePlacement(placement)}, so it cannot declare module '${name}' - import it at the top level of a document instead`, locationOf(line));\n context.skipBlock(line.indent);\n}\n\nfunction reportUnexpectedTopLevel(context: ParserContext, line: SourceLine, placement: PlayPlacement): void {\n const word = firstWord(line.content);\n if (!isDocumentPlacement(placement)) {\n const expected = placement.length === 1 ? moduleBodyExpected : featureBodyExpected;\n context.error(DiagnosticCodes.UnexpectedInPlacedFile,\n `Unexpected '${word}' in a file imported into ${describePlacement(placement)} - expected an application declaration or ${expected}`, locationOf(line));\n } else {\n const hint = bodyKeywords.has(word)\n ? ` - '${word}' belongs in a module or feature; wrap it in one, or import this file from inside one`\n : ' - expected domain, import, concept, type, policy, persona, sticky note, authentication, 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 const goals: string[] = [];\n let position: readonly [number, number] | null = null;\n let size: readonly [number, number] | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'description') {\n description = parseDescription(context, child, description, `Persona '${name}'`);\n } else if (keyword === 'goal') {\n const goal = personaGoalPattern.exec(child.content);\n if (goal === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid goal '${child.content}' - expected 'goal \"<text>\"'`, locationOf(child));\n } else {\n goals.push(unescapeString(goal[1]));\n }\n } else if (keyword === 'position') {\n position = parseCanvasPair(context, child, 'position', 'x', 'y', position, true) ?? position;\n } else if (keyword === 'size') {\n size = parseCanvasPair(context, child, 'size', 'width', 'height', size, false) ?? size;\n } else if (keyword === 'policy') {\n const policy = personaPolicyPattern.exec(child.content);\n if (policy === null) {\n context.error(DiagnosticCodes.InvalidPersonaPolicyReference, `Invalid policy reference '${child.content}' - expected 'policy <Name>'`, locationOf(child));\n } else {\n policies.push(policy[1]);\n }\n } else {\n context.error(DiagnosticCodes.UnknownPersonaDirective, `Unexpected '${keyword}' in persona body - expected description, goal, policy, position or size`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return {\n kind: 'PersonaSyntax', name, description, policies,\n ...(goals.length > 0 ? { goals } : {}),\n ...(position === null ? {} : { x: position[0], y: position[1] }),\n ...(size === null ? {} : { width: size[0], height: size[1] }),\n location: locationOf(line),\n };\n}\n\n// 'sticky note on <canvas>' with the text it carries, an optional colour and where it sits on that canvas - the port of the C# ParseStickyNote.\nfunction parseStickyNote(context: ParserContext, line: SourceLine): StickyNoteSyntax | null {\n const canvasMatch = stickyNotePattern.exec(line.content);\n if (canvasMatch === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid sticky note declaration '${line.content}' - expected 'sticky note on personas', 'sticky note on eventsources', 'sticky note on givencontexts' or 'sticky note on seeddata'`, locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n let text: string | null = null;\n let colour: string | null = null;\n let position: readonly [number, number] | null = null;\n let size: readonly [number, number] | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'description') {\n text = parseDescription(context, child, text, 'A sticky note');\n } else if (keyword === 'colour') {\n const match = stickyNoteColourPattern.exec(child.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, `Invalid colour '${child.content}' - expected 'colour yellow', 'colour pink', 'colour green' or 'colour blue'`, locationOf(child));\n } else {\n colour = match[1];\n }\n } else if (keyword === 'position') {\n position = parseCanvasPair(context, child, 'position', 'x', 'y', position, true) ?? position;\n } else if (keyword === 'size') {\n size = parseCanvasPair(context, child, 'size', 'width', 'height', size, false) ?? size;\n } else {\n context.error(DiagnosticCodes.UnknownPersonaDirective, `Unexpected '${keyword}' in sticky note body - expected description, colour, position or size`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n if (text === null || position === null) {\n context.error(DiagnosticCodes.InvalidPersonaDeclaration, 'A sticky note needs a description (the text on it) and a position', locationOf(line));\n return null;\n }\n return { kind: 'StickyNoteSyntax', canvas: canvasMatch[1] as StickyNoteSyntax['canvas'], text, colour, x: position[0], y: position[1], width: size === null ? null : size[0], height: size === null ? null : size[1], location: locationOf(line) };\n}\n\n"],"mappings":"0gEAqDA,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,EAAqBP,EAAQ,cAAcE,EAAkB,IAAI,EACjEM,EAAoBR,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IAAA,GAAW,EAAQ1F,EAAQ,UAAU+B,EAAK,MAAM,EAAG,CAC1G/B,EAAQ,OAAO,gBAAgB,EAC/B,IAAMgC,EAAUC,EAAUyD,EAAM,OAAO,EACvC,GAAI1D,IAAY,cACZ,EAAO4D,EAAiB5F,EAAS0F,EAAOgB,EAAM,eAAe,OAC1D,GAAI1E,IAAY,SAAU,CAC7B,IAAMQ,EAAQ9C,EAAwB,KAAKgG,EAAM,OAAO,EACpDlD,IAAU,KACVxC,EAAQ,MAAMmC,EAAgB,0BAA2B,mBAAmBuD,EAAM,QAAQ,8EAA+EtD,EAAWsD,CAAK,CAAC,EAE1L,EAASlD,EAAM,EAEvB,MAAWR,IAAY,WACnB,EAAWwE,EAAgBxG,EAAS0F,EAAO,WAAY,IAAK,IAAKW,EAAU,EAAI,GAAKA,EAC7ErE,IAAY,OACnB,EAAOwE,EAAgBxG,EAAS0F,EAAO,OAAQ,QAAS,SAAUY,EAAM,EAAK,GAAKA,GAElFtG,EAAQ,MAAMmC,EAAgB,wBAAyB,eAAeH,EAAQ,wEAAyEI,EAAWsD,CAAK,CAAC,EACxK1F,EAAQ,UAAU0F,EAAM,MAAM,EAEtC,CAKA,OAJIgB,IAAS,MAAQL,IAAa,MAC9BrG,EAAQ,MAAMmC,EAAgB,0BAA2B,oEAAqEC,EAAWL,CAAI,CAAC,EACvI,MAEJ,CAAE,KAAM,mBAAoB,OAAQ0E,EAAY,GAAkC,OAAM,SAAQ,EAAGJ,EAAS,GAAI,EAAGA,EAAS,GAAI,MAAOC,IAAS,KAAO,KAAOA,EAAK,GAAI,OAAQA,IAAS,KAAO,KAAOA,EAAK,GAAI,SAAUlE,EAAWL,CAAI,CAAE,CACrP"}
@@ -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{nativePattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{parseModeledMappingSource as a}from"./ExpressionParser.js";const o=RegExp(`^for\\s+"(${t})"$`,`u`),s=r(`^[A-Z]\\w*$`),c=r(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`);function parseSeed(t,r){let l=[];if(t=t.valueContext,r.content!==`seed`)return t.error(e.InvalidSeedDeclaration,`Invalid seed declaration '${r.content}' - expected 'seed'`,i(r)),t.skipOpaqueBlock(r.indent),{kind:`SeedSyntax`,groups:l,location:i(r)};for(let u=t.peekChild(r.indent);u!==void 0;u=t.peekChild(r.indent)){t.reader.takeSignificant();let r=o.exec(u.content);if(r===null){t.error(e.InvalidSeedGroup,`Invalid seed group '${u.content}' - expected 'for "<event source id>"'`,i(u)),t.skipOpaqueBlock(u.indent);continue}let d=[];for(let n=t.peekChild(u.indent);n!==void 0;n=t.peekChild(u.indent)){if(t.reader.takeSignificant(),!s.test(n.content)){t.error(e.InvalidSeedEvent,`Invalid seed event '${n.content}' - expected an event type name`,i(n)),t.skipOpaqueBlock(n.indent);continue}let r=[];for(let o=t.peekChild(n.indent);o!==void 0;o=t.peekChild(n.indent)){t.reader.takeSignificant();let n=c.exec(o.content);n===null?t.error(e.InvalidSeedPropertyAssignment,`Invalid property assignment '${o.content}' - expected '<property> = <value>'`,i(o)):r.push({kind:`PropertyMappingSyntax`,property:n[1],source:a(n[2],i(o),t),location:i(o)})}d.push({kind:`SeedEventSyntax`,event:n.content,properties:r,location:i(n)})}l.push({kind:`SeedGroupSyntax`,eventSourceId:n(r[1]),events:d,location:i(u)})}return{kind:`SeedSyntax`,groups:l,location:i(r)}}export{parseSeed};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{nativePattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{parseModeledMappingSource as a}from"./ExpressionParser.js";import{firstWord as o}from"./LineText.js";import{parseCanvasPair as s}from"./CanvasPlacement.js";const c=RegExp(`^seed(?:\\s+"(${t})")?$`,`u`),l=RegExp(`^for\\s+"(${t})"$`,`u`),u=r(`^[A-Z]\\w*$`),d=r(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`);function parseSeed(t,r){let f=[];t=t.valueContext;let p=c.exec(r.content);if(p===null)return t.error(e.InvalidSeedDeclaration,`Invalid seed declaration '${r.content}' - expected 'seed' or 'seed "<name>"'`,i(r)),t.skipOpaqueBlock(r.indent),{kind:`SeedSyntax`,groups:f,location:i(r)};let m=null;for(let c=t.peekChild(r.indent);c!==void 0;c=t.peekChild(r.indent)){if(t.reader.takeSignificant(),o(c.content)===`position`){m=s(t,c,`position`,`x`,`y`,m,!0)??m;continue}let r=l.exec(c.content);if(r===null){t.error(e.InvalidSeedGroup,`Invalid seed group '${c.content}' - expected 'for "<event source id>"'`,i(c)),t.skipOpaqueBlock(c.indent);continue}let p=[];for(let n=t.peekChild(c.indent);n!==void 0;n=t.peekChild(c.indent)){if(t.reader.takeSignificant(),!u.test(n.content)){t.error(e.InvalidSeedEvent,`Invalid seed event '${n.content}' - expected an event type name`,i(n)),t.skipOpaqueBlock(n.indent);continue}let r=[];for(let o=t.peekChild(n.indent);o!==void 0;o=t.peekChild(n.indent)){t.reader.takeSignificant();let n=d.exec(o.content);n===null?t.error(e.InvalidSeedPropertyAssignment,`Invalid property assignment '${o.content}' - expected '<property> = <value>'`,i(o)):r.push({kind:`PropertyMappingSyntax`,property:n[1],source:a(n[2],i(o),t),location:i(o)})}p.push({kind:`SeedEventSyntax`,event:n.content,properties:r,location:i(n)})}f.push({kind:`SeedGroupSyntax`,eventSourceId:n(r[1]),events:p,location:i(c)})}return{kind:`SeedSyntax`,groups:f,...p[1]===void 0?{}:{name:n(p[1])},...m===null?{}:{x:m[0],y:m[1]},location:i(r)}}export{parseSeed};
2
2
  //# sourceMappingURL=SeedParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SeedParser.js","names":["pattern","parseMappingSource","forPattern","stringBodyPattern","eventPattern","nativePattern","mappingPattern","groups","context","header","DiagnosticCodes","locationOf","group","match","events","event","properties","property","mapped","parseModeledMappingSource","unescapeString"],"sources":["../../../../../../Compiler/Parsing/SeedParser.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 { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SeedEventSyntax, SeedGroupSyntax, SeedSyntax } from '../Syntax/Seeds';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { nativePattern as pattern } from '../Text/patterns';\nimport { parseModeledMappingSource as parseMappingSource } from './ExpressionParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst forPattern = new RegExp(`^for\\\\s+\"(${stringBodyPattern})\"$`, 'u');\nconst eventPattern = pattern('^[A-Z]\\\\w*$');\nconst mappingPattern = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\n\nexport function parseSeed(context: ParserContext, header: SourceLine): SeedSyntax {\n const groups: SeedGroupSyntax[] = [];\n context = context.valueContext;\n if (header.content !== 'seed') {\n context.error(DiagnosticCodes.InvalidSeedDeclaration, `Invalid seed declaration '${header.content}' - expected 'seed'`, locationOf(header));\n context.skipOpaqueBlock(header.indent);\n return { kind: 'SeedSyntax', groups, location: locationOf(header) };\n }\n for (let group = context.peekChild(header.indent); group !== undefined; group = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const match = forPattern.exec(group.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSeedGroup, `Invalid seed group '${group.content}' - expected 'for \"<event source id>\"'`, locationOf(group));\n context.skipOpaqueBlock(group.indent);\n continue;\n }\n const events: SeedEventSyntax[] = [];\n for (let event = context.peekChild(group.indent); event !== undefined; event = context.peekChild(group.indent)) {\n context.reader.takeSignificant();\n if (!eventPattern.test(event.content)) {\n context.error(DiagnosticCodes.InvalidSeedEvent, `Invalid seed event '${event.content}' - expected an event type name`, locationOf(event));\n context.skipOpaqueBlock(event.indent);\n continue;\n }\n const properties: PropertyMappingSyntax[] = [];\n for (let property = context.peekChild(event.indent); property !== undefined; property = context.peekChild(event.indent)) {\n context.reader.takeSignificant();\n const mapped = mappingPattern.exec(property.content);\n if (mapped !== null) properties.push({ kind: 'PropertyMappingSyntax', property: mapped[1], source: parseMappingSource(mapped[2], locationOf(property), context), location: locationOf(property) });\n else context.error(DiagnosticCodes.InvalidSeedPropertyAssignment, `Invalid property assignment '${property.content}' - expected '<property> = <value>'`, locationOf(property));\n }\n events.push({ kind: 'SeedEventSyntax', event: event.content, properties, location: locationOf(event) });\n }\n groups.push({ kind: 'SeedGroupSyntax', eventSourceId: unescapeString(match[1]), events, location: locationOf(group) });\n }\n return { kind: 'SeedSyntax', groups, location: locationOf(header) };\n}\n"],"mappings":"6WAYA,MAAME,EAAiB,OAAO,aAAaC,EAAkB,KAAM,GAAG,EAChEC,EAAeJ,EAAQ,aAAa,EACpCM,EAAiBN,EAAQ,iCAAiC,EAEhE,SAAgB,UAAU,EAAwB,EAAgC,CAC9E,IAAMO,EAA4B,CAAC,EAEnC,GADA,EAAUC,EAAQ,aACdC,EAAO,UAAY,OAGnB,OAFAD,EAAQ,MAAME,EAAgB,uBAAwB,6BAA6BD,EAAO,QAAQ,qBAAsBE,EAAWF,CAAM,CAAC,EAC1ID,EAAQ,gBAAgBC,EAAO,MAAM,EAC9B,CAAE,KAAM,aAAc,SAAQ,SAAUE,EAAWF,CAAM,CAAE,EAEtE,IAAK,IAAIG,EAAQJ,EAAQ,UAAUC,EAAO,MAAM,EAAGG,IAAU,IAAA,GAAW,EAAQJ,EAAQ,UAAUC,EAAO,MAAM,EAAG,CAC9GD,EAAQ,OAAO,gBAAgB,EAC/B,IAAMK,EAAQX,EAAW,KAAKU,EAAM,OAAO,EAC3C,GAAIC,IA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KAAM,aAAc,SAAQ,SAAUD,EAAWF,CAAM,CAAE,CACtE"}
1
+ {"version":3,"file":"SeedParser.js","names":["pattern","parseMappingSource","headerPattern","stringBodyPattern","forPattern","eventPattern","nativePattern","mappingPattern","groups","context","headerMatch","header","DiagnosticCodes","locationOf","position","group","firstWord","parseCanvasPair","match","events","event","properties","property","mapped","parseModeledMappingSource","unescapeString"],"sources":["../../../../../../Compiler/Parsing/SeedParser.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 { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SeedEventSyntax, SeedGroupSyntax, SeedSyntax } from '../Syntax/Seeds';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { nativePattern as pattern } from '../Text/patterns';\nimport { parseCanvasPair } from './CanvasPlacement';\nimport { parseModeledMappingSource as parseMappingSource } from './ExpressionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst headerPattern = new RegExp(`^seed(?:\\\\s+\"(${stringBodyPattern})\")?$`, 'u');\nconst forPattern = new RegExp(`^for\\\\s+\"(${stringBodyPattern})\"$`, 'u');\nconst eventPattern = pattern('^[A-Z]\\\\w*$');\nconst mappingPattern = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\n\nexport function parseSeed(context: ParserContext, header: SourceLine): SeedSyntax {\n const groups: SeedGroupSyntax[] = [];\n context = context.valueContext;\n const headerMatch = headerPattern.exec(header.content);\n if (headerMatch === null) {\n context.error(DiagnosticCodes.InvalidSeedDeclaration, `Invalid seed declaration '${header.content}' - expected 'seed' or 'seed \"<name>\"'`, locationOf(header));\n context.skipOpaqueBlock(header.indent);\n return { kind: 'SeedSyntax', groups, location: locationOf(header) };\n }\n let position: readonly [number, number] | null = null;\n for (let group = context.peekChild(header.indent); group !== undefined; group = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (firstWord(group.content) === 'position') {\n position = parseCanvasPair(context, group, 'position', 'x', 'y', position, true) ?? position;\n continue;\n }\n const match = forPattern.exec(group.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSeedGroup, `Invalid seed group '${group.content}' - expected 'for \"<event source id>\"'`, locationOf(group));\n context.skipOpaqueBlock(group.indent);\n continue;\n }\n const events: SeedEventSyntax[] = [];\n for (let event = context.peekChild(group.indent); event !== undefined; event = context.peekChild(group.indent)) {\n context.reader.takeSignificant();\n if (!eventPattern.test(event.content)) {\n context.error(DiagnosticCodes.InvalidSeedEvent, `Invalid seed event '${event.content}' - expected an event type name`, locationOf(event));\n context.skipOpaqueBlock(event.indent);\n continue;\n }\n const properties: PropertyMappingSyntax[] = [];\n for (let property = context.peekChild(event.indent); property !== undefined; property = context.peekChild(event.indent)) {\n context.reader.takeSignificant();\n const mapped = mappingPattern.exec(property.content);\n if (mapped !== null) properties.push({ kind: 'PropertyMappingSyntax', property: mapped[1], source: parseMappingSource(mapped[2], locationOf(property), context), location: locationOf(property) });\n else context.error(DiagnosticCodes.InvalidSeedPropertyAssignment, `Invalid property assignment '${property.content}' - expected '<property> = <value>'`, locationOf(property));\n }\n events.push({ kind: 'SeedEventSyntax', event: event.content, properties, location: locationOf(event) });\n }\n groups.push({ kind: 'SeedGroupSyntax', eventSourceId: unescapeString(match[1]), events, location: locationOf(group) });\n }\n return { kind: 'SeedSyntax', groups, ...(headerMatch[1] === undefined ? {} : { name: unescapeString(headerMatch[1]) }), ...(position === null ? {} : { x: position[0], y: position[1] }), location: locationOf(header) };\n}\n"],"mappings":"8cAcA,MAAME,EAAoB,OAAO,iBAAiBC,EAAkB,OAAQ,GAAG,EACzEC,EAAiB,OAAO,aAAaD,EAAkB,KAAM,GAAG,EAChEE,EAAeL,EAAQ,aAAa,EACpCO,EAAiBP,EAAQ,iCAAiC,EAEhE,SAAgB,UAAU,EAA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