Commit Graph

727 Commits

Author SHA1 Message Date
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
Chris Lattner
45610c0ecc rework func argument parsing to be more consistent across ->'s.
Swift SVN r161
2010-08-08 21:36:26 +00:00
Chris Lattner
b927b55863 Finally get around to allowing *use* of a named incoming function argument. The first step is to set up a scope for them and walk the argument names, keeping track of access path info.
Swift SVN r158
2010-08-07 20:10:19 +00:00
Chris Lattner
025143611f implement support for tuple expressions with names specified for the elements.
Swift SVN r157
2010-08-07 06:51:12 +00:00
Chris Lattner
429ecb81da Finish ast and sema support for name binding elements of tuples in var decls.
Swift SVN r152
2010-08-05 22:22:22 +00:00
Chris Lattner
544f3fde60 Now that tuples aren't abusing ParseDeclVar, we can have ParseDeclVar insert the decl into the current scope, a prereq for more interesting names.
Swift SVN r151
2010-08-05 05:10:57 +00:00
Chris Lattner
bf63029ecd rework tuple element parsing to not use ParseDeclVar, since tuple elements are fundamentally different. While we're at it, switch to an arguably more natural syntax for field elements, naming them with .x : type instead of var x : type
Swift SVN r150
2010-08-05 05:03:55 +00:00
Chris Lattner
34a1beac31 inline ParseTypeOrDeclVar and ParseExprOrDeclVar into their single callers and simplify the code around them.
Swift SVN r149
2010-08-05 04:42:13 +00:00
Chris Lattner
43a526f1f5 a step towards parsing richer names. I need to do some refactoring of var parsing before going further.
Swift SVN r148
2010-08-05 04:28:32 +00:00
Chris Lattner
c1294622bf Cleanup type stuff.
Swift SVN r147
2010-08-04 06:35:54 +00:00
Chris Lattner
e1e335610f int is no longer a keyword, it is a type alias for the new __builtin_int32_type type.
Swift SVN r146
2010-08-04 05:27:45 +00:00
Chris Lattner
69133a6ed2 now that we have type aliases, eliminate void as a keyword.
Swift SVN r145
2010-08-04 05:16:37 +00:00
Chris Lattner
a8916a6106 implement semantic analysis and AST representation for AliasType (aka typedefs in C).
Swift SVN r144
2010-08-04 05:14:57 +00:00
Chris Lattner
8f86874c19 add parser support for typealiases, we have to be able to exercise the canonical type system somehow.
Swift SVN r143
2010-08-04 04:42:13 +00:00
Chris Lattner
86ce100404 clean up some parser logic.
Swift SVN r142
2010-08-04 03:38:45 +00:00
Chris Lattner
f704c58c42 Two significant changes:
1. Change the representation of TupleType to contain TupleTypeElt structs instead of PointerUnion<Type*, NameDecl*>
 2. Change type canonicalization to not strip field names off tuples, and change type conversion logic to use canonical types again.

Also adds some stuff to the todo list, destined to never be short.

Swift SVN r141
2010-08-04 03:35:53 +00:00
Chris Lattner
807a82cd3d Resolve a fixme involving precedence of juxtaposition.
Swift SVN r140
2010-08-04 00:34:27 +00:00
Chris Lattner
04f7a08621 add support for tuple field access with ".", e.g.:
var a : (int, var f : int, int);
  var b = a.field0+a.field1+a.f;

This also eliminates TupleConvertExpr.

Swift SVN r137
2010-08-03 06:55:08 +00:00
Chris Lattner
23cca34bae FIXME fixed!
Swift SVN r132
2010-08-03 04:06:56 +00:00
Chris Lattner
c6499fe1ed Fixme patrol, clean some up.
Swift SVN r131
2010-08-01 07:09:40 +00:00
Chris Lattner
08fead5f63 rework func scope insertion so that recursion works, next up: vars.
Swift SVN r127
2010-08-01 05:07:59 +00:00
Chris Lattner
9b30ba0b2c refactor function body parsing+sema a bit.
Swift SVN r126
2010-08-01 04:55:49 +00:00
Chris Lattner
b3c9942644 Rework handling of sequence expressions and juxtaposition to eagerly bind arguments to functions. This means that in situations like:
foo (_0)  bar (_0)

that _0 will be bound properly and individually to foo and bar when they are functions, but if they aren't, then this is just one big 4-element sequence.

Swift SVN r115
2010-07-30 17:53:43 +00:00
Chris Lattner
667078650a Implement support for anonymous closure arguments. For example, we can now compile this:
var func6 : ((int,int) -> int) -> ();  // Takes a function, returns nothing.
func funcdecl5() {
  func6(_0 + _1);         // Closure with two named anonymous arguments
}
into:

  (apply_expr type='()'
    (declref_expr type='(int, int) -> int -> ()' decl=func6)
    (closure_expr type='(int, int) -> int'
     (anondecl '_0' type='int')
     (anondecl '_1' type='int')
     (tuple_expr type='int'
      (binary_expr '+' type='int'
       (declref_expr type='int' decl=_0)
       (declref_expr type='int' decl=_1))))))))

