summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCpp/Parser.cpp
AgeCommit message (Collapse)Author
2021-12-05LibCpp: Cast unused smart-pointer return values to voidSam Atkins
2021-11-29LibCpp: Fix copy paste typo in Parser::match_secondary_expressionBrian Gianforcaro
This was caught by SonarCloud.
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-09-28LibCpp: Remove redundant comparison to Token::Type::PipePipeBrian Gianforcaro
SonarCloud flagged this 'Identical sub-expressions on both sides of operator "||"'. When looking at the git history it looks like it was just a copy / paste mistake that happened when Token::Type::Arrow support was added.
2021-08-07LibCpp: Do macro substitution in the preprocessor instead of the parserItamar
After this change, the parser is completely separated from preprocessor concepts.
2021-08-07LibCpp: Import definitions from headers while processingItamar
When the preprocessor encounters an #include statement it now adds the preprocessor definitions that exist in the included header to its own set of definitions. We previously only aggregated the definitions from headers after processing the source, which was less correct. (For example, there could be an #ifdef that depends on a definition from another header).
2021-08-07LibCpp: Do lexing in the PreprocessorItamar
We now call Preprocessor::process_and_lex() and pass the result to the parser. Doing the lexing in the preprocessor will allow us to maintain the original position information of tokens after substituting definitions.
2021-08-02LibCpp: Allow 'final' in a class declaration with inheritanceAli Mohammad Pur
2021-08-02LibCpp: Add support for east constAli Mohammad Pur
Now LibCpp can understand the eastest of consts too :^)
2021-08-02LibCpp: Allow 'override' as a function target qualifierAli Mohammad Pur
This is just ignored right now.
2021-08-02LibCpp: Add support for parsing function typesAli Mohammad Pur
This makes it work with types like `Function<T(U, V)>`.
2021-08-02LibCpp: Allow 'const' after a function's signatureAli Mohammad Pur
This is too lax for functions that aren't class members, but let's allow that anyway.
2021-08-02LibCpp: Add support for parsing reference typesAli Mohammad Pur
2021-08-02LibCpp: Allow virtual destructorsAli Mohammad Pur
2021-08-02LibCpp: Match and ignore struct/class inheritanceAli Mohammad Pur
2021-08-02LibCpp: Parse enum members with explicit valuesAli Mohammad Pur
2021-08-02LibCpp: Parse "extern" declarationsAli Mohammad Pur
Note that this is not the `extern "C"` declarations, just extern decl qualifiers.
2021-08-02LibCpp: Accept scoped variable declarationsAli Mohammad Pur
For instance, `Type Scope::Class::variable = value;` is a valid declaration.
2021-07-13LibCpp: Don't store entire ASTNode vector in each parser stateItamar
We previously stored the entire ASTNode vector in each parser state, and this vector was copied whenever a state was loaded or saved. We don't actually need to store the whole nodes list in each state because a new state can only add new nodes to this list, and won't mutate existing nodes. It would suffice to only hold a vector of the nodes that were created while parsing in the current state to keep a reference to them. This reduces the time it takes on my machine for the c++ language server to handle a file that #includes <LibGUI/Widget.h> from ~4sec to ~0.7sec.
2021-07-13LibCpp: Only store error messages for the main parser stateItamar
There's no need to store parser error messages for states with depth > 0, as they will eventually be popped from the states stack and their error messages will never be displayed to the user. Profiling shows that this change reduces the % of backtraces that contain the store_state & load_state functions from ~95% to ~70%. Empirically this change reduces the time it takes on my machine for the c++ language server to handle a file that #includes <LibGUI/Widget.h> from ~14sec to ~4sec.
2021-07-10LibCpp: Make the fields of AST node types privateItamar
Previously almost all fields were public and were directly accessed by the Parser and CppComprehensionEngine. This commit makes all fields of AST node types private. They are now accessed via getters & setters.
2021-07-04LibCpp: Add Parser::tokens_in_range(start, end)Itamar
This function returns the tokens that exist in the specified range.
2021-07-04LibCpp: Fix positional information of Pointer typesItamar
2021-07-04LibCpp: Fix parsing of ellipsisItamar
Previously the positional information for the node of an ellipsis was incorrect.
2021-06-29LibCpp: Differentiate between Type and NamedTypeItamar
This adds a new ASTNode type called 'NamedType' which inherits from the Type node. Previously every Type node had a name field, but it was not logically accurate. For example, pointer types do not have a name (the pointed-to type may have one).
2021-06-29LibCpp: Add LOG_SCOPE() macro for debugging the parser's flowItamar
LOG_SCOPE() uses ScopeLogger and additionally shows the current token in the parser's state.
2021-06-29LibCpp: Support parsing enum classesItamar
2021-06-23HackStudio: Make TODO entries clickableFederico Guerinoni
Now you can click a TODO entry to set focus on that position of that file.
2021-06-23LibCpp: Add function for retrieving TODO comments from the parserFederico Guerinoni
Now `get_todo_entries` collects all TODO found within a comment statement.
2021-06-09LibCpp: Parse basic constructors and destructorsItamar
2021-06-09LibCpp: Handle class access-specifiers in the ParserItamar
We can now handle access-specifier tags (for example 'private:') when parsing class declarations. We currently only consume these tags on move on. We'll need to add some logic that accounts for the access level of symbols down the road.
2021-06-09LibCpp: Support non-field class membersItamar
Previously, we had a special ASTNode for class members, "MemberDeclaration", which only represented fields. This commit removes MemberDeclaration and instead uses regular Declaration nodes for representing the members of a class. This means that we can now also parse methods, inner-classes, and other declarations that appear inside of a class.
2021-05-22LibCpp: Modify Token::to_string() to include more informationItamar
Token::to_string() now includes not only the token's type, but also its text and span in the document.
2021-05-19LibCpp: Fix match_expression()Itamar
match_expression() will now return true if there's a match for a Name node.
2021-05-19LibCpp: Support 'auto' TypeItamar
2021-05-15LibCpp: Modify parsing of a Name's scopeItamar
A Name node can now have a non-empty scope and a null name. For example, "AK::" has a non-empty scope and a null name component.
2021-05-15LibCpp: Modify logic of Parser::index_of_node_atItamar
After this commit, Parser::index_of_node_at will prefer to return nodes with greater indices. Since the parsing logic ensures that child nodes come after parent nodes, this change makes this function return child nodes when possible.
2021-05-09LibCpp: Rename m_definitions=>m_preprocessor_definitionsItamar
2021-05-08AK+LibCpp: Remove DEBUG_SPAM in favour of per-application definesAli Mohammad Pur
What happens if one file defines DEBUG_SPAM, and another doesn't, then we link them together and get ODR violations? -- @ADKaster
2021-05-01Everywhere: Turn #if *_DEBUG into dbgln_if/if constexprGunnar Beutner
2021-04-25LibCpp: Convert ScopeLogger to use AK:SourceLocationBrian Gianforcaro
Utilize AK::SourceLocation to get function information into the scope logger, instead of relying on pre-processor macros.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-19LibCpp: Support parsing class declarationsItamar
2021-04-06LibCpp: Add TemplatizedNameItamar
This type represents templatized names, and replaces our previous use of 'TemplatizedType' and 'TemplatizedFunctionCall'. Also, we now parse function calls as secondary expressions.
2021-04-06LanguageServers/Cpp: Refactor logic of find declarationItamar
2021-04-06LibCpp: Introduce DummyASTNodeItamar
This allows us to use pase_* methods inside match_* methods, without adding any actual AST nodes to the m_nodes list.
2021-04-06LibCpp: Parse C-Style parse expressionsItamar
2021-04-06LibCpp: Parse "arrow" operatorItamar
2021-04-06LibCpp: Parse braced initialization listItamar
2021-04-06LibCpp: Parse empty for loopsItamar