X--+Programming+Language+-+Java+Source

=The X-- Programming Language=

About
X-- is a simple interpreted programming language written in Java. X-- is Turing complete and has its own Preprocessor.

It is based on the P'' Programming Language. The current version (1.2.3_2) only supports command line interaction, including interpreting, compiling, and binary execution.

Programs are compiled into Integer byte-code and interpreted by a scripting engine. The language is extremely minimal, but Turing complete. It has support for input and output, flow control, Macros, memory manipulation, and adder arithmetic. In short, given an extremely large, or unlimited amount of memory, this language can calculate any calculable calculation. Currently however programs have a hard restriction of 60KB of memory, or 30,000 'memory cells' to manipulate. Program size is restricted only by Storage Medium and RAM capacity.

How programs work
Programs have access to an array of 16 bit words- main memory. Programs execute instructions that involve manipulating this memory, such as +, which adds one to the current memory cell's value. To change the current memory location, the operators > and < are used to move the current memory position right and left, respectively. So the program - Adds three to a memory cell, moves one cell to the right, adds two to that cell, then moves back one to the left, and adds one again. The final values of the two memory cells would therefore be 4 and 2, respectively.

Programs have support for flow control as well, with the [ and ] operators. [ checks the current memory value. If it is ZERO, then it jumps to the next MATCHING ']'. ] then checks the current memory value, and if it is NON-ZERO then it jumps BACK to the previous MATCHING '['. So the program- Would add three to the current memory cell. It would then check the current memory cell to see if it is zero. Since it is not zero, the program will continue executing, subtracting one from the current memory cell. The following ']' then means that, since the value of the current memory cell is non-zero (it is 2), the program will jump back to the first '[' and begin execution again. This is in essence a while-loop and allows programs to do neat things, such as perform multiplication by addition, or division, or just addition in general.
 * +++[-] ||

Comments
Comments in X-- are any text included in between / and /. Comments are automatically removed from source files by the compiler.

Macros
X-- has a simple Preprocessor similar to C that allows programmers to reuse code easily. There are two basic preprocessor functions: #define and #place. #define allows programmers to define sections of code as reusable, and pass parameters to them, much in the way C Macros work. #place allows programmers to paste the contents of other files into source files, just as #include does in C. Macros have the syntax **#Macroname (Parameters,More Paremeters)**. Custom macros can take an unlimited amount of Parameters. Define a macro with **#define  (some,parameters) parameters >some[-<+]**. Sample Code given. The names of the parameters that appear in the code following the parentheses are replaced by the parameters given when the macro is invoked, as in normal function usage in C. Call a macro by placing # next to its name. e.g. **#My_Macro(23,25)**

Sample Macro Usage

//**header.xmm**// //**main.xmm**// The #defined macro is placed in a header file, which is #place'd into the source file, allowing access to the macro. To compile this, run and then Only the main source file needs to be given to the compiler or interpreter to run an X-- program.
 * #define  (f,s) wf >ws [-<+>]< / This adds two numbers together by using the second parameter as a loop counter / ||
 * #place 
 * 1) AddTwo (23,57) ||
 * java.exe -jar xmm_interpreter.jar -c main.xmm out.bin ||
 * java.exe -jar xmm_interpreter.jar -e out.bin ||

Sample Program and output: //**main.xmm**// .c\n, c\n,
 * #define  (x) wx.
 * 1) define  (r,s,t,u,v,w,x,y,z) cr,cs,ct,cu,cv,cw,cx,cy,cz,
 * 2) define  (f,s) wf >ws [-<+>]< / This adds two numbers together by using the second parameter as a loop counter
 * 3) AddTwo (23,57)
 * 1) Putstring (D,e,r,p,!,, , , ) / This prints 'Derp!' :D

[-] / Zero out out the Current Memory Cell

/ Get a number from stdin ^ > / Get another # from stdin ^ > c , < / Tell the user what's coming up [- < + >]<. / Get the sum / This is just proof of concept
 * 1) Putstring (P,i,c,k, ,a, ,n,u)
 * 2) Putstring (m,b,e,r,:, ,\b,\b, )
 * 1) Putstring (P,i,c,k, ,a, ,n,u)
 * 2) Putstring (m,b,e,r,:, ,\b,\b, )
 * 1) Putstring (T,h,e, ,s,u,m, ,=)
 * 1) AddTwo (78,12)

/ This stuff down here returns 1 or 0 - the inverse boolean value of the current mem cell. i.e. !(boolean)memory[memcell] [ [ - ] @ ] + @ || To run this program through the interpreter, use On windows, in order to run programs, you must open a command prompt interpreter. You can do this by pressing start and typing 'cmd.exe' and then hitting enter. Navigate to the location of the compiled .jar file by typing 'cd "c:\the location\of the\jar\file\"' You can find this information by looking at your Eclipse or Netbeans project folder, and copypasting the URL from explorer into the command prompt.
 * java.exe -jar xmm_interpreter.jar -f main.xmm ||

Sample output for //**main.xmm**//

**Downloads**
Source code is available to download, and is heavily commented.
 * ~ Version ||~ Download ||~ Notes ||
 * 1.2.3_2 || Java Source Code || Updated Version ***New** ||
 * 1.2.3_2 || Jar File || Compiled JAR file ***New** ||
 * 1.2.2_7 || Java Source Code || Old Version ||

**Reference**

 * ~ Commands ||
 * < #define (x,y) wx>wy || Defines a macro named 'Macro' that places the numerical values of x and y into two adjacent memory cells ||
 * < #place || Copies the contents of the file 'filename' into the current source code at compile time ||
 * < + ||< Add One to the current memory cell ||
 * < - ||< Subtract one from the current memory cell ||
 * < > ||< Move one memory cell to the right ||
 * < < ||< Move one memory cell to the left ||
 * < [ ||< If the current memory cell is 0, jump to the next matching ']' ||
 * < ] ||< If the current memory cell is not 0, jump to the previous matching ']' ||
 * < . ||< Print the value of the current memory cell as an integer ||
 * <, ||< Print the value of the current memory cell as a character ||
 * < $ ||< Get one character from Standard Input ||
 * < ^ ||< Get one 16 bit integer from standard Input ||
 * < @ ||< Halt the program and force exit ||
 * < c ||< Read the next character in the program as a character value into memory ||
 * < w ||< Read the next characters that are digits in the source file until another command is found as a 16 bit integer into memory. ||
 * < w ||< Read the next characters that are digits in the source file until another command is found as a 16 bit integer into memory. ||