diff --git a/README.md b/README.md index 4daee5f..332b108 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,13 @@ ## About -This repository contains the common utility packages required for developing backend framework. +This repository contains the common utility packages required for developing dart backend framework. ## Available Packages -* html_builder +* Html Builder +* Code Buffer +* Combinator +* Merge Map +* Symbol Table \ No newline at end of file diff --git a/packages/merge_map/CHANGELOG.md b/packages/merge_map/CHANGELOG.md index 31f362c..90fb9dc 100644 --- a/packages/merge_map/CHANGELOG.md +++ b/packages/merge_map/CHANGELOG.md @@ -1,16 +1,29 @@ -# 2.0.2 +# Change Log + +## 3.0.0 + +* Upgraded from `pendantic` to `lints` linter +* Published as `belatuk_merge_map` package +* Fixed linter warnings + +## 2.0.2 + * Resolve static analysis warnings -# 2.0.1 +## 2.0.1 + * Updated README -# 2.0.0 +## 2.0.0 + * Migrated to work with Dart SDK 2.12.x NNBD -# 1.0.2 +## 1.0.2 + * Add an example, for Pub's sake. -# 1.0.1 +## 1.0.1 + * Add a specific constraint on Dart versions, to prevent Pub from rejecting all packages that depend on `merge_map` (the entire Angel framework). * Add generic type support diff --git a/packages/merge_map/LICENSE b/packages/merge_map/LICENSE index 8f65b57..df5e063 100644 --- a/packages/merge_map/LICENSE +++ b/packages/merge_map/LICENSE @@ -1,21 +1,29 @@ -MIT License (MIT) +BSD 3-Clause License -Copyright (c) 2021 dukefirehawk.com +Copyright (c) 2021, dukefirehawk.com +All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/merge_map/README.md b/packages/merge_map/README.md index 21a94bb..3eef33c 100644 --- a/packages/merge_map/README.md +++ b/packages/merge_map/README.md @@ -1,18 +1,20 @@ -# angel3_merge_map -[![version](https://img.shields.io/badge/pub-v2.0.2-brightgreen)](https://pub.dartlang.org/packages/angel3_merge_map) -[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) -[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) +# Belatuk Merge Map -[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/merge_map/LICENSE) + +[![version](https://img.shields.io/badge/pub-v3.0.1-brightgreen)](https://pub.dartlang.org/packages/belatuk_merge_map) +[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) +[![License](https://img.shields.io/github/license/dart-backend/belatuk-common-utilities)](https://github.com/dart-backend/belatuk-common-utilities/packages/code_buffer/LICENSE) + +**Replacement of `package:merge_map` with breaking changes to support NNBD.** Combine multiple Maps into one. Equivalent to [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) in JS. -# Example +## Example ```dart -import "package:angel3_merge_map/angel3_merge_map.dart"; +import "package:belatuk_merge_map/belatuk_merge_map.dart"; void main() { Map map1 = {'hello': 'world'}; @@ -22,4 +24,4 @@ void main() { // {hello: world, foo: {bar: baz, john: doe, this: overrides previous maps}} } -``` \ No newline at end of file +``` diff --git a/packages/merge_map/analysis_options.yaml b/packages/merge_map/analysis_options.yaml index c230cee..ea2c9e9 100644 --- a/packages/merge_map/analysis_options.yaml +++ b/packages/merge_map/analysis_options.yaml @@ -1,4 +1 @@ -include: package:pedantic/analysis_options.yaml -analyzer: - strong-mode: - implicit-casts: false \ No newline at end of file +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/packages/merge_map/example/main.dart b/packages/merge_map/example/main.dart index c3b7c46..c97ea05 100644 --- a/packages/merge_map/example/main.dart +++ b/packages/merge_map/example/main.dart @@ -1,4 +1,4 @@ -import 'package:angel3_merge_map/angel3_merge_map.dart'; +import 'package:belatuk_merge_map/belatuk_merge_map.dart'; void main() { // ignore: omit_local_variable_types diff --git a/packages/merge_map/lib/angel3_merge_map.dart b/packages/merge_map/lib/belatuk_merge_map.dart similarity index 74% rename from packages/merge_map/lib/angel3_merge_map.dart rename to packages/merge_map/lib/belatuk_merge_map.dart index 8158489..a709908 100644 --- a/packages/merge_map/lib/angel3_merge_map.dart +++ b/packages/merge_map/lib/belatuk_merge_map.dart @@ -2,15 +2,17 @@ library angel3_merge_map; dynamic _copyValues( - Map from, Map? to, bool recursive, bool acceptNull) { + Map from, Map to, bool recursive, bool acceptNull) { for (var key in from.keys) { if (from[key] is Map && recursive) { - if (!(to![key] is Map)) { + if (to[key] is! Map) { to[key] = {} as V; } - _copyValues(from[key] as Map, to[key] as Map?, recursive, acceptNull); + _copyValues(from[key] as Map, to[key] as Map, recursive, acceptNull); } else { - if (from[key] != null || acceptNull) to![key] = from[key]; + if (from[key] != null || acceptNull) { + to[key] = from[key]; + } } } } @@ -27,8 +29,8 @@ dynamic _copyValues( Map mergeMap(Iterable> maps, {bool recursive = true, bool acceptNull = false}) { var result = {}; - maps.forEach((Map map) { + for (var map in maps) { _copyValues(map, result, recursive, acceptNull); - }); + } return result; } diff --git a/packages/merge_map/pubspec.yaml b/packages/merge_map/pubspec.yaml index a4412aa..ad48129 100644 --- a/packages/merge_map/pubspec.yaml +++ b/packages/merge_map/pubspec.yaml @@ -1,9 +1,9 @@ -name: angel3_merge_map -version: 2.0.2 +name: belatuk_merge_map +version: 3.0.0 description: Combine multiple Maps into one. Equivalent to Object.assign in JS. -homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/merge_map +homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/merge_map environment: sdk: '>=2.12.0 <3.0.0' dev_dependencies: test: ^1.17.4 - pedantic: ^1.11.0 + lints: ^1.0.0 diff --git a/packages/merge_map/test/all_test.dart b/packages/merge_map/test/all_test.dart index 06ab569..228215f 100644 --- a/packages/merge_map/test/all_test.dart +++ b/packages/merge_map/test/all_test.dart @@ -1,4 +1,4 @@ -import 'package:angel3_merge_map/angel3_merge_map.dart'; +import 'package:belatuk_merge_map/belatuk_merge_map.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/symbol_table/CHANGELOG.md b/packages/symbol_table/CHANGELOG.md index 9dd305e..fef9186 100644 --- a/packages/symbol_table/CHANGELOG.md +++ b/packages/symbol_table/CHANGELOG.md @@ -1,16 +1,28 @@ -# 2.0.2 +# Change Log + +## 3.0.0 + +* Upgraded from `pendantic` to `lints` linter +* Published as `belatuk_symbol_table` package + +## 2.0.2 + * Resolved static analysis warnings -# 2.0.1 +## 2.0.1 + * Resolved static analysis warnings -# 2.0.0 +## 2.0.0 + * Migrated to work with Dart SDK 2.12.x NNBD ## 1.0.4 + * Added `context` to `SymbolTable`. ## 1.0.3 + * Converted `Visibility` into a `Comparable` class. * Renamed `add` -> `create`, `put` -> `assign`, and `allVariablesOfVisibility` -> `allVariablesWithVisibility`. * Added tests for `Visibility` comparing, and `depth`. @@ -18,9 +30,10 @@ * Fixed a typo in `remove` that would have prevented it from working correctly. ## 1.0.2 + * Added `depth` to `SymbolTable`. * Added `symbolTable` to `Variable`. * Deprecated the redundant `Constant` class. * Deprecated `Variable.markAsPrivate()`. * Added the `Visibility` enumerator. -* Added the field `visibility` to `Variable`. \ No newline at end of file +* Added the field `visibility` to `Variable`. diff --git a/packages/symbol_table/LICENSE b/packages/symbol_table/LICENSE index 8f65b57..df5e063 100644 --- a/packages/symbol_table/LICENSE +++ b/packages/symbol_table/LICENSE @@ -1,21 +1,29 @@ -MIT License (MIT) +BSD 3-Clause License -Copyright (c) 2021 dukefirehawk.com +Copyright (c) 2021, dukefirehawk.com +All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/symbol_table/README.md b/packages/symbol_table/README.md index 364ee10..a6eec58 100644 --- a/packages/symbol_table/README.md +++ b/packages/symbol_table/README.md @@ -1,5 +1,6 @@ -# angel3_symbol_table -[![version](https://img.shields.io/badge/pub-v2.0.2-brightgreen)](https://pub.dartlang.org/packages/angel3_symbol_table) +# Belatuk Merge Map + +[![version](https://img.shields.io/badge/pub-v3.0.0-brightgreen)](https://pub.dartlang.org/packages/belatuk_symbol_table) [![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) @@ -9,7 +10,8 @@ A generic symbol table implementation in Dart, with support for scopes and const The symbol tables produced by this package are hierarchical (in this case, tree-shaped), and utilize basic memoization to speed up repeated lookups. -# Variables +## Variables + To represent a symbol, use `Variable`. I opted for the name `Variable` to avoid conflict with the Dart primitive `Symbol`. @@ -28,6 +30,7 @@ foo.value = 'baz'; // Also throws a StateError - Once a variable is locked, it c ``` ## Visibility + Variables are *public* by default, but can also be marked as *private* or *protected*. This can be helpful if you are trying to determine which symbols should be exported from a library or class. @@ -36,7 +39,8 @@ myVariable.visibility = Visibility.protected; myVariable.visibility = Visibility.private; ``` -# Symbol Tables +## Symbol Tables + It's easy to create a basic symbol table: ```dart @@ -66,7 +70,8 @@ var symbol = doubles.resolveOrCreate('one', value: 1.0); var symbol = doubles.resolveOrCreate('one', value: 1.0, constant: true); ``` -# Exporting Symbols +## Exporting Symbols + Due to the tree structure of symbol tables, it is extremely easy to extract a linear list of distinct variables, with variables lower in the hierarchy superseding their parents (effectively accomplishing variable shadowing). @@ -83,15 +88,17 @@ var exportedSymbols = mySymbolTable.allPublicVariables; ``` It's easy to extract symbols of a given visibility: + ```dart var exportedSymbols = mySymbolTable.allVariablesWithVisibility(Visibility.protected); ``` -# Child Scopes +## Child Scopes + There are three ways to create a new symbol table: +### Regular Children -## Regular Children This is what most interpreters need; it simply creates a symbol table with the current symbol table as its parent. The new scope can define its own symbols, which will only shadow the ancestors within the correct scope. @@ -101,18 +108,21 @@ var child = mySymbolTable.createChild(); var child = mySymbolTable.createChild(values: {...}); ``` -### Depth +#### Depth + Every symbol table has an associated `depth` attached to it, with the `depth` at the root being `0`. When `createChild` is called, the resulting child has an incremented `depth`. -## Clones +### Clones + This creates a scope at the same level as the current one, with all the same variables. ```dart var clone = mySymbolTable.clone(); ``` -## Forked Scopes +### Forked Scopes + If you are implementing a language with closure functions, you might consider looking into this. A forked scope is a scope identical to the current one, but instead of merely copying references to variables, the values of variables are copied into new ones. @@ -128,7 +138,8 @@ var forked = mySymbolTable.fork(); var forked = mySymbolTable.fork(values: {...}); ``` -# Creating Names +## Creating Names + In languages with block scope, oftentimes, identifiers will collide within a global scope. To avoid this, symbol tables expose a `uniqueName()` method that simply attaches a numerical suffix to an input name. The name is guaranteed to never be repeated within a specific scope. @@ -139,7 +150,8 @@ var name1 = mySymbolTable.uniqueName('foo'); // foo1 var name2 = mySymbolTable.uniqueName('foo'); // foo2 ``` -# `this` Context +## `this` Context + Many languages handle a sort of `this` context that values within a scope may optionally be resolved against. Symbol tables can easily set their context as follows: @@ -158,4 +170,4 @@ void bar() { mySymbolTable.context = thisContext; expect(mySymbolTable.createChild().createChild().context, thisContext); } -``` \ No newline at end of file +``` diff --git a/packages/symbol_table/analysis_options.yaml b/packages/symbol_table/analysis_options.yaml index c230cee..ea2c9e9 100644 --- a/packages/symbol_table/analysis_options.yaml +++ b/packages/symbol_table/analysis_options.yaml @@ -1,4 +1 @@ -include: package:pedantic/analysis_options.yaml -analyzer: - strong-mode: - implicit-casts: false \ No newline at end of file +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/packages/symbol_table/pubspec.yaml b/packages/symbol_table/pubspec.yaml index c777d4c..ad19a94 100644 --- a/packages/symbol_table/pubspec.yaml +++ b/packages/symbol_table/pubspec.yaml @@ -1,11 +1,11 @@ -name: angel3_symbol_table -version: 2.0.2 +name: belatuk_symbol_table +version: 3.0.0 description: A generic symbol table implementation in Dart, with support for scopes and constants. -homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/symbol_table +homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/symbol_table environment: sdk: '>=2.12.0 <3.0.0' dependencies: collection: ^1.15.0 dev_dependencies: test: ^1.17.4 - pedantic: ^1.11.0 + lints: ^1.0.0