Commit Graph

276 Commits

Author SHA1 Message Date
Chris Lattner
15f40068d4 remove stmt-brace. If you need something like it for scoping purposes, you can always use "if true {}".
Swift SVN r5034
2013-05-03 05:59:27 +00:00
Doug Gregor
2f3e948ad1 Remove the ".(foo:1 bar:2)" message-send syntax.
Swift SVN r5009
2013-05-01 04:33:59 +00:00
Joe Groff
7ed3285cd4 LangRef: Another small tweak.
The description of identifiers got long enough that it makes sense to break operators out into their own subsection. Also, I snuck '@' into the operator character set.

Swift SVN r5006
2013-05-01 02:47:53 +00:00
Joe Groff
dedbc6d7a6 Update LangRef.
Ternaries are now parsed among sequence expressions, identifiers can use unicode code points, and new now only allocates arrays.

Swift SVN r5003
2013-05-01 00:18:00 +00:00
Dave Zarzycki
106a7f9797 Random doc updates with new keyword ':' syntax
Swift SVN r4580
2013-04-03 00:23:13 +00:00
Chris Lattner
d53efbba38 fix character escape comments.
Swift SVN r4522
2013-03-28 22:03:03 +00:00
Joe Groff
62b03629b9 LangRef: Describe cast expressions.
Swift SVN r4500
2013-03-27 23:29:44 +00:00
Joe Groff
89e1b7e773 Parser: Give IfExpr traditional ternary syntax.
Swift SVN r4489
2013-03-26 01:17:34 +00:00
Joe Groff
3eb2b132eb LangRef: Describe 'if' expressions.
Swift SVN r4409
2013-03-17 18:39:08 +00:00
Joe Groff
08bb23391e LangRef: Describe 'switch'.
Swift SVN r4362
2013-03-12 23:03:34 +00:00
Doug Gregor
4aa6abd9c8 Extend message-send syntax to new expressions and super.constructor expressions.
For example, this allows:
var window = new NSWindow.(initWithContentRect:NSRect(100, 100, 800, 630)
                                     styleMask:Int(NSTitledWindowMask|NSClosableWindowMask|NSResizableWindowMask)
                                       backing:NSBackingStoreType(NSBackingStoreBuffered)
                                         defer:false)


Swift SVN r4315
2013-03-07 04:43:22 +00:00
Doug Gregor
adcd9d91b9 Implement selector argument syntax for method calls.
Introduce a second syntax for method calls that better describes
messages with multiple selector pieces, e.g.,

    undoManager.(registerUndoWithTarget:this
                               selector:"setItemName:"
                                 object:nameSetter)

Note that we're also allowing ':' as a separator for normal keyword
arguments. The intent is to drop the use of '=' for normal keyword
arguments, but that will be a separate change affecting a number of
test cases.



Swift SVN r4313
2013-03-07 02:01:20 +00:00
Dave Zarzycki
68c6d4c6e3 13324820 Change tuple accessor syntax to 'tuple.0'
Swift SVN r4265
2013-03-02 17:51:03 +00:00
Dave Zarzycki
9d777dfad7 Revert \a, \b, \f
This branch should have been committed a long time ago. Sorry.

Swift SVN r4256
2013-03-01 22:36:19 +00:00
Dave Abrahams
52ab572ef5 Fix English grammar
Swift SVN r4241
2013-02-28 22:27:34 +00:00
Joe Groff
c3917ad4ef LangRef: Tweak generics language.
Swift SVN r4055
2013-02-15 20:17:42 +00:00
Joe Groff
df9cf24132 LangRef: Document generic parameter parsing.
Swift SVN r4054
2013-02-15 00:52:16 +00:00
Dave Zarzycki
bf3c98a0e6 Revert \v from r3968
Nobody can find any modern use for \v.

Swift SVN r3990
2013-02-08 18:19:58 +00:00
Dave Zarzycki
a282c35e6a Make floating-point number parsing more strict
The range operators (".." and someday "...") make constructs like .24...42
ambiguous. Therefore, we will enforce that programmers either place digits
on both sides of the decimal place, or use of exponent based notation.

