Commit Graph

419 Commits

Author SHA1 Message Date
Doug Gregor
27e3a03525 Implement parsing, AST, and basic validation of requires clauses
within generic parameter clauses, e.g.,

  func f<T requires T : P1, T : P2>() {}




Swift SVN r2369
2012-07-18 23:36:56 +00:00
Eli Friedman
6b4a248f04 Parsing and AST support for destructors on classes.
Swift SVN r2348
2012-07-12 01:26:02 +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
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
Eli Friedman
75907029f1 Add parsing and semantic analysis for a basic ConstructorDecl. Still missing: no IRGen, and semantic analysis to actually call them.
Swift SVN r2159
2012-06-05 23:51:19 +00:00
Eli Friedman
c404598fcb Parsing and semantic analysis for 'break' and 'continue'.
Swift SVN r2087
2012-05-31 00:55:33 +00:00
Eli Friedman
099a97847d Parsing and AST support for varargs tuples.
Swift SVN r1875
2012-05-16 22:02:01 +00:00
Eli Friedman
a5a39860cd Basic parsing plus a bit more of the AST for ClassDecls.
Swift SVN r1860
2012-05-15 22:07:31 +00:00
Chris Lattner
22300ed57f improve diagnostic for a " in the middle of an interpolated string, including a range:
t.swift:4:19: error: unexpected '"' character in string interpolation
"Hello \(x+1 world"
        ~~~~~~~~~~^



Swift SVN r1759
2012-05-05 23:12:07 +00:00
Chris Lattner
e5108826c2 change the interface to skipToEndOfInterpolatedExpression to return the
interesting character on failure as well as on success.  Simplify the
code in Lexer::getEncodedStringLiteral since it cannot be called on a 
string with an malformed interpolated expression.


Swift SVN r1758
2012-05-05 22:56:40 +00:00
Chris Lattner
822c7a2689 remove a hack that isn't needed now that we pre-lex the tokens in an interpolated string literal, thanks doug.
Swift SVN r1757
2012-05-05 22:44:14 +00:00
Chris Lattner
2f44c0038c Initial stab at implementing string literal interpolation for simple expressions,
e.g. "foo is \(i+j)".  This implements rdar://11223686

Doug implemented all the hard parts of this.  I ripped out support for nested string
literals (i.e. string literals within an interpolated string), which simplified the
approach and defined away some problems with his patch in progress.  I plan a few refinements
on top of this basic patch.



Swift SVN r1738
2012-05-04 05:53:50 +00:00
Chris Lattner
8c478d1cb7 remove the foreach keyword, switching foreach loops to use 'for' instead.
This uses one-token lookahead to distinguish between the two forms.


Swift SVN r1710
2012-05-02 01:06:06 +00:00
Chris Lattner
aa069a90cc fix error recovery to not crash: the lexer should always return a token even in an erroneous token.
Swift SVN r1676
2012-04-27 06:34:45 +00:00
Chris Lattner
615ca4a360 implement the rest of character literal support, and enhance Char to be character literal
compatible.  This wraps up rdar://11305635, though some cleanup of the testsuite can now be done.


Swift SVN r1672
2012-04-27 06:18:30 +00:00
Chris Lattner
c7e68a4a8b langref and lexer support for character literals.
Swift SVN r1671
2012-04-27 05:51:30 +00:00
Doug Gregor
f997a781bf Parsing and basic AST representation for 'foreach' statement.
Swift SVN r1594
2012-04-24 18:12:44 +00:00
Chris Lattner
df74bc03c0 lang ref and parser support for for statements. AST and sema next.
Swift SVN r1493
2012-04-19 18:25:48 +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
71157c65d5 Add parsing support, but no type-checking or IR-generation,
for new expressions.

Swift SVN r1466
2012-04-18 08:09:18 +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
9009d294d2 More strictly special-case '..'; making '-.' etc. an operator would be a complete disaster.
Swift SVN r1444
2012-04-17 00:34:25 +00:00
Eli Friedman
6a001efbbb Make "..", "*^.^*", etc. into overloadable operators. Make 1..10 construct a Range.
This has the side-effect that you can't explicitly refer to an operator* with "swift.*", etc., but per discussion with Doug, that's probably okay.



Swift SVN r1443
2012-04-17 00:21:38 +00:00
Chris Lattner
cc421b20c1 allow ~ as the first character of an operator.
Swift SVN r1413
2012-04-13 05:57:48 +00:00
Chris Lattner
8a7c6f7258 Eli points out that 4 is the max length. apparently I can't handle this. Thanks Eli! :)
Swift SVN r1406
2012-04-12 23:21:54 +00:00
Chris Lattner
b01c3bd989 We need to eventually add unicode identifier support, but it is beyond the scope of
what I intend to do right now.



