Age | Commit message (Collapse) | Author |
|
|
|
This allows us to collect the tokens iteratively instead of having to
lex the whole program and then get a tokens vector.
|
|
Previously, the preprocessor first split the source into lines, and then
processed and lexed each line separately.
This patch makes the preprocessor first lex the source, and then do the
processing on the tokenized representation.
This generally simplifies the code, and also fixes an issue we
previously had with multiline comments (we did not recognize them
correctly when processing each line separately).
|
|
For example, '# include <stdio.h>' is now supported by the Lexer.
|
|
Similarly to the LibCpp parser regression tests, these tests run the
preprocessor on the .cpp test files under
Userland/LibCpp/Tests/preprocessor, and compare the output with existing
.txt ground truth files.
|
|
|
|
|
|
The preprocessor now understands when a function-like macro is defined,
and can also parse calls to such macros.
The actual evaluation of function-like macros will be done in a
separate commit.
|
|
|
|
After this change, the parser is completely separated from preprocessor
concepts.
|
|
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).
|
|
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.
|
|
|
|
|
|
Now LibCpp can understand the eastest of consts too :^)
|
|
This is just ignored right now.
|
|
This makes it work with types like `Function<T(U, V)>`.
|
|
This is too lax for functions that aren't class members, but let's
allow that anyway.
|
|
|
|
|
|
|
|
Such lines should be considered to be joined into the next line.
This makes multiline preprocessor stuff "work".
|
|
|
|
Note that this is not the `extern "C"` declarations, just extern decl
qualifiers.
|
|
For instance, `Type Scope::Class::variable = value;` is a valid
declaration.
|
|
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.
|
|
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.
|
|
Thanks to @alimpfard for suggesting this :)
|
|
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.
|
|
This function returns the tokens that exist in the specified range.
|
|
|
|
Previously the positional information for the node of an ellipsis was
incorrect.
|
|
|
|
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).
|
|
LOG_SCOPE() uses ScopeLogger and additionally shows the current token
in the parser's state.
|
|
|
|
Now you can click a TODO entry to set focus on that position of that
file.
|
|
Now `get_todo_entries` collects all TODO found within a comment
statement.
|
|
|
|
Let's make it a bit more clear when we're appending the elements from
one vector to the end of another vector.
|
|
|
|
|
|
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.
|
|
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.
|
|
|
|
And use them to highlight javascript in HTML source.
This commit also changes how TextDocumentSpan::data is interpreted,
as it used to be an opaque pointer, but everyone stuffed an enum value
inside it, which made the values not unique to each highlighter;
that field is now a u64 serial id.
The syntax highlighters don't need to change their ways of stuffing
token types into that field, but a highlighter that calls another
nested highlighter needs to register the nested types for use with
token pairs.
|
|
This changes the C++ SyntaxHighlighter to conform to the now-fixed
rendering of syntax highlighting spans in GUI::TextEditor.
Contrary to other syntax highlighters, for this one the change has been
made to the SyntaxHighlighter rather than the Lexer. This is due to the
fact that the Parser also uses the same Lexer. I'm soure there is some
more elegant way to do this, but this patch at least unbreaks the C++
syntax highlighting.
|
|
If an include statement didn't contain whitespace between the word
"include" and the '<' or '"', the lexer would previous emit an empty
whitespace token. This has been changed now.
|
|
|
|
|