vala r1446 - in trunk: . vala
- From: jamiemcc svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1446 - in trunk: . vala
- Date: Mon, 26 May 2008 05:47:42 +0000 (UTC)
Author: jamiemcc
Date: Mon May 26 05:47:42 2008
New Revision: 1446
URL: http://svn.gnome.org/viewvc/vala?rev=1446&view=rev
Log:
2008-05-26 Jamie McCracken <jamiemcc gnome org>
* vala/valagenieparser.vala:
allow init block to be used in context.root namespace where
its parsed and converted to the "main" function
Modified:
trunk/ChangeLog
trunk/vala/valagenieparser.vala
Modified: trunk/vala/valagenieparser.vala
==============================================================================
--- trunk/vala/valagenieparser.vala (original)
+++ trunk/vala/valagenieparser.vala Mon May 26 05:47:42 2008
@@ -1952,7 +1952,7 @@
}
}
- Symbol parse_declaration () throws ParseError {
+ Symbol parse_declaration (bool is_root = false) throws ParseError {
comment = scanner.pop_comment ();
var attrs = parse_attributes ();
@@ -1964,6 +1964,9 @@
case TokenType.CLASS:
return parse_class_declaration (attrs);
case TokenType.INIT:
+ if (is_root) {
+ return parse_main_method_declaration (attrs);
+ }
return parse_constructor_declaration (attrs);
case TokenType.DELEGATE:
return parse_delegate_declaration (attrs);
@@ -2104,7 +2107,8 @@
}
void parse_namespace_member (Namespace ns) throws ParseError {
- var sym = parse_declaration ();
+
+ var sym = parse_declaration ((ns == context.root));
if (sym is Namespace) {
ns.add_namespace ((Namespace) sym);
} else if (sym is Class) {
@@ -2365,6 +2369,39 @@
}
}
+
+ Method parse_main_method_declaration (Gee.List<Attribute>? attrs) throws ParseError {
+ var id = "main";
+ var begin = get_location ();
+ DataType type = new VoidType ();
+ expect (TokenType.INIT);
+
+ var method = new Method (id, type, get_src_com (begin));
+ method.access = SymbolAccessibility.PUBLIC;
+
+ set_attributes (method, attrs);
+
+ method.binding = MemberBinding.STATIC;
+
+ var sym = new UnresolvedSymbol (null, "string", get_src (begin));
+ type = new UnresolvedType.from_symbol (sym, get_src (begin));
+ type.value_owned = true;
+ type = new ArrayType (type, 1, get_src (begin));
+ type.nullable = false;
+
+ var param = new FormalParameter ("args", type, get_src (begin));
+ method.add_parameter (param);
+
+
+ expect (TokenType.EOL);
+
+ if (accept_block ()) {
+ method.body = parse_block ();
+ }
+
+ return method;
+ }
+
Method parse_method_declaration (Gee.List<Attribute>? attrs) throws ParseError {
var begin = get_location ();
DataType type = new VoidType ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]