├── .analysis_options ├── .gitignore ├── AUTHORS ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── TODO.md ├── doc ├── GRAMMAR.md └── SYNTAX.md ├── lib ├── angular_ast.dart └── src │ ├── ast.dart │ ├── ast │ ├── attribute.dart │ ├── close_element.dart │ ├── comment.dart │ ├── content.dart │ ├── element.dart │ ├── event.dart │ ├── expression.dart │ ├── interface.dart │ ├── interpolation.dart │ ├── let_binding.dart │ ├── property.dart │ ├── reference.dart │ ├── sugar │ │ ├── banana.dart │ │ └── star.dart │ ├── template.dart │ └── text.dart │ ├── exception_handler │ ├── angular_parser_exception.dart │ ├── exception_handler.dart │ └── exceptions.dart │ ├── expression │ ├── micro.dart │ ├── micro │ │ ├── ast.dart │ │ ├── lexer.dart │ │ ├── parser.dart │ │ ├── scanner.dart │ │ └── token.dart │ ├── ng_dart_ast.dart │ ├── parser.dart │ └── visitor.dart │ ├── lexer.dart │ ├── parser.dart │ ├── parser │ ├── reader.dart │ └── recursive.dart │ ├── recovery_protocol │ ├── angular_analyzer_protocol.dart │ └── recovery_protocol.dart │ ├── scanner.dart │ ├── simple_tokenizer.dart │ ├── token │ ├── lexeme.dart │ ├── token_types.dart │ └── tokens.dart │ ├── visitor.dart │ └── visitors │ ├── desugar_visitor.dart │ ├── expression_parser_visitor.dart │ ├── humanizing.dart │ └── identity.dart ├── pubspec.yaml ├── test ├── ast_cli_tester.dart ├── ast_cli_tester_source.html ├── cli_tester.dart ├── e2e │ ├── e2e_template_tests.dart │ └── templates │ │ ├── fixed_material_tab_strip.html │ │ ├── material_button.html │ │ ├── material_checkbox.html │ │ ├── material_chip.html │ │ ├── material_chips.html │ │ ├── material_dialog.html │ │ ├── material_expansion_panel.html │ │ ├── material_input.html │ │ ├── material_popup.html │ │ ├── material_progress.html │ │ ├── material_toggle.html │ │ ├── scoreboard.html │ │ └── scorecard.html ├── expression │ ├── micro │ │ ├── lexer_test.dart │ │ └── parser_test.dart │ └── parser_test.dart ├── lexer_test.dart ├── parser_test.dart ├── random_generator_test │ └── random_tester.dart ├── recover_errors_lexer_test.dart ├── recover_errors_parser.dart ├── simple_token_test.dart ├── simple_tokenizer_test.dart ├── token_test.dart └── visitor_test.dart └── tool └── presubmit.sh /.analysis_options: -------------------------------------------------------------------------------- 1 | analyzer: 2 | strong-mode: true 3 | linter: 4 | rules: 5 | # Errors 6 | - avoid_empty_else 7 | - control_flow_in_finally 8 | - empty_statements 9 | - test_types_in_equals 10 | - throw_in_finally 11 | - valid_regexps 12 | 13 | # Style 14 | - annotate_overrides 15 | - avoid_init_to_null 16 | - avoid_return_types_on_setters 17 | - await_only_futures 18 | - camel_case_types 19 | - comment_references 20 | - empty_catches 21 | - empty_constructor_bodies 22 | - hash_and_equals 23 | - library_prefixes 24 | - non_constant_identifier_names 25 | - prefer_is_not_empty 26 | - slash_for_doc_comments 27 | - type_init_formals 28 | - unrelated_type_equality_checks 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *packages/ 2 | .packages 3 | .pub 4 | pubspec.lock 5 | test/random_generator_test/incorrect.html 6 | test/random_generator_test/lexer_fixed.html 7 | test/random_generator_test/ast_fixed.html 8 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # Below is a list of people and organizations that have contributed 2 | # to the project. Names should be added to the list like so: 3 | # 4 | # Name/Organization 5 | 6 | Google Inc. -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 0.2.0 4 | 5 | - Add an experimental flag to `NgParser` (`toolFriendlyAstOrigin`) which 6 | wraps de-sugared AST origins in another synthetic AST that represents 7 | the intermediate value (i.e. `BananaAst` or `StarAst`) 8 | - Add support for parsing expressions, including de-sugaring pipes. When 9 | parsing templates, expression AST objects automatically use the Dart 10 | expression parser. 11 | 12 | ```dart 13 | new ExpressionAst.parse('some + dart + expression') 14 | ``` 15 | 16 | - One exception: The `|` operator is not respected, as it is used for 17 | pipes in AngularDart. Instead, this operator is converted into a 18 | special `PipeExpression`. 19 | - Added `TemplateAstVisitor` and two examples: 20 | - `HumanizingTemplateAstVisitor` 21 | - `IdentityTemplateAstVisitor` 22 | - De-sugars the `*ngFor`-style micro expressions; see `micro/*_test.dart`. 23 | - Added `attributes` as a valid property of `EmbeddedTemplateAst` 24 | 25 | ## 0.1.0 26 | 27 | - Initial commit 28 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Want to contribute? Great! First, read this page (including the small print at 2 | the end). 3 | 4 | ### Before you contribute 5 | Before we can use your code, you must sign the 6 | [Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual) 7 | (CLA), which you can do online. The CLA is necessary mainly because you own the 8 | copyright to your changes, even after your contribution becomes part of our 9 | codebase, so we need your permission to use and distribute your code. We also 10 | need to be sure of various other things—for instance that you'll tell us if you 11 | know that your code infringes on other people's patents. You don't have to sign 12 | the CLA until after you've submitted your code for review and a member has 13 | approved it, but you must do it before we can put your code into our codebase. 14 | 15 | Before you start working on a larger contribution, you should get in touch with 16 | us first through the issue tracker with your idea so that we can help out and 17 | possibly guide you. Coordinating up front makes it much easier to avoid 18 | frustration later on. 19 | 20 | ### Code reviews 21 | All submissions, including submissions by project members, require review. 22 | 23 | ### File headers 24 | All files in the project must start with the following header. 25 | 26 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 27 | // for details. All rights reserved. Use of this source code is governed by a 28 | // BSD-style license that can be found in the LICENSE file. 29 | 30 | ### The small print 31 | Contributions made by corporations are covered by a different agreement than the 32 | one above, the 33 | [Software Grant and Corporate Contributor License Agreement](https://developers.google.com/open-source/cla/corporate). -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2016, the Dart project authors. All rights reserved. 2 | Redistribution and use in source and binary forms, with or without 3 | modification, are permitted provided that the following conditions are 4 | met: 5 | 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above 9 | copyright notice, this list of conditions and the following 10 | disclaimer in the documentation and/or other materials provided 11 | with the distribution. 12 | * Neither the name of Google Inc. nor the names of its 13 | contributors may be used to endorse or promote products derived 14 | from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # angular_ast 2 | 3 | Parser and utilities for [AngularDart][gh_angular_dart] templates. 4 | 5 | [gh_angular_dart]: https://github.com/dart-lang/angular2 6 | 7 | 8 | 9 | This package is _platform agnostic_ (no HTML or Dart VM dependencies). 10 | 11 | ## Usage 12 | 13 | *Currently in development* and **not stable**. 14 | 15 | ```dart 16 | import 'package:angular_ast/angular_ast.dart'; 17 | 18 | main() { 19 | // Create an AST tree by parsing an AngularDart template. 20 | var tree = parse(''); 21 | 22 | // Print to console. 23 | print(tree); 24 | 25 | // Output: 26 | // [ 27 | // ElementAst