xmlui 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Pdf-DeGhSMXe.mjs +19537 -0
- package/dist/Pdf.css +1 -0
- package/dist/apiInterceptorWorker-CwuUhYyc.mjs +9229 -0
- package/dist/array-USo-Szhp.mjs +12 -0
- package/dist/index-C24dkfpd.mjs +1434 -0
- package/dist/index-ao27SnVp.mjs +145185 -0
- package/dist/index.css +1 -0
- package/dist/nivo-bar.es-CWh0ZlxB.mjs +1666 -0
- package/dist/nivo-geo.es-BTqNt5Db.mjs +1579 -0
- package/dist/nivo-legends.es-BuIxHGSU.mjs +6916 -0
- package/dist/nivo-pie.es-BvCBFA0L.mjs +700 -0
- package/dist/react-apexcharts.min-DqWuDOyO.mjs +8881 -0
- package/dist/scripts/bin/bootstrap.js +11 -0
- package/dist/scripts/bin/build.js +256 -0
- package/dist/scripts/bin/index.js +88 -0
- package/dist/scripts/bin/preview.js +27 -0
- package/dist/scripts/bin/start.js +41 -0
- package/dist/scripts/bin/vite-ueml-plugin.js +113 -0
- package/dist/scripts/bin/viteConfig.js +112 -0
- package/dist/scripts/src/abstractions/ActionDefs.js +2 -0
- package/dist/scripts/src/abstractions/AppContextDefs.js +2 -0
- package/dist/scripts/src/abstractions/BlockScope.js +4 -0
- package/dist/scripts/src/abstractions/ComponentDefs.js +2 -0
- package/dist/scripts/src/abstractions/ComponentDescriptorDefs.js +2 -0
- package/dist/scripts/src/abstractions/ContainerDefs.js +2 -0
- package/dist/scripts/src/abstractions/FunctionDefs.js +2 -0
- package/dist/scripts/src/abstractions/RendererDefs.js +2 -0
- package/dist/scripts/src/abstractions/scripting/ScriptParserError.js +2 -0
- package/dist/scripts/src/abstractions/scripting/ScriptingSourceTree.js +2 -0
- package/dist/scripts/src/abstractions/scripting/Token.js +110 -0
- package/dist/scripts/src/components/App/App.js +253 -0
- package/dist/scripts/src/components/App/AppLayoutContext.js +9 -0
- package/dist/scripts/src/components/App/AppStateContext.js +9 -0
- package/dist/scripts/src/components/App/Sheet.js +89 -0
- package/dist/scripts/src/components/AppHeader/AppHeader.js +121 -0
- package/dist/scripts/src/components/AppState/AppState.js +29 -0
- package/dist/scripts/src/components/Avatar/Avatar.js +81 -0
- package/dist/scripts/src/components/Badge/Badge.js +56 -0
- package/dist/scripts/src/components/BarChart/BarChart.js +199 -0
- package/dist/scripts/src/components/Bookmark/Bookmark.js +11 -0
- package/dist/scripts/src/components/Button/Button.js +196 -0
- package/dist/scripts/src/components/Card/Card.js +65 -0
- package/dist/scripts/src/components/ChangeListener/ChangeListener.js +43 -0
- package/dist/scripts/src/components/Chart/Chart.js +158 -0
- package/dist/scripts/src/components/Checkbox/Checkbox.js +43 -0
- package/dist/scripts/src/components/Combobox/Combobox.js +145 -0
- package/dist/scripts/src/components/ComponentProvider.js +357 -0
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +40 -0
- package/dist/scripts/src/components/DatePicker/DatePicker.js +196 -0
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +175 -0
- package/dist/scripts/src/components/EmojiSelector/EmojiSelector.js +56 -0
- package/dist/scripts/src/components/FileInput/FileInput.js +127 -0
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.js +106 -0
- package/dist/scripts/src/components/FlowLayout/FlowLayout.js +139 -0
- package/dist/scripts/src/components/Footer/Footer.js +42 -0
- package/dist/scripts/src/components/Form/Form.js +320 -0
- package/dist/scripts/src/components/Form/FormContext.js +9 -0
- package/dist/scripts/src/components/Form/formActions.js +86 -0
- package/dist/scripts/src/components/FormItem/FormItem.js +204 -0
- package/dist/scripts/src/components/FormItem/HelperText.js +27 -0
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +39 -0
- package/dist/scripts/src/components/FormItem/Validations.js +346 -0
- package/dist/scripts/src/components/FormSection/FormSection.js +45 -0
- package/dist/scripts/src/components/Heading/Heading.js +206 -0
- package/dist/scripts/src/components/HoverCard/HoverCard.js +45 -0
- package/dist/scripts/src/components/Icon/ApiIcon.js +10 -0
- package/dist/scripts/src/components/Icon/Attach.js +10 -0
- package/dist/scripts/src/components/Icon/Binding.js +11 -0
- package/dist/scripts/src/components/Icon/BoardIcon.js +7 -0
- package/dist/scripts/src/components/Icon/BoxIcon.js +10 -0
- package/dist/scripts/src/components/Icon/CheckIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronDownIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronLeft.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronRight.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronUpIcon.js +7 -0
- package/dist/scripts/src/components/Icon/CodeFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/CodeSandbox.js +10 -0
- package/dist/scripts/src/components/Icon/CompactListIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ContentCopyIcon.js +7 -0
- package/dist/scripts/src/components/Icon/DatabaseIcon.js +11 -0
- package/dist/scripts/src/components/Icon/DocFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/DocIcon.js +10 -0
- package/dist/scripts/src/components/Icon/DotMenuHorizontalIcon.js +7 -0
- package/dist/scripts/src/components/Icon/DotMenuIcon.js +7 -0
- package/dist/scripts/src/components/Icon/EmailIcon.js +7 -0
- package/dist/scripts/src/components/Icon/EmptyFolderIcon.js +10 -0
- package/dist/scripts/src/components/Icon/ErrorIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ExpressionIcon.js +10 -0
- package/dist/scripts/src/components/Icon/FillPlusCricleIcon.js +7 -0
- package/dist/scripts/src/components/Icon/FilterIcon.js +10 -0
- package/dist/scripts/src/components/Icon/FolderIcon.js +10 -0
- package/dist/scripts/src/components/Icon/GlobeIcon.js +7 -0
- package/dist/scripts/src/components/Icon/HomeIcon.js +7 -0
- package/dist/scripts/src/components/Icon/HyperLinkIcon.js +7 -0
- package/dist/scripts/src/components/Icon/Icon.js +101 -0
- package/dist/scripts/src/components/Icon/ImageFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/LinkIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ListIcon.js +7 -0
- package/dist/scripts/src/components/Icon/LooseListIcon.js +7 -0
- package/dist/scripts/src/components/Icon/MoonIcon.js +10 -0
- package/dist/scripts/src/components/Icon/MoreOptionsIcon.js +7 -0
- package/dist/scripts/src/components/Icon/PDFIcon.js +10 -0
- package/dist/scripts/src/components/Icon/PenIcon.js +7 -0
- package/dist/scripts/src/components/Icon/PhoneIcon.js +7 -0
- package/dist/scripts/src/components/Icon/PhotoIcon.js +10 -0
- package/dist/scripts/src/components/Icon/PlusIcon.js +7 -0
- package/dist/scripts/src/components/Icon/SearchIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ShareIcon.js +10 -0
- package/dist/scripts/src/components/Icon/SunIcon.js +10 -0
- package/dist/scripts/src/components/Icon/TrashIcon.js +7 -0
- package/dist/scripts/src/components/Icon/TxtIcon.js +10 -0
- package/dist/scripts/src/components/Icon/UnknownFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/UnlinkIcon.js +10 -0
- package/dist/scripts/src/components/Icon/UserIcon.js +7 -0
- package/dist/scripts/src/components/Icon/WarningIcon.js +7 -0
- package/dist/scripts/src/components/Icon/XlsIcon.js +10 -0
- package/dist/scripts/src/components/IconProvider.js +249 -0
- package/dist/scripts/src/components/IconRegistryContext.js +307 -0
- package/dist/scripts/src/components/Image/Image.js +34 -0
- package/dist/scripts/src/components/Input/InputAdornment.js +14 -0
- package/dist/scripts/src/components/Input/input-abstractions.js +44 -0
- package/dist/scripts/src/components/Items/Items.js +48 -0
- package/dist/scripts/src/components/Link/Link.js +72 -0
- package/dist/scripts/src/components/List/List.js +442 -0
- package/dist/scripts/src/components/Logo/Logo.js +25 -0
- package/dist/scripts/src/components/Map/Map.js +60 -0
- package/dist/scripts/src/components/Map/world_countries.json +45307 -0
- package/dist/scripts/src/components/Markdown/Markdown.js +120 -0
- package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +106 -0
- package/dist/scripts/src/components/ModalDialog/Dialog.js +20 -0
- package/dist/scripts/src/components/ModalDialog/ModalDialog.js +145 -0
- package/dist/scripts/src/components/MultiCombobox/MultiCombobox.js +249 -0
- package/dist/scripts/src/components/MultiSelect/MultiSelect.js +192 -0
- package/dist/scripts/src/components/NavGroup/NavGroup.js +113 -0
- package/dist/scripts/src/components/NavLink/NavLink.js +115 -0
- package/dist/scripts/src/components/NavPanel/NavPanel.js +101 -0
- package/dist/scripts/src/components/NoResult/NoResult.js +39 -0
- package/dist/scripts/src/components/NumberBox/NumberBox.js +373 -0
- package/dist/scripts/src/components/Option/Option.js +41 -0
- package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.js +22 -0
- package/dist/scripts/src/components/Pages/Pages.js +74 -0
- package/dist/scripts/src/components/Pdf/LazyPdf.js +44 -0
- package/dist/scripts/src/components/Pdf/Pdf.js +19 -0
- package/dist/scripts/src/components/PieChart/PieChart.js +184 -0
- package/dist/scripts/src/components/PositionedContainer/PositionedContainer.js +29 -0
- package/dist/scripts/src/components/ProgressBar/ProgressBar.js +38 -0
- package/dist/scripts/src/components/Queue/Queue.js +286 -0
- package/dist/scripts/src/components/Queue/queueActions.js +87 -0
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +144 -0
- package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapter.js +147 -0
- package/dist/scripts/src/components/Redirect/Redirect.js +10 -0
- package/dist/scripts/src/components/Select/Select.js +139 -0
- package/dist/scripts/src/components/Select/SelectContext.js +45 -0
- package/dist/scripts/src/components/SelectionStore/SelectionStore.js +88 -0
- package/dist/scripts/src/components/SpaceFiller/SpaceFiller.js +22 -0
- package/dist/scripts/src/components/Spinner/Spinner.js +59 -0
- package/dist/scripts/src/components/Splitter/Splitter.js +205 -0
- package/dist/scripts/src/components/Splitter/utils.js +17 -0
- package/dist/scripts/src/components/Stack/Stack.js +117 -0
- package/dist/scripts/src/components/StickyBox/StickyBox.js +33 -0
- package/dist/scripts/src/components/Switch/Switch.js +50 -0
- package/dist/scripts/src/components/Table/Table.js +499 -0
- package/dist/scripts/src/components/Table/useRowSelection.js +169 -0
- package/dist/scripts/src/components/TableColumnDef/TableColumnDef.js +44 -0
- package/dist/scripts/src/components/TableColumnDef/TableContext.js +12 -0
- package/dist/scripts/src/components/Tabs/Tabs.js +85 -0
- package/dist/scripts/src/components/Text/Text.js +175 -0
- package/dist/scripts/src/components/TextArea/TextArea.js +194 -0
- package/dist/scripts/src/components/TextArea/TextAreaResizable.js +63 -0
- package/dist/scripts/src/components/TextArea/useComposedRef.js +50 -0
- package/dist/scripts/src/components/TextBox/TextBox.js +145 -0
- package/dist/scripts/src/components/Theme/NotificationToast.js +39 -0
- package/dist/scripts/src/components/Theme/Theme.js +153 -0
- package/dist/scripts/src/components/ThemeChanger/ThemeChanger.js +125 -0
- package/dist/scripts/src/components/Toggle/Toggle.js +88 -0
- package/dist/scripts/src/components/Tree/TreeComponent.js +79 -0
- package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +59 -0
- package/dist/scripts/src/components/ViewComponentRegistryContext.js +34 -0
- package/dist/scripts/src/components/abstractions.js +2 -0
- package/dist/scripts/src/components/chart-color-schemes.js +43 -0
- package/dist/scripts/src/components/component-utils.js +32 -0
- package/dist/scripts/src/components/container-helpers.js +18 -0
- package/dist/scripts/src/components-core/ApiBoundComponent.js +189 -0
- package/dist/scripts/src/components-core/AppContext.js +17 -0
- package/dist/scripts/src/components-core/ChildrenSlot.js +10 -0
- package/dist/scripts/src/components-core/Component.js +280 -0
- package/dist/scripts/src/components-core/ComponentDecorator.js +63 -0
- package/dist/scripts/src/components-core/CompoundComponent.js +132 -0
- package/dist/scripts/src/components-core/EngineError.js +91 -0
- package/dist/scripts/src/components-core/ErrorBoundary.js +58 -0
- package/dist/scripts/src/components-core/Fragment.js +14 -0
- package/dist/scripts/src/components-core/InvalidComponent.js +15 -0
- package/dist/scripts/src/components-core/LoaderComponent.js +78 -0
- package/dist/scripts/src/components-core/RestApiProxy.js +341 -0
- package/dist/scripts/src/components-core/RootComponent.js +272 -0
- package/dist/scripts/src/components-core/RouteContext.js +45 -0
- package/dist/scripts/src/components-core/ScrollContext.js +9 -0
- package/dist/scripts/src/components-core/UnknownComponent.js +15 -0
- package/dist/scripts/src/components-core/abstractions/ComponentRenderer.js +2 -0
- package/dist/scripts/src/components-core/abstractions/LoaderRenderer.js +2 -0
- package/dist/scripts/src/components-core/abstractions/containers.js +18 -0
- package/dist/scripts/src/components-core/abstractions/treeAbstractions.js +2 -0
- package/dist/scripts/src/components-core/action/ApiAction.js +276 -0
- package/dist/scripts/src/components-core/action/DownloadFileAction.js +80 -0
- package/dist/scripts/src/components-core/action/NavigateAction.js +20 -0
- package/dist/scripts/src/components-core/action/TimedAction.js +21 -0
- package/dist/scripts/src/components-core/action/UploadAction.js +88 -0
- package/dist/scripts/src/components-core/action/actions.js +15 -0
- package/dist/scripts/src/components-core/appContext/date-functions.js +19 -0
- package/dist/scripts/src/components-core/appContext/misc-utils.js +12 -0
- package/dist/scripts/src/components-core/component-hooks.js +25 -0
- package/dist/scripts/src/components-core/constants.js +18 -0
- package/dist/scripts/src/components-core/container/Container.js +1110 -0
- package/dist/scripts/src/components-core/container/ContainerComponentDef.js +16 -0
- package/dist/scripts/src/components-core/container/buildProxy.js +54 -0
- package/dist/scripts/src/components-core/container/collectFnVarDeps.js +26 -0
- package/dist/scripts/src/components-core/container/valueExtractor.js +195 -0
- package/dist/scripts/src/components-core/descriptorHelper.js +75 -0
- package/dist/scripts/src/components-core/interception/abstractions.js +2 -0
- package/dist/scripts/src/components-core/interception/useApiInterceptorContext.js +9 -0
- package/dist/scripts/src/components-core/loader/ApiLoader.js +46 -0
- package/dist/scripts/src/components-core/loader/DataLoader.js +160 -0
- package/dist/scripts/src/components-core/loader/ExternalDataLoader.js +52 -0
- package/dist/scripts/src/components-core/loader/Loader.js +115 -0
- package/dist/scripts/src/components-core/loader/MockLoaderRenderer.js +32 -0
- package/dist/scripts/src/components-core/loader/PageableLoader.js +240 -0
- package/dist/scripts/src/components-core/renderers.js +45 -0
- package/dist/scripts/src/components-core/reportEngineError.js +59 -0
- package/dist/scripts/src/components-core/script-runner/BindingTreeEvaluationContext.js +35 -0
- package/dist/scripts/src/components-core/script-runner/ICustomOperations.js +34 -0
- package/dist/scripts/src/components-core/script-runner/LogicalThread.js +2 -0
- package/dist/scripts/src/components-core/script-runner/LoopScope.js +2 -0
- package/dist/scripts/src/components-core/script-runner/ParameterParser.js +117 -0
- package/dist/scripts/src/components-core/script-runner/TryScope.js +2 -0
- package/dist/scripts/src/components-core/script-runner/asyncProxy.js +96 -0
- package/dist/scripts/src/components-core/script-runner/bannedFunctions.js +34 -0
- package/dist/scripts/src/components-core/script-runner/custom-operations-registry.js +40 -0
- package/dist/scripts/src/components-core/script-runner/custom-ui-data.js +40 -0
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +551 -0
- package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +498 -0
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +434 -0
- package/dist/scripts/src/components-core/script-runner/modules.js +250 -0
- package/dist/scripts/src/components-core/script-runner/process-statement-async.js +818 -0
- package/dist/scripts/src/components-core/script-runner/process-statement-common.js +193 -0
- package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +740 -0
- package/dist/scripts/src/components-core/script-runner/statement-queue.js +62 -0
- package/dist/scripts/src/components-core/script-runner/visitors.js +352 -0
- package/dist/scripts/src/components-core/theming/ThemeContext.js +43 -0
- package/dist/scripts/src/components-core/theming/ThemeProvider.js +334 -0
- package/dist/scripts/src/components-core/theming/abstractions.js +11 -0
- package/dist/scripts/src/components-core/theming/extendThemeUtils.js +114 -0
- package/dist/scripts/src/components-core/theming/hvar.js +105 -0
- package/dist/scripts/src/components-core/theming/themeVars.js +62 -0
- package/dist/scripts/src/components-core/theming/themes/base-utils.js +31 -0
- package/dist/scripts/src/components-core/theming/themes/palette.js +53 -0
- package/dist/scripts/src/components-core/theming/themes/root.js +257 -0
- package/dist/scripts/src/components-core/theming/themes/solid.js +16 -0
- package/dist/scripts/src/components-core/theming/themes/theme-colors.js +407 -0
- package/dist/scripts/src/components-core/theming/themes/xmlui.js +32 -0
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +286 -0
- package/dist/scripts/src/components-core/utils/DataLoaderQueryKeyGenerator.js +34 -0
- package/dist/scripts/src/components-core/utils/LruCache.js +184 -0
- package/dist/scripts/src/components-core/utils/actionUtils.js +32 -0
- package/dist/scripts/src/components-core/utils/classnames.js +58 -0
- package/dist/scripts/src/components-core/utils/css-utils.js +127 -0
- package/dist/scripts/src/components-core/utils/date-utils.js +78 -0
- package/dist/scripts/src/components-core/utils/extractParam.js +148 -0
- package/dist/scripts/src/components-core/utils/hooks.js +221 -0
- package/dist/scripts/src/components-core/utils/mergeProps.js +45 -0
- package/dist/scripts/src/components-core/utils/misc.js +460 -0
- package/dist/scripts/src/components-core/utils/statementUtils.js +205 -0
- package/dist/scripts/src/components-core/utils/treeUtils.js +48 -0
- package/dist/scripts/src/components-core/xmlui-parser.js +52 -0
- package/dist/scripts/src/parsers/scripting/InputStream.js +59 -0
- package/dist/scripts/src/parsers/scripting/Lexer.js +1028 -0
- package/dist/scripts/src/parsers/scripting/Parser.js +2647 -0
- package/dist/scripts/src/parsers/scripting/ParserError.js +46 -0
- package/dist/scripts/src/parsers/scripting/TokenTrait.js +109 -0
- package/dist/scripts/src/parsers/scripting/code-behind-collect.js +118 -0
- package/dist/scripts/src/parsers/scripting/tree-visitor.js +602 -0
- package/dist/scripts/src/parsers/style-parser/StyleInputStream.js +39 -0
- package/dist/scripts/src/parsers/style-parser/StyleLexer.js +621 -0
- package/dist/scripts/src/parsers/style-parser/StyleParser.js +1000 -0
- package/dist/scripts/src/parsers/style-parser/errors.js +37 -0
- package/dist/scripts/src/parsers/style-parser/source-tree.js +2 -0
- package/dist/scripts/src/parsers/style-parser/style-compiler.js +513 -0
- package/dist/scripts/src/parsers/style-parser/tokens.js +42 -0
- package/dist/scripts/src/parsers/ueml/ParserError.js +54 -0
- package/dist/scripts/src/parsers/ueml/UemlHelper.js +579 -0
- package/dist/scripts/src/parsers/ueml/UemlInputStream.js +59 -0
- package/dist/scripts/src/parsers/ueml/UemlLexer.js +868 -0
- package/dist/scripts/src/parsers/ueml/UemlParser.js +1439 -0
- package/dist/scripts/src/parsers/ueml/UemlToken.js +24 -0
- package/dist/scripts/src/parsers/ueml/fileExtensions.js +6 -0
- package/dist/scripts/src/parsers/ueml/source-tree.js +2 -0
- package/dist/scripts/src/parsers/ueml/ueml-tree.js +2 -0
- package/dist/scripts/src/parsers/xmlui-parser/CharacterCodes.js +136 -0
- package/dist/scripts/src/parsers/xmlui-parser/diagnostics.js +100 -0
- package/dist/scripts/src/parsers/xmlui-parser/parser.js +476 -0
- package/dist/scripts/src/parsers/xmlui-parser/scanner.js +415 -0
- package/dist/scripts/src/parsers/xmlui-parser/syntax-kind.js +106 -0
- package/dist/scripts/src/parsers/xmlui-parser/syntax-node.js +2 -0
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +922 -0
- package/dist/scripts/src/parsers/xmlui-parser/utils.js +83 -0
- package/dist/xmlui.es.d.ts +1667 -0
- package/dist/xmlui.es.js +17 -0
- package/dist/xmlui.umd.js +1589 -0
- package/package.json +175 -0
|
@@ -0,0 +1,1439 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UemlParser = void 0;
|
|
4
|
+
const UemlInputStream_1 = require("./UemlInputStream");
|
|
5
|
+
const UemlLexer_1 = require("./UemlLexer");
|
|
6
|
+
const UemlToken_1 = require("./UemlToken");
|
|
7
|
+
const ParserError_1 = require("./ParserError");
|
|
8
|
+
const UemlHelper_1 = require("./UemlHelper");
|
|
9
|
+
const Parser_1 = require("../scripting/Parser");
|
|
10
|
+
const code_behind_collect_1 = require("../scripting/code-behind-collect");
|
|
11
|
+
const BindingTreeEvaluationContext_1 = require("../../components-core/script-runner/BindingTreeEvaluationContext");
|
|
12
|
+
/**
|
|
13
|
+
* This class parses a binding expression and transforms it into an evaluable expression tree
|
|
14
|
+
*/
|
|
15
|
+
class UemlParser {
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the parser with the specified source code
|
|
18
|
+
* @param source Source code to parse
|
|
19
|
+
* @param moduleResolver
|
|
20
|
+
*/
|
|
21
|
+
constructor(source, moduleResolver = () => "") {
|
|
22
|
+
this.source = source;
|
|
23
|
+
this.moduleResolver = moduleResolver;
|
|
24
|
+
// --- Keep track of error messages
|
|
25
|
+
this._parseErrors = [];
|
|
26
|
+
this._lexer = new UemlLexer_1.UemlLexer(new UemlInputStream_1.UemlInputStream(source));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The errors raised during the parse phase
|
|
30
|
+
*/
|
|
31
|
+
get errors() {
|
|
32
|
+
return this._parseErrors;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Gets the current token
|
|
36
|
+
*/
|
|
37
|
+
get current() {
|
|
38
|
+
return this._lexer.peek();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Checks if we're at the end of the expression
|
|
42
|
+
*/
|
|
43
|
+
get isEof() {
|
|
44
|
+
return this._lexer.peek().type === UemlToken_1.UemlTokenType.Eof;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Parses a component element
|
|
48
|
+
*
|
|
49
|
+
* umlNode
|
|
50
|
+
* : umlComment* umlElement umlComment*
|
|
51
|
+
* ;
|
|
52
|
+
*
|
|
53
|
+
* umlComment:
|
|
54
|
+
* : "<!-- {any chars} -->"
|
|
55
|
+
* ;
|
|
56
|
+
*/
|
|
57
|
+
parseComponentElement() {
|
|
58
|
+
const nodes = [];
|
|
59
|
+
let hasUmlElement = false;
|
|
60
|
+
let startToken = this._lexer.peek();
|
|
61
|
+
while (!this.isEof) {
|
|
62
|
+
switch (startToken.type) {
|
|
63
|
+
case UemlToken_1.UemlTokenType.Comment:
|
|
64
|
+
const commentToken = this._lexer.get();
|
|
65
|
+
nodes.push(this.createNode("Comment", {
|
|
66
|
+
text: commentToken.text,
|
|
67
|
+
}, startToken));
|
|
68
|
+
break;
|
|
69
|
+
case UemlToken_1.UemlTokenType.OpenNodeStart:
|
|
70
|
+
if (hasUmlElement) {
|
|
71
|
+
this.reportError("U002", startToken);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const element = this.parseElement();
|
|
75
|
+
if (!element) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
nodes.push(element);
|
|
79
|
+
hasUmlElement = true;
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
this.reportError("U001", startToken, startToken.text);
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
// --- Move to the next token
|
|
86
|
+
startToken = this._lexer.peek();
|
|
87
|
+
}
|
|
88
|
+
if (!hasUmlElement) {
|
|
89
|
+
this.reportError("U002", startToken);
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return nodes;
|
|
93
|
+
}
|
|
94
|
+
parseFragment() {
|
|
95
|
+
const nodes = [];
|
|
96
|
+
let startToken = this._lexer.peek();
|
|
97
|
+
while (!this.isEof) {
|
|
98
|
+
switch (startToken.type) {
|
|
99
|
+
case UemlToken_1.UemlTokenType.Comment:
|
|
100
|
+
const commentToken = this._lexer.get();
|
|
101
|
+
nodes.push(this.createNode("Comment", {
|
|
102
|
+
text: commentToken.text,
|
|
103
|
+
}, startToken));
|
|
104
|
+
break;
|
|
105
|
+
case UemlToken_1.UemlTokenType.OpenNodeStart:
|
|
106
|
+
const element = this.parseElement();
|
|
107
|
+
if (!element) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
nodes.push(element);
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
this.reportError("U001", startToken, startToken.text);
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
// --- Move to the next token
|
|
117
|
+
startToken = this._lexer.peek();
|
|
118
|
+
}
|
|
119
|
+
return nodes;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Transforms the provided nodes to their component definition
|
|
123
|
+
* @param nodes Nodes to transform
|
|
124
|
+
*/
|
|
125
|
+
transformToComponentDef(nodes) {
|
|
126
|
+
if (!nodes) {
|
|
127
|
+
const parsedNodes = this.parseComponentElement();
|
|
128
|
+
if (!parsedNodes)
|
|
129
|
+
return null;
|
|
130
|
+
nodes = parsedNodes;
|
|
131
|
+
}
|
|
132
|
+
// --- Check that the nodes contains exactly only a single component root element
|
|
133
|
+
const rootElements = nodes.filter((e) => e.type === "Element");
|
|
134
|
+
if (rootElements.length !== 1) {
|
|
135
|
+
this.reportError("T001");
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
// --- Search for the element, take a note of the preceding comment
|
|
139
|
+
const index = nodes.findIndex((n) => n.type === "Element");
|
|
140
|
+
const element = nodes[index];
|
|
141
|
+
const comment = index > 0 ? nodes[index - 1] : undefined;
|
|
142
|
+
if (!UemlHelper_1.UCRegex.test(element.id)) {
|
|
143
|
+
this.reportError("T002");
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
// --- Done
|
|
147
|
+
const usesStack = [];
|
|
148
|
+
return this.transformSingleElement(usesStack, element);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Transforms the provided nodes to their component definition
|
|
152
|
+
* @param usesStack "Uses" stack
|
|
153
|
+
* @param nodes Nodes to transform
|
|
154
|
+
*/
|
|
155
|
+
transformToObject(nodes, usesStack = []) {
|
|
156
|
+
var _a;
|
|
157
|
+
if (!nodes) {
|
|
158
|
+
const parsedNodes = this.parseFragment();
|
|
159
|
+
if (!parsedNodes)
|
|
160
|
+
return null;
|
|
161
|
+
nodes = parsedNodes;
|
|
162
|
+
}
|
|
163
|
+
const root = {
|
|
164
|
+
type: "Element",
|
|
165
|
+
id: "root",
|
|
166
|
+
attributes: [
|
|
167
|
+
{
|
|
168
|
+
type: "Attribute",
|
|
169
|
+
name: "name",
|
|
170
|
+
value: "object",
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
childNodes: nodes,
|
|
174
|
+
};
|
|
175
|
+
// --- Done
|
|
176
|
+
return (_a = this.collectValue(usesStack, root)) === null || _a === void 0 ? void 0 : _a.value;
|
|
177
|
+
}
|
|
178
|
+
// ==================================================================================================================
|
|
179
|
+
// Transform methods
|
|
180
|
+
transformSingleElement(usesStack, node) {
|
|
181
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
182
|
+
let component;
|
|
183
|
+
if (node.id === UemlHelper_1.COMPOUND_COMP_ID) {
|
|
184
|
+
// --- Validate component name
|
|
185
|
+
const compoundName = ((_a = node.attributes) !== null && _a !== void 0 ? _a : []).find((attr) => attr.name === "name");
|
|
186
|
+
if (!compoundName) {
|
|
187
|
+
this.reportError("T003");
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
if (!UemlHelper_1.UCRegex.test(compoundName.value)) {
|
|
191
|
+
this.reportError("T004");
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
// --- Get "api" attributes
|
|
195
|
+
let api;
|
|
196
|
+
const apiAttrs = ((_b = node.attributes) !== null && _b !== void 0 ? _b : []).filter((attr) => attr.startSegment === "api");
|
|
197
|
+
if (apiAttrs.length > 0) {
|
|
198
|
+
api = {};
|
|
199
|
+
apiAttrs.forEach((attr) => {
|
|
200
|
+
api[attr.name] = attr.value;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
// --- Get "var" attributes
|
|
204
|
+
let vars;
|
|
205
|
+
const varsAttrs = ((_c = node.attributes) !== null && _c !== void 0 ? _c : []).filter((attr) => attr.startSegment === "var");
|
|
206
|
+
if (varsAttrs.length > 0) {
|
|
207
|
+
vars = {};
|
|
208
|
+
varsAttrs.forEach((attr) => {
|
|
209
|
+
vars[attr.name] = attr.value;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
// --- Check for nested component
|
|
213
|
+
const nestedCompound = ((_d = node.childNodes) !== null && _d !== void 0 ? _d : []).find((child) => child.type === "Element" && child.id === UemlHelper_1.COMPOUND_COMP_ID);
|
|
214
|
+
if (nestedCompound) {
|
|
215
|
+
this.reportError("T006");
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
// --- Get the single component definition
|
|
219
|
+
const nestedComponents = ((_e = node.childNodes) !== null && _e !== void 0 ? _e : []).filter((child) => child.type === "Element" && UemlHelper_1.UCRegex.test(child.id));
|
|
220
|
+
if (nestedComponents.length === 0) {
|
|
221
|
+
nestedComponents.push({
|
|
222
|
+
type: "Element",
|
|
223
|
+
id: "TextNode",
|
|
224
|
+
attributes: [
|
|
225
|
+
{
|
|
226
|
+
type: "Attribute",
|
|
227
|
+
name: "value",
|
|
228
|
+
value: "",
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
const nestedVars = ((_f = node.childNodes) !== null && _f !== void 0 ? _f : []).filter((child) => child.type === "Element" && child.id === "var");
|
|
234
|
+
const childrenToCollect = ((_g = node.childNodes) !== null && _g !== void 0 ? _g : []).filter((child) => child.type === "Element" && !UemlHelper_1.UCRegex.test(child.id) && child.id !== "var");
|
|
235
|
+
// --- Should we use a Fragment?
|
|
236
|
+
if (nestedComponents.length > 1 || nestedVars.length > 0) {
|
|
237
|
+
// --- Wrap the children in a Fragment
|
|
238
|
+
const fragmentElement = {
|
|
239
|
+
type: "Element",
|
|
240
|
+
id: "Fragment",
|
|
241
|
+
childNodes: [...nestedVars, ...nestedComponents],
|
|
242
|
+
};
|
|
243
|
+
const nestedFragment = this.transformSingleElement(usesStack, fragmentElement);
|
|
244
|
+
component = {
|
|
245
|
+
name: compoundName.value,
|
|
246
|
+
component: nestedFragment,
|
|
247
|
+
};
|
|
248
|
+
if (api) {
|
|
249
|
+
component.api = api;
|
|
250
|
+
}
|
|
251
|
+
if (vars) {
|
|
252
|
+
nestedFragment.vars = Object.assign(Object.assign({}, nestedFragment.vars), vars);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
// --- Search for the element, take a note of the preceding comment
|
|
257
|
+
const element = nestedComponents[0];
|
|
258
|
+
const nestedComponent = this.transformSingleElement(usesStack, element);
|
|
259
|
+
// --- Create the component
|
|
260
|
+
component = {
|
|
261
|
+
name: compoundName.value,
|
|
262
|
+
component: nestedComponent,
|
|
263
|
+
};
|
|
264
|
+
if (api) {
|
|
265
|
+
component.api = api;
|
|
266
|
+
}
|
|
267
|
+
if (vars) {
|
|
268
|
+
nestedComponent.vars = Object.assign(Object.assign({}, nestedComponent.vars), vars);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const nodeClone = Object.assign({}, node);
|
|
272
|
+
nodeClone.childNodes = childrenToCollect;
|
|
273
|
+
this.collectTraits(usesStack, component, nodeClone);
|
|
274
|
+
return component;
|
|
275
|
+
}
|
|
276
|
+
// --- Not a reusable component
|
|
277
|
+
if (!UemlHelper_1.UCRegex.test(node.id)) {
|
|
278
|
+
this.reportError("T002");
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
component = {
|
|
282
|
+
type: node.id,
|
|
283
|
+
};
|
|
284
|
+
// --- Done
|
|
285
|
+
this.collectTraits(usesStack, component, node);
|
|
286
|
+
return component;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Collects component traits from attributes and child elements
|
|
290
|
+
* @param usesStack "Uses" stack
|
|
291
|
+
* @param comp Component definition
|
|
292
|
+
* @param element Component element
|
|
293
|
+
*/
|
|
294
|
+
collectTraits(usesStack, comp, element) {
|
|
295
|
+
var _a, _b, _c, _d;
|
|
296
|
+
const isCompound = !isComponent(comp);
|
|
297
|
+
// --- Process attributes
|
|
298
|
+
((_a = element.attributes) !== null && _a !== void 0 ? _a : []).forEach((attr) => {
|
|
299
|
+
// --- Process the attribute
|
|
300
|
+
if (attr.namespace) {
|
|
301
|
+
this.reportError("T021");
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
this.collectAttribute(comp, attr.startSegment, attr.name, attr.value);
|
|
305
|
+
});
|
|
306
|
+
let lastComment = null;
|
|
307
|
+
// --- Process child nodes
|
|
308
|
+
((_b = element.childNodes) !== null && _b !== void 0 ? _b : []).forEach((child) => {
|
|
309
|
+
var _a;
|
|
310
|
+
if (child.type === "Comment") {
|
|
311
|
+
lastComment = child;
|
|
312
|
+
}
|
|
313
|
+
if (isCompound && child.type === "Element" && UemlHelper_1.UCRegex.test(child.id)) {
|
|
314
|
+
// --- This is the single nested component definition of a compound component,
|
|
315
|
+
// --- it is already processed
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
// --- Single text element, consider it a child name
|
|
319
|
+
if (child.type === "Text" && !isCompound) {
|
|
320
|
+
comp.children = this.mergeValue(comp.children, child.text);
|
|
321
|
+
}
|
|
322
|
+
// --- It should not happen, but just for being safe...
|
|
323
|
+
if (child.type !== "Element")
|
|
324
|
+
return;
|
|
325
|
+
// --- Element name starts with an uppercase letter
|
|
326
|
+
if (UemlHelper_1.UCRegex.test(child.id) && !isCompound) {
|
|
327
|
+
// --- This must be a child component
|
|
328
|
+
const childComponent = this.transformSingleElement(usesStack, child);
|
|
329
|
+
if (childComponent) {
|
|
330
|
+
if (!comp.children) {
|
|
331
|
+
comp.children = [childComponent];
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
if (typeof comp.children === "string") {
|
|
335
|
+
comp.children = [comp.children, childComponent];
|
|
336
|
+
}
|
|
337
|
+
else if (Array.isArray(comp.children)) {
|
|
338
|
+
comp.children.push(childComponent);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
// --- Element with a lowercase start letter, it must be some traits of the host component
|
|
345
|
+
switch (child.id) {
|
|
346
|
+
case "prop":
|
|
347
|
+
this.collectElementHelper(usesStack, comp, child, (name) => { var _a; return (isComponent(comp) ? (_a = comp.props) === null || _a === void 0 ? void 0 : _a[name] : undefined); }, (name, value) => {
|
|
348
|
+
var _a;
|
|
349
|
+
if (!isComponent(comp))
|
|
350
|
+
return;
|
|
351
|
+
(_a = comp.props) !== null && _a !== void 0 ? _a : (comp.props = {});
|
|
352
|
+
comp.props[name] = value;
|
|
353
|
+
});
|
|
354
|
+
return;
|
|
355
|
+
case "event":
|
|
356
|
+
this.collectElementHelper(usesStack, comp, child, (name) => { var _a; return (isComponent(comp) ? (_a = comp.events) === null || _a === void 0 ? void 0 : _a[name] : undefined); }, (name, value) => {
|
|
357
|
+
var _a;
|
|
358
|
+
if (!isComponent(comp))
|
|
359
|
+
return;
|
|
360
|
+
(_a = comp.events) !== null && _a !== void 0 ? _a : (comp.events = {});
|
|
361
|
+
comp.events[name] = value;
|
|
362
|
+
}, (name) => {
|
|
363
|
+
if (UemlHelper_1.onPrefixRegex.test(name)) {
|
|
364
|
+
this.reportError("T008", undefined, name);
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
return;
|
|
368
|
+
case "var":
|
|
369
|
+
this.collectElementHelper(usesStack, comp, child, (name) => { var _a; return (isComponent(comp) ? (_a = comp.vars) === null || _a === void 0 ? void 0 : _a[name] : undefined); }, (name, value) => {
|
|
370
|
+
var _a;
|
|
371
|
+
if (!isComponent(comp))
|
|
372
|
+
return;
|
|
373
|
+
(_a = comp.vars) !== null && _a !== void 0 ? _a : (comp.vars = {});
|
|
374
|
+
comp.vars[name] = value;
|
|
375
|
+
});
|
|
376
|
+
return;
|
|
377
|
+
case "loaders":
|
|
378
|
+
this.collectLoadersElements(usesStack, comp, child);
|
|
379
|
+
return;
|
|
380
|
+
case "uses":
|
|
381
|
+
this.collectUsesElements(comp, child);
|
|
382
|
+
return;
|
|
383
|
+
case "api":
|
|
384
|
+
this.collectElementHelper(usesStack, comp, child, (name) => { var _a; return (isComponent(comp) ? (_a = comp.api) === null || _a === void 0 ? void 0 : _a[name] : undefined); }, (name, value) => {
|
|
385
|
+
var _a;
|
|
386
|
+
(_a = comp.api) !== null && _a !== void 0 ? _a : (comp.api = {});
|
|
387
|
+
comp.api[name] = value;
|
|
388
|
+
});
|
|
389
|
+
return;
|
|
390
|
+
case "script":
|
|
391
|
+
if (child.attributes && child.attributes.length > 0) {
|
|
392
|
+
this.reportError("T022");
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (!child.childNodes || !child.childNodes.length) {
|
|
396
|
+
// --- No children, no script
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
if (child.childNodes.length === 1 && child.childNodes[0].type === "Text") {
|
|
400
|
+
// --- We have a single text child
|
|
401
|
+
(_a = comp.script) !== null && _a !== void 0 ? _a : (comp.script = "");
|
|
402
|
+
if (comp.script.length > 0) {
|
|
403
|
+
comp.script += "\n";
|
|
404
|
+
}
|
|
405
|
+
comp.script += child.childNodes[0].text;
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
this.reportError("T023");
|
|
409
|
+
}
|
|
410
|
+
return;
|
|
411
|
+
case "metadata":
|
|
412
|
+
this.collectMetadataElements(comp);
|
|
413
|
+
return;
|
|
414
|
+
default:
|
|
415
|
+
this.reportError("T009", undefined, child.id);
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
if (!comp.script || comp.script.trim().length === 0) {
|
|
420
|
+
// --- No (or whitespace only) script
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
// --- Run the parse and collect on scripts
|
|
424
|
+
const parser = new Parser_1.Parser(comp.script);
|
|
425
|
+
try {
|
|
426
|
+
// --- We parse the module file to catch parsing errors
|
|
427
|
+
parser.parseStatements();
|
|
428
|
+
const evalContext = (0, BindingTreeEvaluationContext_1.createEvalContext)({});
|
|
429
|
+
comp.scriptCollected = (0, code_behind_collect_1.collectCodeBehindFromSource)("Main", comp.script, this.moduleResolver, evalContext);
|
|
430
|
+
}
|
|
431
|
+
catch (err) {
|
|
432
|
+
if (parser.errors && parser.errors.length > 0) {
|
|
433
|
+
comp.scriptError = parser.errors;
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
comp.scriptError = err;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
// --- We may have module parsing/execution errors
|
|
440
|
+
const moduleErrors = (_d = (_c = comp.scriptCollected) === null || _c === void 0 ? void 0 : _c.moduleErrors) !== null && _d !== void 0 ? _d : {};
|
|
441
|
+
if (Object.keys(moduleErrors).length > 0) {
|
|
442
|
+
comp.scriptError = moduleErrors;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Process a single component attribute
|
|
447
|
+
* @param comp Component definition to merge the attribute into
|
|
448
|
+
* @param startSegment Starts segment name
|
|
449
|
+
* @param name Attribute name
|
|
450
|
+
* @param value Attribute value
|
|
451
|
+
*/
|
|
452
|
+
collectAttribute(comp, startSegment, name, value) {
|
|
453
|
+
var _a, _b, _c, _d, _e;
|
|
454
|
+
const isCompound = !isComponent(comp);
|
|
455
|
+
// --- Handle single-word attributes
|
|
456
|
+
if (isCompound) {
|
|
457
|
+
if (startSegment && startSegment !== "api" && startSegment !== "var") {
|
|
458
|
+
this.reportError("T021");
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
if (name === "name" && !startSegment) {
|
|
462
|
+
// --- We already processed name
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
// --- Compound components do not have any other attributable props
|
|
466
|
+
if (!startSegment && !startSegment) {
|
|
467
|
+
this.reportError("T021", undefined, name);
|
|
468
|
+
}
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
// --- Do not allow segmented attribute names
|
|
472
|
+
if (name.indexOf(".") >= 0) {
|
|
473
|
+
this.reportError("T007", undefined, name);
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
// --- Recognize special attributes by component definition type
|
|
477
|
+
switch (name) {
|
|
478
|
+
case "id":
|
|
479
|
+
comp.uid = value;
|
|
480
|
+
return;
|
|
481
|
+
case "testId":
|
|
482
|
+
comp.testId = value;
|
|
483
|
+
return;
|
|
484
|
+
case "when":
|
|
485
|
+
comp.when = value;
|
|
486
|
+
return;
|
|
487
|
+
default:
|
|
488
|
+
if (startSegment === "var") {
|
|
489
|
+
(_a = comp.vars) !== null && _a !== void 0 ? _a : (comp.vars = {});
|
|
490
|
+
comp.vars[name] = value;
|
|
491
|
+
}
|
|
492
|
+
else if (startSegment === "api") {
|
|
493
|
+
(_b = comp.api) !== null && _b !== void 0 ? _b : (comp.api = {});
|
|
494
|
+
comp.api[name] = value;
|
|
495
|
+
}
|
|
496
|
+
else if (startSegment === "event") {
|
|
497
|
+
(_c = comp.events) !== null && _c !== void 0 ? _c : (comp.events = {});
|
|
498
|
+
comp.events[name] = value;
|
|
499
|
+
}
|
|
500
|
+
else if (UemlHelper_1.onPrefixRegex.test(name)) {
|
|
501
|
+
(_d = comp.events) !== null && _d !== void 0 ? _d : (comp.events = {});
|
|
502
|
+
const eventName = name[2].toLowerCase() + name.substring(3);
|
|
503
|
+
comp.events[eventName] = value;
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
(_e = comp.props) !== null && _e !== void 0 ? _e : (comp.props = {});
|
|
507
|
+
comp.props[name] = value;
|
|
508
|
+
}
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
collectElementHelper(usesStack, comp, child, getter, setter, nameValidator) {
|
|
513
|
+
// --- Compound component do not have a uses
|
|
514
|
+
var _a;
|
|
515
|
+
// --- Get the value
|
|
516
|
+
const valueInfo = this.collectValue(usesStack, child);
|
|
517
|
+
if (!valueInfo) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
// --- Extra name validation, if required so
|
|
521
|
+
nameValidator === null || nameValidator === void 0 ? void 0 : nameValidator((_a = valueInfo === null || valueInfo === void 0 ? void 0 : valueInfo.name) !== null && _a !== void 0 ? _a : "");
|
|
522
|
+
const name = valueInfo.name;
|
|
523
|
+
const value = valueInfo.value;
|
|
524
|
+
if ((valueInfo === null || valueInfo === void 0 ? void 0 : valueInfo.value) !== undefined) {
|
|
525
|
+
setter(name, this.mergeValue(getter(name), value));
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
// --- Consider the value to be null; check optional child items
|
|
529
|
+
const itemValue = this.collectObjectOrArray(usesStack, child.childNodes);
|
|
530
|
+
let updatedValue = getter(name);
|
|
531
|
+
updatedValue = this.mergeValue(updatedValue, itemValue);
|
|
532
|
+
setter(name, updatedValue);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
collectValue(usesStack, element, allowName = true) {
|
|
536
|
+
var _a, _b, _c, _d;
|
|
537
|
+
// --- Accept only "name", "value"
|
|
538
|
+
const nestedComponents = ((_a = element.childNodes) !== null && _a !== void 0 ? _a : []).filter((c) => c.type === "Element" && UemlHelper_1.UCRegex.test(c.id));
|
|
539
|
+
const nestedElements = ((_b = element.childNodes) !== null && _b !== void 0 ? _b : []).filter((c) => c.type === "Element" && !UemlHelper_1.UCRegex.test(c.id));
|
|
540
|
+
const attrProps = ((_c = element.attributes) !== null && _c !== void 0 ? _c : []).filter((attr) => propAttrs.indexOf(attr.name) >= 0);
|
|
541
|
+
if (((_d = element.attributes) !== null && _d !== void 0 ? _d : []).length > attrProps.length) {
|
|
542
|
+
this.reportError("T011", undefined, element.id);
|
|
543
|
+
return null;
|
|
544
|
+
}
|
|
545
|
+
// --- Validate the "name" usage
|
|
546
|
+
const nameAttr = attrProps.find((attr) => attr.name === "name");
|
|
547
|
+
if (allowName) {
|
|
548
|
+
if (!(nameAttr === null || nameAttr === void 0 ? void 0 : nameAttr.value)) {
|
|
549
|
+
this.reportError("T012", undefined, element.id);
|
|
550
|
+
return null;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
if (nameAttr) {
|
|
555
|
+
this.reportError("T018", undefined, element.id);
|
|
556
|
+
return null;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
const name = nameAttr === null || nameAttr === void 0 ? void 0 : nameAttr.value;
|
|
560
|
+
// --- Get the value attribute
|
|
561
|
+
const valueAttr = attrProps.find((attr) => attr.name === "value");
|
|
562
|
+
if (valueAttr && valueAttr.value === undefined) {
|
|
563
|
+
this.reportError("T019", undefined, element.id);
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
// --- Let's handle a special case, when the value is a component definition
|
|
567
|
+
if (name && nestedComponents.length >= 1) {
|
|
568
|
+
if (nestedElements.length > 0) {
|
|
569
|
+
this.reportError("T020");
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
// --- We expect a component definition here!
|
|
573
|
+
const nestedComps = nestedComponents.map((nc) => this.transformSingleElement(usesStack, nc));
|
|
574
|
+
return { name, value: nestedComps.length === 1 ? nestedComps[0] : nestedComps };
|
|
575
|
+
}
|
|
576
|
+
// --- At this point, all attributes are ok, let's get the value.
|
|
577
|
+
let value = valueAttr === null || valueAttr === void 0 ? void 0 : valueAttr.value;
|
|
578
|
+
if (value === null) {
|
|
579
|
+
return null;
|
|
580
|
+
}
|
|
581
|
+
if (typeof value === "string") {
|
|
582
|
+
return { name, value };
|
|
583
|
+
}
|
|
584
|
+
return { name, value: this.collectObjectOrArray(usesStack, element.childNodes) };
|
|
585
|
+
}
|
|
586
|
+
collectLoadersElements(usesStack, comp, loaders) {
|
|
587
|
+
var _a, _b, _c, _d, _e;
|
|
588
|
+
if (!isComponent(comp)) {
|
|
589
|
+
this.reportError("T009", undefined, "loaders");
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
if (isComponent(comp) && ((_b = (_a = loaders === null || loaders === void 0 ? void 0 : loaders.childNodes) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0) {
|
|
593
|
+
(_c = comp.loaders) !== null && _c !== void 0 ? _c : (comp.loaders = []);
|
|
594
|
+
}
|
|
595
|
+
// --- Loaders element must not have attributes
|
|
596
|
+
if (((_d = loaders.attributes) !== null && _d !== void 0 ? _d : []).length > 0) {
|
|
597
|
+
this.reportError("T012", undefined, "loaders");
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
// --- Iterate through child elements
|
|
601
|
+
let lastComment = null;
|
|
602
|
+
((_e = loaders.childNodes) !== null && _e !== void 0 ? _e : []).forEach((loader) => {
|
|
603
|
+
var _a;
|
|
604
|
+
// --- Take a note of the last comment
|
|
605
|
+
if (loader.type === "Comment") {
|
|
606
|
+
lastComment = loader;
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
// --- Test is not supported
|
|
610
|
+
if (loader.type === "Text") {
|
|
611
|
+
this.reportError("T010", undefined, "loader");
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
// --- Just for the sake of being sure...
|
|
615
|
+
if (loader.type !== "Element")
|
|
616
|
+
return;
|
|
617
|
+
const loaderDef = this.transformSingleElement(usesStack, loader);
|
|
618
|
+
// --- Get the uid value
|
|
619
|
+
if (!loaderDef.uid) {
|
|
620
|
+
this.reportError("T013");
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
// --- Check props that a loader must not have
|
|
624
|
+
if (loaderDef.vars) {
|
|
625
|
+
this.reportError("T014", undefined, "vars");
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
if (loaderDef.loaders) {
|
|
629
|
+
this.reportError("T014", undefined, "loaders");
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
if (loaderDef.uses) {
|
|
633
|
+
this.reportError("T014", undefined, "uses");
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
// --- Store this loader
|
|
637
|
+
(_a = comp.loaders) !== null && _a !== void 0 ? _a : (comp.loaders = []);
|
|
638
|
+
comp.loaders.push(loaderDef);
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
collectUsesElements(comp, uses) {
|
|
642
|
+
var _a, _b, _c, _d;
|
|
643
|
+
// --- Compound component do not have a uses
|
|
644
|
+
if (!isComponent(comp)) {
|
|
645
|
+
this.reportError("T009", undefined, "uses");
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
const valueAttr = ((_a = uses.attributes) !== null && _a !== void 0 ? _a : []).find((attr) => attr.name === "value");
|
|
649
|
+
if (!(valueAttr === null || valueAttr === void 0 ? void 0 : valueAttr.value) || ((_c = (_b = uses.attributes) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) !== 1) {
|
|
650
|
+
this.reportError("T015", undefined, "uses");
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
// --- Extract the value
|
|
654
|
+
(_d = comp.uses) !== null && _d !== void 0 ? _d : (comp.uses = valueAttr.value.split(",").map((v) => v.trim()));
|
|
655
|
+
}
|
|
656
|
+
collectMetadataElements(comp) {
|
|
657
|
+
if (isComponent(comp)) {
|
|
658
|
+
this.reportError("T009", undefined, "meadata");
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
collectObjectOrArray(usesStack, children) {
|
|
663
|
+
let result = null;
|
|
664
|
+
// --- No children, it's a null object
|
|
665
|
+
if (!children)
|
|
666
|
+
return result;
|
|
667
|
+
let nestedElementType = null;
|
|
668
|
+
children.forEach((child) => {
|
|
669
|
+
if (child.type === "Text") {
|
|
670
|
+
result = this.mergeValue(result, child.text);
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
if (child.type !== "Element")
|
|
674
|
+
return;
|
|
675
|
+
// --- The only element names we accept are "field" or "item"
|
|
676
|
+
if (child.id !== "field" && child.id !== "item") {
|
|
677
|
+
this.reportError("T016");
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
if (child.id === "field") {
|
|
681
|
+
if (!nestedElementType) {
|
|
682
|
+
// --- First nested element is "field", so we have an object
|
|
683
|
+
nestedElementType = child.id;
|
|
684
|
+
result = {};
|
|
685
|
+
}
|
|
686
|
+
else if (nestedElementType !== child.id) {
|
|
687
|
+
this.reportError("T017");
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
else if (child.id === "item") {
|
|
692
|
+
if (!nestedElementType) {
|
|
693
|
+
// --- First nested element is "item", so we have an array
|
|
694
|
+
nestedElementType = child.id;
|
|
695
|
+
result = [];
|
|
696
|
+
}
|
|
697
|
+
else if (nestedElementType !== child.id) {
|
|
698
|
+
this.reportError("T017");
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
// --- Get the field value
|
|
703
|
+
let valueInfo = this.collectValue(usesStack, child, child.id === "field");
|
|
704
|
+
if (!valueInfo) {
|
|
705
|
+
return null;
|
|
706
|
+
}
|
|
707
|
+
// --- Does the field have a value?
|
|
708
|
+
if (nestedElementType === "field") {
|
|
709
|
+
result[valueInfo.name] = valueInfo.value;
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
result.push(valueInfo.value);
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
return result;
|
|
716
|
+
}
|
|
717
|
+
mergeValue(oldValue, itemValue) {
|
|
718
|
+
if (oldValue) {
|
|
719
|
+
if (Array.isArray(oldValue)) {
|
|
720
|
+
if (typeof oldValue === "string") {
|
|
721
|
+
return [oldValue, itemValue];
|
|
722
|
+
}
|
|
723
|
+
else {
|
|
724
|
+
oldValue.push(itemValue);
|
|
725
|
+
return oldValue;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
return [oldValue, itemValue];
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
else {
|
|
733
|
+
return itemValue;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
// ==================================================================================================================
|
|
737
|
+
// Parsing methods
|
|
738
|
+
/**
|
|
739
|
+
* Parses an UEML elements
|
|
740
|
+
*
|
|
741
|
+
* uemlElement
|
|
742
|
+
* : "<" id uemlAttribute* ">" (uemlLiteral? | uemlElement*) "</" id ">"
|
|
743
|
+
* | "<" id uemlAttribute* "/>"
|
|
744
|
+
* ;
|
|
745
|
+
*
|
|
746
|
+
*/
|
|
747
|
+
parseElement() {
|
|
748
|
+
let startToken = this._lexer.peek();
|
|
749
|
+
let attributes = [];
|
|
750
|
+
// --- Test the open node start token
|
|
751
|
+
if (startToken.type !== UemlToken_1.UemlTokenType.OpenNodeStart) {
|
|
752
|
+
this.reportError("U003", startToken);
|
|
753
|
+
return null;
|
|
754
|
+
}
|
|
755
|
+
// --- Get the node id
|
|
756
|
+
this._lexer.get();
|
|
757
|
+
let namespace = "";
|
|
758
|
+
let idToken = this._lexer.peek();
|
|
759
|
+
if (idToken.type !== UemlToken_1.UemlTokenType.Identifier) {
|
|
760
|
+
this.reportError("U004", idToken);
|
|
761
|
+
return null;
|
|
762
|
+
}
|
|
763
|
+
// --- Check for namespace
|
|
764
|
+
this._lexer.get();
|
|
765
|
+
if (this._lexer.peek().type === UemlToken_1.UemlTokenType.Colon) {
|
|
766
|
+
this._lexer.get();
|
|
767
|
+
namespace = idToken.text;
|
|
768
|
+
idToken = this._lexer.peek();
|
|
769
|
+
if (idToken.type !== UemlToken_1.UemlTokenType.Identifier) {
|
|
770
|
+
this.reportError("U004", idToken);
|
|
771
|
+
return null;
|
|
772
|
+
}
|
|
773
|
+
this._lexer.get();
|
|
774
|
+
}
|
|
775
|
+
// --- Parse attributes
|
|
776
|
+
let nextToken = this._lexer.peek();
|
|
777
|
+
// --- Skip comment
|
|
778
|
+
while (nextToken.type === UemlToken_1.UemlTokenType.Comment) {
|
|
779
|
+
this._lexer.get();
|
|
780
|
+
nextToken = this._lexer.peek();
|
|
781
|
+
}
|
|
782
|
+
// --- Get the next attribute
|
|
783
|
+
while (nextToken.type === UemlToken_1.UemlTokenType.Identifier) {
|
|
784
|
+
// --- Seems to be an attribute value
|
|
785
|
+
const attribute = this.parseAttribute();
|
|
786
|
+
if (attribute) {
|
|
787
|
+
if (attributes.find((attr) => attr.name === attribute.name)) {
|
|
788
|
+
this.reportError("U012", nextToken, attribute.name);
|
|
789
|
+
return null;
|
|
790
|
+
}
|
|
791
|
+
if (UemlHelper_1.UCRegex.test(attribute.name)) {
|
|
792
|
+
this.reportError("U013");
|
|
793
|
+
return null;
|
|
794
|
+
}
|
|
795
|
+
attributes.push(attribute);
|
|
796
|
+
}
|
|
797
|
+
nextToken = this._lexer.peek();
|
|
798
|
+
// --- Skip comment
|
|
799
|
+
while (nextToken.type === UemlToken_1.UemlTokenType.Comment) {
|
|
800
|
+
this._lexer.get();
|
|
801
|
+
nextToken = this._lexer.peek();
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
// --- Test the closing of the node
|
|
805
|
+
if (nextToken.type === UemlToken_1.UemlTokenType.NodeClose) {
|
|
806
|
+
// --- This node is closed, return it
|
|
807
|
+
this._lexer.get();
|
|
808
|
+
return this.createNode("Element", {
|
|
809
|
+
id: idToken.text,
|
|
810
|
+
namespace,
|
|
811
|
+
attributes,
|
|
812
|
+
}, nextToken);
|
|
813
|
+
}
|
|
814
|
+
// --- Check the closing token of the node
|
|
815
|
+
if (nextToken.type !== UemlToken_1.UemlTokenType.NodeEnd) {
|
|
816
|
+
this.reportError("U006", nextToken);
|
|
817
|
+
return null;
|
|
818
|
+
}
|
|
819
|
+
this._lexer.get();
|
|
820
|
+
// --- Get the nested children or text
|
|
821
|
+
const isComponentElement = UemlHelper_1.UCRegex.test(idToken.text);
|
|
822
|
+
const shouldUseTextNode = isComponentElement || idToken.text === "prop";
|
|
823
|
+
const shouldPreserveWhitespace = idToken.text === "event" || idToken.text === "api" || idToken.text === "script";
|
|
824
|
+
let childNodes = this.parseElementChildren(shouldPreserveWhitespace, shouldUseTextNode);
|
|
825
|
+
if (!childNodes) {
|
|
826
|
+
return null;
|
|
827
|
+
}
|
|
828
|
+
// --- Separate helper nodes from <script> and component children
|
|
829
|
+
const helperNodes = childNodes.filter((n) => n.type === "Element" && !UemlHelper_1.UCRegex.test(n.id) && n.id !== "script");
|
|
830
|
+
const otherNodes = childNodes.filter((n) => helperNodes.indexOf(n) < 0);
|
|
831
|
+
const hasScript = otherNodes.some((n) => n.type === "Element" && n.id === "script");
|
|
832
|
+
const hasComponent = otherNodes.some((n) => n.type === "Element" && UemlHelper_1.UCRegex.test(n.id));
|
|
833
|
+
// --- Wrap with fragment if needed
|
|
834
|
+
if (hasComponent && hasScript) {
|
|
835
|
+
const fragmentElement = {
|
|
836
|
+
type: "Element",
|
|
837
|
+
id: "Fragment",
|
|
838
|
+
childNodes: otherNodes,
|
|
839
|
+
};
|
|
840
|
+
childNodes = [...helperNodes, fragmentElement];
|
|
841
|
+
}
|
|
842
|
+
// --- Get the start token of the closing tag
|
|
843
|
+
const closeToken = this._lexer.peek();
|
|
844
|
+
if (closeToken.type !== UemlToken_1.UemlTokenType.CloseNodeStart) {
|
|
845
|
+
this.reportError("U005", closeToken);
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
// --- Test closing node identifier
|
|
849
|
+
this._lexer.get();
|
|
850
|
+
let closeNamespace = "";
|
|
851
|
+
let closeIdToken = this._lexer.peek();
|
|
852
|
+
if (closeIdToken.type !== UemlToken_1.UemlTokenType.Identifier) {
|
|
853
|
+
this.reportError("U004", closeIdToken);
|
|
854
|
+
return null;
|
|
855
|
+
}
|
|
856
|
+
// --- Check for closing namespace
|
|
857
|
+
this._lexer.get();
|
|
858
|
+
if (this._lexer.peek().type === UemlToken_1.UemlTokenType.Colon) {
|
|
859
|
+
this._lexer.get();
|
|
860
|
+
closeNamespace = closeIdToken.text;
|
|
861
|
+
closeIdToken = this._lexer.peek();
|
|
862
|
+
if (closeIdToken.type !== UemlToken_1.UemlTokenType.Identifier) {
|
|
863
|
+
this.reportError("U004", closeIdToken);
|
|
864
|
+
return null;
|
|
865
|
+
}
|
|
866
|
+
this._lexer.get();
|
|
867
|
+
}
|
|
868
|
+
// --- The start end closing namespace must match
|
|
869
|
+
if (namespace !== closeNamespace) {
|
|
870
|
+
this.reportError("U014", closeIdToken, namespace, closeNamespace);
|
|
871
|
+
return null;
|
|
872
|
+
}
|
|
873
|
+
// --- The start end closing ID must match
|
|
874
|
+
if (idToken.text !== closeIdToken.text) {
|
|
875
|
+
this.reportError("U007", closeIdToken, idToken.text, closeIdToken.text);
|
|
876
|
+
return null;
|
|
877
|
+
}
|
|
878
|
+
// --- Check the element's final token
|
|
879
|
+
const finalToken = this._lexer.peek();
|
|
880
|
+
if (finalToken.type !== UemlToken_1.UemlTokenType.NodeEnd) {
|
|
881
|
+
this.reportError("U008", finalToken);
|
|
882
|
+
return null;
|
|
883
|
+
}
|
|
884
|
+
// --- Done.
|
|
885
|
+
this._lexer.get();
|
|
886
|
+
return this.createNode("Element", {
|
|
887
|
+
id: idToken.text,
|
|
888
|
+
namespace,
|
|
889
|
+
attributes,
|
|
890
|
+
childNodes,
|
|
891
|
+
}, startToken);
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Parses an UEML attribute
|
|
895
|
+
*
|
|
896
|
+
* uemlAttribute
|
|
897
|
+
* : id "=" (singleWord | stringLiteral)
|
|
898
|
+
* ;
|
|
899
|
+
*/
|
|
900
|
+
parseAttribute() {
|
|
901
|
+
let namespace;
|
|
902
|
+
let name;
|
|
903
|
+
const startToken = this._lexer.peek();
|
|
904
|
+
if (startToken.type !== UemlToken_1.UemlTokenType.Identifier) {
|
|
905
|
+
this.reportError("U009", startToken);
|
|
906
|
+
return null;
|
|
907
|
+
}
|
|
908
|
+
name = startToken.text;
|
|
909
|
+
// --- Check for type spec
|
|
910
|
+
this._lexer.get();
|
|
911
|
+
let nextToken = this._lexer.peek();
|
|
912
|
+
if (nextToken.type === UemlToken_1.UemlTokenType.Colon) {
|
|
913
|
+
this._lexer.get();
|
|
914
|
+
namespace = name;
|
|
915
|
+
const nameToken = this._lexer.peek();
|
|
916
|
+
if (nameToken.type !== UemlToken_1.UemlTokenType.Identifier) {
|
|
917
|
+
this.reportError("U009", nameToken);
|
|
918
|
+
return null;
|
|
919
|
+
}
|
|
920
|
+
name = nameToken.text;
|
|
921
|
+
this._lexer.get();
|
|
922
|
+
nextToken = this._lexer.peek();
|
|
923
|
+
}
|
|
924
|
+
// --- Check segments
|
|
925
|
+
const segments = name.split(".");
|
|
926
|
+
if (segments.length > 2) {
|
|
927
|
+
this.reportError("T007", startToken, name);
|
|
928
|
+
return null;
|
|
929
|
+
}
|
|
930
|
+
let startSegment;
|
|
931
|
+
if (segments.length === 2) {
|
|
932
|
+
startSegment = segments[0];
|
|
933
|
+
name = segments[1];
|
|
934
|
+
if (name.trim() === "") {
|
|
935
|
+
this.reportError("T007", startToken, name);
|
|
936
|
+
return null;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
// --- ID ok, check for "="
|
|
940
|
+
let value;
|
|
941
|
+
if (nextToken.type === UemlToken_1.UemlTokenType.Equal) {
|
|
942
|
+
// --- Get the value
|
|
943
|
+
this._lexer.get();
|
|
944
|
+
const valueToken = this._lexer.peek();
|
|
945
|
+
if (valueToken.type === UemlToken_1.UemlTokenType.StringLiteral) {
|
|
946
|
+
value = this.parseStringLiteral(valueToken.text);
|
|
947
|
+
}
|
|
948
|
+
else {
|
|
949
|
+
this.reportError("U011", valueToken);
|
|
950
|
+
return null;
|
|
951
|
+
}
|
|
952
|
+
this._lexer.get();
|
|
953
|
+
}
|
|
954
|
+
else {
|
|
955
|
+
this.reportError("U010", nextToken);
|
|
956
|
+
return null;
|
|
957
|
+
}
|
|
958
|
+
// --- Done
|
|
959
|
+
return this.createNode("Attribute", {
|
|
960
|
+
namespace,
|
|
961
|
+
startSegment,
|
|
962
|
+
name,
|
|
963
|
+
value,
|
|
964
|
+
}, startToken);
|
|
965
|
+
}
|
|
966
|
+
// --- Parses the nested children of an element
|
|
967
|
+
parseElementChildren(preserveWhitespace, useTextNode) {
|
|
968
|
+
var _a, _b, _c;
|
|
969
|
+
const childNodes = [];
|
|
970
|
+
let found = false;
|
|
971
|
+
let disallowTextLike = false;
|
|
972
|
+
while (true) {
|
|
973
|
+
let nextToken = this._lexer.peekNested();
|
|
974
|
+
if (nextToken.type === UemlToken_1.UemlTokenType.Eof) {
|
|
975
|
+
return childNodes;
|
|
976
|
+
}
|
|
977
|
+
let textAsHardLiteral = false;
|
|
978
|
+
switch (nextToken.type) {
|
|
979
|
+
case UemlToken_1.UemlTokenType.CloseNodeStart:
|
|
980
|
+
// --- No more nested child to parse
|
|
981
|
+
found = true;
|
|
982
|
+
break;
|
|
983
|
+
case UemlToken_1.UemlTokenType.Comment:
|
|
984
|
+
childNodes.push(this.createNode("Comment", { text: nextToken.text.trim() }, nextToken));
|
|
985
|
+
this._lexer.get();
|
|
986
|
+
disallowTextLike = false;
|
|
987
|
+
break;
|
|
988
|
+
case UemlToken_1.UemlTokenType.OpenNodeStart:
|
|
989
|
+
const childNode = this.parseElement();
|
|
990
|
+
if (childNode) {
|
|
991
|
+
childNodes.push(childNode);
|
|
992
|
+
}
|
|
993
|
+
disallowTextLike = false;
|
|
994
|
+
break;
|
|
995
|
+
case UemlToken_1.UemlTokenType.ScriptLiteral: {
|
|
996
|
+
this._lexer.get();
|
|
997
|
+
let text = nextToken.text.trim();
|
|
998
|
+
text = text.substring(UemlLexer_1.SCRIPT_LITERAL_START.length, text.length - UemlLexer_1.SCRIPT_LITERAL_END.length);
|
|
999
|
+
childNodes.push(this.createNode("Element", {
|
|
1000
|
+
id: "script",
|
|
1001
|
+
attributes: [],
|
|
1002
|
+
childNodes: [
|
|
1003
|
+
this.createNode("Text", {
|
|
1004
|
+
text,
|
|
1005
|
+
}, nextToken, nextToken),
|
|
1006
|
+
],
|
|
1007
|
+
}, nextToken));
|
|
1008
|
+
break;
|
|
1009
|
+
}
|
|
1010
|
+
case UemlToken_1.UemlTokenType.HardLiteral:
|
|
1011
|
+
case UemlToken_1.UemlTokenType.NestedText:
|
|
1012
|
+
case UemlToken_1.UemlTokenType.StringLiteral:
|
|
1013
|
+
case UemlToken_1.UemlTokenType.Identifier:
|
|
1014
|
+
if (disallowTextLike && nextToken.type !== UemlToken_1.UemlTokenType.HardLiteral) {
|
|
1015
|
+
this.reportError("U015", nextToken, (_c = (_b = (_a = nextToken.text) === null || _a === void 0 ? void 0 : _a.trim()) === null || _b === void 0 ? void 0 : _b.substring(1, 100)) !== null && _c !== void 0 ? _c : "");
|
|
1016
|
+
return null;
|
|
1017
|
+
}
|
|
1018
|
+
disallowTextLike =
|
|
1019
|
+
nextToken.type === UemlToken_1.UemlTokenType.StringLiteral || nextToken.type === UemlToken_1.UemlTokenType.NestedText;
|
|
1020
|
+
let text = nextToken.text;
|
|
1021
|
+
if (nextToken.type === UemlToken_1.UemlTokenType.StringLiteral) {
|
|
1022
|
+
let literalText = nextToken.text;
|
|
1023
|
+
if (!preserveWhitespace) {
|
|
1024
|
+
literalText = literalText.trim();
|
|
1025
|
+
literalText = literalText.substring(1, literalText.length - 1).replace(/\s+/g, " ");
|
|
1026
|
+
}
|
|
1027
|
+
const wrapper = nextToken.text.trim()[0];
|
|
1028
|
+
text = this.parseStringLiteral(`${wrapper}${literalText}${wrapper}`);
|
|
1029
|
+
}
|
|
1030
|
+
else if (nextToken.type === UemlToken_1.UemlTokenType.HardLiteral) {
|
|
1031
|
+
if (!preserveWhitespace) {
|
|
1032
|
+
text = nextToken.text.trim();
|
|
1033
|
+
text = text.substring(UemlLexer_1.HARD_LITERAL_START.length, text.length - UemlLexer_1.HARD_LITERAL_END.length);
|
|
1034
|
+
}
|
|
1035
|
+
textAsHardLiteral = true;
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
if (!preserveWhitespace) {
|
|
1039
|
+
text = text.replace(/\s+/g, " ");
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
childNodes.push(useTextNode
|
|
1043
|
+
? this.createNode("Element", {
|
|
1044
|
+
id: textAsHardLiteral ? "TextNodeCData" : "TextNode",
|
|
1045
|
+
attributes: [
|
|
1046
|
+
{
|
|
1047
|
+
type: "Attribute",
|
|
1048
|
+
name: "value",
|
|
1049
|
+
value: text,
|
|
1050
|
+
},
|
|
1051
|
+
],
|
|
1052
|
+
}, nextToken)
|
|
1053
|
+
: this.createNode("Text", {
|
|
1054
|
+
text,
|
|
1055
|
+
}, nextToken));
|
|
1056
|
+
this._lexer.get();
|
|
1057
|
+
break;
|
|
1058
|
+
default:
|
|
1059
|
+
found = true;
|
|
1060
|
+
break;
|
|
1061
|
+
}
|
|
1062
|
+
if (found) {
|
|
1063
|
+
// --- No more nested element to parse
|
|
1064
|
+
break;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
// --- Preprocess text-like children
|
|
1068
|
+
const processedChildNodes = [];
|
|
1069
|
+
let text = "";
|
|
1070
|
+
let useCData = false;
|
|
1071
|
+
for (const childNode of childNodes) {
|
|
1072
|
+
if (childNode.type === "Element" && (childNode.id === "TextNode" || childNode.id === "TextNodeCData")) {
|
|
1073
|
+
// --- This is a TextNode, it behaves just like text
|
|
1074
|
+
text += childNode.attributes[0].value;
|
|
1075
|
+
useCData = childNode.id === "TextNodeCData";
|
|
1076
|
+
}
|
|
1077
|
+
else if (childNode.type === "Element" || childNode.type === "Comment") {
|
|
1078
|
+
// --- This is a component/helper node or a comment, so store the previously collected text
|
|
1079
|
+
storeText(false);
|
|
1080
|
+
// --- Store the node
|
|
1081
|
+
processedChildNodes.push(childNode);
|
|
1082
|
+
}
|
|
1083
|
+
else if (childNode.type === "Text") {
|
|
1084
|
+
// --- Append the text
|
|
1085
|
+
text += childNode.text;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
// --- We may have a pending (not stored text node)
|
|
1089
|
+
storeText(useCData);
|
|
1090
|
+
// --- Done.
|
|
1091
|
+
return processedChildNodes;
|
|
1092
|
+
// --- Store the processed text
|
|
1093
|
+
function storeText(useCData) {
|
|
1094
|
+
if (text) {
|
|
1095
|
+
processedChildNodes.push(useTextNode
|
|
1096
|
+
? {
|
|
1097
|
+
type: "Element",
|
|
1098
|
+
id: useCData ? "TextNodeCData" : "TextNode",
|
|
1099
|
+
attributes: [
|
|
1100
|
+
{
|
|
1101
|
+
type: "Attribute",
|
|
1102
|
+
name: "value",
|
|
1103
|
+
value: text,
|
|
1104
|
+
},
|
|
1105
|
+
],
|
|
1106
|
+
}
|
|
1107
|
+
: {
|
|
1108
|
+
type: "Text",
|
|
1109
|
+
text: text,
|
|
1110
|
+
});
|
|
1111
|
+
text = "";
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
// ==========================================================================
|
|
1116
|
+
// Helpers
|
|
1117
|
+
/**
|
|
1118
|
+
* Reports the specified error
|
|
1119
|
+
* @param errorCode Error code
|
|
1120
|
+
* @param token Token that represents the error's position
|
|
1121
|
+
* @param options Error message options
|
|
1122
|
+
*/
|
|
1123
|
+
reportError(errorCode, token, ...options) {
|
|
1124
|
+
var _a;
|
|
1125
|
+
let errorText = (_a = ParserError_1.errorMessages[errorCode]) !== null && _a !== void 0 ? _a : "Unknown error";
|
|
1126
|
+
if (options) {
|
|
1127
|
+
options.forEach((o, idx) => (errorText = replace(errorText, `{${idx}}`, o.toString())));
|
|
1128
|
+
}
|
|
1129
|
+
if (!token) {
|
|
1130
|
+
token = this._lexer.peek();
|
|
1131
|
+
}
|
|
1132
|
+
this._parseErrors.push({
|
|
1133
|
+
code: errorCode,
|
|
1134
|
+
text: errorText,
|
|
1135
|
+
line: token.location.startLine,
|
|
1136
|
+
column: token.location.startColumn,
|
|
1137
|
+
position: token.location.startPosition,
|
|
1138
|
+
});
|
|
1139
|
+
throw new ParserError_1.ParserError(errorText, errorCode);
|
|
1140
|
+
function replace(input, placeholder, replacement) {
|
|
1141
|
+
do {
|
|
1142
|
+
input = input.replace(placeholder, replacement);
|
|
1143
|
+
} while (input.includes(placeholder));
|
|
1144
|
+
return input;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Creates an expression node
|
|
1149
|
+
* @param type Expression type
|
|
1150
|
+
* @param stump Stump properties
|
|
1151
|
+
* @param startToken The token that starts the expression
|
|
1152
|
+
* @param endToken The token that ends the expression
|
|
1153
|
+
* @param source Expression source code to store to the node
|
|
1154
|
+
*/
|
|
1155
|
+
createNode(type, stump, startToken, endToken, source) {
|
|
1156
|
+
// if (!endToken) {
|
|
1157
|
+
// endToken = this._lexer.peek();
|
|
1158
|
+
// }
|
|
1159
|
+
const startPosition = startToken.location.startPosition;
|
|
1160
|
+
const endPosition = endToken ? endToken.location.startPosition : this._lexer.input.position;
|
|
1161
|
+
return Object.assign({}, stump, {
|
|
1162
|
+
type,
|
|
1163
|
+
startPosition,
|
|
1164
|
+
endPosition,
|
|
1165
|
+
startLine: startToken.location.startLine,
|
|
1166
|
+
startColumn: startToken.location.startColumn,
|
|
1167
|
+
endLine: endToken ? endToken.location.endLine : this._lexer.input.line,
|
|
1168
|
+
endColumn: endToken ? endToken.location.endColumn : this._lexer.input.column,
|
|
1169
|
+
source: source !== null && source !== void 0 ? source : this.getSource(startToken, endToken),
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Gets the source code for the specified token range
|
|
1174
|
+
* @param start Start token
|
|
1175
|
+
* @param end Optional end token
|
|
1176
|
+
* @returns The source code for the token range
|
|
1177
|
+
*/
|
|
1178
|
+
getSource(start, end) {
|
|
1179
|
+
return this.source.substring(start.location.startPosition, end ? end.location.startPosition : this._lexer.input.position);
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Converts a string token to intrinsic string
|
|
1183
|
+
* @param text Literal text to parse
|
|
1184
|
+
*/
|
|
1185
|
+
parseStringLiteral(text) {
|
|
1186
|
+
const input = text.length < 2 ? "" : text.substring(1, text.length - 1);
|
|
1187
|
+
let result = "";
|
|
1188
|
+
let state = StrParseState.Normal;
|
|
1189
|
+
let collect = 0;
|
|
1190
|
+
for (const ch of input) {
|
|
1191
|
+
switch (state) {
|
|
1192
|
+
case StrParseState.Normal:
|
|
1193
|
+
if (ch === "\\") {
|
|
1194
|
+
state = StrParseState.Backslash;
|
|
1195
|
+
}
|
|
1196
|
+
else {
|
|
1197
|
+
result += ch;
|
|
1198
|
+
}
|
|
1199
|
+
break;
|
|
1200
|
+
case StrParseState.Backslash:
|
|
1201
|
+
state = StrParseState.Normal;
|
|
1202
|
+
switch (ch) {
|
|
1203
|
+
case "b":
|
|
1204
|
+
result += "\b";
|
|
1205
|
+
break;
|
|
1206
|
+
case "f":
|
|
1207
|
+
result += "\f";
|
|
1208
|
+
break;
|
|
1209
|
+
case "n":
|
|
1210
|
+
result += "\n";
|
|
1211
|
+
break;
|
|
1212
|
+
case "r":
|
|
1213
|
+
result += "\r";
|
|
1214
|
+
break;
|
|
1215
|
+
case "t":
|
|
1216
|
+
result += "\t";
|
|
1217
|
+
break;
|
|
1218
|
+
case "v":
|
|
1219
|
+
result += "\v";
|
|
1220
|
+
break;
|
|
1221
|
+
case "S":
|
|
1222
|
+
result += "\xa0";
|
|
1223
|
+
break;
|
|
1224
|
+
case "0":
|
|
1225
|
+
result += String.fromCharCode(0x00);
|
|
1226
|
+
break;
|
|
1227
|
+
case "'":
|
|
1228
|
+
result += "'";
|
|
1229
|
+
break;
|
|
1230
|
+
case '"':
|
|
1231
|
+
result += '"';
|
|
1232
|
+
break;
|
|
1233
|
+
case "\\":
|
|
1234
|
+
result += "\\";
|
|
1235
|
+
break;
|
|
1236
|
+
case "x":
|
|
1237
|
+
state = StrParseState.X;
|
|
1238
|
+
break;
|
|
1239
|
+
case "u":
|
|
1240
|
+
state = StrParseState.UX1;
|
|
1241
|
+
break;
|
|
1242
|
+
default:
|
|
1243
|
+
result += "\\" + ch;
|
|
1244
|
+
break;
|
|
1245
|
+
}
|
|
1246
|
+
break;
|
|
1247
|
+
case StrParseState.X:
|
|
1248
|
+
if (isHexadecimal(ch)) {
|
|
1249
|
+
collect = parseInt(ch, 16);
|
|
1250
|
+
state = StrParseState.Xh;
|
|
1251
|
+
}
|
|
1252
|
+
else {
|
|
1253
|
+
result += "x";
|
|
1254
|
+
state = StrParseState.Normal;
|
|
1255
|
+
}
|
|
1256
|
+
break;
|
|
1257
|
+
case StrParseState.Xh:
|
|
1258
|
+
if (isHexadecimal(ch)) {
|
|
1259
|
+
collect = collect * 0x10 + parseInt(ch, 16);
|
|
1260
|
+
result += String.fromCharCode(collect);
|
|
1261
|
+
state = StrParseState.Normal;
|
|
1262
|
+
}
|
|
1263
|
+
else {
|
|
1264
|
+
result += String.fromCharCode(collect);
|
|
1265
|
+
result += ch;
|
|
1266
|
+
state = StrParseState.Normal;
|
|
1267
|
+
}
|
|
1268
|
+
break;
|
|
1269
|
+
case StrParseState.UX1:
|
|
1270
|
+
if (ch === "{") {
|
|
1271
|
+
state = StrParseState.Ucp1;
|
|
1272
|
+
break;
|
|
1273
|
+
}
|
|
1274
|
+
if (isHexadecimal(ch)) {
|
|
1275
|
+
collect = parseInt(ch, 16);
|
|
1276
|
+
state = StrParseState.UX2;
|
|
1277
|
+
}
|
|
1278
|
+
else {
|
|
1279
|
+
result += "x";
|
|
1280
|
+
state = StrParseState.Normal;
|
|
1281
|
+
}
|
|
1282
|
+
break;
|
|
1283
|
+
case StrParseState.UX2:
|
|
1284
|
+
if (isHexadecimal(ch)) {
|
|
1285
|
+
collect = collect * 0x10 + parseInt(ch, 16);
|
|
1286
|
+
state = StrParseState.UX3;
|
|
1287
|
+
}
|
|
1288
|
+
else {
|
|
1289
|
+
result += String.fromCharCode(collect);
|
|
1290
|
+
result += ch;
|
|
1291
|
+
state = StrParseState.Normal;
|
|
1292
|
+
}
|
|
1293
|
+
break;
|
|
1294
|
+
case StrParseState.UX3:
|
|
1295
|
+
if (isHexadecimal(ch)) {
|
|
1296
|
+
collect = collect * 0x10 + parseInt(ch, 16);
|
|
1297
|
+
state = StrParseState.UX4;
|
|
1298
|
+
}
|
|
1299
|
+
else {
|
|
1300
|
+
result += String.fromCharCode(collect);
|
|
1301
|
+
result += ch;
|
|
1302
|
+
state = StrParseState.Normal;
|
|
1303
|
+
}
|
|
1304
|
+
break;
|
|
1305
|
+
case StrParseState.UX4:
|
|
1306
|
+
if (isHexadecimal(ch)) {
|
|
1307
|
+
collect = collect * 0x10 + parseInt(ch, 16);
|
|
1308
|
+
result += String.fromCharCode(collect);
|
|
1309
|
+
state = StrParseState.Normal;
|
|
1310
|
+
}
|
|
1311
|
+
else {
|
|
1312
|
+
result += String.fromCharCode(collect);
|
|
1313
|
+
result += ch;
|
|
1314
|
+
state = StrParseState.Normal;
|
|
1315
|
+
}
|
|
1316
|
+
break;
|
|
1317
|
+
case StrParseState.Ucp1:
|
|
1318
|
+
if (isHexadecimal(ch)) {
|
|
1319
|
+
collect = parseInt(ch, 16);
|
|
1320
|
+
state = StrParseState.Ucp2;
|
|
1321
|
+
}
|
|
1322
|
+
else {
|
|
1323
|
+
result += "x";
|
|
1324
|
+
state = StrParseState.Normal;
|
|
1325
|
+
}
|
|
1326
|
+
break;
|
|
1327
|
+
case StrParseState.Ucp2:
|
|
1328
|
+
if (isHexadecimal(ch)) {
|
|
1329
|
+
collect = collect * 0x10 + parseInt(ch, 16);
|
|
1330
|
+
state = StrParseState.Ucp3;
|
|
1331
|
+
}
|
|
1332
|
+
else {
|
|
1333
|
+
result += String.fromCharCode(collect);
|
|
1334
|
+
result += ch;
|
|
1335
|
+
state = StrParseState.Normal;
|
|
1336
|
+
}
|
|
1337
|
+
break;
|
|
1338
|
+
case StrParseState.Ucp3:
|
|
1339
|
+
if (isHexadecimal(ch)) {
|
|
1340
|
+
collect = collect * 0x10 + parseInt(ch, 16);
|
|
1341
|
+
state = StrParseState.Ucp4;
|
|
1342
|
+
}
|
|
1343
|
+
else {
|
|
1344
|
+
result += String.fromCharCode(collect);
|
|
1345
|
+
result += ch;
|
|
1346
|
+
state = StrParseState.Normal;
|
|
1347
|
+
}
|
|
1348
|
+
break;
|
|
1349
|
+
case StrParseState.Ucp4:
|
|
1350
|
+
if (isHexadecimal(ch)) {
|
|
1351
|
+
collect = collect * 0x10 + parseInt(ch, 16);
|
|
1352
|
+
state = StrParseState.Ucp5;
|
|
1353
|
+
}
|
|
1354
|
+
else {
|
|
1355
|
+
result += String.fromCharCode(collect);
|
|
1356
|
+
result += ch;
|
|
1357
|
+
state = StrParseState.Normal;
|
|
1358
|
+
}
|
|
1359
|
+
break;
|
|
1360
|
+
case StrParseState.Ucp5:
|
|
1361
|
+
if (isHexadecimal(ch)) {
|
|
1362
|
+
collect = collect * 0x10 + parseInt(ch, 16);
|
|
1363
|
+
state = StrParseState.Ucp6;
|
|
1364
|
+
}
|
|
1365
|
+
else {
|
|
1366
|
+
result += String.fromCharCode(collect);
|
|
1367
|
+
result += ch;
|
|
1368
|
+
state = StrParseState.Normal;
|
|
1369
|
+
}
|
|
1370
|
+
break;
|
|
1371
|
+
case StrParseState.Ucp6:
|
|
1372
|
+
if (isHexadecimal(ch)) {
|
|
1373
|
+
collect = collect * 0x10 + parseInt(ch, 16);
|
|
1374
|
+
state = StrParseState.UcpTail;
|
|
1375
|
+
}
|
|
1376
|
+
else {
|
|
1377
|
+
result += String.fromCharCode(collect);
|
|
1378
|
+
result += ch;
|
|
1379
|
+
state = StrParseState.Normal;
|
|
1380
|
+
}
|
|
1381
|
+
break;
|
|
1382
|
+
case StrParseState.UcpTail:
|
|
1383
|
+
result += String.fromCharCode(collect);
|
|
1384
|
+
if (ch !== "}") {
|
|
1385
|
+
result += ch;
|
|
1386
|
+
}
|
|
1387
|
+
state = StrParseState.Normal;
|
|
1388
|
+
break;
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
// --- Handle the final machine state
|
|
1392
|
+
switch (state) {
|
|
1393
|
+
case StrParseState.Backslash:
|
|
1394
|
+
result += "\\";
|
|
1395
|
+
break;
|
|
1396
|
+
case StrParseState.X:
|
|
1397
|
+
result += "x";
|
|
1398
|
+
break;
|
|
1399
|
+
case StrParseState.Xh:
|
|
1400
|
+
result += String.fromCharCode(collect);
|
|
1401
|
+
break;
|
|
1402
|
+
}
|
|
1403
|
+
// --- Done
|
|
1404
|
+
return result;
|
|
1405
|
+
function isHexadecimal(ch) {
|
|
1406
|
+
return (ch >= "0" && ch <= "9") || (ch >= "a" && ch <= "f") || (ch >= "A" && ch <= "F");
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
exports.UemlParser = UemlParser;
|
|
1411
|
+
/**
|
|
1412
|
+
* States of the string parsing
|
|
1413
|
+
*/
|
|
1414
|
+
var StrParseState;
|
|
1415
|
+
(function (StrParseState) {
|
|
1416
|
+
StrParseState[StrParseState["Normal"] = 0] = "Normal";
|
|
1417
|
+
StrParseState[StrParseState["Backslash"] = 1] = "Backslash";
|
|
1418
|
+
StrParseState[StrParseState["X"] = 2] = "X";
|
|
1419
|
+
StrParseState[StrParseState["Xh"] = 3] = "Xh";
|
|
1420
|
+
StrParseState[StrParseState["UX1"] = 4] = "UX1";
|
|
1421
|
+
StrParseState[StrParseState["UX2"] = 5] = "UX2";
|
|
1422
|
+
StrParseState[StrParseState["UX3"] = 6] = "UX3";
|
|
1423
|
+
StrParseState[StrParseState["UX4"] = 7] = "UX4";
|
|
1424
|
+
StrParseState[StrParseState["Ucp1"] = 8] = "Ucp1";
|
|
1425
|
+
StrParseState[StrParseState["Ucp2"] = 9] = "Ucp2";
|
|
1426
|
+
StrParseState[StrParseState["Ucp3"] = 10] = "Ucp3";
|
|
1427
|
+
StrParseState[StrParseState["Ucp4"] = 11] = "Ucp4";
|
|
1428
|
+
StrParseState[StrParseState["Ucp5"] = 12] = "Ucp5";
|
|
1429
|
+
StrParseState[StrParseState["Ucp6"] = 13] = "Ucp6";
|
|
1430
|
+
StrParseState[StrParseState["UcpTail"] = 14] = "UcpTail";
|
|
1431
|
+
})(StrParseState || (StrParseState = {}));
|
|
1432
|
+
const propAttrs = ["name", "value"];
|
|
1433
|
+
// --- Gets the content text of a comment element
|
|
1434
|
+
function getCommentText(comment) {
|
|
1435
|
+
return comment.text.substring("<!--".length, comment.text.length - "-->".length);
|
|
1436
|
+
}
|
|
1437
|
+
function isComponent(obj) {
|
|
1438
|
+
return obj.type;
|
|
1439
|
+
}
|