diff options
author | Mark Wielaard <mark@klomp.org> | 2021-07-09 00:32:30 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2021-07-11 21:09:21 +0200 |
commit | e1e14958a90397a1ed6ab7236dc5a6f1c2f22505 (patch) | |
tree | 9c16ca669be22146c007ad846f32f81158828b65 /gcc/rust/backend | |
parent | 4560f469ee33536cec6af0f8e5816ff97de60de0 (diff) | |
download | gcc-e1e14958a90397a1ed6ab7236dc5a6f1c2f22505.zip gcc-e1e14958a90397a1ed6ab7236dc5a6f1c2f22505.tar.gz gcc-e1e14958a90397a1ed6ab7236dc5a6f1c2f22505.tar.bz2 |
Handle doc comment strings in lexer and parser
Remove (unused) comment related tokens and replace them with
INNER_DOC_COMMENT and OUTER_DOC_COMMENT tokens, which keep the comment
text as a string. These can be constructed with the new
make_inner_doc_comment and make_outer_doc_comment methods.
Make sure to not confuse doc strings with normal comments in the lexer
when detecting shebang lines. Both single line //! and /*! */ blocks
are turned into INNER_DOC_COMMENT tokens. And both single line /// and
/** */ blocks are turned into OUTER_DOC_COMMENT tokens.
Also fixes some issues with cr/lf line endings and keeping the line
map correct when seeing \n in a comment.
In the parser handle INNER_DOC_COMMENT and OUTER_DOC_COMMENTS where
inner (#[]) and outer (#![]) attributes are handled. Add a method
parse_doc_comment which turns the tokens into an "doc" Attribute with
the string as literal expression.
Add get_locus method to Attribute class for better error reporting.
Tests are added for correctly placed and formatted doc strings, with
or without cr/lf line endings. Incorrect formatted (isolated CRs) doc
strings and badly placed inner doc strings. No tests add handling of
the actual doc attributes yet. These could be tested once we add
support for the #![warn(missing_docs)] attribute.
Diffstat (limited to 'gcc/rust/backend')
0 files changed, 0 insertions, 0 deletions