C++ :: Output Compiled Script Into Binary File - Scripting Tool Algorithms

Dec 25, 2014

I am working on a script compiler that must output compiled script into binary file. Compiling etc is not a problem. The problem is detecting some specific cases. Nothing seems to work. If it works, then it breaks as soon as i modify the script.

Here is example "script1":

Code:
1VAR1 c1 = 44
2VAR2 c2 = 66
3beginscript
4if(c1=44)
5do_nothing

[Code] ....

Second example "script2", when there can be also some command between ENDIF and ENDIF. In this case: do_nothing command.

Code:
1VAR1 c1 = 44
2VAR2 c2 = 66
3beginscript
4if(c1=44)
5do_nothing

[Code] ....

The INDEXES before each line are not in actual script. They are just to point YOU to specific lines. Although the INDEXes are in compiled script!! This is very important. As you see there can be simple IF_ENDIF and nested (more complex) IF_ENDIF.

i.e IF_ENDIF inside another IF_ENDIF.

There are also IF_ELSE_ENDIF and some other ones, but im trying to make simple IF_ENDIF work first.

ENDIF is "SPECIAL" command, the IF, DO_NOTHING are "usual" commands.

"Usual" commands must always jump over(!) the ENDIF. ALWAYS!!

They must "ignore" them!

One strong RULE is like this for usual commands: always jump over any ENDIF, not matter what. If there is one, two or more ENDIF's in a row, then just jump over them to the closest NEXT usual block command. If there is some "usual" block command between multiple ENDIFs, then jump to this command and this command must therefore check whats next command right after it. And do the same: check if next command is ENDIF, if yes, jump over it, until "usual" block command is found.

This is the place im stuck. When i some time ago thinked about some ideas, i saw some patterns. One of them was that: Seems like if its nested IF_ENDIF, then every usual block command jumps out of it, i.e. right after the final ENDIF of this current nested IF_ENDIF.

But as soon as i added do_nothing between the two ENDIFs the so called "pattern" broke. In script2 above you see index 11 is do_nothing. Ok its in nested IF_ENDIF it should jump out to command index 17. But no, because there is do_nothing between index 13 and 16. If we jump out at index 11, the command 14 would never execute. This is a BIG NO. One idea i was thinking and trying was to use STL::FIND, STL::FIND_IF to find next "usual" command after specific index. But my code seems to crash sometimes and not work always.

Code:
bool NextNonENDIF(int i) {
return (i!=98);
}
int findNextBlockCmd(vector<int>&vec, int curidx)

[Code] ....

Here i pass him the vector that contains all the command TYPES in current script. Each command has its own TYPE or better called unique ID in which way compiler knows what is what. So in this case im trying to find a command thats NOT "ENDIF", in other words im trying to find next usual command after specific type of command. Lets just say the TYPE or unique ID of do_nothing is 555, im trying to find it.

How i should continue with this? What to use maybe stl::stack, some custom command indexing, some sort of labelling for usual commands in nested IF_ENDIFs or what?

In general, look script2, and i ask: There is index 11, this guy should look if there is any usual block command left for him before the final ENDIF at index 16. If there is, jump to it. If there is none, jump out of this nested IF_ENDIF to index 17.

Question: how to do it? What algorithms to use? I can use STL, BOOST, whatever. And i can use C++11.

View 1 Replies


ADVERTISEMENT

C :: File Which Can Be Compiled In Linux Via GCC

Aug 16, 2013

I have a c file which can be compiled in Linux via GCC , but when I compile it in NetBeans via Cygwin or MinGW , it doesn't work and keeps throwing a segmentation fault.

View 14 Replies View Related

C++ ::  Compiled Function In A File

Oct 9, 2013

Today I am given an assignment to find the zeroes of a function using Newton-Raphson method. Till now, the input I gave to a program was data. But now the function (whose zeroes are to be calculated) is also an input.

Is there a way where I can compile and build a function into a file and during execution of my program open the file and run the machine-language code in it and get the return value?

View 3 Replies View Related

C++ :: Source File And Header File Are Not Compiled Together

Jan 30, 2013

My socket.cpp program got error. it showed "socket.h: no such file or directory". I had put my header file (socket.h) in the same place with my source file.

View 1 Replies View Related

C++ :: Echo Meaning In Bash Scripting

Apr 1, 2014

What does echo in a bash script mean?

The code I'm trying to understand says:

