Commit graph

39 commits

Author SHA1 Message Date
Ali Mohammad Pur
8fefbfd5ac LibCpp: Parse enum members with explicit values 2021-08-02 01:03:59 +02:00
Itamar
34fc6c7e1c LibCpp: Make the fields of AST node types private
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-10 21:58:28 +02:00
Itamar
d7aa831a43 LibCpp: Differentiate between Type and NamedType
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-29 00:07:19 +04:30
Andreas Kling
dc65f54c06 AK: Rename Vector::append(Vector) => Vector::extend(Vector)
Let's make it a bit more clear when we're appending the elements from
one vector to the end of another vector.
2021-06-12 13:24:45 +02:00
Itamar
7de6c1489b LibCpp: Parse basic constructors and destructors 2021-06-09 22:26:46 +02:00
Itamar
dcdb0c7035 LibCpp: Support non-field class members
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-06-09 22:26:46 +02:00
Itamar
b5da0b71e5 LibCpp: Consider declarations inside a function's body
... in FunctionDeclaration::declarations()
2021-06-01 22:20:13 +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
f28d944122 LibCpp: Support 'auto' Type 2021-05-19 23:19:07 +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
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
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
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
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
68f420ed42 LibCpp: Fix null dereference in IfStatement::declarations() 2021-04-06 21:51:58 +02:00
Itamar
b5cab861e3 LibCpp: Parse Namespace declaration
Also, remove unused State::Context
2021-03-23 18:32:39 +01:00
Andreas Kling
ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
Itamar
a2ac86f5e1 LibCpp: Check if type is null in VariableDeclaration::dump 2021-03-06 09:40:33 +01:00
Itamar
1d3b5dabc3 LibCpp: Parse ellipsis
We can now parse the printf function declaration :^)
2021-03-02 12:50:37 +01:00
Itamar
5a7abb8363 LibCpp: Parse type qualifiers 2021-03-02 12:50:37 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling
bd830c2dfe LibCpp: Fix yet another broken outln() invocation..
Fixes #5463
2021-02-21 22:13:32 +01:00
Andreas Kling
0bb2729423 LibCpp: Fix busted outln() invocations 2021-02-21 21:32:16 +01:00
Andreas Kling
68406fc0ef LibCpp: Replace dbgprintf() with outln() 2021-02-20 17:12:25 +01:00
Itamar
8ed65d7b48 LibCpp: Parse If statements 2021-02-08 23:10:38 +01:00
Itamar
c96b6987c4 LibCpp: Add the beginning of a C++ parser
This parser will be used by the C++ langauge server to provide better
auto-complete (& maybe also other things in the future).

It is designed to be error tolerant, and keeps track of the position
spans of the AST nodes, which should be useful later for incremental
parsing.
2021-01-27 21:10:57 +01:00