Swift SVN r3989
2013-02-08 15:48:02 +00:00
Dave Zarzycki
9ad1e4c950 C/C++/ObjC Interop: string/char escapes
If we're going to import C/C++/ObjC code, we ought to "just work" with
their escape patterns when reasonable. (No error-prone octal escapes or
trigraph support). Also, update LangRef to document what the escapes do.

This patch DOES fix a bug with lexing operators in the case of (already
warned about) embedded NUL bytes within a source file.

This patch DOES NOT change what we consider to be valid whitespace in
the language.

Swift SVN r3970
2013-02-06 17:51:18 +00:00
Joe Groff
081787c3d5 Lexer: Lex C99-style hexadecimal float literals.
APFloat's parser gives us the parsing for free. Unlike C99 we require at least one digit on both sides of the hexadecimal point in order to allow '0x1.method()' expressions, similar to Dave's proposed change to float lexing. Also, we were requiring a sign after 'e' in the exponent, which is inconsistent with C, C++, and the Java regex we claim to follow, so I made the exponent sign optional.

Swift SVN r3940
2013-02-03 19:06:08 +00:00
Dave Zarzycki
ff8bd176b4 Sort the reserved keyword list
Swift SVN r3894
2013-01-29 21:13:41 +00:00
Dave Zarzycki
b36678214a Rename l_(paren|square)_(call|subscript)
Thanks Chris and John for the feedback.

Swift SVN r3893
2013-01-29 21:13:39 +00:00
Dave Zarzycki
5fe85d7020 Formalize unary prefix '&' to mean "make ref"
This makes reserved operator parsing more robust and easier to understand.

Swift SVN r3884
2013-01-27 21:20:06 +00:00
Dave Zarzycki
d7cc4b4a91 Reclaim "in" as an identifier
In Swift the "in" keyword is really a form of punctuation, and highly
context specific punctuation at that. It never begins a statement, nor
does the grammar require it be statement keyword. The grammar also
doesn't use it outside of for-each loops, and its use within a for-each
loop is highly unambiguous.

Thanks to Chris for the performance related feedback. This improves the
performance of getter/setter parsing as well.

Swift SVN r3880
2013-01-26 01:49:18 +00:00
Dave Zarzycki
73c31768ae The ++/-- hack doesn't exist anymore.
"var x = 123 ++y" is now unambiguously not a binary ++ operator.

Swift SVN r3868
2013-01-25 19:20:47 +00:00
Dave Zarzycki
b2173ef730 LangRef: add float commentary / question
Swift SVN r3867
2013-01-25 19:20:44 +00:00
Joe Groff
01f7030291 LangRef: Grammar and description of super exprs.
Swift SVN r3861
2013-01-24 22:34:43 +00:00
Dave Zarzycki
dd717e200f Update LangRef list of keywords and sort them
Swift SVN r3860
2013-01-24 22:01:35 +00:00
Dave Zarzycki
60eb51b85b Document that unary '&' is reserved
Swift SVN r3856
2013-01-24 17:36:35 +00:00
Dave Zarzycki
9eb53f37f5 12641063 Fix the double-indent problem with properties
Swift SVN r3822
2013-01-21 22:43:19 +00:00
Dave Zarzycki
78785c903f Char: add NUL literal and unit tests
Swift SVN r3681
2013-01-04 19:47:40 +00:00
Dave Zarzycki
dd53919b2a LangRef: for-each now uses formal protocols
Swift SVN r3657
2013-01-03 18:45:16 +00:00
Dave Zarzycki
3959f6f5ef LangRef: '//', '/*', and '*/' are not overloadable
Swift SVN r3656
2013-01-03 18:32:59 +00:00
Chris Lattner
b19f4ffaf5 fix typo in regex.
Swift SVN r3598
2012-12-28 09:55:16 +00:00
Dave Zarzycki
c825debf2f Cleanup Enumeration
I tried to transform getEnumeratorType() into a VarDecl, but IRGen hasn't implement this feature yet.