for((m=0; m<1;m++))
do
#assign the correct mechanism to run
RMFilename=${Mechanisms[m]}

[Code] .....

View 3 Replies View Related

C :: Configuration Tool That Edits Certain Parameters In File

Sep 15, 2014

I want to make a configuration tool that edits certain parameters in my C. file. My problem is that I don't have a clue on how to start making this.

View 12 Replies View Related

C :: Binary File Write By User Input Then Printing Binary File Data Out

Dec 6, 2013

Following is the program I wrote it basically takes 9 inputs and then save them into binary file. then print out the data stored in binary data and find inverse of it then print the inverse out. but its stuck in a loop somewhere.

Code:
#include <stdio.h>
int main() {
int a[3][3],i,j;
float determinant=0;
int x;
FILE *fp = fopen ("file.bin", "wb");

[Code] .....

View 6 Replies View Related

C++ :: How To Output All Possible Binary Combinations

Mar 4, 2014

I need to create a function that outputs all possible binary combinations. I'm really stumped on this. I have to do it with nested loops, and am not sure how to go about it. Below is what I tried so far.

The output should look like this:

00000000
00000001
00000010
00000011
00000100
...
11111110
11111111

Code:

void outputBinary(){
int a[2][2][2][2][2][2][2][2];
for (int i = 0; i < 2; i++){
for (int j = 0; j < 2; j++){

[Code] .....

View 2 Replies View Related

C/C++ :: 3 Led Output Binary Counter

Oct 4, 2014

I need to get up to speed in Embedded systems. I need to create a 3led binary counter, when an input is operated the it needs to count up using these leds from 0 to 7. I have written this so far and how to pulse a counter or interger to 7 and then reset back to 0.

int main (void) {
LED_Init_1();
LED_Init_2();
LED_Init_3();

[Code]......

View 2 Replies View Related

C++ :: Some Algorithms For Compressing Images?

Feb 16, 2014

RLE(Run Length Encoding)
using namespace std;
class Bitwriter{
private:

[Code]....

View 1 Replies View Related

C/C++ :: Analysis And Evaluation Algorithms?

Mar 25, 2015

#include <iostream>
#include <vector>
#include <list>

[Code].....

The problem is it's not finding the shortest path.

View 1 Replies View Related

C :: Positive Binary Output Function

Mar 27, 2013

I have written a function that takes in a positive decimal and returns its Binary equivalent; however, the output always adds an additional zero to the binary. What could I do to get rid of it?

If the number is 7, it outputs 0111 instead of 111.

Code:
#include <stdio.h>
void Dec(int n) {
if(n > 0)
Dec(n/2);
printf("%i", n%2);

[Code] ....

View 2 Replies View Related

C++ :: Output Address Of Variable In Binary?

Sep 24, 2014

How can I output the address of a variable in binary?

#include <iostream>
#include <sstream>
#include <string>
using namespace std;

[Code] ....

View 2 Replies View Related

C :: Time Scheduling Algorithms Program

Jan 20, 2014

I am an IT college student and this is a self-assigned project i have done in an attempt to learn programming in C AND at the same time how time scheduling of an OS works (Both done in order to prepare for upcoming semester exams) using FCFS ,SJF, RR and PS algorithms (planning on adding SRT too sometime soon). (took me 9 hours total work time including validations). What i wanna know is from more seasoned coders if i am on the right track. *cross fingers*

Code:

#include <stdio.h>
#include <stdlib.h>
#define P_Q 1000

int main(int argc, char *argv[])
{
float min_value,
}

[code]....

View 11 Replies View Related

C++ :: Text Editor Printing Algorithms?

Mar 26, 2013

They should apply for: backspace, return, regular char input, vertical scrolling. There is only one buffer, and it is not allowed to side scroll past max col, instead it must scroll down, appending the line cur_y + 1.

View 4 Replies View Related

C/C++ :: Sorting Algorithms And Comparison Count

Jan 30, 2014

I am trying to count the number of comparisons for each of the following sorting algorithms, Selection, Insertion, Bubble, Merge, and Quick sort. This is using an array of numbers that are sorted, reversed, and randomly arranged.

I currently increment the "number of comparison" variable before every conditional statement that compares two numbers and am getting the following results:

Number of Items in Array = 100
Selection: random = 5049; reverse = 5049; sorted = 5049;
Insertion: random = 2640; reverse = 5049; sorted = 99;
Bubble: random = 9207; reverse = 9900; sorted = 99;
Merge: random = 1221; revere = 988; sorted = 1028;
Quick: random = 690; revere = 587; sorted = 636;

View 1 Replies View Related

Visual C++ :: Analysis And Evaluation Algorithms

Mar 25, 2015

Undirected graph G = {V, E} is given by the list next to the DS. Let u, v of V. Construction of two paths algorithm A1 (u, v) and A2 (u, v) such that no edge in common and have the shortest total length.

View 1 Replies View Related

C :: Simple Decimal Input To Binary Output

Jun 22, 2013

I am learning c because I want to get back into programming microcontrollers, which I previously did in assembly. I wanted to make something fairly tight in terms of program memory and RAM to show me an output in binary form. When you are troubleshooting a file register or serial interface when you can see the actual bit values (on a small LCD for a micro-controller) and compare it to a datasheet.

Code:
#include <stdio.h>
#include <math.h>
int main() {
int i;
int decimaltoconvert;
int convertingarray[7];
int convertingarray2[7];

[Code] .....

Also, how might I go about putting that into a function that I could call?

View 6 Replies View Related

C++ :: Separate Binary String Every 4 Characters - How To Add Spaces To Output

Sep 28, 2014

I want to separate this binary string every 4 characters..I am trying to get a better understanding of how variables are stored in memory and I am looking at their binary address for a pattern..I see a pattern for the last 4 bits

#include <iostream>
#include <bitset>
int main() {
using namespace std;
int x[100];

[Code] ....

View 2 Replies View Related

C++ :: Creating Binary Calculator - Output Operation Of Subtraction

Feb 10, 2014

I need to create a binary calculator that outputs the operation of subtraction whenever you input 2 4 bit binary numbers. For example:

If I enter

1000
- 0111

View 1 Replies View Related

C/C++ :: Incorrect Output From Unsigned Binary To Decimal Program

Feb 2, 2015

This program has to convert an unsigned binary number into a decimal number. No matter what binary number I enter, however, it always outputs that the decimal number is 0.

My code is as follows:

#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
string binarynumber;
cout << "Enter an unsigned binary number up to 32 bits." << endl;

[Code] ....

And my output:

Enter an unsigned binary number up to 32 bits.
00001111
That number in decimal is 0

The output should have shown the binary number in decimal to be 15, and I cannot find my error.

View 6 Replies View Related

C++ :: Multi-level Algorithms For Date-driven Scheduling

Apr 18, 2012

What is Multi-level algorithms for date-driven scheduling?

View 8 Replies View Related

C++ :: Accept Signed Decimal Integer As Input And Output In Binary

Jan 29, 2015

Write a C++ application program to accept a signed decimal integer as input and output the equivalent 2s complement version in 16-bit binary. Include a space between every four bits in the output string. The input will only be processed by the application if it falls in the valid range that can be represented in 2s complement format with 16 bits. The range of a decimal number from - to + is -32768 to 32767.

View 3 Replies View Related

C++ :: Compiled Program Error Win32 Invalid

Nov 30, 2013

I am using visual studio 2012 on windows 7. but, when I have compiled my programs and run them on an older pc to test out its functions, I receive an error saying that the program is not a "valid win32 application." I have even tested this with a very simple hello world console application, but the problem still remains. Where is the error coming from? is the application corrupted during transport? (upload to internet) or are programs compiled on win 7 incompatible with win xp

View 6 Replies View Related

C++ :: Computer Restarts Every Time Program Is Compiled

Feb 26, 2013

I have a weird problem, my computer restarts imidiately after program writen in dev-cpp is compiled AND run. When I run any program, it lasts about 1 second, then program closes, and computer reboots. It doesn't matter whether program is writen now or earlier, my dev-cpp version is 4.9.9.2. Source code can be as simple as this:

#include <iostream>
#include <conio.h>
using namespace std;
int main() {
getch();
return 0;
}

and it restarts anyway...

View 2 Replies View Related

C++ :: How To Make (compiled) Code That Other Programmers Can Use (cross-platform)

Mar 29, 2013

(C++ question) I need to be able make a compiled code (like a .dll?) which other programmers can use on linux, win,, mac, etc.

The compiled code would simply do calculations and spit out an answer in memory.

I need it to have certain functions that they can easily call and understand (without actually seeing the source).

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved