Commit Graph

334 Commits

Author SHA1 Message Date
Dmitri Hrybenko
10d8fdc64f AST/AbstractFunctionDecl: Remember if a function had a selector-style signature
... and use this information in AST printing


Swift SVN r8583
2013-09-24 00:56:33 +00:00
Joe Groff
5d8a7ff9e7 Allow multiple comma-separated enum elements in a 'case' decl.
Introduce an EnumCaseDecl for source fidelity to track the 'case' location and ordering of EnumElementDecls. Parse a comma-separated list of EnumElementDecls after a 'case' token.

Swift SVN r8509
2013-09-20 19:51:13 +00:00
Joe Groff
e109124186 Replace 'union' keyword with 'enum'.
This only touches the compiler and tests. Doc updates to follow.

Swift SVN r8478
2013-09-20 01:33:14 +00:00
Dmitri Hrybenko
0aaceb3878 Parser: improve error recovery in case of a bad function signature with selector-style arguments
We used to skip until the end of the file in two of these cases.
Looks like plain skipUntil() is never the correct tool for recovery.


Swift SVN r8441
2013-09-19 02:24:59 +00:00
Doug Gregor
978959ced8 Make the "init" and "constructor" keywords synonymns.
Swift SVN r8391
2013-09-18 04:23:28 +00:00
Doug Gregor
90b8b3e499 Constructor selectors always start with 'init'.
Implement the new rules for mapping between selector names and
constructors. The selector for a given constructor is formed by
looking at the names of the constructor parameters:
  * For the first parameter, prepend "init" to the parameter name and
  uppercase the first letter of the parameter name. Append ':' if
  there are > 1 parameters or the parameter has non-empty-tuple type.
  * For the remaining parameters, the name of each parameter followed
  by ':'.

When a parameter doesn't exist, assume that the parameter name is the
empty string.

And, because I failed to commit it separately, support selector-style
declarations of constructor parameters so that we can actually write
constructors nicely, e.g.:

  // selector is initWithFoo:bar:
  constructor withFoo(foo : Foo) bar(bar : Bar) { ... }



Swift SVN r8361
2013-09-17 22:49:05 +00:00
Dmitri Hrybenko
07e83ea49c Code completion: basic completion in constructor bodies
Swift SVN r8338
2013-09-17 18:20:26 +00:00
Argyrios Kyrtzidis
61b4e8ede5 [Lexer] Add some comments for Lexer::getLocForStartOfToken().
Swift SVN r8288
2013-09-16 19:32:13 +00:00
Argyrios Kyrtzidis
5db368ce7b [Lexer] Introduce Lexer::getLocForStartOfToken() that returns the location at the start of the token that a given offset points to.
Swift SVN r8281
2013-09-16 18:41:16 +00:00
Dmitri Hrybenko
0d6d9a0ffb Move the DeclContext base class from FuncExpr to FuncDecl
FuncDecl still has a FuncExpr because capture list is stored in FuncExpr
(which is a CapturingExpr).


Swift SVN r8179
2013-09-13 01:40:41 +00:00
Dmitri Hrybenko
c69c79084a Move result typeloc and body result type from FuncExpr to FuncDecl
Swift SVN r8153
2013-09-12 18:40:57 +00:00
Dmitri Hrybenko
3cc01cf7d6 Introduce AbstractFunctionDecl -- a base class for ConstructorDecl,
DestructorDecl, FuncDecl -- and move some of the common concepts and logic
into it

No functionality change.


Swift SVN r8090
2013-09-11 04:04:01 +00:00
Dmitri Hrybenko
94d417a838 Parser: introduce skipUntilGreaterInTypeList(), which implements a better
heuristic than skipUntilAnyOperator() to find the end of a type list

Almost all testcases added in this commit used to skip all the way to EOF.


Swift SVN r7991
2013-09-06 17:50:11 +00:00
Dmitri Hrybenko
9bbfe27615 Add an option for diagnostics -- PointsToFirstBadToken
Diagnostics that point to the first bad token are marked with this option in
Diagnostics.def.  Parser::diagnose treats the source location of such
diagnostics in a special way: if source location points to a token at the
beginning of the line, then it moves the diagnostic to the end of the previous
token.

This behaviour improves experience for "expected token X" diagnostics.


Swift SVN r7965
2013-09-05 23:38:32 +00:00
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
53652960a6 Make 'self' and 'Self' real keywords.
Also, remove IDENTIFIER_KEYWORD macro because these two were the last
identifier keywords.


Swift SVN r7806
2013-08-30 22:07:47 +00:00
Dmitri Hrybenko
44e8296f7f Make 'weak' and 'unowned' real keywords
Swift SVN r7802
2013-08-30 21:29:50 +00:00
Dmitri Hrybenko
e378af3c37 Make 'metatype' a normal keyword
Swift SVN r7801
2013-08-30 21:22:10 +00:00
Dmitri Hrybenko
1500410290 Make 'super' a normal keyword
Swift SVN r7775
2013-08-30 01:40:18 +00:00
Dmitri Hrybenko
ceffc29bc9 Make 'constructor' a normal keyword.
Swift SVN r7773
2013-08-30 01:34:29 +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
Dmitri Hrybenko
53e0921e75 Make 'self' and 'Self' keywords
Add a test for recovery after misplaced 'self' and 'Self'.  We don't diagnose
many cases of invalid usage, and in some cases diagnostics are bad.  This will
be fixed separately.


Swift SVN r7661
2013-08-28 03:42:04 +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
b91b4b61e1 Code completion: complete type-ident without dot, for example Foo#^A^#
Swift SVN r7499
2013-08-23 01:30:04 +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