This repository has been archived by the owner on Jul 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates ------------ - Added variables - Temporal variable created! - Now you can ask and store the answer (Pregunta y guardalo) - Code comments using ( comentario ) - Ignored some dialog auxiliary chars: [ . , y ]
- Loading branch information
Showing
20 changed files
with
328 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
venv | ||
build | ||
*.pyc | ||
*.spec | ||
*.egg* | ||
src/__pycache__ | ||
lib/__pycache__ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# :chart_with_upwards_trend: CHANGELOG | ||
--- | ||
|
||
### 0.0.1.dev1 | ||
##### May 17th, 2019 | ||
|
||
###### Updates | ||
- [x] Added variables | ||
- [x] Temporal variable created! | ||
- [x] Now you can ask and store the answer (Pregunta y guardalo) | ||
- [x] Code comments using *( comentario )* | ||
- [x] Ignored some dialog auxiliary chars: *[ . , y ]* |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# :memo: TODO | ||
--- | ||
|
||
Estructura: | ||
- [x] Asignar variables | ||
- [x] Evaluar variables | ||
- [ ] Funciones (¿Módulos en una carpeta especial?) | ||
- [x] Comentarios | ||
- [ ] Añadir acentos (UTF-8) | ||
Instrucciones: | ||
- [x] Di (println) | ||
- [x] Escribe (print) | ||
- [x] Pregunta (input) | ||
- [x] Guarda | ||
|
||
Control: | ||
- [ ] If | ||
- [ ] If .. Else | ||
- [ ] If .. Else If | ||
- [ ] If .. Else If .. Else | ||
- [ ] While | ||
- [ ] For |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.1.dev1 |
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Alfred. | ||
(La instrucción "Escribe" | ||
muestra el texto sin un salto de línea) | ||
Escribe "Un \"cachito\" de texto ". | ||
(La instrucción "Di" | ||
muestra el texto con un salto de línea) | ||
Di "y otra porción.". |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(Todos los programas | ||
empiezan llamando a Alfred) | ||
|
||
Alfred, di "¡Hola Batman!". |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Alfred, | ||
|
||
(Alfred puede preguntar para recibir datos | ||
por la entrada estándar. | ||
La respuesta se guarda en una variable temporal | ||
y has de pedirle que te la guarde en otro lado) | ||
Pregunta "¿Cuál es tu nombre?: " y guardalo en nombre. | ||
Escribe "Encantado de conocerte ", escribe nombre y di ".". | ||
|
||
(También puede preguntar sin decir nada) | ||
Escribe "¿Te apetecen magdalenas? ". | ||
Pregunta y di "¡Pues ya me las he comido todas!". |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
|
||
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from symbols import symbols,_tmpvar | ||
|
||
class Node(): | ||
def eval(self): | ||
raise NotImplementedError() | ||
|
||
class InstructionList(Node): | ||
def __init__(self, child=list()): | ||
self.child = child | ||
def __repr__(self): | ||
return "<InstructionList {}>".format(self.child) | ||
def __iter__(self): | ||
return iter(self.child) | ||
def eval(): | ||
ret = list() | ||
for instruction in self.child: | ||
result = instruction.eval() | ||
if res is not None: | ||
ret.append(result) | ||
return ret | ||
|
||
class Primitive(Node): | ||
def __init__(self,value): | ||
self.value = value | ||
def __repr__(self): | ||
return "<Primitive {} ({})>".format(self.value, self.value.__class__) | ||
def eval(self): | ||
return self.value | ||
|
||
class Identifier(Node): | ||
def __init__(self,name): | ||
self.name = name | ||
def __repr__(self): | ||
return "<Identifier {} ({})>".format(self.name, self.eval()) | ||
def eval(self): | ||
return symbols.get(self.name) | ||
def assign(self, value): | ||
symbols.set(self.name,value) | ||
|
||
class Assignment(Node): | ||
def __init__(self,name,value=Identifier(_tmpvar)): | ||
self.name = name | ||
self.value = value | ||
def __repr__(self): | ||
return "<Assignment {} ({})>".format(self.name, self.value) | ||
def eval(self): | ||
value = self.value.eval() | ||
self.name.assign(value.eval()) | ||
|
||
class Stdin(Node): | ||
def __init__(self,text): | ||
self.text = text | ||
def __repr__(self): | ||
return "<Input {}>".format(self.text) | ||
def eval(self): | ||
value = self.text.eval() | ||
if not isinstance(value, str): | ||
raise TypeError("[x] Sólo se puede preguntar texto.") | ||
response = input(value) | ||
symbols.set(_tmpvar,Primitive(response)) | ||
|
||
class Stdout(Node): | ||
def __init__(self,text,end='\n'): | ||
self.end = end | ||
self.text = text | ||
def __repr__(self): | ||
if self.end == '': | ||
return "<Print {}>".format(self.text) | ||
else: | ||
return "<Println {}>".format(self.text) | ||
def eval(self): | ||
print(self.text.eval(),end=self.end) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Symbols(): | ||
def __init__(self): | ||
self.identifiers = dict() | ||
def set(self, id, value): | ||
self.identifiers[id] = value | ||
def get(self, id): | ||
return self.identifiers.get(id,None) | ||
|
||
_tmpvar = "$-tmp-$" | ||
symbols = Symbols() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Dependencies | ||
ply | ||
ply>=3.11 | ||
|
||
# Dev Dependencies | ||
PyInstaller | ||
setuptools>=41.0.1 | ||
PyInstaller>=3.4 |
Oops, something went wrong.