Commit Graph

510 Commits

Author SHA1 Message Date
John Holdsworth
74dd71ca9b Delimited/Raw strings inside interpolations 2018-08-10 17:27:38 +01:00
Jordan Rose
fc9ea1e329 Add Lexer::IsHashbangAllowed, drop SourceManager::getHashbangBufferID (#18534)
Having this be a single buffer hardcoded in the SourceManager and set
by all clients is silly. SourceFiles with the 'Main' kind are allowed
to have hashbang lines (`#!`), other files are not. And anyone
manually setting up a Lexer can decide for themselves.

No intended behavioral change.
2018-08-07 08:25:05 -07:00
Rintaro Ishizaki
1aacb8fefb Merge pull request #17788 from rintaro/parse-identifier-drop3
[Parse] Drop Swift3 support for '$', 'throws', and 'rethrows' as identifier
2018-07-25 19:36:39 +09:00
Rintaro Ishizaki
21db9723e4 [Lexer] Don't include backtick length into comment length
Although backtick is a kind of trivia piece, Token::getCommentRange doesn't
take it into account. Invalid Token::getCommentRange used to cause
compiler crash.

rdar://problem/42492793
https://bugs.swift.org/browse/SR-8315
2018-07-24 04:37:07 +09:00
John Holdsworth
2317048f44 Alternative implementation for raw strings 2018-07-09 18:38:54 +01:00
Rintaro Ishizaki
a810908da1 [Parse] Drop Swift3 support for '$' as an identifier
Swift3 used to parse '$' as an identifier without digagnostics.

Related 6accc5989e
2018-07-06 18:04:26 +09:00
John Holdsworth
14213b84bd Revised implementation for raw strings 2018-07-02 12:54:06 +01:00
Rintaro Ishizaki
da764e16f2 [Lexer][QoI] Diagnose and fix-it consecutive 'U+00A0's at once 2018-05-01 20:31:37 +09:00
Ahmad Alhashemi
036b2f534d Minor style edits 2018-04-23 13:21:06 -04:00
Ahmad Alhashemi
e8c17b6686 Move non-breaking space handling to lexUnknown 2018-04-22 15:54:07 -04:00
Ahmad Alhashemi
1603ec2bee [Parser] Detect nonbreaking space U+00A0 and fixit 2018-04-22 15:54:07 -04:00
Huon Wilson
00c32698e2 [Parse] Put indent-is-4-spaces assumption in one place.
This single location can, theoretically, be made more intelligent about
deducing indent from elsewhere and all the consumers will just work.
2018-04-04 10:34:33 +10:00
Rintaro Ishizaki
7237875870 [Parse] Eliminate square_lit token 2018-03-14 21:50:53 +09:00
omochimetaru
3c8057e13f [Parse] Remove unnecessary Lexer fields 2018-03-12 23:35:13 +09:00
Rintaro Ishizaki
1dc3e17f52 [Lexer] Performance improvement for Lexer::kindOfIdentifier (#15168)
Don't check SIL_KEYWORDs when we're not in SIL mode.
Lexer::kindOfIdentifier is super hot-path because many of
tokens in a swift source file are keywords or identifiers.
2018-03-12 15:03:58 +09:00
omochimetaru
8592496b22 [Parse] Remove dead code in lexHash (#15154) 2018-03-12 08:47:54 +09:00
omochimetaru
5e555868fe [Parse] Reduce branch by running lexTrivia always (#15137) 2018-03-10 21:26:54 +09:00
Sho Ikeda
74ba135008 Merge pull request #15040 from ikesyo/gardening-not-empty
[gardening] Use `!empty()` over `size() > 0`
2018-03-08 18:47:12 +09:00
omochimetaru
c4c5b7130e [Parse] Fix error in unsigned char target (#15068) 2018-03-08 15:57:43 +09:00
omochimetaru
967a48cb77 [Parse] refactor Lexer initialization 2018-03-08 11:17:51 +09:00
Sho Ikeda
cea6c03eb2 [gardening] Use !empty() over size() > 0 2018-03-08 09:21:09 +09:00
Sho Ikeda
25cdc981c7 Merge pull request #14977 from ikesyo/gardening-use-empty
[gardening] Use `empty()` over `size() == 0`
2018-03-07 09:34:26 +09:00
omochimetaru
22cddbf033 [Syntax] Parse invalid chars as trivia 2018-03-06 08:25:09 -08:00
omochimetaru
b4192d80e9 [Parse] EmitDiagnosticsIfToken in lexUnknown
It is needed from lexTrivia update future.
2018-03-06 08:25:09 -08:00
omochimetaru
e6f42fc63d [Parse] split lexUnknown function from lexImpl 2018-03-06 08:25:09 -08:00
omochimetaru
0a69bd7f8d [NFC] readable control flow in lexImpl default case
There are 3 token flow and 2 trivia flow.
This commit makes it clear and more readable.

And apply clang-format.
2018-03-06 08:25:09 -08:00
omochimetaru
3e252c98a8 [NFC] Fix naming style in lexImpl default case 2018-03-06 08:25:09 -08:00
omochimetaru
190af6c063 [Syntax] support nul character as garbage trivia 2018-03-05 16:53:24 +09:00
omochimetaru
58857fa1cb [Parse] refactor Lexer by made NulCharacterKind type 2018-03-05 16:53:18 +09:00
Sho Ikeda
26d650292f [gardening] Use empty() over size() == 0 2018-03-05 14:43:13 +09:00
Rintaro Ishizaki
766774206b [Lexer] Don't setEscapedIdentifier(true) for tok::eof at ArtificialEOF
https://bugs.swift.org/browse/SR-6926

This happens when the Parser re-lexing comment tokens that sets
ArtificialEOF at the end of comment range.
It used to cause an assertion failure:
(!value || Kind == tok::identifier) && "only identifiers can be escaped identifiers"
2018-02-12 14:58:12 +09:00
Rintaro Ishizaki
0780c529c4 [Syntax] Unify RawSyntax and RawTokenSyntax using union and TrailingObjects
It better matches with SwiftSyntax model.

Using TrailingObjects reduces the number of heap allocation which
gains 18% performance improvement.
2018-01-18 14:49:46 +09:00
Erik Eckstein
a680768971 SIL: In textual SIL allow global SIL names starting with '$'.
For example: @$S1m3fooyyF
It's needed to change the mangling prefix to $S.
The parser change only affects SIL (and not swift).

I didn't add test case because it will be fully tested when changing the mangling prefix.
2018-01-05 11:29:15 -08:00
omochimetaru
bc88330740 [Parse] Lexer build backtick trivia around espaced identifier token 2017-12-29 00:22:49 +09:00
omochimetaru
ebd5323b42 [Syntax] add UTF-8 BOM support to libSyntax 2017-12-28 01:26:09 +09:00
omochimetaru
861ee3a112 [Parse] use pre increment for simple increment (#13624) 2017-12-27 15:46:58 +09:00
omochimetaru
70986a687f [Parse] fix lexTrivia LF bug 2017-12-22 14:04:14 +09:00
omochimetaru
fbe34e0f6f [Parse] improve LF handling efficiency. 2017-12-22 01:23:25 +09:00
omochimetaru
f86e1c8201 [Parse] add CRLF support in lexTrivia 2017-12-21 14:27:13 +09:00
omochimetaru
9daeaf0d06 [Parse] refactor lexTrivia with squash 2017-12-20 14:09:47 +09:00
omochimetaru
24509a0bde [Parse] Change LeadingTrivia type to Trivia 2017-12-20 14:09:47 +09:00
Rintaro Ishizaki
cc72a3b934 [Lexer] Use ContentStart position for hashbang trivia 2017-12-19 09:24:34 +09:00
Rintaro Ishizaki
2c06060165 [Syntax] Add CarriageReturn trivia kind
To distinguish '\r' from '\n'.
2017-12-19 09:24:34 +09:00
Rintaro Ishizaki
181333ce0f [Lexer] Lex conflict marker as a trivia 2017-12-19 09:24:33 +09:00
omochimetaru
5de598f34a [Parse] use skipHashbang in lexTrivia 2017-12-18 18:22:04 +09:00
omochimetaru
aeb9ba6f96 [Parse] use skipSlashSlashComment in lexTrivia 2017-12-18 18:22:04 +09:00
omochimetaru
f7136ae635 [Parse] delete skipUpToEndOfLine 2017-12-18 18:22:04 +09:00
omochimetaru
ed58c152bf [Parse] Improve Lexer's UTF-8 BOM handling (#13483)
* Add BOM handling testcases
* Add ContentStart to Lexer for BOM handling
2017-12-18 17:22:11 +09:00
Rintaro Ishizaki
5571e5cc76 [Lexer] Clear trivia at the top of lexImpl()
To make sure we only parse trivia for the current token.
2017-12-08 12:08:05 +09:00
Rintaro Ishizaki
9b32c62fbf [Lexer] Add TODO/FIXMEs for lexTrivia 2017-12-08 12:08:05 +09:00