This project is read-only.

XMLmosaic : The Language

Below there is a copy of the latest (compatible with the latest Interpreter release) XMLmosaic Report. You may see it before deciding if you are going to use XMLmosaic or not. The report gives details on every thing that is possible with the language (syntax details). Each example was tested with the Interpreter at the stage that function was implemented. The entries are in chronological order, therefore it is easier for you to read the report from top to bottom instead of starting in the middle or another point.

The Report

This is a list of what XMLmosaic programming language can do up till today 12/4/2009 v 6.3.
(examples are included for the commands and also for syntax for general procedures)

make a procedure like in C# or C++ using { } to hold the commands and a ; as the line terminator
e.g. void Main()
{
command;
}

comments using // like in C# or C++ altough the terminator is still needed
e.g. // this is a comment;

creation of bool, int, double, and string variables like in C#
e.g.
// note that a file called vars.xml is made under My Documents\XMLO\ that holds all variable data during runtime;
string strtest;
int inttest;
bool booltest;
double doubletest;

assigning a value to bool, int, double and string variables like in C#
e.g.
// the values are verified to be the data type they are declared to be and strings are placed in ' ' such as in the

example below;
strtest = 'String';
inttest = 11;
booltest = True;
doubletest = 11.5;

output of a string (not from a variable) to the console using Console.WriteLine() like in C#
e.g.
// note that concatenation using the + char is supported, see examples below;
Console.WriteLine('Hello World');
Console.WriteLine('foobar');
Console.WriteLine('Success');
Console.WriteLine('bad' + 'string' + ' / ' + 'good ' + ' string');
Console.WriteLine('12' + ' can be written in words as ' + 'twelve');
Console.WriteLine('End' + ' of ' + 'program');

output of a variable to the console (including concatenation) using Console.WriteLine() like in C#
e.g.
booltest = True;
string strtest;
strtest = 'Dylan Borg';
booltest = True;
int finalint;
finalint = 2038;
// variable output using the console;
Console.WriteLine(strtest + ' is ' + booltest + ' and his index number is ' + finalint);

assigning the value of a variable to anothher variable like in C# (but if a string is convertable to int/bool/double it

will be automatically converted.
e.g.
// assigning a variable's value to another variable;
string givestr;
bool givebool;
int givint;
double givedbl;
givestr = strtest;
givebool = booltest;
givedbl = inttest;
givint = doubletest;

the use of Console.ReadKey()
e.g.
Console.ReadKey();

assigning Console.ReadLine() to a variable (reading rom the console)
e.g.
Console.WriteLine('Please enter a string!');
givestr = Console.ReadLine();
Console.WriteLine(givestr + ' was entered on this very console');

the usage (now mandatory) of solution files that include data about the classes included and the class containing void

Main;
e.g.
<Solution>
<Type>XMLmosaic Program</Type>
<StartClass>D:\Code\xmlmosaic\test\test\hello.xml</StartClass>
<Using></Using>
<Include>Include D:\Code\xmlmosaic\test\test\hello.xml;
Include D:\Code\xmlmosaic\test\test\extclass.xml;
</Include>
</Solution>

the creation of more than one procedure in one class and more than one class in a solution
e.g.
<Class>
<Type>XMLmosaic Class</Type>
<Method>
<Name id="1">Receive</Name>
<Code id="1">void Receive()
{
// sample Xmlmosaic code;
// console output;
Console.WriteLine('You have called upon Receive in extclass');
}
</Code>
</Method>
<Method>
<Name id="2">NameAge</Name>
<Code id="2">void NameAge()
{
// sample Xmlmosaic code;
Console.WriteLine('Please write down your name');
string name;
name = Console.ReadLine();
Console.WriteLine('Please write down your age as a number');
int age;
age = Console.ReadLine();
Console.WriteLine('Your name is ' + name + ' and you are ' + age + ' years old');
}
</Code>
</Method>
<Counter>
<Count>2</Count>
</Counter>
</Class>

the calling of a procedure from one of the classes included in the solution by the use of Include classname; statement
e.g.
extclass.Receive();
extclass.NameAge();

