Professional Documents
Culture Documents
GENERAL RULES:
1. The Mything GeeCS Compiler should start with reserved word URANUS and must end with
GAIA.
2. The Mything GeeCS Compiler can declare variables globally and locally.
3. Global declarations must start before the main function.
4. Data types are required when declaring an identifier: NTGR, FLT, STRNG, CHR, BLN.
5. Each data type should contain at least 1 and a maximum of 5 identifiers.
6. All reserved words in Mything GeeCS Compiler are in uppercase letters.
7. A colon ( : ) is used to terminate a statement.
8. The Mything GeeCS Compiler accepts non-void and void functions.
9. Non Void functions can return a value.
10. Functions must be followed by a pair of parentheses in which the parameters will be declared.
11. VoidFunctions must start with the reserved word HADES and must end with CHAOS.
12. Non Void Function must start with the reserved word
13. Sub-functions must be coded after the main function.
14. STRUCT must start after the reserved word URANUS and before the global declaration.
15. Scope can be well-defined as the range of accessibility has to the program in
which it is declared: Local Variables, Function Parameters, Global Variables.
16. Multiple declaration of a structure with same structure name is not allowed.
17. Identifiers must all be in lowercase.
18. Identifiers must start with a letter and may be followed by any alphanumeric characters.
Minimum number of characters is 1 maximum of 8. No other special characters allowed.
19. Arrays are two dimensional.
GREEK GODS COMPILER | 1
20. Parameters (accepts only 4): Each parameter consists of a type followed by an
identifier, with each parameter being separated from the next by a comma. Each
parameter looks like a regular variable declaration.
21. The parameter list does not need to include the parameter names, but only their types
22. In a mathematical expression, the PEMDAS rule is being followed.
23. Struct must be declared by using the reserved word STRUCT, followed by type_ name.
Declaration of struct should be before the global declarations only.
24. In a mathematical expression, the PEMDAS rule is being followed.
25. Mything GeeCs Compiler allow comments. The formats are the same for both
Single-line and Multi-line. The style of commenting is \* and *\
26. Functions cannot be called before they are declared. That is why, in all the
previous examples of functions, the functions were always defined before the main
function, which is the function from where the other functions were called. If main were
defined before the other functions, this would break the rule that functions shall be
declared before being used, and thus would not compile.
27. To call a function, you simply need to pass the required parameters along with
function name, and if function returns a value, then you can store returned value.
28. The declaration shall include all types involved (the return type and the type of its
arguments), using the same syntax as used in the definition of the function, but replacing
the body of the function (the block of statements) with an ending semicolon.
RULES FOR:
I.
IDENTIFIERS/ VARIABLES
Identifiers must start with a letter and may be followed by any alphanumeric characters.
FORMAT:
<identifier>
EXAMPLE:
num1
studname
II.
Constant Declaration:
1) Starts with the reserved word OLYMPUS followed by the data type, variable name, equal sign
and then the value.
2) The constant value must follow the limits set in the data types NTGR, FLT, CHR and STRNG.
3) Declaration of constant are placed before the main function.
FORMAT:
OLYMPUS <data_type> <identifier> = <value>:
GREEK GODS COMPILER | 3
Variable Declaration:
1.
2.
comma.
FORMAT:
<data type><identifier1>, <identifier2>,.,<identifierN>:
EXAMPLE:
NTGR sum, num1, num:
Array Declaration:
1)
2)
3)
4)
FORMAT:
<data type><identifier_name> [array_size]
EXAMPLE:
NTGR num[10]:
NTGR num[10] = {1,2}:
Literals
Valid
Invalid
NTGR
100,000,000
13942.12
CHR
a, X
output, as
FLT
245.500267897
754.977377777
STRNG
Hi my name is &&&&&
III.
STRUCTURE OF PROGRAM
1.
Program should start with the reserved word URANUS which is the main function
2.
The main function should always be the first function followed by the sub-functions.
3. The main function should start with the Reserved word ZEUS and must end with HERA
GREEK GODS COMPILER | 5
4.
5.
6.
Void functions should always start with the reserved word HADES and must end with CHAOS.
7.
Non-Void functions should always start with the reserved word ARTEMIS and must end with
APOLLO.
8.
To return a value in a non - void function, use the reserved word CALYPSO then the value to be
returned.
FORMAT:
URANUS
<global declaration>
HADES<function name>(argument/s):
ZEUS
<datatype><identifier1>,<identifier2>,.<identifierN>:
HADES<function name>(argument/s):
HERA
HADES<function name>(paramaeter/s)
<datatype><identifier1>,<identifier2>,.<identifierN>:
<statement/s>:
CHAOS
GAIA
IV.
FUNCTIONS
1.
2.
Non Void Functions should start with the reserved word ARTEMIS.
3.
a) Starts with a letter and may be followed by any alphanumeric characters and must be in
lowercase.
b) Minimum number of character is 1 maximum of 8.
c) Must be unique with other function names.
d) Non-Void functions could return a value using the reserved word CALYPSO.
4.
5.
Statements can be local declarations, conditional statements, looping statements, I/O statements,
arithmetic statements, assignment statements, function calling, or comments.
6.
PARAMETERS:
FUNCTION CALLING:
a) Void functions must use the reserved word HADES followed by the function name.
b) Non Void Functions must use the reserved word ARTEMIS followed by the function name.
c) Can be used within ZEUS which is the main function.
d) To call a function, you simply need to pass the required parameters along with function name and
if function returns a value, then you can store returned value.
8.
ARGUMENTS:
a) Must have a counterpart on the parameters from the function. Sticks with the chronological order
of the parameters.
b) Consist of data type
and variable data type must be the same with its counterpart parameter.
FORMAT:
c) It should be insideHADES<function
of parentheses after
the function name.
name>(parameter/s)
d) Multiple arguments are separated by a comma
(,).
<datatype><identifier1>,
<identifier2>,
e) Only variables and literals are allowed
to be passed as arguments
.<identifierN>:
<statement/s>:
CHAOS
ARTEMIS <function name>(parameter/s){
<datatype><identifier1>, <identifier2>,
.<identifierN>:
<statement/s>:
FORMAT PARAMETERS:
(<datatype><variable>, <datatype><variable>,,
<datatype><variable>)
V.
1.
STRUCT
Struct must be declared by using the reserved word STRUCT, followed by type_ name.
Declaration of struct should be before the global declarations only.
2.
3.
4.
Multiple declaration of a structure with the same structure name is not allowed.
GREEK GODS COMPILER | 9
Data member/s initialization is allowed. Data member/s in the same structure must not have the
same variable names.
FORMAT:
STRUCT <type_name> {
<data type><datamember1>:
<data type><datamember2>:
<data type><datamemberN>:
}
<object_name1>,
<object_name2>
<object_nameN>:
OBJECT DECLARATION:
1. After the } symbol, global objects are declared.
2. Structure name must first be defined for local objet declaration.
3. A declaration must be done first before having a local object declaration.
4. No repetitive declarations of an object with the
same name inside the same function.
FORMAT:
object[index].datamember
FORMAT:
Object_name.data_member
VI.
DATA TYPES
NTGR
1. Must be in uppercase.
2.
3.
4.
5.
6.
FORMAT:
NTGR<identifier>:
EXAMPLE:
NTGR a:
NTGR num1:
GREEK GODS COMPILER | 11
FLT
1.
Must be in uppercase.
2.
3.
4.
5.
6.
FORMAT:
FLT<identifier>:
EXAMPLE:
FLT a:
FLT num1:
CHR
1.
Must be in uppercase.
2.
3.
4.
5.
FORMAT:
CHR<identifier>:
EXAMPLE:
CHR a:
STRNG
1.
Must be in uppercase
2.
4.
5.
FORMAT:
STRNG<identifier>:
EXAMPLE:
STRNG a:
VII.
CONDITIONAL STATEMENTS
1. VENUS (IF)
FORMAT:
VENUS (condition)
{
Statement1:
Statement2:
}
2. VENUS-ARES (IF-ELSE)
A VENUS statement can be followed by an optional ARES statement, which
executes when the Boolean expression is false.
FORMAT:
VENUS (condition)
{
Statement1:
Statement2:
}
ARES{
Statement1:
}
GREEK GODS COMPILER | 14
3. VENUS-ARES-VENUS (IF-ELSE-IF)
FORMAT:
VENUS(condition1) {
Statements:
} ARES VENUS (condition2)
{
Statements;
} ARES {
Statements:
}
4. Nested VENUS-ARES(IF-ELSE)
FORMAT:
VENUS (condition1) {
Statements;
VENUS (condition2) {
Statements;
}
ARES {
Statements;
}
}
GREEK GODS COMPILER | 15
5. EROS (SWITCH)
An EROS statement allows a variable to be tested for equality against a list of values.
FORMAT:
EROS(expression)
{
ARROW(CASE) constant expression1;
statements1:
PSYCHE (BREAK):
ARROW constant expression2;
statements1:
PSYCHE:
CUPID (DEFAULT);
StatementsN:
}
VIII.
ITERATIVE STATEMENTS
1. FATES (FOR) Loop
Executes a sequence of statements multiple times and abbreviates the code that manages the loop
variable.
FORMAT:
FATES (init; condition; increment)
{
Statement1:
}
GREEK GODS COMPILER | 16
2. ENDYMION(WHILE) Loop
given condition is true. It tests the condition before executing the loop body.
FORMAT:
ENDYMION(condition)
{
Statement:
}
3. SELENE(DO-WHILE) Loop
FORMAT:
SELENE
{
Statement:
} ENDYMION( condition ):
IX.
RELATIONAL OPERATORS
GREEK GODS COMPILER | 18
the value of right operand. If yes, then the condition becomes true.
Val can be any mathematical expressions, including identifiers, NTGR and FLT literals.
FORMAT:
<value>><value2>
FORMAT:
<value>>= <value2>
FORMAT:
<value><<value2>
Checks if the value of left operand is less than or equal to the value
FORMAT:
<value><= <value2>
FORMAT:
<value> != <value2>
FORMAT:
<value> == <value2>
X. GENERAL
EXPRESSIONS
FORM
FOR
RELATIONAL
literals, identifiers)
FORMAT:
<value1><relop><value2>
XI.
LOGICAL OPERATORS
1. AND operator (&&)
FORMAT:
<expression1>&&<expression2>
2. OR operator (||)
FORMAT:
<expression1> || <expression2>
FORMAT:
!(<expression>)
XII.GENERAL
FORMAT
FOR
LOGICAL
EXPRESSIONS
expression1/expression2
any
valid
conditional
expressions.
FORMAT:
<expression1><logop><expression2>
XIII.UNARY OPERATORS
1.
FORMAT:
++<identifier>or<identifier>++
2.
FORMAT:
--<identifier>or<identifier>--
Assignment by Addition
FORMAT:
<identifier> += <value>:
EXAMPLE:
a+=1:
2.
Assignment by Subtraction
FORMAT:
<identifier> -= <value>:
EXAMPLE:
a-=1:
3.
Assignment by Multiplication
FORMAT:
<identifier> *= <value>:
EXAMPLE:
a*=1:
4.
Assignment by Division
FORMAT:
<identifier> /= <value>:
EXAMPLE:
a/=1:
FORMAT:
<identifier> %= <value>:
EXAMPLE:
a%=4:
XV.
1.
I/O STATEMENTS
ECHO(COUT)
<output>
mathematical expressions.
string
to
be
displayed,
identifier
and
FORMAT:
ECHO"<output>":
EXAMPLE:
ECHO "Hello World:
ECHO "The total amount is ", <identifier>:
ECHO <identifier>:
2.
CIRCE(CIN)
FORMAT:
CIRCE <identifier>:
EXAMPLE:
CIRCE a:
XVI.MATHEMATICAL OPERATORS
1.
FORMAT:
<val1> + <val2>...<valn>
EXAMPLE:
GREEK GODS COMPILER | 25
1 + 3:
id + 2 +id1 + idn:
2.
FORMAT:
<val1> - <val2>...<valn>
EXAMPLE:
1 - 3:
id - 2 - id1 - idn:
3.
FORMAT:
<val1> * <val2>...<valn>
EXAMPLE:
1 * 3:
id * 2 * id1 * idn:
4.
FORMAT:
<val1> /<val2>...<valn>
EXAMPLE:
1 / 3:
id / 2 / id1 / idn:
5.
FORMAT:
<val1> % <val2>:
EXAMPLE:
12%2:
id%id2:
XVII.
OPERATORS
FORMAT:
<term1><mathop><term2><mathop>...<termn>
XVIII.
DIFFERENT SYMBOLS
SYMBOL
DESCRIPTION
\n
new line
assignment operator
==
equality symbol
!=
inequality symbol
[<size>]
array size/index
variable separator
addition operator
subtraction operator
multiplication operator
division operator
++
increment
--
decrement
modulus
+=
-=
*=
/=
>
>=
<
less than
<=
\*
comment open
*\
comment close
line terminator
Negative
ARES
IN OTHER
PL (C++)
END
NON-VOID
ELSE
ARTEMIS
NON VOID
ARROW
CASE
BACCHUS
NULL
CALYPSO
RETURN
CHAOS
END VOID
CIRCE
CIN
CUPID
DEFAULT
ECHO
COUT
ENDYMION
WHILE
EROS
SWITCH
FATES
FOR
APOLLO
DEFINITION
end a sub function
executes the commands and statement if the
VENUS statement is not satisfied
used to start a sub-function
which holds one of the values to be compared
to the variable in the ARTEMIS statement
an uninitialized, undefined, or empty value
GAIA
HADES
VOID
HERA
END MAIN
HERA
END MAIN
ORPHEUS
PSYCHE
RESUME
BREAK
SELENE
DO
URANUS
VENUS
IF
ZEUS
MAIN
DATA TYPES
IN Mything GeeCS
IN OTHER PL
(C++)
DEFINITION
NTGR
INTEGER
FLT
FLOAT
CHR
CHARACTER
STRNG
STRING
BLN
BOOLEAN
DEFINITION
EXPRESSION USED
letter
a . z
digit
1 9
alpha
Az
ASCII
mathop
zero
space
colon
comma
semicolon
newline
\n
delim1
space, newline
delim2
space, (
delim3
delim4
colon, letter, )
delim5
delim6
delim7
delim8
delim9
space, colon
Regular Expression
APOLLO
(A)(P)(O)(L)(L)(O)
ARES
(A)(R)(E)(S)
ARROW
(A)(R)(R)(O)(W)
ARTEMIS
(A)(R)(T)(E)(M)(I)(S)
BACCHUS
(B)(A)(C)(C)(H)(U)(S)
BLN
(B)(L)(N)
CALYPSO
(C)(A)(L)(Y)(P)(S)(O)
CHR
(C)(H)(R)
CIRCE
(C)(I)(R)(C)(E)
CUPID
(C)(U)(P)(I)(D)
ECHO
(E)(C)(H)(O)
ENDYMION
(E)(N)(D)(Y)(M)(I)(O)(N)
EROS
(E)(R)(O)(S)
FLT
(F)(L)(T)
GAIA
(G)(A)(I)(A)
HADES
(H)(A)(D)(E)(S)
HERA
(H)(E)(R)(A)
NTGR
(N)(T)(G)(R)
OLYMPUS
(O)(L)(Y)(M)(P)(U)(S)
ORPHEUS
(O)(R)(P)(H)(E)(U)(S)
SELENE
(S)(E)(L)(E)(N)(E)
STRNG
(S)(T)(R)(N)(G)
GREEK GODS COMPILER | 33
URANUS
(U)(R)(A)(N)(U)(S)
VENUS
(V)(E)(N)(U)(S)
ZEUS
(Z)(E)(U)(S)
(+)
(-)
(*)
(/)
(/)
(=)
+=
(+)(=)
-=
(-)(=)
*=
(*)(=)
/=
(/)(=)
==
(=)(=)
({)
(})
(:)
([)
(])
(()
())
>
(>)
<
(<)
>=
(>)(=)
<=
(<)(=)
++
(+)(+)
--
(-)(-)
GREEK GODS COMPILER | 34
(%)
(,)
IDENTIFIER
NTGR LITERAL
FLT LITERAL
CHR LITERAL
() (ASCII) ()
STRNG LITERAL
() (ASCII) (ASCII/ )+ ()
BLN LITERAL
CFG
1
<program>
<cmts>URANUS
<cmts>
<cmts><struct_dec><cmts><declaration><cmts><body> GAIA
/*ASCII*/
<cmts>
<struct_dec>
STRUCT id {<simple_dec>}<object><struct_dec>
<struct-dec>
6
7
<simple_dec>
<simple_dec>
<dtype>
NTGR
<dtype>
FLT
10
<dtype>
CHR
11
<dtype>
STRNG
12
13
<simdec_tail>
<simdec_tail>
,id<simdec_tail>
[<NTGRlit>]<array_tail>
14
<simdec_tail>
= <value>
15
<simdec_tail>
16
<NTGRlit>
NTGR literals
17
<array_tail>
= {<value><value_tail>}
18
<value>
<literals>
19
<value_tail>
,<value>
20
<value_tail>
21
<literals>
NTGR lit
22
<literals>
FLT lit
23
<literals>
CHR lit
24
<literals>
STRNG lit
25
<object>
id<object_tail>:
26
<object>
27
<object_tail>
,id <object_tail>
GREEK GODS COMPILER | 39
28
<object_tail>
29
<declaration>
30
<declaration>
31
<constant>
<constant><simple_dec>
32
<constant>
OLYMPUS id = <literals>:<constant>
33
<body>
<main><subfunc>
34
<main>
35
<statement>
<simple_dec>
36
<statement>
<input>:
37
<statement>
<output>:
38
<statement>
<while>
39
<statement>
<dowhile>:
40
<statement>
<assignment>:
41
<statement>
<for>
42
<statement>
<if>
43
<statement>
<switch>:
44
<statement>
<return>
45
<statement>
ORPHEUS
46
<statement>
HADES func_name(<param>)
47
<input>
CIRCE id
48
<output>
ECHO <disp><disp_tail>
49
<disp>
<disp1>
50
<disp>
<disp2>
51
<disp1>
ASCII
52
<disp2>
id
53
<disp2>
54
<disp_tail>
<disp1><disp2><disptail>
55
<disp_tail>
56
<while>
ENDYMION(<expr>){stmts}
GREEK GODS COMPILER | 40
57
<stmts>
<cmts><statement><stmt-block><stmt-tail1>
58
<stmt-block>
{<cmts><statement>}
59
<stmt-block>
60
<stmt_tail1>
<statement><stmt_block><stmt_tail>
61
<stmt_tail1>
62
<dowhile>
SELENE{<statement><stmtblock><stmt-
63
<condition>
tail1>}ENDYMION(<condition>)
<relexpr><logexpr>
64
<relexpr>
<term><relop><term>
65
<term>
(<mathexpr>)
66
<term>
INT LIT
67
<term>
FLT LIT
68
<term>
id
69
<mathexpr>
<term><mathop><term>
70
<mathop>
71
<mathop>
72
<mathop>
73
<mathop>
74
<mathop>
75
<relop>
<
76
<relop>
>
77
<relop>
==
78
<relop>
<=
79
<relop>
>=
80
<relop>
!=
81
<logexpr>
<logop><condition>
82
<logop>
&&
83
<logop>
||
84
<logop>
85
<assignment>
Id<assignment_tail>
GREEK GODS COMPILER | 41
86
<assignment>
id<assign-tail>
87
<assign-tail>
=<term>
88
<assign-tail>
<crement>
89
<assign-tail>
+=<term>
90
<assign-tail>
-=<term>
91
<assign-tail>
/=<term>
92
<assign-tail>
*=<term>
93
<crement>
++
94
<crement>
--
95
<for>
96
<ifelse>
VENUS(<condition>){<stmts>}<else>
97
<else>
ARES{<stmts>}
98
<else>
99
<switch>
EROS(switch_name){<case><default>}
100
<case>
101
<case>
102
<default>
CUPID <stmts>:
103
<default>
104
<return>
CALYPSO <value>:
105
<return>
CALYPSO id:
106
<subfunc>
107
<param>
CHAOS
<datatype> id, <param>
108
<param>
109
<program_exit>
<program>GAIA