Re: [Vala] Worried about the state of Genie

2013-09-10 Thread Luca Bruno

On 10/09/2013 06:00, Landon Blake wrote:

I have some interest in making small improvements to Genie. I've been
wanting to learn more Vala programming...and Genie seems like a great
little language. I think this might be a cool project. (I think both Genie
and Vala are important for to make Gnome programming more accessible to
more programmers.)

I'd obviously would need to start by looking at the Vala source code files
for Genie. I'm a little confused at how Genie works. I read on the Genie
web page that it compiles down to byte code like Vala, yet it is written in
Vala. That makes me think it would work more like an interpreted language
than a compiled one...but I could be missing something obvious.

I do know a bit about parsing, and have written some fairly gnarly parsers
before.


Your vision of Genie is quite complex :-) Forget about what you said.

This is how vala works: lexer - parser - analysis - codegen.
Genie only has its own lexer and parser. It's just 3 files:
- https://git.gnome.org/browse/vala/tree/vala/valagenieparser.vala
- https://git.gnome.org/browse/vala/tree/vala/valageniescanner.vala
- https://git.gnome.org/browse/vala/tree/vala/valagenietokentype.vala

In other words, the only difference between Vala and Genie is the 
syntax, the semantics is the same for both Vala and Genie. The code is 
really really straightforward to understand.


Best regards,

___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Worried about the state of Genie

2013-09-10 Thread Evan Nemerson
On Mon, 2013-09-09 at 21:00 -0700, Landon Blake wrote:
 I have some interest in making small improvements to Genie. I've been
 wanting to learn more Vala programming...and Genie seems like a great
 little language. I think this might be a cool project. (I think both Genie
 and Vala are important for to make Gnome programming more accessible to
 more programmers.)
 
 I'd obviously would need to start by looking at the Vala source code files
 for Genie. I'm a little confused at how Genie works. I read on the Genie
 web page that it compiles down to byte code like Vala, yet it is written in
 Vala. That makes me think it would work more like an interpreted language
 than a compiled one...but I could be missing something obvious.

I'm not sure where you're looking, but that's not true.  Genie is
compiled by valac to C (just like Vala) which is then compiled by a C
compiler into native code.

Internally, Genie uses the same AST as Vala, which is why it is part of
the Vala project.  The AST is not what is used when executing the code—
it is merely an intermediate representation which is part of the
compiler.  If that's what made you think bytecode, you should read the
Wikipedia page on ASTs:
https://en.wikipedia.org/wiki/Abstract_syntax_tree


-Evan

___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] [PATCH] [Genie] Add coalescing functionality to Genie

2013-09-10 Thread Steven Oliver
Vala Devs,
I originally attached this patch to:
https://bugzilla.gnome.org/show_bug.cgi?id=620133

Upon further review though I'm not really sure if the patch and the bug
report are related. Given that, I've decided to re-post the patch here. I
think it's still worth committing even if it doesn't solve the
aforementioned bug.

Steven N. Oliver
From f7dd5161bc35306b2ff8ad12e4d8a5e16f32c773 Mon Sep 17 00:00:00 2001
From: Steven Oliver oliver.ste...@gmail.com
Date: Mon, 9 Sep 2013 17:17:22 -0400
Subject: [PATCH] [Genie] Add coalescing function

---
 vala/valagenieparser.vala| 11 +++
 vala/valagenietokentype.vala |  1 +
 2 files changed, 12 insertions(+)

diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index f479905..ad84415 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -1520,6 +1520,17 @@ public class Vala.Genie.Parser : CodeVisitor {
return left;
}
 
+Expression parse_coalescing_expression () throws ParseError {
+   var begin = get_location ();
+   var left = parse_conditional_or_expression ();
+   if (accept (TokenType.OP_COALESCING)) {
+   var right = parse_coalescing_expression ();
+   return new BinaryExpression (BinaryOperator.COALESCE, 
left, right, get_src (begin));
+   } else {
+   return left;
+   }
+   }
+
Expression parse_conditional_or_expression () throws ParseError {
var begin = get_location ();
var left = parse_conditional_and_expression ();
diff --git a/vala/valagenietokentype.vala b/vala/valagenietokentype.vala
index 920a96a..df78e22 100644
--- a/vala/valagenietokentype.vala
+++ b/vala/valagenietokentype.vala
@@ -107,6 +107,7 @@ public enum Vala.Genie.TokenType {
OF,
OUT,
OP_AND,
+   OP_COALESCING,
OP_DEC,
OP_EQ,
OP_GE,
-- 
1.8.3.1

___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list