Commit Graph

1125 Commits

Author SHA1 Message Date
Dmitri Hrybenko
d52982cd0d Recovery from parsing extensions for non-nominal types: stop abusing the type
checker for what can be a simple syntactic check, when implemented on
appropriate level -- during type parsing.


Swift SVN r7954
2013-09-05 20:22:31 +00:00
Dmitri Hrybenko
ddfa9bc8d8 Parser::skip*() routines: don't stop on code completion token anymore
Our recovery is better now, and we don't skip that much.  Actually, even if we
would stop at code completion token during recovery, completion results would
be something very generic anyway (because there is no interesting parser state
to observe), and these results can be produced as a fallback separately (not
implemented).


Swift SVN r7754
2013-08-29 22:15:12 +00:00
Dmitri Hrybenko
9b90a66087 Use \returns in the documentation comment
Swift SVN r7745
2013-08-29 21:21:04 +00:00
Dmitri Hrybenko
3a6feb7814 Disallow constructors in protocols
Swift SVN r7701
2013-08-28 23:03:37 +00:00
Jordan Rose
fa3dd42c54 Don't parse function bodies in imported TUs.
...unless the functions are declared [transparent], or if we're in an
immediate mode (in which case we won't get a separate chance to link
against the imported TUs).

This is an optimization that will matter more when we start dealing with
Xcode projects with many cross-file dependencies, especially if we have
some kind of implicit import of the other source files in the project.

In the future, we may want to parse more function bodies for the purpose
of inlining, not just the transparent ones, but we weren't taking
advantage of that now, so it's not a regression. (We're still not taking
advantage of it even for [transparent] functions.)

Swift SVN r7698
2013-08-28 22:53:28 +00:00
Dmitri Hrybenko
9447f6c73f parseBraceItems(): don't skip over braced lists of statements during recovery
This increases the amount of noise in diagnostics.  But we did not get these
diagnostics before because we were just skipping these brace statements.  We
shoud improve recovery in parsing of whatever declaration that precedes the
brace statement so that it is picked up as a body of that declaration.


Swift SVN r7679
2013-08-28 19:33:43 +00:00
Ted Kremenek
8f5b8ccb02 Rename "This" to "Self" and "this" to "self".
This was not likely an error-free change.  Where you see problems
please correct them.  This went through a fairly tedious audit
before committing, but comments might have been changed incorrectly,
not changed at all, etc.

Swift SVN r7631
2013-08-27 21:58:27 +00:00
Dmitri Hrybenko
db44574605 parseBraceItemList(): use ParserResult
Now we propagate error bits better, which decreases noise in diagnostics in one
case.


Swift SVN r7628
2013-08-27 19:01:15 +00:00
Dmitri Hrybenko
55dec1eca5 Remove outdated comment.
Swift SVN r7626
2013-08-27 17:33:53 +00:00
Dmitri Hrybenko
d07a5e82cc parseStmtCase(): use ParserResult
Swift SVN r7620
2013-08-27 02:09:08 +00:00
Dmitri Hrybenko
c3c5d7d5f3 parseStmt(): use ParserResult
Swift SVN r7617
2013-08-27 01:08:02 +00:00
Dmitri Hrybenko
af8fd2c25f Change variable name in header to match source file
Swift SVN r7615
2013-08-27 00:52:54 +00:00
Dmitri Hrybenko
78d2f03a8d parseStmtSwitch(): use ParserResult
Swift SVN r7614
2013-08-27 00:48:24 +00:00
Dmitri Hrybenko
cadc9016c5 parseExprOrStmt(): use ParserStatus
Swift SVN r7613
2013-08-27 00:41:37 +00:00
Dmitri Hrybenko
e1d39e5052 parseStmtFor(): use ParserResult
Swift SVN r7612
2013-08-27 00:20:29 +00:00
Dmitri Hrybenko
09ad614035 parseStmtDoWhile(): use ParserResult
Swift SVN r7608
2013-08-26 23:43:09 +00:00
Dmitri Hrybenko
a9f56c4839 parseStmtWhile(): use ParserResult
Swift SVN r7606
2013-08-26 23:38:52 +00:00
Dmitri Hrybenko
45c46314ab parseStmtIf(): use ParserResult
Swift SVN r7605
2013-08-26 23:33:32 +00:00
Dmitri Hrybenko
c6f0dd106d parseStmtReturn(): use ParserResult
This caught a bug in parseExprPostfix(): it did not return a code completion
status.


