Create MY Compiler Constriction Rule
LANGUAGE DESCRIPTION:
Data Types:
•
Dual (du) as double
•
Only as char
• Signal as bool
•
Partial as float
• Strand (str) as string
•
Single as int
Iterative statements:
• When loop //pre-incremental
• When loop //post-incremental
• makeit Whereas
loop
Conditional Statements:
• check
(if c++)
• last (else
c++)
• check
last (else if c++)
Comments (Multi
line + Single line):
• ::
(Single)
• =::= (Multi Line)
Line terminator:
•
?
Operators:
·
Increment (++)
·
decrement (--)
·
divide (/)
·
remainder (%)
·
multiply (*)
·
also (&&)
·
either (||)
·
!=
·
==
·
=
·
<
·
>
·
>=
·
<=
Punctuators:
·
<::>
as {} in (c++)
·
**
as ““ in (c++)
·
^^
as ‘‘ in (c++)
Identifiers:
·
They
must begin with a letter or underscore (_).
·
They
must consist of only letters, digits, or underscore. No other special character is allowed.
·
It
should not be a keyword.
·
It
must not contain white space.
Keywords:
|
Keyword |
Keyword |
Keyword |
|
omit as delete (C++) |
essential as main (C++) |
showup as cout (C++) |
|
Dual as double (C++) |
when as while (C++) |
only as char (C++) |
|
single as int (C++) |
option as case (C++) |
perfect as true (C++) |
|
last as else (C++) |
result as return (C++) |
blank as void (C++) |
|
makeit as do (C++) |
Partial as float (C++) |
Check last as Else if (C++) |
|
jamm as break (C++) |
Str as string (C++) |
NULL |
|
nottrue as false (C++) |
sign as bool (C++) |
Read as cin (C++) |
|
Shift as switch(C++) |
failure as default(C++) |
|
int main()
{
Code;
}
Start_End:
Single
essentia()
<:
Code?
:>
Declaration:
partial a = 3.2?
only ch = ^a^?
str flirt = *Hello Word*?
Function
Syntax c++
void myFunction() {
// code to be
executed
}
------------------------------------
MY Language Function Syntax
blank _myFunction() <:
:: code to be
executed
:>
-------------------------------------------------------------------------------------------
Loop
C++ Loop
for (initialization;
condition; update) {
// body of-loop
}
------------------------------------------------------------------
C++ syntax
for (int i = 1; i <= 5; ++i) {
cout << i << " ";
}
----------------------------------------------------------
MY Language Loop Syntax
for (Single _i = 1; _i <= 5; Increment_i) <:
showup << _i << **;
:>
------------------------------------------------------------
C++ while Loop
The syntax of the while loop is:
while (condition) {
// body of the loop
}
--------------------------------------------------------------------
//C++ create int variable
int i = 1;
// while loop from 1 to 5
while (i <= 5) {
cout << i << " ";
++i;
}
--------------------------------------------------------------
MY Language while Syntax
:: create int variable
Single _i = 1;
:: while loop from 1 to 5
when (_i <= 5) {
showup << _i << **;
Increment_i;
}
---------------------------------------------------------------------
C++ do...while Loop
The syntax of the do while loop is:
do {
// body of loop;
}
while (condition);
--------------------------------------------------------------------
//create int variable
int i = 1;
// do...while loop from 1 to
5
do {
cout << i << " ";
++i;
}
while (i <= 5);
--------------------------------------------------------------
MY Language Do while Syntax
:: create int variable
Single _i = 1?
:: do...while loop from 1
to 5
makeit <:
showup << i << **?
_iIncrement?
:>
when (_i <= 5)?
C++ if,
if...else
int number = 5;
if (number > 0) {
cout << "The number is
positive." ;
else {
cout << "The number is
negative.";
}
----------------------------------------------------------------------------
MY Language if else Syntax
:: create int variable
Single i = 1?
check (Single > 0) <:
showup << *The number is positive.* ?
:>
last <:
showup << *The
number is negative.*?
:>
-------------------------------------------------------------------------
C++
switch..case Statement
switch (oper) {
case '1':
cout << “1”;
break;
case '2':
cout << “2”;
break;
default:
// doesn't match any case
cout << "Error! The
operator is not correct";
break;
}
-------------------------------------------------------------------------
MY Language switch..case
Statement Syntax
Shift (_oper) <:
option ^1^:
cout << *1*?
Jamm?
option ^2^:
cout << *2*?
Jamm?
failure:
:: doesn't match any case
showup << *Error! The operator
is not correct*?
Jamm?
:>
![]()



Example my language
Single a=3?
when(a<=8)<:
showup<<a?
++a?
:>
--------------------------------
Single a=9?
showup<<a?
Single a=9?
showup<<"sdf"<<endl<<a?
Single a=4?
Read>>a?
showup<<a?
Single
a,as?
Read>>as?
showup<<as?
Partial a=9.7?
showup<<a?
str
a="dds"?
showup<<a<<endl?
-----------------------------
Single a=8?
check(2>2)<:
showup<<a?
:>
last<:
showup<<"check last"?
:>
Single a=3?
when(a<=8)<:
showup<<a?
++a?
:>
Single a=2?
Single b=9?
when(b>=a)<:
showup<<a?
++a?
:>
![]() |
|||||
![]() |
|||||


Comments
Post a Comment