the creation of void procedures that take parameters of types bool, int, double and string as well as their calling
e.g.
//declaration;
<Method>
<Name id="3">FullName</Name>
<Code id="3">void FullName(string nameonly; string surname;)
{
// sample Xmlmosaic code;
Console.WriteLine('Your full name is ' + nameonly + ' ' + surname);
}
</Code>
</Method>
//calling;
Console.WriteLine('Enter your first name);
string firstname;
firstname = Console.ReadLine();
Console.WriteLine('Enter your last name);
string lastname;
lastname = Console.ReadLine();
extclass.FullName(firstname, lastname);

the redeclaration of a variable no longer creates an error as there is a safety mechanism to stop the creation of a

variable with the same name as another variable.
e.g.
//now this will not trigger an error;
string abc;
string abc;
abc = 'abcdefghijklmnopqrstuvwxyz';

the creation of a function of type string/int/double/bool (include return statement) (parameters are also supported like

in procedures)
e.g.
<Method>
<Name id="4">RetHello</Name>
<Code id="4">string RetHello()
{
string xyz;
xyz = 'Hello World';
return xyz;
}
</Code>
</Method>
//examples of other functions - the solution of a quadratic equation;
<Method>
<Name id="1">SolveTrinomialPos</Name>
<Code id="1">double SolveTrinomialPos(double a; double b; double c;)
{
double x;
double minb;
minb = b * -1;
double bsqr;
bsqr = b * b;
double frac;
frac = 4 * a * c;
double ta;
ta = 2 * a;
double expr;
expr = bsqr - frac;
double sqrexpr;
sqrexpr = Sqrt|expr;
double expr2;
expr2 = minb + sqrexpr;
x = expr2 / ta;
return x;
}
</Code>
</Method>
<Method>
<Name id="2">SolveTrinomialNeg</Name>
<Code id="2">double SolveTrinomialNeg(double a; double b; double c;)
{
double x;
double minb;
minb = b * -1;
double bsqr;
bsqr = b * b;
double frac;
frac = 4 * a * c;
double ta;
ta = 2 * a;
double expr;
expr = bsqr - frac;
double sqrexpr;
sqrexpr = Sqrt|expr;
double expr2;
expr2 = minb - sqrexpr;
x = expr2 / ta;
return x;
}
</Code>
</Method>


the assignment of a value returned by a function to avariable and then outputting it
e.g.
string abc;
abc = extclass.RetHello();
Console.WriteLine(abc);

the assignment of a mathematical expression (/,*,-,+) to int/double variables
e.g.
double x;
x = 1 + 10 * 34 - 4 / 2 * 23 - 4;
Console.WriteLine(x);
x = 2 + 3;
Console.WriteLine(x);
x = 5 - 3;
Console.WriteLine(x);
x = 5 * 4;
Console.WriteLine(x);
x = 100 / 4;
Console.WriteLine(x);
x = 20 * 4 / 2 + 10 * 2 - 7;
Console.WriteLine(x);
x = 1 / 2;
Console.WriteLine(x);
int y;
y = x;
Console.WriteLine(y);

the usage of int/double variables in mathematical expressions
e.g.
double x;
int i;
Console.WriteLine('Please enter a value for i');
i = Console.ReadLine();
i = i * 5;
Console.WriteLine(i);
Console.WriteLine('Please enter a value for x');
x = Console.ReadLine();
y = 3 * x - 3;
Console.WriteLine(y);

the usage of negative numbers in maths expressions
e.g.
double x;
x = -12;
Console.WriteLine(x);
x = -12 + 25;
Console.WriteLine(x);

the usage of the Sqrt| command in maths expressions
e.g.
double x;
x = 16;
x = Sqrt|x;
Console.WriteLine(x);
x = x * x;
Console.WriteLine(x);

the concatenation of strings and variables in an assigning of a value to a variable of type string (gives alternative to

concatenation in writelines)
e.g.
//The code;
double x;
x = Sqrt|100;
string ansx;
ansx = 'The answer for x is ' + x;
Console.WriteLine(ansx);
//means the same as this code;
double x;
x = Sqrt|100;
Console.WriteLine('The answer for x is ' + x);

the use of if..then..else statements in the format decribed in the example below. The statement may be made out of a

single if node, a single if node and a single else node or a single if node with many elseif node and a single else node.
the operators supported are (for like operators the value to compare to is like in visual basic):
== - is equal to
!= - is not equal to
) - more than
!( - is not less than
( - less than
!) - is not more than
)= - more than or equal to
(= - less than or equal to
!)= - is not more than or equal to
!(= - is not less than or equal to
like - is like
!like - is not like

Note that the bounds of the code to execute for evry condition are not defined like in C# (using {}) but by using [] (see

example). Inside the nodes the libne terminator is not ; but : (see example). Note that the statement is finished by a ;

after the end ] in the format: ];The if statement is considered as 1 instruction and the instrucrions in it are

