Parse the text stored in the container into a def syntax tree The returned syntax tree reference is never null
| 836 | // Parse the text stored in the container into a def syntax tree |
| 837 | // The returned syntax tree reference is never null |
| 838 | DefSyntaxTree::Ptr parse() |
| 839 | { |
| 840 | auto syntaxTree = std::make_shared<DefSyntaxTree>(); |
| 841 | |
| 842 | while (!_tokIter.isExhausted()) |
| 843 | { |
| 844 | auto token = *_tokIter; |
| 845 | |
| 846 | switch (token.type) |
| 847 | { |
| 848 | case DefSyntaxToken::Type::BlockComment: |
| 849 | case DefSyntaxToken::Type::EolComment: |
| 850 | syntaxTree->getRoot()->appendChildNode(std::make_shared<DefCommentSyntax>(token)); |
| 851 | ++_tokIter; |
| 852 | break; |
| 853 | case DefSyntaxToken::Type::Whitespace: |
| 854 | syntaxTree->getRoot()->appendChildNode(std::make_shared<DefWhitespaceSyntax>(token)); |
| 855 | ++_tokIter; |
| 856 | break; |
| 857 | case DefSyntaxToken::Type::BracedBlock: |
| 858 | rWarning() << "Unnamed block encountered: " << token.value << std::endl; |
| 859 | syntaxTree->getRoot()->appendChildNode(std::make_shared<DefBlockSyntax>(token, std::vector<DefSyntaxNode::Ptr>())); |
| 860 | ++_tokIter; |
| 861 | break; |
| 862 | case DefSyntaxToken::Type::Token: |
| 863 | auto blockNodes = parseBlock(); |
| 864 | |
| 865 | for (auto&& node : blockNodes) |
| 866 | { |
| 867 | syntaxTree->getRoot()->appendChildNode(std::move(node)); |
| 868 | } |
| 869 | break; |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | return syntaxTree; |
| 874 | } |
| 875 | |
| 876 | private: |
| 877 | std::vector<DefSyntaxNode::Ptr> parseBlock() |
nothing calls this directly
no test coverage detected