Chris Lattner
db236941d0
Check in a massive rewrite of how sema works for expressions in an effort to make way for separate parsing, name binding, type checking phases.
...
Highlights of this include:
1) most of SemaExpr is gone now, when parsing, all expressions are assigned null types.
2) the introduction of a new TypeChecking pass, which assigns types to expressions, and checks their constraints.
3) ElementRefDecl now properly stores an access path for what it is accessing, and ElementRefDecl's get added to the AST.
4) The parser is much much simpler for expressions now, it just collects lists of primary exprs into SequenceExprs unconditionally.
5) This means that formation of binary expressions, function application etc is now done by TypeChecking. This is actually simpler, though admittedly surprising.
6) This introduces a new -parse-dump mode which just parses but does not perform name binding or type checking.
I've been working on this for a while and it is still quite broken: it still doesn't handle anondecls at all, doesn't perform conversion checking for default tuple elements, has missing pieces of varname name binding etc. However, there is no reason to not crash land it now, it's not like I'm going to break anyone else.
Swift SVN r262
2011-03-13 21:52:03 +00:00
Chris Lattner
b3e5c55fbc
Change the parser methods to lower case to follow naming conventions.
...
Swift SVN r256
2011-03-06 23:28:17 +00:00
Chris Lattner
ddb760bf2b
Remove the concept of an ASTConsumer, add a new TranslationUnitDecl.
...
Swift SVN r255
2011-03-04 22:08:34 +00:00
Chris Lattner
abb710acaa
Minor code tidying + comments, add some expected error tests.
...
Swift SVN r252
2011-03-02 07:59:48 +00:00
Chris Lattner
bd4ccf1a55
Fix structs to require that their element type be a syntactic tuple. Rejecting the testcase.
...
Swift SVN r251
2011-03-02 07:11:34 +00:00
Chris Lattner
291967ceb0
Make ParseIdentifier do the string->identifier conversion, simplifying clients. no functionality change.
...
Swift SVN r250
2011-03-02 06:55:35 +00:00
Chris Lattner
61d62179ee
Improve consistency by pushing Identifiers into Sema instead of StringRefs.
...
Swift SVN r249
2011-03-02 06:50:13 +00:00
Chris Lattner
b233848006
Tidy up and clean up code and error recovery in the parser. Add some templated allocation functions to ASTContext to simplify clients.
...
Swift SVN r248
2011-03-02 06:15:52 +00:00
Chris Lattner
272d9e8dad
Propagate "there were errors in the input" out to the exit code of the swift app by adding a "HadError" bool to ASTContext.
...
Swift SVN r244
2011-03-01 07:59:53 +00:00
Chris Lattner
ffef30f2c3
Change name lookup of types to always succeed: if a type is used before it is defined, just cons up a new TypeAliasDecl for the unresolved type and return it. Diagnose these at the end of the translation unit instead of at their first use.
...
Swift SVN r240
2011-02-27 20:49:29 +00:00
Chris Lattner
80e1ae6104
Rework a bunch of stuff in the type system: now the *only* way to name a type is through a 'typealias' and there is no such thing as a OneOfDecl. Instead, we have OneOfType's, which are always anonymous. "oneof declarations" and "struct declarations" are now both just sugar.
...
This eliminates the NamedTypeDecl class (because there is now only one named type decl), eliminates OneOfDecl, renames AliasTypeDecl to NameAliasTypeDecl for good measure, and introduces OneOfType.
This preserves all existing syntax, and allows stuff like this:
func test6(checkboxenabled : oneof { Yep, Nope }) {
test6(:Yep)
}
Which is an anonymous oneof.
Swift SVN r237
2011-02-26 02:03:01 +00:00
Chris Lattner
7bbe52b52a
Expand the swift language to allow typealiases, oneof, and struct within a brace expression. This allows us to have shadowing of type names.
...
Swift SVN r236
2011-02-22 07:41:44 +00:00
Chris Lattner
6a1416b3b8
Revert my last patch. Instead of having a TypeScope and ValueScope, we'll just make Scope do both!
...
Swift SVN r231
2011-02-22 06:36:52 +00:00
Chris Lattner
e6f00fe1cc
Rename the Scope class to ValueScope
...
Swift SVN r230
2011-02-22 06:30:18 +00:00
Chris Lattner
cb9b1838a6
Introduce and create a new TypeAliasDecl for typealiases.
...
Swift SVN r227
2011-02-22 05:47:08 +00:00
Chris Lattner
8234b6fd66
Add some sema for tuple elements which are specified with a default value. Still not used for conversions yet.
...
Swift SVN r219
2010-11-25 21:18:48 +00:00
Chris Lattner
f6d7adc4cb
Parse tuple element types as value-specifier's, allowing them to have initializers. Sema isn't wired up yet though.
...
Swift SVN r218
2010-11-25 20:49:01 +00:00
Chris Lattner
bc616e9fcd
Split the initializer syntax from var decls out to their own 'value-specifier' production
...
Swift SVN r217
2010-11-25 17:00:34 +00:00
Chris Lattner
28789d43d2
Resolve a fixme: use foo.$1 instead of foo.field1
...
Swift SVN r216
2010-11-11 23:04:29 +00:00
Chris Lattner
3bd8a85784
Fix weirdness in the lang spec by making $123 be a special type of implementation identifier token, handling it uniformly in the grammar in the few places that it is valid.
...
Swift SVN r215
2010-11-11 22:27:39 +00:00
Chris Lattner
2653092ae5
Change the grammar for oneof elements to require a ':' make them more swift like and less ml like. Before we had:
...
oneof MaybeInt {
None,
Some int
}
Now we have:
oneof MaybeInt {
None,
Some : int
}
This resolves a fixme in the langref.
Swift SVN r214
2010-11-11 21:06:00 +00:00
Chris Lattner
906ba908fd
Rename 'data' to 'oneof', resolving a fixme in the spec. Yay for CLU!
...
Swift SVN r212
2010-11-11 01:20:36 +00:00
Chris Lattner
2f0d96885a
Move field exprs to their own section in langref. Document subscript exprs. Still no sema support.
...
Swift SVN r210
2010-10-18 06:34:46 +00:00
Chris Lattner
6f8dd4cf32
add parser support for array indexes
...
Swift SVN r209
2010-10-17 14:15:33 +00:00
Chris Lattner
f66d7a6faf
Update langref for array types.
...
Swift SVN r208
2010-10-17 13:57:10 +00:00
Chris Lattner
fd54c7f5a0
add parser support for array types, no sema or ast yet.
...
Swift SVN r205
2010-10-15 11:54:34 +00:00
Chris Lattner
d6862a7e5f
Fix decl-brace to not require ';'s
...
Swift SVN r204
2010-10-15 11:16:36 +00:00
Chris Lattner
154c0c6eb9
Resolve a fixme by eliminating the ; in func decls and making the grammar more restrictive.
...
Swift SVN r203
2010-10-15 11:07:49 +00:00
Chris Lattner
b9fbd77f58
Fix a bunch of minor bugs found through inspection:
...
1. Punctuation identifiers were missing some characters.
2. Some parser production and methods were misnamed.
3. Top level var decls don't need a ; after them.
4. Various parser comments were out of date.
5. We now allow any type in a struct decl, e.g. "struct foo int", even though it's weird.
Swift SVN r199
2010-10-12 07:24:33 +00:00
Chris Lattner
bb541a2f31
add a note.
...
Swift SVN r198
2010-10-11 21:18:15 +00:00
Chris Lattner
26e63c29ac
rip out a bunch of special case parsing logic for function arguments now that tuples have a sane syntax.
...
Swift SVN r197
2010-10-11 21:05:07 +00:00
Chris Lattner
0fcf9a4199
Bertand finally beat some sense into me, convincing me that tuples with named elements are more important than tuples with anonymous elements.
...
This changes the grammar for tuple type elements to be:
/// type-tuple-element:
/// identifier? ':' type
instead of:
/// type-tuple-element:
/// type
/// '.' identifier ':' type
In practice this means that you don't have to use things like (.x : int, .y : int) you can just use (x :int, y:int) which is what we already have for function argument lists.
Swift SVN r196
2010-10-11 21:00:55 +00:00
Chris Lattner
e9db331fa0
Struct declarations also inject their name into the global scope, allowing them to be used unqualified.
...
Swift SVN r193
2010-10-10 06:45:11 +00:00
Chris Lattner
f92a3d56d7
Implement parser support for structs, improve datadecl dumping.
...
Swift SVN r192
2010-10-10 06:38:24 +00:00
Chris Lattner
272cbcaba3
Implement parser, ast and minimal sema support for :foo expressions, type resolution isn't done yet.
...
Swift SVN r185
2010-10-10 00:15:46 +00:00
Chris Lattner
ad438c55e3
Implement the rest of sema for scoped identifier references (X::Y) we now get a proper DeclRefExpr, and this:
...
var def = DataSearchFlags::None;
-ast-dump's into:
(vardecl 'def' type='DataSearchFlags'
(declref_expr type='DataSearchFlags' decl=None))
Swift SVN r182
2010-10-09 23:46:16 +00:00
Chris Lattner
43f2d1dfa5
wire up parser and basic sema support for scoped identifier expressions (X::Y).
...
Swift SVN r180
2010-10-09 23:01:17 +00:00
Chris Lattner
09a023c3cd
Now that we have simple user defined data types, remove the __builtin_else_hack type. woot.
...
Swift SVN r179
2010-10-09 22:06:13 +00:00
Chris Lattner
ac855b690b
Move ActOnTypeAlias to SemaDecl since a type alias *is* a decl that *installs* a type. Add some fixme's and rename some junk in ASTContext relating to the typemap. Diagnose redefinitions of named types. Install a typemap entry when a data declaration is defined.
...
We can now declare variables to be of data type.
Swift SVN r178
2010-10-09 22:01:25 +00:00
Chris Lattner
a43a8f27f5
Wire data decls up to -ast-dump. Fix some minor bugs exposed along the way.
...
Swift SVN r175
2010-10-09 20:46:10 +00:00
Chris Lattner
57c697172a
Split NamedDecl into NamedDecl with a ValueDecl subclass that has the type and value of the decl.
...
Swift SVN r173
2010-10-09 20:28:11 +00:00
Chris Lattner
3ea5878390
add scafolding for sema of datas.
...
Swift SVN r172
2010-10-09 19:33:50 +00:00
Chris Lattner
ecdc8da738
add parser support for type specifiers in data descriptors.
...
Swift SVN r171
2010-10-09 18:58:18 +00:00
Chris Lattner
17c36aa749
add parser support for simple data declarations
...
Swift SVN r170
2010-10-09 18:42:54 +00:00
Chris Lattner
19e5390b78
twinify more diagnostics.
...
Swift SVN r168
2010-10-09 17:50:40 +00:00
Chris Lattner
51b9de2931
update to build with llvm mainline (twinification of SourceMgr)
...
Swift SVN r167
2010-10-09 17:44:21 +00:00
Chris Lattner
91f5abd1e9
Implement parser support for assignment, what a hack :-)
...
Swift SVN r166
2010-09-18 17:26:01 +00:00
Chris Lattner
fb75d0cdf1
cleanup
...
Swift SVN r164
2010-09-04 19:26:34 +00:00
Chris Lattner
29503975d2
Enhance juxtaposition binding handling to handle binary operators and functions in a more fine-grained way, allowing if/else to work without braces.
...
Swift SVN r163
2010-09-04 19:25:56 +00:00
Chris Lattner
d2abfde434
introduce a new builtin type to represent the result of the else binary operator (which is a temporary hack until we get user defined types).
...
Use it to define ife/else. Fix some precedence/parsing bugs that implementing else exposed.
Swift SVN r162
2010-08-08 22:37:56 +00:00