Commit Graph

808 Commits

Author SHA1 Message Date
Chris Lattner
44af5d13ef refactor some code to expose a new expr-or-stmt-assign production.
Swift SVN r1492
2012-04-19 17:57:22 +00:00
Doug Gregor
6897b6ab44 Add support for parsing a subscripting declaration, e.g.,
subscript (i : Int) -> Double {
    get { /* get ith element of something */ }
    set { /* set ith element of something to value*/ }
  }



Swift SVN r1476
2012-04-18 21:43:54 +00:00
John McCall
e6d56fd718 Require an unspaced [ to start a subscript or array-type suffix.
Per discussion, this should probably be "no newline since the last
token", but that decision should be made simultaneously for ( and [.

Swift SVN r1461
2012-04-18 08:08:58 +00:00
Eli Friedman
ecb0f2bba4 Add a little bit of missing error-checking for libraries.
Swift SVN r1455
2012-04-18 01:50:24 +00:00
Eli Friedman
cf10f0096e Make the REPL allow mutually recursive functions spread across multiple lines, like we do in script mode.
Swift SVN r1453
2012-04-18 01:20:38 +00:00
Eli Friedman
37de44a35d Implement changes to parsing/sema/etc so that we can implement a REPL and the main module parses the same way as a REPL.
Next step: implement an actual REPL.



Swift SVN r1441
2012-04-16 23:52:01 +00:00
Chris Lattner
fbfb76a515 rename 'plus' methods to 'static' methods, resolving:
<rdar://problem/10718220> Need a better name than 'plus' for "static" functions



Swift SVN r1340
2012-04-06 17:50:43 +00:00
Eli Friedman
f477cf588e Introduce the notion of the "main" module, i.e. the module which defines main(). Disallow top-level statements in modules other than the main module. Fix IRGen to generate a main() function in the main module, and implement top-level statements. Get rid of the main() mangling hack. Part of <rdar://problem/11185451>.
I haven't really carefully considered whether existing type-checking etc. is correct for the main module (I think the name-binding rules need to be a bit different?), but it seems to work well enough for the obvious cases.

This is enough to get the one-liner "println(10)" to print "10" in "swift -i" mode, although the path to swift.swift still needs to be explicitly provided with -I.



Swift SVN r1325
2012-04-05 00:35:28 +00:00
Eli Friedman
862646c1dd Perform conversion to bool in conditionals by repeatedly calling ".getLogicValue()" on the value until we reach Builtin.Int1, instead of using convertToLogicValue(). <rdar://problem/10100856>.
Swift SVN r1173
2012-03-10 00:02:36 +00:00
Chris Lattner
601e401dfa document the forthcoming expr-anon-closure syntax, part of rdar://10666917
Swift SVN r1151
2012-03-02 01:30:18 +00:00
Chris Lattner
ce9d3c4398 remove Parser::isStartOfExpr, which is only used by one caller that can
be done in a simpler way.


Swift SVN r1150
2012-03-02 01:07:21 +00:00
Chris Lattner
58b4a5d7cc have the parser produce ErrorStmt nodes to handle semantic errors...
except that it never produces semantic errors.  How about that.


Swift SVN r1143
2012-03-01 22:54:41 +00:00
Chris Lattner
6692cba150 simplify expression parsing to return a NullablePtr<Expr> instead of a ParseError<Expr>.
The later could represent semantic errors, but we'd rather represent those with an
ExprError node instead.  This simplifies the code and allows the parser to build a more
fully-formed AST that IDE clients will like.


Swift SVN r1141
2012-03-01 22:34:32 +00:00
Chris Lattner
17ea0a6670 finish my pass over LangRef, updating it and changing it and the parser to keep the grammars in sync.
Swift SVN r1132
2012-03-01 16:55:09 +00:00
John McCall
2b65cf22d1 Make 'this' implicitly [byref] when the container type does
not have reference semantics.  Deciding whether the container
type has reference semantics requires us to perform
some amount of limited name-binding and type-checking first,
which introduces a few complexities.

Also, fix a bug in uncurried call emission.

Methods work now.



Swift SVN r1112
2012-02-11 07:37:57 +00:00
John McCall
d0f4d86f3e Use LValueType everywhere instead of the l-value value kind.
Kill off TypeJudgement.  Various fixes and improvements.



Swift SVN r1107
2012-02-06 22:47:08 +00:00
Chris Lattner
bab9ca384c switch TupleExpr to use MutableArrayRef.
Swift SVN r1090
2012-01-19 06:54:43 +00:00
Chris Lattner
27f47dd705 eliminate the concept of a singular expression, which is obsolete and not in lang ref.
Swift SVN r1084
2012-01-18 23:59:04 +00:00
John McCall
59bed696a5 Introduce a ParenExpr to represent the special case of
a tuple with one element and no labels.  This form is
treated specially in essentially every case, so it might
as well be its own expression kind.



Swift SVN r1021
2012-01-12 19:55:06 +00:00
Chris Lattner
17b11e9bbd implement parsing, AST, and LangRef support for 'plus' methods. Dot syntax will need some work though to actually use them.
Swift SVN r949
2011-12-21 23:21:58 +00:00
Chris Lattner
eef2f69637 improve AST modeling of dot syntax calls to follow the syntactic structure instead of being weird and broken and losing source loc info.
Swift SVN r938
2011-12-15 00:52:58 +00:00
Chris Lattner
3d4111475e fix a minor pasto.
Swift SVN r912
2011-12-07 00:10:42 +00:00
Chris Lattner
0b72409c9c ensure that extension members get the proper function type, and a 'this' argument.
Swift SVN r908
2011-12-06 20:23:53 +00:00
Chris Lattner
8d53c9f3b9 restrict 'extension' to only exist at file scope.
Swift SVN r899
2011-12-06 00:11:13 +00:00
Doug Gregor
1ed6cdbb09 Fix broken source-range information for expressions of the form "x.y".
Swift SVN r861
2011-11-10 17:25:08 +00:00
Doug Gregor
0223f3edf1 Implement Expr::getSourceRange() and introduce proper support for this
function into all of the expression nodes. Re-implement
Expr::getStartLoc() in terms of this function, and add it's brother
Expr::getEndLoc(), removing the specialized implementations.

Clean up the source ranges of implicitly-created tuple expressions in
the process.


Swift SVN r855
2011-11-10 00:25:48 +00:00
Chris Lattner
9e783adda1 introduce and use a new parseMatchingToken method.
Swift SVN r841
2011-11-09 01:09:07 +00:00
Chris Lattner
f02dc055d3 introduce a form of parseToken that returns the location of the parsed token
on success, allowing simplifications in clients.


Swift SVN r840
2011-11-09 00:56:52 +00:00
Chris Lattner
ffa9a55002 implement skeleton of extension body parsing.
Swift SVN r839
2011-11-09 00:49:54 +00:00
Chris Lattner
0b9b982758 rework parseDecl to do validation itself, allow decls in oneof's
Swift SVN r837
2011-11-08 22:41:27 +00:00
Chris Lattner
c872bb4782 improve error recovery in {}'s by using less hacky recovery.
Swift SVN r836
2011-11-08 21:09:28 +00:00
Chris Lattner
b5c6fa8e21 split error recovery behavior out of parseDecl, making it more
conventional and allowing more appropriate recovery in various 
caller's contexts.


Swift SVN r835
2011-11-08 21:05:10 +00:00
Chris Lattner
7e08140150 rearrange some code to use common predicates.
Swift SVN r834
2011-11-08 20:12:05 +00:00
Chris Lattner
bcd6f2f474 helper function-ize.
Swift SVN r833
2011-11-08 20:02:30 +00:00
Chris Lattner
9b7ec6785f improve error recovery with mangled decls.
Swift SVN r832
2011-11-08 19:59:45 +00:00
Chris Lattner
eac219bee8 Rework the decl grammar a bit: now "decl" doesn't include import
declarations, but they are explicitly allowed at translation unit scope.
This also introduces a parseDecl method which does the obvious thing.



Swift SVN r830
2011-11-08 19:30:00 +00:00
Chris Lattner
b081915dd3 clean up the interface to parseDeclFunc, and fix a FIXME whereby the
'this' argument to protocol methods wasn't injected early enough to be
found by name lookup.


Swift SVN r822
2011-11-03 18:46:39 +00:00
Chris Lattner
9298082ebb move Diagnostics header to include/swift/AST to match .cpp files.
Swift SVN r782
2011-10-22 00:47:35 +00:00
Chris Lattner
dfd529ce3a rename diags::foo to diag::foo
Swift SVN r779
2011-10-22 00:36:19 +00:00
Chris Lattner
a1781fed38 switch expr parsing to the new diagnostics subsystem
Swift SVN r766
2011-10-20 20:41:48 +00:00
Chris Lattner
8c07ba4034 switch parseStmtBrace to the new diagnostics api
Swift SVN r764
2011-10-20 20:18:36 +00:00
Chris Lattner
d8343e9a42 convert parseToken to new diagnostic api
Swift SVN r763
2011-10-20 20:09:04 +00:00
Chris Lattner
a7c7d64fa0 Switch swift to use SourceLoc instead of SMLoc.
Also use the new getAdvancedLoc() method instead of hacking
on SMLoc directly.

Also fix the warning/note/error methods to forward through ASTContext
instead of being replicated everywhere.



Swift SVN r750
2011-10-18 01:22:29 +00:00
John McCall
6b27921ce3 Propagate around l-value-ness. There aren't any interesting invariants
here yet.



Swift SVN r740
2011-09-27 23:46:08 +00:00
Doug Gregor
3d15bf3d55 Introduce a diagnostic-formatting engine and port most of the parser's
diagnostics over to it.

There are a few differences between this diagnostic engine and Clang's
engine:
  - Diagnostics are specified by a .def file (Diagnostics.def), rather
  than via tblgen, which drastically simplifies the build and makes
  code completion work when you add a new diagnostic.
  - Calls to the "diagnose()" method are safely typed based on the
  argument types specified in the .def file, so it's harder to write a
  diagnostic whose expected arguments (in the string) and whose actual
  arguments (in the code) don't match.
  - It uses variadic templates, so it hangs with the cool kids.



Swift SVN r734
2011-09-26 23:46:28 +00:00
John McCall
b2facdae4b Getterize Stmt.h.
Swift SVN r720
2011-09-20 07:07:53 +00:00
John McCall
7a259f4bad Differentiate between the starting location and caret location of
an expression.  More incremental getterization.



Swift SVN r717
2011-09-19 22:45:58 +00:00
Chris Lattner
c7fd9ec3bc remove the old grammar production for func's in protocols and just use
decl-func instead.  Hey look, now we have support for default 
implementations.


Swift SVN r671
2011-09-01 21:34:04 +00:00
Chris Lattner
5d78286e3f split the "func a::b()" form out to its own grammar production.
Swift SVN r669
2011-09-01 18:21:27 +00:00
Chris Lattner
d77e4ad649 implement support for protocol decls.
Swift SVN r655
2011-08-31 19:58:47 +00:00