Skip to content

Instantly share code, notes, and snippets.

View pedrogk's full-sized avatar

Pedro Galvan pedrogk

View GitHub Profile
@pedrogk
pedrogk / CustomGrammar.cs
Last active September 24, 2016 00:12 — forked from pedro-ramirez-suarez/CustomGrammar.cs
Intelligent Personal Assistant
//Terminals
var cuantos = ToTerm("cuantos");
var cuantas = ToTerm("cuantas");
var cual = ToTerm("cual");
var que = ToTerm("que");
var cuando = ToTerm("cuando");
var tiene = ToTerm("tiene");
/* más aquí */
var number = new NumberLiteral("number");
var number2 = new NumberLiteral("number2");
var o = {
a: 2,
m: function(b){
return this.a + 1;
}
};
console.log(o.m()); // 3
// 'this' se refiere a 'o' cuya propiedad 'a' vale 2,
// así que m() regresa 3.
var o = {
a: 2,
m: function(b){
return this.a + 1;
}
};
// Asumamos que tenemos un objeto o, con propiedades a y b:
// {a: 1, b: 2}
// o.[[Prototype]] tiene las propiedades b y c:
// {b: 3, c: 4}
// Finalmente, o.[[Prototype]].[[Prototype]] es null.
// Así que la cadena de prototipos queda como
// {a:1, b:2} ---> {b:3, c:4} ---> null
console.log(o.a); // 1
// Existe una propiedad 'a' en o? Sí, y su valor es 1.