go back to disallowing ; in switch statements, people should use break
for empty statements. It is much more explicit and obvious what you mean.
Swift SVN r17662
Introduce a small amount of whitespace sensitivity into break/continue parsing
so that we don't consider an identifier on the next line to be a label.
Swift SVN r17439
As part of this, use tail allocation to reduce the memory footprint of
TupleExprs. Use factory methods to make it easier to construct.
I'll be using this information in a follow-on patch. SourceKit
probably wants it as well.
Swift SVN r17129
This implements true and false as magic constants in build configurations.
I considered adding 0 and 1 as magic integers, but true/false fit better with
our boolean centric model.
Swift SVN r16915
This restructures IfConfigDecl/Stmt to be a list of clauses controlled
by a condition. This makes it straight-forward to drop in #elseif support.
While I'm in here, this patch moves checking for extraneous stuff at the
end of the #if line from the lexer to the parser. This means that you can
now put a comment on the same line as a #if/#else/#elseif/#endif.
Swift SVN r16912
Right now you can 'break' out of a labeled switch statement, but unlabeled
break retains its previous semantics of breaking out of the nearest loop.
Swift SVN r16616
improves location information to track the label location in the AST. We
don't currently track the location of the colon, but that would be trivial
to drop in if it is interesting.
Swift SVN r16608
This is meant to be utilized for a narrow set of scenarios specific to dogfooding our pre-1.0 compiler, so please do not take any dependencies on this. In fact, I'll be removing this in the next milestone. (See rdar://problem/16380797.)
Also included - improve error recovery when parsing broken build configuration clauses.
Swift SVN r15694
func braceStmt3() {
{
undefinedIdentifier {}
}
}
caused by the parser trying to be helpful and unwrapping the closure's
BraceStmt. Unfortunately, DeclContexts inside the BraceStmt are wrong with
this recovery approach.
Unfortunately, this causes us to produce some extra error messages that the
original recovery strategy tried to avoid.
One thing we could do alternatively without making QoI worse is trying to save
the parser position and trying to reparse with correct assumptions, but that
could slow down the parser, so I did not implement this.
Swift SVN r14456
- Respond to Doug's code review feedback
- Stop hacking around with scopes and use "emplace" to work around RAII in the inactive config case
- Limit use of StringRef on the front-end, in favor of std::string
- Use ArrayRef rather than SmallVector within IfConfigDecl
- Reorder new property declarations on BraceStmt to prevent unnecessary alignment issues
- Update ParseBraceItems to better capture top-level declarations, rather than using token lookahead
Swift SVN r14306
These changes add support for build and target configurations in the compiler.
Build and target configurations, combined with the use of #if/#else/#endif allow
for conditional compilation within declaration and statement contexts.
Build configurations can be passed into the compiler via the new '-D' flag, or
set within the LangOptions class. Target configurations are implicit, and
currently only "os" and "arch" are supported.
Swift SVN r14305
Implement several rules that determine when an identifier on a new
line is a continuation of a selector-style call on a previous line:
- In certain contexts, such as parentheses or square brackets, it's
always a continuation because one does not split statements in
those contexts;
- Otherwise, compare the leading whitespace on the line containing
the nearest enclosing statement or declaration to the leading
whitespace for the line containing the identifier.
The leading whitespace for a line is currently defined as all space
and tab characters from the start of the line up to the first
non-space, non-tab character. Leading whitespace is compared via a
string comparison, which eliminates any dependency on the width of a
tab. One can run into a few amusing cases where adjacent lines that
look indented (under some specific tab width) aren't actually indented
according to this rule because there are different mixes of tabs and
spaces in the two lines. See the bottom of call-suffix-indent.swift
for an example.
I had to adjust two test cases that had lines with slightly different
indentation. The diagnostics here are awful; I've made no attempt at
improving them.
Swift SVN r13843
This allows code such as
obj.closure { return 0 } onError { println("error") }
to parse appropriately. The only other functionality change here is
that we no longer allow the use of a trailing closure within the
condition of a C-style for loop, because it did awful things to
recovery. I doubt we'll miss it.
Swift SVN r13823
clients to either go through the new parseExpr (which is never "basic")
or the existing parseExprBasic entrypoint if they don't want trailing
closures.
Swift SVN r13724
down next to case statement parsing logic since it is specific to
it. It looks like we can't fully eliminate this right now, because
patterns in case statements are parsed generally as expr patterns
and sema'd into something more useful later, too late for setting
variables in scopes. The parsing logic could be improved here, but
I'm not going to work on this.
As a driveby, improve error recovery when type checking of case
statement patterns fails by marking the decls inside of them as
invalid.
Swift SVN r13712
from the pattern to the scope (it doesn't do other argument
specific stuff like mucking with decl contexts) rename it to
addPatternVariablesToScope, and use it in two more places
in the parser.
Swift SVN r13710
now that they are implicitly updated. This exposes two things:
1) we're unncessarily serializing selfdecls in ctors and dtors.
2) The index pattern of a SubscriptDecl has no sensible DeclContext that
owns variables in it.
I'll deal with the first tomorrow, I'm not sure what to do with
the second one.
Swift SVN r13703
all of their generic parameters. This simplifies logic creating them,
allowing us to eliminate all setDeclContext() calls from the parser.
While we're at it, change Parser::addVarsToScope to be a static
function in ParseStmt.cpp and dramatically cut it down since none of
its remaining clients are using most of its capabilities. It needs
to be simplified even further.
Swift SVN r13702
for loop that walks the pattern variables and sets them up.
Move addVarsToScope to ParseStmt.cpp which is what is left
using it.
Add a new "addAccessorsInOrder" helper to add the get/set
accessors to the Decls tree in the right order.
Swift SVN r13697
Allow IfStmts and WhileStmts to have as their condition either an expression, as usual, or a pattern binding introduced by 'var' or 'let', which will conditionally bind to the value inside an optional. Unlike normal pattern bindings, these bindings require an in-line initializer, which will be required to be Optional type. Parse variable bindings in this position, and type-check them by requiring an Optional on the right-hand side and unwrapping it to form the pattern type. Extend SILGen's lowering of if and while statements to handle conditionally binding variables.
Swift SVN r13146