diff options
author | Itamar <itamar8910@gmail.com> | 2021-02-20 12:23:53 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-20 15:53:37 +0100 |
commit | d3ff82ba8087ccc357c3f3e893951a60620bddf0 (patch) | |
tree | 2150d3b2aa8c2ae26fbee58a53074a064235b3d8 /Userland/Libraries/LibCpp/Parser.h | |
parent | c4139be4611f08dcf40db5c2969852141c51b04d (diff) | |
download | serenity-d3ff82ba8087ccc357c3f3e893951a60620bddf0.zip |
LibCpp: Store filename in ASTNodes
As part of the position information, we now also store the filename the
ASTNode belongs to.
Diffstat (limited to 'Userland/Libraries/LibCpp/Parser.h')
-rw-r--r-- | Userland/Libraries/LibCpp/Parser.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Libraries/LibCpp/Parser.h b/Userland/Libraries/LibCpp/Parser.h index 5fe0ec6279..91e3580792 100644 --- a/Userland/Libraries/LibCpp/Parser.h +++ b/Userland/Libraries/LibCpp/Parser.h @@ -34,7 +34,7 @@ namespace Cpp { class Parser final { public: - explicit Parser(const StringView&); + explicit Parser(const StringView& program, const String& filename); ~Parser() = default; NonnullRefPtr<TranslationUnit> parse(); @@ -137,7 +137,7 @@ private: NonnullRefPtr<T> create_ast_node(ASTNode& parent, const Position& start, Optional<Position> end, Args&&... args) { - auto node = adopt(*new T(&parent, start, end, forward<Args>(args)...)); + auto node = adopt(*new T(&parent, start, end, m_filename, forward<Args>(args)...)); m_nodes.append(node); return node; } @@ -145,7 +145,7 @@ private: NonnullRefPtr<TranslationUnit> create_root_ast_node(const Position& start, Position end) { - auto node = adopt(*new TranslationUnit(nullptr, start, end)); + auto node = adopt(*new TranslationUnit(nullptr, start, end, m_filename)); m_nodes.append(node); m_root_node = node; return node; @@ -153,6 +153,7 @@ private: StringView m_program; Vector<StringView> m_lines; + String m_filename; Vector<Token> m_tokens; State m_state; Vector<State> m_saved_states; |