Itamar
832e9c6e02
LibCpp: Add regression tests for the parser
...
For each .cpp file in the test suite data, there is a .ast file that
represents the "known good" baseline of the parser result.
Each .cpp file goes through the parser, and the result of
invoking `ASTNode::dump()` on the root node is compared to the
baseline to find regressions.
We also check that there were no parser errors when parsing the .cpp
files.
2021-05-19 23:19:07 +02:00
Itamar
fbf796cd9f
LibCpp: Fix "NumricLiteral" => "NumericLiteral" typo
2021-05-19 23:19:07 +02:00
Itamar
402483ec1f
LibCpp: Generalize ASTNode::dump() to support redirecting its output
...
Previously, ASTNode::dump() used outln() for output, which meant it
always wrote its output to stdout.
After this commit, ASTNode::dump() receives an 'output' argument (which
is stdout by default). This enables writing the output to somewhere
else.
This will be useful for testing the LibCpp Parser with the output of
ASTNode::dump.
2021-05-19 23:19:07 +02:00
Itamar
ef95ddcbfa
LibCpp: Fix match_expression()
...
match_expression() will now return true if there's a match for a Name
node.
2021-05-19 23:19:07 +02:00
Itamar
f28d944122
LibCpp: Support 'auto' Type
2021-05-19 23:19:07 +02:00
Itamar
0e51aea781
LibCpp: Modify parsing of a Name's scope
...
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-15 23:28:50 +02:00
Itamar
84e41c4565
LibCpp: Modify logic of Parser::index_of_node_at
...
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-15 23:28:50 +02:00
Itamar
1bd6705636
LibCpp: Support Lexing escaped newlines
2021-05-09 20:58:27 +02:00
Itamar
5c42dc854d
LibCpp: Rename m_definitions=>m_preprocessor_definitions
2021-05-09 20:58:27 +02:00
Ali Mohammad Pur
62af7c4bdf
AK+LibCpp: Remove DEBUG_SPAM in favour of per-application defines
...
What happens if one file defines DEBUG_SPAM, and another doesn't,
then we link them together and get ODR violations? -- @ADKaster
2021-05-08 22:14:39 +02:00
Gunnar Beutner
6cf59b6ae9
Everywhere: Turn #if *_DEBUG into dbgln_if/if constexpr
2021-05-01 21:25:06 +02:00
Brian Gianforcaro
7a73f11005
LibCpp: Convert ScopeLogger to use AK:SourceLocation
...
Utilize AK::SourceLocation to get function information into
the scope logger, instead of relying on pre-processor macros.
2021-04-25 09:32:03 +02:00
Andreas Kling
b91c49364d
AK: Rename adopt() to adopt_ref()
...
This makes it more symmetrical with adopt_own() (which is used to
create a NonnullOwnPtr from the result of a naked new.)
2021-04-23 16:46:57 +02:00
Brian Gianforcaro
1682f0b760
Everything: Move to SPDX license identifiers in all files.
...
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-22 11:22:27 +02:00
Itamar
4831dc0e30
LibCpp: Support parsing class declarations
2021-04-19 21:48:42 +02:00
Itamar
b87791cada
LibCpp: Add 'Namespace' and 'Member' declaration types
2021-04-13 15:16:27 +02:00
Itamar
c6c83bd80e
HackStudio+LibCpp: Include class members in Locator
2021-04-13 15:16:27 +02:00
Itamar
9e2e36724d
LibCpp: Add TemplatizedName
...
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-06 21:51:58 +02:00
Itamar
510b5073de
LanguageServers/Cpp: Refactor logic of find declaration
2021-04-06 21:51:58 +02:00
Itamar
e16036b9cc
LibCpp: Introduce DummyASTNode
...
This allows us to use pase_* methods inside match_* methods,
without adding any actual AST nodes to the m_nodes list.
2021-04-06 21:51:58 +02:00
Itamar
aa717e6a62
LibCpp: Parse C-Style parse expressions
2021-04-06 21:51:58 +02:00
Itamar
ec2c54ee2e
LibCpp: Parse "arrow" operator
2021-04-06 21:51:58 +02:00
Itamar
44833f1621
LibCpp: Parse braced initialization list
2021-04-06 21:51:58 +02:00
Itamar
d482b3fd60
LibCpp: Parse empty for loops
2021-04-06 21:51:58 +02:00
Itamar
fc503b1368
LibCpp: Parse sizeof() expression
2021-04-06 21:51:58 +02:00
Itamar
8bcf5daf3f
LibCpp: Handle 'struct' prefix before a type
2021-04-06 21:51:58 +02:00
Itamar
575d6a8ee1
LibCpp: Parse Bitwise & Logical Or & And operators
2021-04-06 21:51:58 +02:00
Itamar
8962581c9c
LibCpp: Parse C++ cast expressions
...
parse static_cast, reinterpret_cast, dynamic_cast & const_cast
2021-04-06 21:51:58 +02:00
Itamar
646aaa111b
LibCpp: Support parsing templatized function calls
2021-04-06 21:51:58 +02:00
Itamar
fe4122bbae
LibCpp: Support parsing '!=" operator
2021-04-06 21:51:58 +02:00
Itamar
68e9a05472
LibCpp: Parse character literals
2021-04-06 21:51:58 +02:00
Itamar
3295609aea
LibCpp: Add AST::Name
...
A Name node is basically an identifier with an optional scope,
e.g Core::File.
2021-04-06 21:51:58 +02:00
Itamar
29b6915db9
LibCpp: Parse templatized types
...
We can now parse things like Vector<int>
2021-04-06 21:51:58 +02:00
Itamar
9954a1837f
LibCpp: Parse nullptr literal
2021-04-06 21:51:58 +02:00
Itamar
cbb49f26d9
LibCpp: Support parsing binary "==" Operator
2021-04-06 21:51:58 +02:00
Itamar
1f9f6ea9d6
LibCpp: Support parsing function qualifiers
2021-04-06 21:51:58 +02:00
Itamar
ee35fc0da3
LibCpp: Support parsing empty return statements
2021-04-06 21:51:58 +02:00
Itamar
0babb39cae
LibCpp: Parse variable declarations in global scope
2021-04-06 21:51:58 +02:00
Itamar
68f420ed42
LibCpp: Fix null dereference in IfStatement::declarations()
2021-04-06 21:51:58 +02:00
Itamar
84e34d76d8
HackStudio+LanguageServers/Cpp: Show scope of symbols in Locator
2021-03-23 18:32:39 +01:00
Itamar
b5cab861e3
LibCpp: Parse Namespace declaration
...
Also, remove unused State::Context
2021-03-23 18:32:39 +01:00
Vyacheslav Pukhanov
0b5d414eba
LibCpp: Add preprocessor option to ignore unsupported keywords
...
Under some circumstances we need to ignore unsupported preprocessor
keywords instead of crashing the processing, for example during live
parsing in HackStudio.
2021-03-18 07:49:18 +01:00
Linus Groh
6c8185151e
LibCpp: Return empty TranslationUnit from Parser::parse() if no tokens exist
...
Fixes #5704 .
Fixes #5825 .
Fixes #5827 .
2021-03-16 18:59:19 +01:00
Itamar
8688259ed9
LanguageServers/Cpp: Support jumping to declaration of preprocessor
...
.. definitions.
2021-03-13 10:17:02 +01:00
Itamar
7bf6eca9d8
LanguageServers/Cpp: Complete Preprocessor definitions
...
Preprocessor definitions now appear in the AutoComplete suggestions box
as well as in the Locator.
2021-03-13 10:17:02 +01:00
Itamar
5b22f6f45a
LibCpp: Parser no longer holds the program's source
...
After we moved to storing the text of each token in the token itself,
we no longer have to store the source of the program in the Parser.
This makes more sense because the parser should deal with tokens, not
with raw source code.
2021-03-13 10:17:02 +01:00
Itamar
8a102fe3ec
LibCpp: Implement Parser::text_in_range using text of tokens
...
It was previously implemented by directly iterating over the program's
source.
2021-03-13 10:17:02 +01:00
Itamar
97f2cd596b
LibCpp: Remove node_span_size, add index_of_node_at
2021-03-13 10:17:02 +01:00
Itamar
26d9485562
LibCpp: Store the text of a token as a StringView member
2021-03-13 10:17:02 +01:00
Itamar
5cd1c69b96
LibCpp: Access Cpp::Token members via getter functions
2021-03-13 10:17:02 +01:00