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,868 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UemlLexer = exports.SCRIPT_LITERAL_END = exports.SCRIPT_LITERAL_START = exports.HARD_LITERAL_END = exports.HARD_LITERAL_START = void 0;
|
|
4
|
+
const UemlToken_1 = require("./UemlToken");
|
|
5
|
+
// States of the lexer's state machine
|
|
6
|
+
var LexerPhase;
|
|
7
|
+
(function (LexerPhase) {
|
|
8
|
+
LexerPhase[LexerPhase["Start"] = 0] = "Start";
|
|
9
|
+
LexerPhase[LexerPhase["InWhiteSpace"] = 1] = "InWhiteSpace";
|
|
10
|
+
LexerPhase[LexerPhase["LeftAngle"] = 2] = "LeftAngle";
|
|
11
|
+
LexerPhase[LexerPhase["LeftAngleExcl"] = 3] = "LeftAngleExcl";
|
|
12
|
+
LexerPhase[LexerPhase["LeftAngleExclDash"] = 4] = "LeftAngleExclDash";
|
|
13
|
+
LexerPhase[LexerPhase["Comment"] = 5] = "Comment";
|
|
14
|
+
LexerPhase[LexerPhase["CommentDash"] = 6] = "CommentDash";
|
|
15
|
+
LexerPhase[LexerPhase["CommentTwoDash"] = 7] = "CommentTwoDash";
|
|
16
|
+
LexerPhase[LexerPhase["SingleWord"] = 8] = "SingleWord";
|
|
17
|
+
LexerPhase[LexerPhase["CloseStart"] = 9] = "CloseStart";
|
|
18
|
+
LexerPhase[LexerPhase["HardLiteral"] = 10] = "HardLiteral";
|
|
19
|
+
LexerPhase[LexerPhase["ScriptLiteral"] = 11] = "ScriptLiteral";
|
|
20
|
+
LexerPhase[LexerPhase["InNestedWhitespace"] = 12] = "InNestedWhitespace";
|
|
21
|
+
LexerPhase[LexerPhase["NestedText"] = 13] = "NestedText";
|
|
22
|
+
// --- String processing phases
|
|
23
|
+
LexerPhase[LexerPhase["String"] = 14] = "String";
|
|
24
|
+
LexerPhase[LexerPhase["StringBackSlash"] = 15] = "StringBackSlash";
|
|
25
|
+
LexerPhase[LexerPhase["StringHexa1"] = 16] = "StringHexa1";
|
|
26
|
+
LexerPhase[LexerPhase["StringHexa2"] = 17] = "StringHexa2";
|
|
27
|
+
LexerPhase[LexerPhase["StringUHexa1"] = 18] = "StringUHexa1";
|
|
28
|
+
LexerPhase[LexerPhase["StringUHexa2"] = 19] = "StringUHexa2";
|
|
29
|
+
LexerPhase[LexerPhase["StringUHexa3"] = 20] = "StringUHexa3";
|
|
30
|
+
LexerPhase[LexerPhase["StringUHexa4"] = 21] = "StringUHexa4";
|
|
31
|
+
LexerPhase[LexerPhase["StringUcp1"] = 22] = "StringUcp1";
|
|
32
|
+
LexerPhase[LexerPhase["StringUcp2"] = 23] = "StringUcp2";
|
|
33
|
+
LexerPhase[LexerPhase["StringUcp3"] = 24] = "StringUcp3";
|
|
34
|
+
LexerPhase[LexerPhase["StringUcp4"] = 25] = "StringUcp4";
|
|
35
|
+
LexerPhase[LexerPhase["StringUcp5"] = 26] = "StringUcp5";
|
|
36
|
+
LexerPhase[LexerPhase["StringUcp6"] = 27] = "StringUcp6";
|
|
37
|
+
LexerPhase[LexerPhase["StringUcpTail"] = 28] = "StringUcpTail";
|
|
38
|
+
LexerPhase[LexerPhase["BackSlash"] = 29] = "BackSlash";
|
|
39
|
+
LexerPhase[LexerPhase["Ampersand"] = 30] = "Ampersand";
|
|
40
|
+
})(LexerPhase || (LexerPhase = {}));
|
|
41
|
+
// --- Regex used to recognize UEML identifiers
|
|
42
|
+
const uemlIdRegex = /^[A-Z_][$0-9A-Z_.\-]*$/i;
|
|
43
|
+
exports.HARD_LITERAL_START = "<![CDATA[";
|
|
44
|
+
exports.HARD_LITERAL_END = "]]>";
|
|
45
|
+
exports.SCRIPT_LITERAL_START = "<script>";
|
|
46
|
+
exports.SCRIPT_LITERAL_END = "</script>";
|
|
47
|
+
/**
|
|
48
|
+
* This class implements the lexer of binding expressions
|
|
49
|
+
*/
|
|
50
|
+
class UemlLexer {
|
|
51
|
+
/**
|
|
52
|
+
* Initializes the tokenizer with the input stream
|
|
53
|
+
* @param input Input source code stream
|
|
54
|
+
*/
|
|
55
|
+
constructor(input) {
|
|
56
|
+
this.input = input;
|
|
57
|
+
// --- Already fetched tokens
|
|
58
|
+
this._ahead = [];
|
|
59
|
+
// --- Prefetched character (from the next token)
|
|
60
|
+
this._prefetched = null;
|
|
61
|
+
// --- Prefetched character position (from the next token)
|
|
62
|
+
this._prefetchedPos = null;
|
|
63
|
+
// --- Prefetched character column (from the next token)
|
|
64
|
+
this._prefetchedColumn = null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Fetches the next token without advancing to its position
|
|
68
|
+
* @param ws If true, retrieve whitespaces too
|
|
69
|
+
*/
|
|
70
|
+
peek(ws = false) {
|
|
71
|
+
return this.ahead(0, ws);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Reads tokens ahead
|
|
75
|
+
* @param n Number of token positions to read ahead
|
|
76
|
+
* @param ws If true, retrieve whitespaces too
|
|
77
|
+
*/
|
|
78
|
+
ahead(n = 1, ws = false) {
|
|
79
|
+
if (n > 16) {
|
|
80
|
+
throw new Error("Cannot look ahead more than 16 tokens");
|
|
81
|
+
}
|
|
82
|
+
// --- Prefetch missing tokens
|
|
83
|
+
while (this._ahead.length <= n) {
|
|
84
|
+
const token = this.fetch();
|
|
85
|
+
if (isEof(token)) {
|
|
86
|
+
return token;
|
|
87
|
+
}
|
|
88
|
+
if (ws || (!ws && !isWs(token))) {
|
|
89
|
+
this._ahead.push(token);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return this._ahead[n];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Fetches the next token and advances the stream position
|
|
96
|
+
* @param ws If true, retrieve whitespaces too
|
|
97
|
+
@param searchForNested Search for a nested element token */
|
|
98
|
+
get(ws = false, searchForNested = false) {
|
|
99
|
+
if (this._ahead.length > 0) {
|
|
100
|
+
const token = this._ahead.shift();
|
|
101
|
+
if (!token) {
|
|
102
|
+
throw new Error("Token expected");
|
|
103
|
+
}
|
|
104
|
+
return token;
|
|
105
|
+
}
|
|
106
|
+
while (true) {
|
|
107
|
+
const token = this.fetch(searchForNested);
|
|
108
|
+
if (isEof(token) || ws || (!ws && !isWs(token))) {
|
|
109
|
+
return token;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Fetches the next child element token without advancing to its position
|
|
115
|
+
*/
|
|
116
|
+
peekNested() {
|
|
117
|
+
if (!this._ahead.length) {
|
|
118
|
+
const token = this.fetch(true);
|
|
119
|
+
if (isEof(token)) {
|
|
120
|
+
return token;
|
|
121
|
+
}
|
|
122
|
+
this._ahead.push(token);
|
|
123
|
+
}
|
|
124
|
+
return this._ahead[0];
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Fetches the next token from the input stream
|
|
128
|
+
* @param searchForNested Search for a nested element token
|
|
129
|
+
*/
|
|
130
|
+
fetch(searchForNested = false) {
|
|
131
|
+
var _a;
|
|
132
|
+
// --- Captured constants used in nested functions
|
|
133
|
+
const lexer = this;
|
|
134
|
+
const input = this.input;
|
|
135
|
+
const startPos = this._prefetchedPos || input.position;
|
|
136
|
+
const line = input.line;
|
|
137
|
+
const startColumn = this._prefetchedColumn || input.column;
|
|
138
|
+
// --- State variables
|
|
139
|
+
let stringState = null;
|
|
140
|
+
let text = "";
|
|
141
|
+
let tokenType = UemlToken_1.UemlTokenType.Eof;
|
|
142
|
+
let lastEndPos = input.position;
|
|
143
|
+
let lastEndColumn = input.column;
|
|
144
|
+
let ch = null;
|
|
145
|
+
let skipTextAppend = false;
|
|
146
|
+
// --- Start from the beginning
|
|
147
|
+
let phase = LexerPhase.Start;
|
|
148
|
+
// --- Process all token characters
|
|
149
|
+
while (true) {
|
|
150
|
+
// --- Get the next character
|
|
151
|
+
ch = fetchNextChar();
|
|
152
|
+
skipTextAppend = false;
|
|
153
|
+
// --- In case of EOF, return the current token data
|
|
154
|
+
if (ch === null) {
|
|
155
|
+
return makeToken();
|
|
156
|
+
}
|
|
157
|
+
// --- Set the initial token type to unknown for the other characters
|
|
158
|
+
if (tokenType === UemlToken_1.UemlTokenType.Eof) {
|
|
159
|
+
tokenType = UemlToken_1.UemlTokenType.Unknown;
|
|
160
|
+
}
|
|
161
|
+
// --- Follow the lexer state machine
|
|
162
|
+
switch (phase) {
|
|
163
|
+
// ====================================================================
|
|
164
|
+
// Process the first character
|
|
165
|
+
case LexerPhase.Start:
|
|
166
|
+
switch (ch) {
|
|
167
|
+
// --- Go on with whitespaces
|
|
168
|
+
case " ":
|
|
169
|
+
case "\t":
|
|
170
|
+
case "\n":
|
|
171
|
+
case "\r":
|
|
172
|
+
if (searchForNested) {
|
|
173
|
+
phase = searchForNested ? LexerPhase.InNestedWhitespace : LexerPhase.InWhiteSpace;
|
|
174
|
+
tokenType = UemlToken_1.UemlTokenType.NestedText;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
phase = LexerPhase.InWhiteSpace;
|
|
178
|
+
tokenType = UemlToken_1.UemlTokenType.Ws;
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
case "<":
|
|
182
|
+
phase = handleHardLiteralCase();
|
|
183
|
+
if (phase === LexerPhase.LeftAngle) {
|
|
184
|
+
phase = handleScriptLiteralCase();
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
case ">":
|
|
188
|
+
return completeToken(UemlToken_1.UemlTokenType.NodeEnd);
|
|
189
|
+
case "/":
|
|
190
|
+
if (searchForNested) {
|
|
191
|
+
phase = LexerPhase.NestedText;
|
|
192
|
+
tokenType = UemlToken_1.UemlTokenType.NestedText;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
phase = LexerPhase.CloseStart;
|
|
196
|
+
break;
|
|
197
|
+
case "=":
|
|
198
|
+
if (searchForNested) {
|
|
199
|
+
phase = LexerPhase.NestedText;
|
|
200
|
+
tokenType = UemlToken_1.UemlTokenType.NestedText;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
return completeToken(UemlToken_1.UemlTokenType.Equal);
|
|
204
|
+
case ":":
|
|
205
|
+
if (searchForNested) {
|
|
206
|
+
phase = LexerPhase.NestedText;
|
|
207
|
+
tokenType = UemlToken_1.UemlTokenType.NestedText;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
return completeToken(UemlToken_1.UemlTokenType.Colon);
|
|
211
|
+
case "'":
|
|
212
|
+
case '"':
|
|
213
|
+
case "`":
|
|
214
|
+
phase = LexerPhase.String;
|
|
215
|
+
stringState = ch;
|
|
216
|
+
break;
|
|
217
|
+
case "&":
|
|
218
|
+
if (searchForNested) {
|
|
219
|
+
phase = LexerPhase.Ampersand;
|
|
220
|
+
tokenType = UemlToken_1.UemlTokenType.NestedText;
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
224
|
+
case "\\":
|
|
225
|
+
if (searchForNested) {
|
|
226
|
+
phase = LexerPhase.BackSlash;
|
|
227
|
+
tokenType = UemlToken_1.UemlTokenType.NestedText;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
231
|
+
default:
|
|
232
|
+
if (isSingleWordChar(ch)) {
|
|
233
|
+
if (searchForNested) {
|
|
234
|
+
phase = LexerPhase.NestedText;
|
|
235
|
+
tokenType = UemlToken_1.UemlTokenType.NestedText;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
phase = LexerPhase.SingleWord;
|
|
239
|
+
tokenType = UemlToken_1.UemlTokenType.SingleWord;
|
|
240
|
+
}
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
if (searchForNested) {
|
|
244
|
+
phase = LexerPhase.NestedText;
|
|
245
|
+
tokenType = UemlToken_1.UemlTokenType.NestedText;
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
249
|
+
}
|
|
250
|
+
break;
|
|
251
|
+
// ====================================================================
|
|
252
|
+
// Whitespace processing
|
|
253
|
+
case LexerPhase.InWhiteSpace:
|
|
254
|
+
if (ch !== " " && ch !== "\t" && ch !== "\r" && ch !== "\n") {
|
|
255
|
+
return makeToken();
|
|
256
|
+
}
|
|
257
|
+
break;
|
|
258
|
+
case LexerPhase.InNestedWhitespace:
|
|
259
|
+
if (ch === " " || ch === "\t" || ch === "\r" || ch === "\n") {
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
if (ch === "<") {
|
|
263
|
+
phase = handleHardLiteralCase();
|
|
264
|
+
if (phase === LexerPhase.LeftAngle) {
|
|
265
|
+
phase = handleScriptLiteralCase();
|
|
266
|
+
}
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
if (ch === "'" || ch === '"' || ch === "`") {
|
|
270
|
+
phase = LexerPhase.String;
|
|
271
|
+
stringState = ch;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
// --- This is the start of a nested text
|
|
275
|
+
phase = LexerPhase.NestedText;
|
|
276
|
+
tokenType = UemlToken_1.UemlTokenType.NestedText;
|
|
277
|
+
break;
|
|
278
|
+
// ====================================================================
|
|
279
|
+
// Hard literal processing
|
|
280
|
+
case LexerPhase.HardLiteral:
|
|
281
|
+
if (ch === exports.HARD_LITERAL_END[0]) {
|
|
282
|
+
// --- Recognize if hard literal end found
|
|
283
|
+
let isHardLiteral = true;
|
|
284
|
+
for (let i = 1; i < exports.HARD_LITERAL_END.length; i++) {
|
|
285
|
+
isHardLiteral = isHardLiteral && input.ahead(i - 1) === exports.HARD_LITERAL_END[i];
|
|
286
|
+
if (!isHardLiteral)
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
if (isHardLiteral) {
|
|
290
|
+
text += exports.HARD_LITERAL_END;
|
|
291
|
+
skipTextAppend = true;
|
|
292
|
+
for (let i = 1; i < exports.HARD_LITERAL_END.length; i++) {
|
|
293
|
+
input.get();
|
|
294
|
+
}
|
|
295
|
+
return completeToken(UemlToken_1.UemlTokenType.HardLiteral);
|
|
296
|
+
}
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
// --- We're still within a hard literal
|
|
300
|
+
break;
|
|
301
|
+
// ====================================================================
|
|
302
|
+
// Hard literal processing
|
|
303
|
+
case LexerPhase.ScriptLiteral:
|
|
304
|
+
if (ch === exports.SCRIPT_LITERAL_END[0]) {
|
|
305
|
+
// --- Recognize if hard literal end found
|
|
306
|
+
let isScriptLiteral = true;
|
|
307
|
+
for (let i = 1; i < exports.SCRIPT_LITERAL_END.length; i++) {
|
|
308
|
+
isScriptLiteral = isScriptLiteral && input.ahead(i - 1) === exports.SCRIPT_LITERAL_END[i];
|
|
309
|
+
if (!isScriptLiteral)
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
if (isScriptLiteral) {
|
|
313
|
+
text += exports.SCRIPT_LITERAL_END;
|
|
314
|
+
skipTextAppend = true;
|
|
315
|
+
for (let i = 1; i < exports.SCRIPT_LITERAL_END.length; i++) {
|
|
316
|
+
input.get();
|
|
317
|
+
}
|
|
318
|
+
return completeToken(UemlToken_1.UemlTokenType.ScriptLiteral);
|
|
319
|
+
}
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
// --- We're still within a script literal
|
|
323
|
+
break;
|
|
324
|
+
// ====================================================================
|
|
325
|
+
// Nested text processing
|
|
326
|
+
case LexerPhase.BackSlash:
|
|
327
|
+
if (ch === "&") {
|
|
328
|
+
// --- Remove the last "\"
|
|
329
|
+
text = text.substring(0, text.length - 1);
|
|
330
|
+
}
|
|
331
|
+
phase = LexerPhase.NestedText;
|
|
332
|
+
tokenType = UemlToken_1.UemlTokenType.NestedText;
|
|
333
|
+
break;
|
|
334
|
+
case LexerPhase.Ampersand:
|
|
335
|
+
const tail = input.getTail(input.position - 1);
|
|
336
|
+
if (tail.startsWith("amp;")) {
|
|
337
|
+
text = text.substring(0, text.length - 1);
|
|
338
|
+
ch = "&";
|
|
339
|
+
input.get(); // m
|
|
340
|
+
input.get(); // p
|
|
341
|
+
input.get(); // ;
|
|
342
|
+
}
|
|
343
|
+
else if (tail.startsWith("gt;")) {
|
|
344
|
+
text = text.substring(0, text.length - 1);
|
|
345
|
+
ch = ">";
|
|
346
|
+
input.get(); // t
|
|
347
|
+
input.get(); // ;
|
|
348
|
+
}
|
|
349
|
+
else if (tail.startsWith("lt;")) {
|
|
350
|
+
text = text.substring(0, text.length - 1);
|
|
351
|
+
ch = "<";
|
|
352
|
+
input.get(); // t
|
|
353
|
+
input.get(); // ;
|
|
354
|
+
}
|
|
355
|
+
else if (tail.startsWith("apos;")) {
|
|
356
|
+
text = text.substring(0, text.length - 1);
|
|
357
|
+
ch = "'";
|
|
358
|
+
input.get(); // p
|
|
359
|
+
input.get(); // o
|
|
360
|
+
input.get(); // s
|
|
361
|
+
input.get(); // ;
|
|
362
|
+
}
|
|
363
|
+
else if (tail.startsWith("quot;")) {
|
|
364
|
+
text = text.substring(0, text.length - 1);
|
|
365
|
+
ch = '"';
|
|
366
|
+
input.get(); // u
|
|
367
|
+
input.get(); // o
|
|
368
|
+
input.get(); // t
|
|
369
|
+
input.get(); // ;
|
|
370
|
+
}
|
|
371
|
+
phase = LexerPhase.NestedText;
|
|
372
|
+
break;
|
|
373
|
+
case LexerPhase.NestedText:
|
|
374
|
+
if (ch === "\\") {
|
|
375
|
+
phase = LexerPhase.BackSlash;
|
|
376
|
+
}
|
|
377
|
+
else if (ch === "&") {
|
|
378
|
+
phase = LexerPhase.Ampersand;
|
|
379
|
+
}
|
|
380
|
+
else if (ch === "<") {
|
|
381
|
+
return makeToken();
|
|
382
|
+
}
|
|
383
|
+
// --- We're still within a nested text
|
|
384
|
+
break;
|
|
385
|
+
// ====================================================================
|
|
386
|
+
// Opening and closing tags
|
|
387
|
+
case LexerPhase.LeftAngle:
|
|
388
|
+
if (ch === "!") {
|
|
389
|
+
phase = LexerPhase.LeftAngleExcl;
|
|
390
|
+
tokenType = UemlToken_1.UemlTokenType.Unknown;
|
|
391
|
+
}
|
|
392
|
+
else if (ch === "/") {
|
|
393
|
+
return completeToken(UemlToken_1.UemlTokenType.CloseNodeStart);
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
return makeToken();
|
|
397
|
+
}
|
|
398
|
+
break;
|
|
399
|
+
// --- Testing for closing tags
|
|
400
|
+
case LexerPhase.CloseStart:
|
|
401
|
+
return ch === ">" ? completeToken(UemlToken_1.UemlTokenType.NodeClose) : makeToken();
|
|
402
|
+
// ====================================================================
|
|
403
|
+
// Collecting "single word" characters
|
|
404
|
+
case LexerPhase.SingleWord:
|
|
405
|
+
if (!isSingleWordChar(ch)) {
|
|
406
|
+
return makeToken();
|
|
407
|
+
}
|
|
408
|
+
break;
|
|
409
|
+
// ====================================================================
|
|
410
|
+
// Comment processing
|
|
411
|
+
case LexerPhase.LeftAngleExcl:
|
|
412
|
+
if (ch === "-") {
|
|
413
|
+
phase = LexerPhase.LeftAngleExclDash;
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
return makeToken();
|
|
417
|
+
}
|
|
418
|
+
break;
|
|
419
|
+
case LexerPhase.LeftAngleExclDash:
|
|
420
|
+
if (ch === "-") {
|
|
421
|
+
phase = LexerPhase.Comment;
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
return makeToken();
|
|
425
|
+
}
|
|
426
|
+
break;
|
|
427
|
+
case LexerPhase.Comment:
|
|
428
|
+
if (ch === "-") {
|
|
429
|
+
phase = LexerPhase.CommentDash;
|
|
430
|
+
}
|
|
431
|
+
break;
|
|
432
|
+
case LexerPhase.CommentDash:
|
|
433
|
+
phase = ch === "-" ? LexerPhase.CommentTwoDash : LexerPhase.Comment;
|
|
434
|
+
break;
|
|
435
|
+
case LexerPhase.CommentTwoDash:
|
|
436
|
+
if (ch === ">") {
|
|
437
|
+
return completeToken(UemlToken_1.UemlTokenType.Comment);
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
phase = LexerPhase.Comment;
|
|
441
|
+
}
|
|
442
|
+
break;
|
|
443
|
+
// ====================================================================
|
|
444
|
+
// String processing
|
|
445
|
+
case LexerPhase.String:
|
|
446
|
+
if (ch === stringState) {
|
|
447
|
+
if (searchForNested) {
|
|
448
|
+
const tail = (_a = input.getTail(input.position)) === null || _a === void 0 ? void 0 : _a.trim();
|
|
449
|
+
if ((tail === null || tail === void 0 ? void 0 : tail[0]) === "<") {
|
|
450
|
+
return completeToken(UemlToken_1.UemlTokenType.StringLiteral);
|
|
451
|
+
}
|
|
452
|
+
phase = LexerPhase.NestedText;
|
|
453
|
+
tokenType = UemlToken_1.UemlTokenType.NestedText;
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
return completeToken(UemlToken_1.UemlTokenType.StringLiteral);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
else if (ch === "\\") {
|
|
461
|
+
const tail = input.getTail(input.position);
|
|
462
|
+
if (tail.startsWith("&")) {
|
|
463
|
+
text += "&";
|
|
464
|
+
ch = ";";
|
|
465
|
+
input.get(); // &
|
|
466
|
+
input.get(); // a
|
|
467
|
+
input.get(); // m
|
|
468
|
+
input.get(); // p
|
|
469
|
+
input.get(); // ;
|
|
470
|
+
}
|
|
471
|
+
else if (tail.startsWith(">")) {
|
|
472
|
+
text += ">";
|
|
473
|
+
ch = ";";
|
|
474
|
+
input.get(); // &
|
|
475
|
+
input.get(); // g
|
|
476
|
+
input.get(); // t
|
|
477
|
+
input.get(); // ;
|
|
478
|
+
}
|
|
479
|
+
else if (tail.startsWith("<")) {
|
|
480
|
+
text += "<";
|
|
481
|
+
ch = ";";
|
|
482
|
+
input.get(); // &
|
|
483
|
+
input.get(); // l
|
|
484
|
+
input.get(); // t
|
|
485
|
+
input.get(); // ;
|
|
486
|
+
}
|
|
487
|
+
else if (tail.startsWith("'")) {
|
|
488
|
+
text += "&apos";
|
|
489
|
+
ch = ";";
|
|
490
|
+
input.get(); // &
|
|
491
|
+
input.get(); // a
|
|
492
|
+
input.get(); // p
|
|
493
|
+
input.get(); // o
|
|
494
|
+
input.get(); // s
|
|
495
|
+
input.get(); // ;
|
|
496
|
+
}
|
|
497
|
+
else if (tail.startsWith(""")) {
|
|
498
|
+
text += """;
|
|
499
|
+
ch = ";";
|
|
500
|
+
input.get(); // &
|
|
501
|
+
input.get(); // q
|
|
502
|
+
input.get(); // u
|
|
503
|
+
input.get(); // o
|
|
504
|
+
input.get(); // t
|
|
505
|
+
input.get(); // ;
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
phase = LexerPhase.StringBackSlash;
|
|
509
|
+
tokenType = UemlToken_1.UemlTokenType.Unknown;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
const tail = input.getTail(input.position - 1);
|
|
514
|
+
if (tail.startsWith("&")) {
|
|
515
|
+
ch = "&";
|
|
516
|
+
input.get(); // a
|
|
517
|
+
input.get(); // m
|
|
518
|
+
input.get(); // p
|
|
519
|
+
input.get(); // ;
|
|
520
|
+
}
|
|
521
|
+
else if (tail.startsWith(">")) {
|
|
522
|
+
ch = ">";
|
|
523
|
+
input.get(); // g
|
|
524
|
+
input.get(); // t
|
|
525
|
+
input.get(); // ;
|
|
526
|
+
}
|
|
527
|
+
else if (tail.startsWith("<")) {
|
|
528
|
+
ch = "<";
|
|
529
|
+
input.get(); // l
|
|
530
|
+
input.get(); // t
|
|
531
|
+
input.get(); // ;
|
|
532
|
+
}
|
|
533
|
+
else if (tail.startsWith("'")) {
|
|
534
|
+
ch = "'";
|
|
535
|
+
input.get(); // a
|
|
536
|
+
input.get(); // p
|
|
537
|
+
input.get(); // o
|
|
538
|
+
input.get(); // s
|
|
539
|
+
input.get(); // ;
|
|
540
|
+
}
|
|
541
|
+
else if (tail.startsWith(""")) {
|
|
542
|
+
ch = '"';
|
|
543
|
+
input.get(); // q
|
|
544
|
+
input.get(); // u
|
|
545
|
+
input.get(); // o
|
|
546
|
+
input.get(); // t
|
|
547
|
+
input.get(); // ;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
break;
|
|
551
|
+
// Start of string character escape
|
|
552
|
+
case LexerPhase.StringBackSlash:
|
|
553
|
+
switch (ch) {
|
|
554
|
+
case "b":
|
|
555
|
+
case "f":
|
|
556
|
+
case "n":
|
|
557
|
+
case "r":
|
|
558
|
+
case "t":
|
|
559
|
+
case "v":
|
|
560
|
+
case "S":
|
|
561
|
+
case "0":
|
|
562
|
+
case "'":
|
|
563
|
+
case '"':
|
|
564
|
+
case "`":
|
|
565
|
+
case "\\":
|
|
566
|
+
phase = LexerPhase.String;
|
|
567
|
+
break;
|
|
568
|
+
case "x":
|
|
569
|
+
phase = LexerPhase.StringHexa1;
|
|
570
|
+
break;
|
|
571
|
+
case "u":
|
|
572
|
+
phase = LexerPhase.StringUHexa1;
|
|
573
|
+
break;
|
|
574
|
+
default:
|
|
575
|
+
phase = LexerPhase.String;
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
break;
|
|
579
|
+
// --- First hexadecimal digit of string character escape
|
|
580
|
+
case LexerPhase.StringHexa1:
|
|
581
|
+
if (isHexadecimalDigit(ch)) {
|
|
582
|
+
phase = LexerPhase.StringHexa2;
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
585
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
586
|
+
}
|
|
587
|
+
break;
|
|
588
|
+
// --- Second hexadecimal digit of character escape
|
|
589
|
+
case LexerPhase.StringHexa2:
|
|
590
|
+
if (isHexadecimalDigit(ch)) {
|
|
591
|
+
phase = LexerPhase.String;
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
595
|
+
}
|
|
596
|
+
break;
|
|
597
|
+
// --- First hexadecimal digit of Unicode string character escape
|
|
598
|
+
case LexerPhase.StringUHexa1:
|
|
599
|
+
if (ch === "{") {
|
|
600
|
+
phase = LexerPhase.StringUcp1;
|
|
601
|
+
break;
|
|
602
|
+
}
|
|
603
|
+
if (isHexadecimalDigit(ch)) {
|
|
604
|
+
phase = LexerPhase.StringUHexa2;
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
608
|
+
}
|
|
609
|
+
break;
|
|
610
|
+
// --- Second hexadecimal digit of Unicode string character escape
|
|
611
|
+
case LexerPhase.StringUHexa2:
|
|
612
|
+
if (isHexadecimalDigit(ch)) {
|
|
613
|
+
phase = LexerPhase.StringUHexa3;
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
617
|
+
}
|
|
618
|
+
break;
|
|
619
|
+
// --- Third hexadecimal digit of Unicode string character escape
|
|
620
|
+
case LexerPhase.StringUHexa3:
|
|
621
|
+
if (isHexadecimalDigit(ch)) {
|
|
622
|
+
phase = LexerPhase.StringUHexa4;
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
626
|
+
}
|
|
627
|
+
break;
|
|
628
|
+
// --- Fourth hexadecimal digit of Unicode string character escape
|
|
629
|
+
case LexerPhase.StringUHexa4:
|
|
630
|
+
if (isHexadecimalDigit(ch)) {
|
|
631
|
+
phase = LexerPhase.String;
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
635
|
+
}
|
|
636
|
+
break;
|
|
637
|
+
// --- First hexadecimal digit of Unicode codepoint string character escape
|
|
638
|
+
case LexerPhase.StringUcp1:
|
|
639
|
+
if (isHexadecimalDigit(ch)) {
|
|
640
|
+
phase = LexerPhase.StringUcp2;
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
644
|
+
}
|
|
645
|
+
break;
|
|
646
|
+
// --- Second hexadecimal digit of Unicode codepoint string character escape
|
|
647
|
+
case LexerPhase.StringUcp2:
|
|
648
|
+
if (ch === "}") {
|
|
649
|
+
phase = LexerPhase.String;
|
|
650
|
+
}
|
|
651
|
+
else if (isHexadecimalDigit(ch)) {
|
|
652
|
+
phase = LexerPhase.StringUcp3;
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
656
|
+
}
|
|
657
|
+
break;
|
|
658
|
+
// --- Third hexadecimal digit of Unicode codepoint string character escape
|
|
659
|
+
case LexerPhase.StringUcp3:
|
|
660
|
+
if (ch === "}") {
|
|
661
|
+
phase = LexerPhase.String;
|
|
662
|
+
}
|
|
663
|
+
else if (isHexadecimalDigit(ch)) {
|
|
664
|
+
phase = LexerPhase.StringUcp4;
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
668
|
+
}
|
|
669
|
+
break;
|
|
670
|
+
// --- Fourth hexadecimal digit of Unicode codepoint string character escape
|
|
671
|
+
case LexerPhase.StringUcp4:
|
|
672
|
+
if (ch === "}") {
|
|
673
|
+
phase = LexerPhase.String;
|
|
674
|
+
}
|
|
675
|
+
else if (isHexadecimalDigit(ch)) {
|
|
676
|
+
phase = LexerPhase.StringUcp5;
|
|
677
|
+
}
|
|
678
|
+
else {
|
|
679
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
680
|
+
}
|
|
681
|
+
break;
|
|
682
|
+
// --- Fifth hexadecimal digit of Unicode codepoint string character escape
|
|
683
|
+
case LexerPhase.StringUcp5:
|
|
684
|
+
if (ch === "}") {
|
|
685
|
+
phase = LexerPhase.String;
|
|
686
|
+
}
|
|
687
|
+
else if (isHexadecimalDigit(ch)) {
|
|
688
|
+
phase = LexerPhase.StringUcp6;
|
|
689
|
+
}
|
|
690
|
+
else {
|
|
691
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
692
|
+
}
|
|
693
|
+
break;
|
|
694
|
+
// --- Sixth hexadecimal digit of Unicode codepoint string character escape
|
|
695
|
+
case LexerPhase.StringUcp6:
|
|
696
|
+
if (ch === "}") {
|
|
697
|
+
phase = LexerPhase.String;
|
|
698
|
+
}
|
|
699
|
+
else if (isHexadecimalDigit(ch)) {
|
|
700
|
+
phase = LexerPhase.StringUcpTail;
|
|
701
|
+
}
|
|
702
|
+
else {
|
|
703
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
704
|
+
}
|
|
705
|
+
break;
|
|
706
|
+
// --- Closing bracket of Unicode codepoint string character escape
|
|
707
|
+
case LexerPhase.StringUcpTail:
|
|
708
|
+
if (ch === "}") {
|
|
709
|
+
phase = LexerPhase.String;
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
return completeToken(UemlToken_1.UemlTokenType.Unknown);
|
|
713
|
+
}
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
// --- Append the char to the current text
|
|
717
|
+
appendTokenChar();
|
|
718
|
+
// --- Go on with parsing the next character
|
|
719
|
+
}
|
|
720
|
+
// --- Handle hard literal checking
|
|
721
|
+
function handleHardLiteralCase() {
|
|
722
|
+
let isHardLiteral = true;
|
|
723
|
+
for (let i = 1; i < exports.HARD_LITERAL_START.length; i++) {
|
|
724
|
+
const ahead = input.ahead(i - 1);
|
|
725
|
+
isHardLiteral = isHardLiteral && ahead === exports.HARD_LITERAL_START[i];
|
|
726
|
+
if (!isHardLiteral)
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
729
|
+
if (isHardLiteral) {
|
|
730
|
+
text += exports.HARD_LITERAL_START;
|
|
731
|
+
skipTextAppend = true;
|
|
732
|
+
for (let i = 1; i < exports.HARD_LITERAL_START.length; i++) {
|
|
733
|
+
input.get();
|
|
734
|
+
}
|
|
735
|
+
return LexerPhase.HardLiteral;
|
|
736
|
+
}
|
|
737
|
+
tokenType = UemlToken_1.UemlTokenType.OpenNodeStart;
|
|
738
|
+
return LexerPhase.LeftAngle;
|
|
739
|
+
}
|
|
740
|
+
// --- Handle hard literal checking
|
|
741
|
+
function handleScriptLiteralCase() {
|
|
742
|
+
let isScriptLiteral = true;
|
|
743
|
+
for (let i = 1; i < exports.SCRIPT_LITERAL_START.length; i++) {
|
|
744
|
+
const ahead = input.ahead(i - 1);
|
|
745
|
+
isScriptLiteral = isScriptLiteral && ahead === exports.SCRIPT_LITERAL_START[i];
|
|
746
|
+
if (!isScriptLiteral)
|
|
747
|
+
break;
|
|
748
|
+
}
|
|
749
|
+
if (isScriptLiteral) {
|
|
750
|
+
text += exports.SCRIPT_LITERAL_START;
|
|
751
|
+
skipTextAppend = true;
|
|
752
|
+
for (let i = 1; i < exports.SCRIPT_LITERAL_START.length; i++) {
|
|
753
|
+
input.get();
|
|
754
|
+
}
|
|
755
|
+
return LexerPhase.ScriptLiteral;
|
|
756
|
+
}
|
|
757
|
+
tokenType = UemlToken_1.UemlTokenType.OpenNodeStart;
|
|
758
|
+
return LexerPhase.LeftAngle;
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Appends the last character to the token, and manages positions
|
|
762
|
+
*/
|
|
763
|
+
function appendTokenChar() {
|
|
764
|
+
if (!skipTextAppend) {
|
|
765
|
+
text += ch;
|
|
766
|
+
}
|
|
767
|
+
lexer._prefetched = null;
|
|
768
|
+
lexer._prefetchedPos = null;
|
|
769
|
+
lexer._prefetchedColumn = null;
|
|
770
|
+
lastEndPos = input.position;
|
|
771
|
+
lastEndColumn = input.position;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Fetches the next character from the input stream
|
|
775
|
+
*/
|
|
776
|
+
function fetchNextChar() {
|
|
777
|
+
if (!lexer._prefetched) {
|
|
778
|
+
lexer._prefetchedPos = input.position;
|
|
779
|
+
lexer._prefetched = input.get();
|
|
780
|
+
}
|
|
781
|
+
return lexer._prefetched;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Packs the specified type of token to send back
|
|
785
|
+
*/
|
|
786
|
+
function makeToken() {
|
|
787
|
+
if (tokenType === UemlToken_1.UemlTokenType.SingleWord) {
|
|
788
|
+
// --- A single word may be an identifier
|
|
789
|
+
if (uemlIdRegex.test(text)) {
|
|
790
|
+
tokenType = UemlToken_1.UemlTokenType.Identifier;
|
|
791
|
+
}
|
|
792
|
+
else {
|
|
793
|
+
tokenType = UemlToken_1.UemlTokenType.Unknown;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
return {
|
|
797
|
+
text,
|
|
798
|
+
type: tokenType,
|
|
799
|
+
location: {
|
|
800
|
+
startPosition: startPos,
|
|
801
|
+
endPosition: lastEndPos,
|
|
802
|
+
startLine: line,
|
|
803
|
+
endLine: line,
|
|
804
|
+
startColumn,
|
|
805
|
+
endColumn: lastEndColumn,
|
|
806
|
+
},
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Add the last character to the token and return it
|
|
811
|
+
*/
|
|
812
|
+
function completeToken(suggestedType) {
|
|
813
|
+
appendTokenChar();
|
|
814
|
+
// --- Send back the token
|
|
815
|
+
if (suggestedType !== undefined) {
|
|
816
|
+
tokenType = suggestedType;
|
|
817
|
+
}
|
|
818
|
+
return makeToken();
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
exports.UemlLexer = UemlLexer;
|
|
823
|
+
/**
|
|
824
|
+
* Tests if a token id EOF
|
|
825
|
+
* @param t Token instance
|
|
826
|
+
*/
|
|
827
|
+
function isEof(t) {
|
|
828
|
+
return t.type === UemlToken_1.UemlTokenType.Eof;
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Tests if a token is whitespace
|
|
832
|
+
* @param t Token instance
|
|
833
|
+
*/
|
|
834
|
+
function isWs(t) {
|
|
835
|
+
return t.type <= UemlToken_1.UemlTokenType.Ws;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Tests if a character is an identifier start character
|
|
839
|
+
* @param ch Character to test
|
|
840
|
+
*/
|
|
841
|
+
function isSingleWordChar(ch) {
|
|
842
|
+
return ((ch >= "a" && ch <= "z") ||
|
|
843
|
+
(ch >= "A" && ch <= "Z") ||
|
|
844
|
+
(ch >= "0" && ch <= "9") ||
|
|
845
|
+
ch === "$" ||
|
|
846
|
+
ch === "#" ||
|
|
847
|
+
ch === "@" ||
|
|
848
|
+
ch === "_" ||
|
|
849
|
+
ch === "." ||
|
|
850
|
+
ch === "," ||
|
|
851
|
+
ch === "%" ||
|
|
852
|
+
ch === "(" ||
|
|
853
|
+
ch === ")" ||
|
|
854
|
+
ch === "{" ||
|
|
855
|
+
ch === "}" ||
|
|
856
|
+
ch === "[" ||
|
|
857
|
+
ch === "]" ||
|
|
858
|
+
ch === "+" ||
|
|
859
|
+
ch === "*" ||
|
|
860
|
+
ch === "-");
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Tests if a character is a hexadecimal digit
|
|
864
|
+
* @param ch Character to test
|
|
865
|
+
*/
|
|
866
|
+
function isHexadecimalDigit(ch) {
|
|
867
|
+
return (ch >= "0" && ch <= "9") || (ch >= "A" && ch <= "F") || (ch >= "a" && ch <= "f");
|
|
868
|
+
}
|