Comments (9)
try using timer to see line number steps/goto's
from please.
"end function" not working:
After checking goto_stack's functions' local_variables and index_called_froms, it seems that actually end function
(for user-defined functions) needs to act more like return function
--> otherwise once the interpreter gets to the end of the function, it keeps reading, instead of going to where it might have been called from.
from please.
Maybe move functions from variable_dictionary
to goto_stack
?
from please.
check_function(): i = function.index_called_from = None <-- goto_stack = [...] but goto_stack[-1][1].index_called_from = None
from please.
Issue found: Tracked index_called_from for each item in goto_stack: for some reason all recursive instances have the same index_called_from (they should have different index_called_from's; i.e. the first call should have been made outside the function).
Possible fix(es):
- Make deep copy? (understand pass by ref/val/other)
- A separate stack/list of indices?
from please.
Problem 1: When trying to assign a function output to a variable, it seems the variable is created in the global variable_dictionary instead of the local function local_variables, and
Problem 2: the value does not seem to be passed along.
- Correct debug output at line 3:
output_variable = answer
,output_value = 1
; i.e. answer = 1. - Example incorrect debug output at line 7:
answer = None
. - Example incorrect debug output at line 8:
output_value = None
. - Example incorrect print output at line 15:
step 3: output = None
.
Test 0c98e2c with:
please define function fibonacci with number
please if variable number equals zero then return zero
please if variable number equals one then return one
please assign variable number minus one to subresult
please assign use function fibonacci on variable subresult to variable answer
please note assign use function fibonacci on variable number minus one to variable answer
please print answer = variable answer
please return variable answer
please end function
please assign use function fibonacci with zero to variable output
please print step 1: output = variable output
please assign use function fibonacci with one to variable output
please print step 2: output = variable output
please assign use function fibonacci with two to variable output
please print step 3: output = variable output
from please.
should output:
step 1: output = zero
step 2: output = 1
answer = 1
step 3: output = 1
from please.
not quite closed: test with:
please define function fibonacci with number
please if variable number equals zero then return zero
please if variable number equals one then return one
please assign variable number minus one to subresult
please assign use function fibonacci on variable subresult to variable answer
please note assign use function fibonacci on variable number minus one to variable answer
please print answer = variable answer
please return variable answer
please end function
please assign use function fibonacci with zero to variable output
please print step 1: output = variable output
please assign use function fibonacci with one to variable output
please print step 2: output = variable output
please assign use function fibonacci with two to variable output
please print step 3: output = variable output
please assign use function fibonacci with three to variable output
please print step 4: output = variable output
this incorrectly outputs:
step 1: output = zero
step 2: output = 1
answer = 1
step 3: output = 1
answer = 1
answer = 1
step 4: output = 1
when it should output:
step 1: output = zero
step 2: output = 1
step 3: output = 1
step 4: output = 2
[EDIT:]
Actually, with the code above as-is, it's not actually fibonacci --> the output IS CORRECT.
What does not work is using two recursive calls within the function (even if assigning to separate variables first).
from please.
v0.1.0 Interpreter --> v0.2.0 Transformer (translates to Python code)
from please.
Related Issues (20)
- for loop should check if in_function HOT 1
- maybe separate goto list for functions? (see #46) HOT 1
- just make a compiler ("translator")? HOT 1
- fix transformer.py to match expected output HOT 1
- fix transformer.py to create pseudo-fibonacci code properly HOT 1
- codepen web GUI instead of relying on Terminal? HOT 1
- certain multiline if-statements not tabbing correctly
- end if/for/function -> add done if/for/function
- Better string interpolation ideas? HOT 1
- add better variable/list creation phrasing? ('to' keeps being transcribed as '2') HOT 4
- some variables should not have been created
- consolidate into one regex in check_use(sentence0
- "3 00" -> "300" :) but "some words" -> "somewords" :(
- ability to edit earlier lines?
- add exceptions
- higher-level programming? HOT 1
- make as editor plugin?
- other natural languages? (i.e. besides English)
- other programming languages? (i.e. besides Python)
- ability to learn/search/recognize/suggest design pattern templates? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from please.