module main
import glloq
function main = |args| {
var maBoite = boite():
ajouter(): trois(): alumettes():
ajouter(): quatre(): cailloux():
enlever(): une(): alumette()
combien(): de(): cailloux(): dans(maBoite)
combien(): de(): alumettes(): dans(maBoite)
}
Last active
December 14, 2015 16:59
le "Glloq", 1er DSL pour enfants en Golo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module glloq | |
function boite = -> DynamicObject(): | |
op(""): | |
value(0): | |
nbCailloux(0): | |
nbAllumettes(0): | |
define("alumette", |this| { | |
if this: op(): equals("+") { this: nbAllumettes(this: nbAllumettes() + this: value())} | |
if this: op(): equals("-") { this: nbAllumettes(this: nbAllumettes() - this: value())} | |
return this | |
}): | |
define("caillou", |this| { | |
if this: op() == "+" { this: nbCailloux(this: nbCailloux() + this: value())} | |
if this: op() == "-" { this: nbCailloux(this: nbCailloux() - this: value())} | |
return this | |
}): | |
define("alumettes", |this| { | |
return this: alumette() | |
}): | |
define("cailloux", |this| { | |
return this: caillou() | |
}): | |
define("ajouter", |this| { | |
this: op("+") | |
return this | |
}): | |
define("enlever", |this| { | |
this: op("-") | |
return this | |
}): | |
define("une", |this| { | |
this: value(1) | |
return this | |
}): | |
define("un", |this| { | |
this: value(1) | |
return this | |
}): | |
define("deux", |this| { | |
this: value(2) | |
return this | |
}): | |
define("trois", |this| { | |
this: value(3) | |
return this | |
}): | |
define("quatre", |this| { | |
this: value(4) | |
return this | |
}) | |
function combien = -> DynamicObject(): | |
quoi(""): | |
define("de", |this| { | |
return this | |
}): | |
define("alumettes", |this| { | |
this: quoi("alumettes") | |
return this | |
}): | |
define("cailloux", |this| { | |
this: quoi("cailloux") | |
return this | |
}): | |
define("dans", |this, boite| { | |
if this: quoi(): equals("alumettes") { println(boite: nbAllumettes() + " alumettes") } | |
if this: quoi(): equals("cailloux") { println(boite: nbCailloux() + " cailloux") } | |
return this | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
on obtient :
4 cailloux
2 alumettes