Swift SVN r3527
2012-12-18 02:12:19 +00:00
Joe Groff
6449655e21 Implement selector-style function definition syntax.
rdar://12315571
Allow a function to be defined with this syntax:

  func doThing(a:Thing) withItem(b:Item) -> Result { ... }

This allows the keyword names in the function type (in this case
`(_:Thing, withItem:Item) -> Result`) to differ from the names bound in the
function body (in this case `(a:Thing, b:Item) -> Result`, which allows
for Cocoa-style `verbingNoun` keyword idioms to be used without requiring
those keywords to also be used as awkward variable names. In addition
to modifying the parser, this patch extends the FuncExpr type by replacing
the former `getParamPatterns` accessor with separate `getArgParamPatterns`
and `getBodyParamPatterns`, which retrieve the argument name patterns and
body parameter binding patterns respectively.



Swift SVN r3098
2012-11-01 21:53:15 +00:00
John McCall
2f8f05615e Rename TypeOfExpr / TypeOfInst to MetatypeExpr / MetatypeInst.
Introduce a '.metatype' form in the syntax and do some basic
type-checking that I probably haven't done right.  Change
IR-generation for that and GetMetatypeExpr to use code that
actually honors the dynamic type of an expression.

Swift SVN r3053
2012-10-24 07:54:23 +00:00
John McCall
a6a2ab92b3 Add a production to the type grammar for writing metatypes.
Swift SVN r3052
2012-10-24 07:54:17 +00:00
Eli Friedman
428745e741 Add a bit more to the section on classes in LangRef, with some FIXMEs for
more missing stuff, per Chris's request.



Swift SVN r2957
2012-10-09 02:36:46 +00:00
Chris Lattner
b6f6eec106 implement rdar://11935352 - accepting closures with no body expression (the closure
just returns "()").


Swift SVN r2503
2012-08-02 20:08:51 +00:00
Daniel Dunbar
1eeecdd874 Change Swift docs to use Sphinx.
- I've converted every document except the LangRef, which is more trouble to
   convert because of the use of styling to embed notes.
 - 'make html' with sphinx-build in your path to build the docs.

Now back to my regularly scheduled breaking things. :)

Swift SVN r2410
2012-07-23 18:50:00 +00:00
Eli Friedman
4b34dc582b Add a quick description of constructors and destructors to LangRef.
Swift SVN r2349
2012-07-12 01:57:04 +00:00
Doug Gregor
35e6e56595 When we split a token starting with '<' or '>', make sure that the
resulting token goes back through the lexer to get the appropriate
token kind. Thanks to Chris for spotting this.

Also, document the '<' and '>' splitting behavior in LangRef.


Swift SVN r2192
2012-06-18 16:40:59 +00:00
Doug Gregor
1aea990492 Add protocol composition types to LangRef.
Swift SVN r2191
2012-06-18 16:14:42 +00:00
Doug Gregor
afec173412 Fix typo
Swift SVN r2190
2012-06-18 14:35:27 +00:00
Chris Lattner
db0cd646fc lexer/parser/ast/sema support for do/while statements. irgen next.
Swift SVN r2186
2012-06-17 02:29:54 +00:00
John McCall
8c46c69efa Lexically distinguish prefix, postfix, and binary operators
and use this information as cues in the language.  Right now,
we do not accept things like "-- *i" because the prefix
operator is not correctly right-bound;  instead you have to
write "--(*i)".  I'm okay with that;  I did add a specialized
diagnostic recognizing operator-binary in a place where we're
expecting a potential operator-prefix.

Swift SVN r2161
2012-06-07 01:00:06 +00:00
Doug Gregor
1bf18a2472 Implement requirements on associated types (<rdar://problem/11548273>).
Swift SVN r2134
2012-06-04 16:43:40 +00:00
Doug Gregor
9abd2340bc Allow an 'inheritance' clause on typealiases, specifying what
protocols the underlying type of the type alias shall conform to. This
isn't super-motivating by itself (one could extend the underying type
instead), but serves as documentation, makes typealiases provide the
same syntax as other nominal types in this regard, and will also be
used to specify requirements on associated types.


Swift SVN r2133
2012-06-04 16:15:47 +00:00