Swift SVN r7603
2013-08-26 23:18:51 +00:00
Dmitri Hrybenko
45c4cc334f Brush up comments in Parser: no need to describe the return value of functions
that return ParserResult; use Doxygen syntax.


Swift SVN r7550
2013-08-24 01:25:19 +00:00
Dmitri Hrybenko
4bc13e6cd2 Code completion: complete types in the typealias inheritance clause
Swift SVN r7524
2013-08-23 21:10:53 +00:00
Dmitri Hrybenko
a56893dec2 parseDecl(): use ParserResult
Now we make the desicion to delay parsing if the parsed production contained a
code completion token, not if we just stopped at the code completion token.


Swift SVN r7442
2013-08-22 00:39:45 +00:00
Dmitri Hrybenko
caeddfdaf0 parseExprList(): use ParserResult
Swift SVN r7440
2013-08-22 00:27:43 +00:00
Dmitri Hrybenko
421b107091 parseExprCollection, parseExprArray, parseExprDictionary: use ParserResult
Swift SVN r7439
2013-08-21 23:47:07 +00:00
Dmitri Hrybenko
2bf010151b parseExprSequence(): use ParserResult
Swift SVN r7438
2013-08-21 23:30:47 +00:00
Dmitri Hrybenko
4957bca697 parseExprUnary(): use ParserResult
Swift SVN r7437
2013-08-21 23:20:23 +00:00
Dmitri Hrybenko
f9a24073a5 parseExprPostfix(): use ParserResult
Swift SVN r7430
2013-08-21 21:53:52 +00:00
Dmitri Hrybenko
04bcc5553e parseExprNew(): use ParserResult
Swift SVN r7429
2013-08-21 21:32:21 +00:00
Dmitri Hrybenko
2e3d313d6b parseExprSuper(): use ParserResult
Swift SVN r7427
2013-08-21 21:26:09 +00:00
Dmitri Hrybenko
faff10f310 Parser: use ParserResult in 'is' and 'as' expression parsing
Swift SVN r7426
2013-08-21 21:15:43 +00:00
Dmitri Hrybenko
ec7b2eb3db Parser: use ParserResult in the interface of parseExpr()
But the implementation of expression parsing still does not propagate the code
completion bits because it uses NullablePtr for results.


Swift SVN r7425
2013-08-21 21:10:09 +00:00
Dmitri Hrybenko
f7ad1c9b03 parseDeclVar(): use ParserStatus
Swift SVN r7421
2013-08-21 20:15:01 +00:00
Dmitri Hrybenko
ad2ca67858 parseDeclSubscript(): use ParserStatus
Swift SVN r7415
2013-08-21 19:15:55 +00:00
Dmitri Hrybenko
255aeae1f9 parseDeclUnionElement(): use ParserResult because this function returns at most
one Decl, no need to pass in a vector


Swift SVN r7414
2013-08-21 19:04:12 +00:00
Dmitri Hrybenko
76d11315b0 parseDeclImport(): use ParserResult because this function returns at most one
Decl, no need to pass in a vector


Swift SVN r7413
2013-08-21 18:49:24 +00:00
Dmitri Hrybenko
ecf4cc44b1 parseDeclClass(): use ParserResult because this function returns at most one
Decl, no need to pass in a vector


Swift SVN r7410
2013-08-21 18:26:23 +00:00
Dmitri Hrybenko
e392e1a551 parseStruct(): use ParserResult because this function returns at most one Decl,
no need to pass in a vector


