[SOLVED] PNF: Even Though I Passed true to Function, Always Puts false
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I know that the problem is somewhere in the file pnf.hpp. I suspect that it changes when I'm calling the function.
This set of tools is my best experience (real world), for developing compilers and interpreters. I have been working on it since I was 15, and with some small help, I believe that I can get it to have all the features of C.
First big goal, a milestone to achieving my actual goal, not really a goal, but milestone: Have all the same features as C, essentially.
I am getting better at debugging, and hopefully, better at posting on linuxquestions.org. Thanks!
Sample test file:
Code:
funcdef 0V a(0V);
funcdef 0V b(var a: number);
funcdef 0V c(var b: string, var c: number);
funcdef 0V d(var d: string, var e: number, var f: number);
funcdef 0V e(0V);
funcdef 0V f(0V);
funcdef 0V g(var g: string);
funcdef 0V h(0V);
funcdef 0V i(var h: boolean);
funcdef 0V j(0V);
funcdef var: number k(0V);
funcdef var: boolean l(0V);
funcdef var: number, var: boolean m(0V);
funcdef 0V n(var a: boolean, var b: number);
funcdef 0V o(var a: number);
function 0V a(0V)
{
println "a()";
fret;
};
function 0V b(var a: number)
{
println "b()";
load aload 77;
fparameter 0V b(var a: number) a number number;
print '"';
fparameter 0V b(var a: number) a number;
print;
println '"';
fret;
};
function 0V c(var b: string, var c: number)
{
println "c()";
fret;
};
function 0V d(var d: string, var e: number, var f: number)
{
println "d()";
fret;
};
function 0V e(0V)
{
println "e()";
fret;
};
function 0V f(0V)
{
println "f()";
fret;
};
function 0V g(var g: string)
{
println "g()";
fret;
};
function 0V h(0V)
{
println "h()";
funccall 0V a(0V);
fret;
};
function 0V i(var h: boolean)
{
println "i()";
fparameter 0V i(var h: boolean) h boolean;
println;
fret;
};
function 0V j(0V)
{
println "j()";
funccall 0V h(0V);
fret;
};
function var: number k(0V)
{
println "k()";
load function var: number k(0V) rvalue 0 : 76;
fret;
};
function var: boolean l(0V)
{
println "l()";
load function var: boolean l(0V) rvalue 0 : true;
fret;
};
function var: number, var: boolean m(0V)
{
println "m()";
load function var: number, var: boolean m(0V) rvalue 0 : 75;
load function var: number, var: boolean m(0V) rvalue 1 : true;
fret;
};
function 0V n(var a: boolean, var b: number)
{
println "n()";
print "Values: ";
fparameter 0V n(var a: boolean, var b: number) a boolean;
print;
print " ";
fparameter 0V n(var a: boolean, var b: number) b number;
println;
fret;
};
function 0V o(var a: number)
{
println "o()";
print "Value: ";
fparameter 0V o(var a: number) a number;
println;
fret;
};
funccall 0V a(0V);
funccall 0V b(22);
funccall 0V c("true", 77);
funccall 0V d("hello", 76, 79);
funccall 0V e(0V);
funccall 0V f(0V);
funccall 0V g("not a toy.");
funccall 0V h(0V);
funccall 0V i(true);
funccall 0V j(0V);
println "";
funccall var: number k(0V);
load rvalue 0;
print "The value returned was: ";
println;
println "";
funccall var: boolean l(0V);
load rvalue 0;
print "The value returned was: ";
println;
println "";
funccall var: number, var: boolean m(0V);
load rvalue 0;
print "The first return value was: ";
println;
load rvalue 1;
print "The second return value was: ";
println;
println "";
funccall 0V n(true, 99);
println "";
funccall 0V o(62);
end 0;
When the interpreter, pnf, is run on the above file, it produces this output:
Code:
a()
b()
"77"
c()
d()
e()
f()
g()
h()
a()
i()
v2: false
false
j()
h()
a()
k()
The value returned was: 76
l()
The value returned was: true
m()
The first return value was: 75
The second return value was: true
n()
Values: v2: false
false 99
o()
Value: 62
It "should" produce this output:
Code:
a()
b()
"77"
c()
d()
e()
f()
g()
h()
a()
i()
v2: true
true
j()
h()
a()
k()
The value returned was: 76
l()
The value returned was: true
m()
The first return value was: 75
The second return value was: true
n()
Values: v2: true
true 99
o()
Value: 62
Don't know exactly where the bug is, but probably in PARAMF or PARAMF2 instructions. Those are jump to case labels prefixed with "I", in PNF::execute(). I don't know exactly what and where the bug is though...
@des_a - There is no question in your post which could realistically be answered by anyone else.
Repeatedly restating that you are creating a suite of languages which may someday include features which are only imagined at this time is irrelevant, as is your knowledge of github and the intended license. You have been asked in the past to not post threads which become endless discussions of your PNF language which lead nowhere and can have no answer, and this thread has every indication of being yet another of those. If this thread develops in that way it will be closed.
Reduce your test case code to a minimal, repeatable example which includes everything necessary for others to understand what you are asking without reliance on knowledge of your PNF language itself and without asking others to build your interpreter or run a precompiled binary, or to sift through your repo for clues to understand your question.
If it is an interpreter error then add debugging code to your interpreter which will allow you to understand what is happening. If after doing that you still cannot understand what is happening then you will at least have isolated the code to a small example along with runtime variable values which may be evaluated independently of your PNF syntax. At that point you will be prepared to post a clear question which others may be able to answer. Please make that effort.
Step through it with a debugger?
Edit:
A casual glance, a very casual glance cause this header file is huge, makes me wonder about your usage of "new", etc.
Go run your thing through valgrind, too. Just in case.
Also, I'm suspecting some sort of copy constructor failure, but again, this ain't fun to look through.
AlsoČ, seeing how you don't seem to bother with curlies very much when it comes to if's, it's not impossible that you messed up somewhere because of it.
Don't save in the wrong places, especially when you're still developing it. You can optimize later.
Oops! I'd forgotten to use the debugger! This is the first real world use I've used the debugger for. The rest has been accedemic.
Quote:
AlsoČ, seeing how you don't seem to bother with curlies very much when it comes to if's, it's not impossible that you messed up somewhere because of it.
I've adopted a style from a book. If the body of the if or else is one line, I omit the curly braces. Messed up by mistake on my alignment of my switch statement, but still works there...
The problem was I was asking to set the index to the Boolean value of the %accumulator. I needed to set it to number. Why? What I am trying to do with that instruction, is to get the function number from the %accumulator. This should be a number value. I was therefore, asking for the wrong function in just that part of the code. I guess it still matches another function...
Reduce your test case code to a minimal, repeatable example which includes everything necessary for others to understand what you are asking without reliance on knowledge of your PNF language itself and without asking others to build your interpreter or run a precompiled binary, or to sift through your repo for clues to understand your question.
I was asking for help on a bug, which I described.
If it is an interpreter error then add debugging code to your interpreter which will allow you to understand what is happening. If after doing that you still cannot understand what is happening then you will at least have isolated the code to a small example along with runtime variable values which may be evaluated independently of your PNF syntax. At that point you will be prepared to post a clear question which others may be able to answer. Please make that effort.
I believe you are talking about the WRITE technique. I use and remember to use that, all the time. There was extra put there for that. I just forgot to use the debugger.
Please review the Site FAQ for guidance in posting your questions and general forum usage. Especially, read the link in that page, How To Ask Questions The Smart Way.
I will read that before posting another bug, if I do need to.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.