subinstructions.
e.g.
if x == 10 then
[
Console.WriteLine('x is 10'):
]
elseif x == 5 then
[
Console.WriteLine('x is 5'):
Console.WriteLine('x is not 10'):
]
elseif x != 12 then
[
Console.WriteLine('x is 12'):
]
else
[
Console.WriteLine('this was the last resort'):
Console.WriteLine('x is not 10'):
Console.WriteLine('x is not 5'):
Console.WriteLine('x could be 12'):
];
Console.WriteLine('----------------------------------------------------');
x = 4;
if x == 10 then
[
Console.WriteLine('x is 10'):
]
elseif x !( 10 then
[
Console.WriteLine('x is more than 10'):
]
elseif x !) 10 then
[
Console.WriteLine('x is less than 10'):
]
else
[
];
Console.WriteLine('----------------------------------------------------');
x = 7;
if x !(= 5 then
[
Console.WriteLine('condition has been met'):
]
else
[
];
string teststr;
Console.WriteLine('----------------------------------------------------');
teststr = 'hello world';
if teststr like 'h*' then
[
Console.WriteLine('word begins with h'):
]
elseif teststr == 'fello' then
[
Console.WriteLine('word is fello'):
]
elseif teststr != 'hello' then
[
Console.WriteLine('word is not hello'):
]
else
[
];

looping using do until and do while loops that support all the operators supporting all the operators used in if

statements. The statement also uses the same methods of if statements that use the characters [ and ] to define bounds

and : as a line terminator.
e.g.
double x;
x = 0;
do until x == 5
[
x = x + 1:
Console.WriteLine(x):
];
Console.WriteLine('----------------------------------------------------');
x = 0;
do until x ) 5
[
x = x + 1:
Console.WriteLine(x):
];
Console.WriteLine('----------------------------------------------------');
x = 0;
do until x != 0
[
x = x + 1:
Console.WriteLine(x):
];
Console.WriteLine('----------------------------------------------------');
x = 0;
do until x ( -3
[
x = x - 1:
Console.WriteLine(x):
];
//do while loops have a similar syntax;

the use of Pi| in maths expressions to represent the vaue of Pi
e.g.
<Method>
<Name id="1">Area</Name>
<Code id="1">double Area(double r;)
{
double rsqr;
rsqr = r * r;
Area = Pi| * rsqr;
return Area;
}
</Code>
</Method>



Also note that all XMLmosaic source files are .xml files (you may ask for a sample file) and no .exe is produced. This

means that the XMLmosaic Interpreter is needed together with .NET 3.5 and its SP1 to run a program which is loaded into

the interpreter which runs the program. Console outputs are in fact made to the interpreter console. The interpreter has

been written using Visual Basic 2008 and .NET 3.5. The Interpreter works on both XP and Vista. A GUI (basic IDE) is now

available so as to aid in the correct production of solution files. XMLmosaic Translator can now translate XMLmosaic code

to Visual Basic.NET code and then compile it to a .NET assembly ready for exexcution.

For a .txt file version of the report (latest one) click this link : XMLmosaic report.txt

Some Useful Classes

You may also download the following two XML files which contain functions (not voids) which means they are used in the format: <varname> = <classname>.<funcname>(<params>); and code has to be written to get the variable to be passed (see the report for complete examples).

algebra.xml
arit.xml

For the complete Maths testing solution (including its VB representation and the exe compiled from it) click here: maths.zip (Remember to arrange the addresses in maths.xml to reflect the position of the files on your hard drive). Also the complete testing project used to test the interpreter and translator is avaiable as XMLmosaic code and as translated VB code and as a .NET assembly. Get ir here:test.zip.

Last edited Apr 17, 2009 at 9:29 AM by Borgdylan, version 15

Comments

No comments yet.