Swift SVN r1405
2012-04-12 23:14:48 +00:00
Chris Lattner
09e051ce99 reject invalid UTF8 characters in comments.
Swift SVN r1403
2012-04-12 21:58:30 +00:00
Chris Lattner
d19939ead3 rearrange file a bit, no functionality change.
Swift SVN r1402
2012-04-12 21:51:55 +00:00
Chris Lattner
c92cf52358 since we allow utf8 source files, start validating utf8 characters in string literals
and test that they continue to work.  Part of rdar://11220029


Swift SVN r1401
2012-04-12 21:47:12 +00:00
Chris Lattner
2e3c720e46 fix regex's for floating_literal because "0" is an integer literal not floating.
Swift SVN r1396
2012-04-11 22:22:27 +00:00
Chris Lattner
9b2c6acd37 improve comment with some justification.
Swift SVN r1374
2012-04-10 23:54:59 +00:00
Chris Lattner
ac61437b8b by popular demand, reject over-large codepoints.
Swift SVN r1371
2012-04-10 23:52:06 +00:00
Chris Lattner
cac963c6d6 reject unicode encodings for surrogate pairs, and reject \x80 and above.
This completes unicode validation for \x, \u, and \U.


Swift SVN r1369
2012-04-10 23:26:46 +00:00
Chris Lattner
4ff016d0a8 start diagnosing invalid UTF encodings, more to follow.
Swift SVN r1365
2012-04-10 22:02:57 +00:00
Chris Lattner
2b1bcdcdf6 Implement basic encoding to UTF8, giving us the snowman. Codepoint validation comes next.
Swift SVN r1364
2012-04-10 21:50:28 +00:00
Chris Lattner
ce7403dd1e implement IRGen of escapes. High unicode escapes aren't handled yet, but all the
basics are.


Swift SVN r1363
2012-04-10 20:59:45 +00:00
Chris Lattner
1bb2443498 document and lex the basic and unicode escape characters.
IRGen after lunch.



Swift SVN r1361
2012-04-10 19:30:18 +00:00
Chris Lattner
e31361f174 Progress towards rdar://11216049 - Strings cannot span multiple lines, and \ is an
escape character (not yet implemented).


Swift SVN r1360
2012-04-10 18:14:27 +00:00
Chris Lattner
c78bdcff0e Initial lexer support for string literals. The regex is trivial and will be extended in the future.
Swift SVN r1348
2012-04-10 00:38:13 +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
John McCall
b8b1694564 Complain about file names that aren't valid identifiers.
When we divide the world into scripts and modules, this
won't matter for the former.  Recognize <stdin> as a
special case;  it should instead just always be a script.
Fixes rdar://problem/10986311.

Swift SVN r1181
2012-03-11 09:15:17 +00:00
Eli Friedman
eada7c6558 Make sure we catch 0x/0o/0b which isn't followed by an appropriate digit. Per Chris's comment.
Swift SVN r1174
2012-03-10 00:12:43 +00:00
Eli Friedman
6c439ec301 Add grammar for hex/octal/binary literals. Not completely sure this is the grammar we want (how do we want to handle 0b1a?), but it appears to work. Sema already handles hex and binary; still needs a bit of hacking for octal. <rdar://problem/10700832>
Swift SVN r1170
2012-03-07 04:01:05 +00:00
Chris Lattner
21c8b4dae9 implement a more-sane floating point literal syntax, adding support for
exponents.  This resolves rdar://10877508


Swift SVN r1140
2012-03-01 21:42:10 +00:00
Chris Lattner
1076367d73 implement rdar://10962528 - split up the int/fp literal lexing and grammar.
This cleans up handling of int/fp literals by splitting them appart at the
lexer level.


Swift SVN r1137
2012-03-01 19:06:55 +00:00
Chris Lattner
578686379d start updating some dox.
Swift SVN r1082
2012-01-18 22:58:18 +00:00
Chris Lattner
f1db6de509 remove the :: token and DCE UnresolvedScopedIdentifierExpr.
Swift SVN r1043
2012-01-14 07:00:45 +00:00
Chris Lattner
378f91b07f add lexer support for the new & terrible 'plus' keyword.
Swift SVN r946
2011-12-21 22:17:14 +00:00
Doug Gregor
b1c98e1731 Introduce Lexer::getLocForEndOfToken() to adjust source locations to
the end of the current token, and use it for proper translation from
SourceRange to SMRange when printing diagnostics.



Swift SVN r853
2011-11-09 22:03:30 +00:00