However, there are still some problems with this (and we're definitely not doing type inference yet, all anon args are assumed 'int').

Swift SVN r111
2010-07-28 06:25:16 +00:00
Chris Lattner
bb0fecffa6 fix an error recovery bug that lead to a crash.
Swift SVN r110
2010-07-27 21:46:09 +00:00
Chris Lattner
6d9d480d52 Allow optional = after func with a body.
Swift SVN r106
2010-07-27 20:21:04 +00:00
Chris Lattner
e842e93c89 improve error recovery for var decls and simplify parser code.
Swift SVN r105
2010-07-27 06:57:02 +00:00
Chris Lattner
4cba5da90e Improve error recovery (and clean up code!) on a malformed func decl
Swift SVN r104
2010-07-27 06:54:43 +00:00
Chris Lattner
ce55229f0f Allow arbitrary expressions as the body of a function, don't require brace-expr.
Swift SVN r103
2010-07-27 06:36:04 +00:00
Chris Lattner
874421d4ce Implement AST and Sema support for auto-closures. We now parse:
var closure1 : () -> int = 4;  // Function producing 4 whenever it is called.
var closure2 : (int,int) -> int = 4; // Has some (dead) arguments.

into:

(vardecl 'closure1' type='() -> int'
 (closure_expr type='() -> int'
  (integer_literal type='int' value=4)))
(vardecl 'closure2' type='(int, int) -> int'
 (closure_expr type='(int, int) -> int'
  (integer_literal type='int' value=4)))


Swift SVN r101
2010-07-27 06:27:02 +00:00
Chris Lattner
fef3e71b42 stub out parsing of func declarations.
Swift SVN r95
2010-07-27 05:32:16 +00:00
Chris Lattner
883efc284b various cleanups to fixmes. Move a parsing check from sema to parser.
Swift SVN r91
2010-07-25 22:48:47 +00:00
Chris Lattner
fa78da101b implement lazy construction of canonical types, ala clang. This only affect tuples at the moment, but will affect type aliases someday.
Swift SVN r90
2010-07-25 22:41:05 +00:00
Chris Lattner
4740573188 tidy up some dead code in parser, rearrange readme
Swift SVN r89
2010-07-25 22:15:45 +00:00
Chris Lattner
7e0123c768 Kill off add/sub/mul/div as special AST nodes. Instead, + is just yet-another identifier token and BinaryExpr is a generalized infix call expression.
Swift SVN r88
2010-07-25 19:16:45 +00:00
Chris Lattner
5562fc3cff Actually form ApplyExprs. We're not checking that the actual argument matches the formal argument for a function yet, but we can parse some nice stuff like:
var func3 : () -> () -> ();     // Takes nothing, returns a function.
var call4 = func3()();

into:
(vardecl 'call4' type='()'
 (brace_expr type='()'
  (apply_expr type='()'
   (apply_expr type='() -> ()'
    (declref_expr type='() -> () -> ()' decl=func3)
    (tuple_expr type='()'))
   (tuple_expr type='()'))))


Swift SVN r86
2010-07-25 05:57:53 +00:00
Chris Lattner
6c89184aee rework sequence handling, we still build an incorrect AST: this time we build a BraceExpr to represent it.
Swift SVN r84
2010-07-25 05:27:15 +00:00
Chris Lattner
cd99eee0c6 Add parser support and stub out a SemaExpr callback for sequence exprs, the foundation of function calls.
Swift SVN r83
2010-07-24 22:07:23 +00:00
Chris Lattner
9b42d1b273 enhance parenexpr to be tupleexpr. The grouping paren case is just a special case of a tuple literal with one child.
Swift SVN r81
2010-07-24 21:24:44 +00:00
Chris Lattner
4a2ea23b23 Enhance the parser to parse infix decls. The AST it constructs is still not correct though. We have no way to represent function calls yet!
Swift SVN r80
2010-07-24 20:59:00 +00:00
Chris Lattner
94110869e0 add support for parsing attribute lists, and add the first attribute, infix=42. It is now parsed and slammed into the AST, but not used.
Swift SVN r79
2010-07-24 20:44:56 +00:00
Chris Lattner
2bafb0e8fb Introduce new NamedDecl and FuncDecl classes. The difference between the two is syntactic sugar, so most clients want NamedDecl. This doesn't implement FuncDecl yet, which isn't a high prio for me in the short term.
Swift SVN r77
2010-07-24 19:09:09 +00:00
Chris Lattner
9a0d6c735a change the handling of nullable so that hte parser actually checks for the error and only invokes sema if the inputs are valid, tidying up some code.
Swift SVN r76
2010-07-24 18:52:46 +00:00
Chris Lattner
315107d5c6 Use the new NullablePtr<> class to allow better error recovery when parsing invalid expressions.
Swift SVN r74
2010-07-24 18:48:37 +00:00
Chris Lattner
1103ff5227 Implement basic parser support for brace expressions.
Swift SVN r69
2010-07-23 18:33:49 +00:00
Chris Lattner
58185415a1 now that we have name lookup, we can implement references to
other values.  crazzay.


Swift SVN r67
2010-07-23 05:48:20 +00:00
Chris Lattner
f248ffb53a Introduce a scope abstraction, the next step to implementing
name lookup.


Swift SVN r65
2010-07-23 04:37:16 +00:00