Swift SVN r7407
2013-08-21 18:10:16 +00:00
Dmitri Hrybenko
53685fe05f parseUnion(): use ParserResult because; it returns at most one Decl, no need to
pass in a vector

This a bit of noise to the diagnostics (see test change); this issue will be
fixed uniformly for all nominal decls in future commits.


Swift SVN r7399
2013-08-21 02:23:38 +00:00
Dmitri Hrybenko
581db767bf Use ParserResult and ParserStatus in tuple and function argument parsing
This finally fixes a few code completion test cases.

This also regresses the error message in one parsing testcase because
previously we would just happily skip those tokens, but now error handling path
is a little bit different and these tokens hit different error handling code.
This can be fixed by parsing a tuple for the selector argument and complaining
if the tuple had more than one element.


Swift SVN r7389
2013-08-20 23:55:00 +00:00
Dmitri Hrybenko
11b5e47479 Add a default argument to skipUntilDeclRBrace() so that it can be used with a
single token


Swift SVN r7381
2013-08-20 23:08:41 +00:00
Dmitri Hrybenko
f13b5845bb Parser: use ParserStatus in parseList()
This will allow us to do code completion inside lists (e.g., tuples) *and* get
parser recovery instead of stopping at the code completion token immediately.


Swift SVN r7366
2013-08-20 18:26:01 +00:00
Dmitri Hrybenko
26bde07f76 Parser: use ParserResult in parseTypeArray() and parseTypeOptional()
While there, improve recovery in parseTypeArray() a bit: don't drop the
previously parsed type if we see a syntax error *after that*.


Swift SVN r7365
2013-08-20 17:57:06 +00:00
Dmitri Hrybenko
c3954987d6 Parser: use ParserResult in parseTypeSimple() and everything that uses it/
is used in it


Swift SVN r7355
2013-08-20 02:12:31 +00:00
Dmitri Hrybenko
b0dd877454 Use ParserResult in type parsing
Swift SVN r7353
2013-08-20 01:19:31 +00:00
Doug Gregor
1ddb34fb71 Factor generic parameters and associated types into their own decl nodes.
Previously, TypeAliasDecl was used for typealiases, generic
parameters, and assocaited types, which is hideous and the source of
much confusion. Factor the latter two out into their own decl nodes,
with a common abstract base for "type parameters", and push these
nodes throughout the frontend.

No real functionality change, but this is a step toward uniquing
polymorphic types, among other things.


Swift SVN r7345
2013-08-19 23:36:58 +00:00
Dmitri Hrybenko
deff836592 Parser: use ParserResult in parseDeclFunc
Swift SVN r7341
2013-08-19 23:02:06 +00:00
Dmitri Hrybenko
c098cd1476 Parser: convert some pattern parsing functions to ParserResult
Swift SVN r7336
2013-08-19 22:38:34 +00:00
Dmitri Hrybenko
19a90b69f7 Parser: add ParserResult<T> -- a wrapper around the AST node plus extra bits
This allows the parser to recover, create an AST node, return it to the caller
*and* signal the caller that there was an error to trigger recovery in the
caller.  Until now the error was signalled with a nullptr result (any non-null
result was considered a success and no recovery was done in that case).

This also allows us to signal the caller if there was a code completion token
inside the production we tried to parse to trigger delayed parsing in the
caller while doing recovery in the callee.  Until now we could not do recovery
in the callee so that the caller could find the code completion token.

Right now we don't take any advantage of these features.  This commit just
replaces some uses of NullablePtr with ParserResult.


Swift SVN r7332
2013-08-19 22:11:23 +00:00
Dmitri Hrybenko
23d48b6b3b Use NullablePtr in more decl parser functions
Swift SVN r7274
2013-08-16 00:46:26 +00:00
Dmitri Hrybenko
536723eca4 Code completion: implement delayed parsing of all (?) declarations
This allows us to show generic parameters in:
struct S<T> {
  func f(a: #^A^#
}

And show the type Z in:
struct S {
  func f(a: #^A^#
  typealias Z = Int
}


Swift SVN r7216
2013-08-13 23:53:39 +00:00