You are on page 1of 43

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

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

AUTOMATA & LANGUAGE


THEORY

COMPUTER SCIENCE DEPARTMENT

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.

GREEK GODS COMPILER | 2

AUTOMATA & LANGUAGE


THEORY

COMPUTER SCIENCE DEPARTMENT

RULES FOR:
I.

IDENTIFIERS/ VARIABLES

Identifiers must be in lowercase.

Identifiers must start with a letter and may be followed by any alphanumeric characters.

Minimum number of characters is 1 and maximum of 8.

No other special characters allowed.

FORMAT:
<identifier>

EXAMPLE:
num1
studname

II.

CONSTANT AND VARIABLE DECLARATION

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

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

Variable Declaration:
1.

A data type is required when declaring a variable.

2.

Multiple variables under one declaration is separated by a

comma.

FORMAT:
<data type><identifier1>, <identifier2>,.,<identifierN>:

EXAMPLE:
NTGR sum, num1, num:

Array Declaration:
1)

Two-dimensional arrays are allowed.

2)

It follows the rules of Variable Declaration

3)

An array size (enclosed in brackets) is required

4)

Array size must be greater than or equal to the number of

array elements initiated.


5)

Array can have no initialized value/s.

FORMAT:
<data type><identifier_name> [array_size]

EXAMPLE:
NTGR num[10]:
NTGR num[10] = {1,2}:

GREEK GODS COMPILER | 4

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

Literals

1. NTGR - maximum of 9 digits only.


2. CHR - Single character enclosed in single quotation marks.
3. FLT maximum of 9digits only before decimal point and 9 digits after.
4. STRNG Maximum of 150 characters (ASCII) and enclosed in double quotation marks.
Data Type

Valid

Invalid

NTGR

100,000,000

13942.12

CHR

a, X

output, as

FLT

245.500267897

754.977377777

STRNG

Hi my name is &&&&&

<characters that exceeds the 150


limit>

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

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

4.

Global Declarations are only done before the main function.

5.

Declarations can be done within functions.

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

GREEK GODS COMPILER | 6

COMPUTER SCIENCE DEPARTMENT

IV.

AUTOMATA & LANGUAGE


THEORY

FUNCTIONS

1.

Void Functions should start with the reserved word HADES.

2.

Non Void Functions should start with the reserved word ARTEMIS.

3.

FUNCTION NAMES must:

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.

Variable declarations can be done within the function.

5.

Statements can be local declarations, conditional statements, looping statements, I/O statements,
arithmetic statements, assignment statements, function calling, or comments.

6.

PARAMETERS:

a) Consists of data type and variable.


b) Considered a regular variable which is local to the function.
c) It should be inside of parentheses after the function name.
d) Multiple parameters are separated by a comma (,).
GREEK GODS COMPILER | 7

AUTOMATA & LANGUAGE


THEORY

COMPUTER SCIENCE DEPARTMENT

e) Arrays in parameter are not allowed.


f) The maximum number of parameters allowed for each function is 4.
g) The parameter list does not need to include the
parameter names, but only their types
7.

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>:

GREEK GODS COMPILER | 8

CALYPSO <return value>:


APOLLO

AUTOMATA & LANGUAGE


THEORY

COMPUTER SCIENCE DEPARTMENT

FORMAT PARAMETERS:
(<datatype><variable>, <datatype><variable>,,
<datatype><variable>)

FORMAT FOR FUNCTION CALLING:


HADES <functionname>(<argument/s>):

FORMAT FOR ARGUMENTS:


(<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.

All structures must have at least one data member.

3.

Data member/s of the structure is enclosed by {.}.

4.

Multiple declaration of a structure with the same structure name is not allowed.
GREEK GODS COMPILER | 9

COMPUTER SCIENCE DEPARTMENT


5.

AUTOMATA & LANGUAGE


THEORY

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.

ACCESSING DATA ELEMENTS:


RULES:
1. A dot (.) is placed before the object name, then followed by the data
element.
2. The data item/s being accessed must be part of the structure of the object.

FORMAT:
object[index].datamember

GREEK GODS COMPILER | 10

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

ACCESSING DATA ELEMENTS OF AN OBJECT


RULES:
1. Data item/s can only be accessed one a time.
2. When accessing, a dot (.) is placed before the object name, then followed by the data element.
3. The data item/s being reached should be part of the structure of the object.

FORMAT:
Object_name.data_member

VI.

DATA TYPES

NTGR
1. Must be in uppercase.
2.

It accepts numbers/digits without decimal point.

3.

It accepts positive and negative digits/numbers.

4.

Zero having negative signs will be considered as invalid.

5.

Numbers with leading zero are not valid.

6.

Default value for NTGR is 0.

FORMAT:
NTGR<identifier>:

EXAMPLE:
NTGR a:
NTGR num1:
GREEK GODS COMPILER | 11

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

FLT
1.

Must be in uppercase.

2.

It accepts numbers with or without decimal point.

3.

It accepts positive and negative numbers.

4.

Zero having negative signs will be considered as invalid.

5.

Numbers with leading zero are not valid. (e.g. 031.34).

6.

Default value for FLT is 0.0.

FORMAT:
FLT<identifier>:

EXAMPLE:
FLT a:
FLT num1:

CHR
1.

Must be in uppercase.

2.

It accepts a character enclosed in single quotation marks.

3.

Empty single quote (') is invalid.

4.

Note that an apostrophe (') enclosed in single quotes is invalid.

5.

Default value for CHR is NULL.

GREEK GODS COMPILER | 12

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

FORMAT:
CHR<identifier>:

EXAMPLE:
CHR a:

STRNG
1.

Must be in uppercase
2.

It accepts a character or group of characters

enclosed in double quotation marks.


3.

Maximum no. of characters is 150.

4.

Can also accept and input a NULL character ("").

5.

Note that a double quotation mark (") enclosed in

double quotes is invalid.


6.

Default value for STRNG is NULL.

FORMAT:
STRNG<identifier>:

EXAMPLE:
STRNG a:

GREEK GODS COMPILER | 13

COMPUTER SCIENCE DEPARTMENT

VII.

AUTOMATA & LANGUAGE


THEORY

CONDITIONAL STATEMENTS
1. VENUS (IF)

A VENUS statement consists of a Boolean expression followed by one or more


statements.

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

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

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

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

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

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

2. ENDYMION(WHILE) Loop

Repeats a statement or group of statements while a

given condition is true. It tests the condition before executing the loop body.

FORMAT:
ENDYMION(condition)
{
Statement:
}

3. SELENE(DO-WHILE) Loop

It is more like an ENDYMION statement, except

that it tests the condition at the end of the loop body.

FORMAT:
SELENE
{
Statement:
} ENDYMION( condition ):

GREEK GODS COMPILER | 17

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

NESTED LOOPING STATEMENTS:


4. Nested FATES (FOR) Loop
FORMAT:
FATES(init; condition; increment) {
FATES(init; condition; increment) {
Statement:
}
Statement:}

5. Nested ENDYMION Loop


FORMAT:
ENDYMION(condition) {
ENDYMION (condition) {
Statement:
}
Statement:
}

IX.

RELATIONAL OPERATORS
GREEK GODS COMPILER | 18

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

1. Greater than operator (>)

Checks if the value of left operand is greater than

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>

2. Greater than or equal to operator (>=)

Value can be any mathematical expressions,

including identifiers and literals

FORMAT:
<value>>= <value2>

3. Less than operator (<)

Checks if the value of left operand is less than the value of

right operand. If yes, then the condition becomes true.


Value can be any mathematical expressions, including identifiers,

NTGR and FLT literals.

FORMAT:
<value><<value2>

4. Less than or equal to operator (<=)

GREEK GODS COMPILER | 19

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

Checks if the value of left operand is less than or equal to the value

of right operand. If yes, then the condition becomes true.

FORMAT:
<value><= <value2>

5. Inequality operator (!=)

Checks if the values of two operands are equal or not. If the

values are not equal, then the condition becomes true.

Value can be any mathematical expressions, including

identifiers, NTGR and FLT literals.

FORMAT:
<value> != <value2>

6. Equality operator (==)

Checks if the values of two operands are equal or not. If

yes, then the condition becomes true.

Value can be any mathematical expressions, including

identifiers and literals

FORMAT:
<value> == <value2>

GREEK GODS COMPILER | 20

COMPUTER SCIENCE DEPARTMENT

X. GENERAL
EXPRESSIONS

FORM

AUTOMATA & LANGUAGE


THEORY

FOR

RELATIONAL

value1/value2 - any valid mathematical expressions (zero,

literals, identifiers)

relop - any relational operators (>,<,<=,>=,==,!=)

FORMAT:
<value1><relop><value2>

XI.

LOGICAL OPERATORS
1. AND operator (&&)

If both the operands are non-zero, then the condition

becomes true, otherwise false.

FORMAT:
<expression1>&&<expression2>

2. OR operator (||)

If any of the two operands are non-zero, then the condition

becomes true, otherwise false.

FORMAT:
<expression1> || <expression2>

GREEK GODS COMPILER | 21

AUTOMATA & LANGUAGE


THEORY

COMPUTER SCIENCE DEPARTMENT

3. NOT Operator (!)


It returns the opposite Boolean value of evaluating its operand.

FORMAT:
!(<expression>)

XII.GENERAL

FORMAT

FOR

LOGICAL

EXPRESSIONS

expression1/expression2

any

valid

conditional

expressions.

Logop (AND, OR).

FORMAT:
<expression1><logop><expression2>

XIII.UNARY OPERATORS
1.

Increment operator (++)

increases the integer value by one

FORMAT:
++<identifier>or<identifier>++

2.

Decrement operator (--)

decreases the integer value by one


GREEK GODS COMPILER | 22

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

FORMAT:
--<identifier>or<identifier>--

XIV.COMPOUND ASSIGNMENT OPERATORS


1.

Assignment by Addition

<identifier> must be an identifier under the NTGR and

FLT. <value> can be a numeric literal or identifier.

FORMAT:
<identifier> += <value>:
EXAMPLE:
a+=1:

2.

Assignment by Subtraction

<identifier> must be an identifier under the NTGR and FLT

data type. <value> can be a numeric literal or identifier.

FORMAT:
<identifier> -= <value>:
EXAMPLE:
a-=1:

3.

Assignment by Multiplication

<identifier> must be an identifier under the NTGR and FLT

data type. <value> can be a numeric literal or identifier.

FORMAT:
<identifier> *= <value>:
EXAMPLE:
a*=1:

GREEK GODS COMPILER | 23

COMPUTER SCIENCE DEPARTMENT

4.

AUTOMATA & LANGUAGE


THEORY

Assignment by Division

<identifier> must be an identifier under the NTGR and FLT

data type. <value> can be a numeric literal or identifier.

FORMAT:
<identifier> /= <value>:
EXAMPLE:
a/=1:

5. Assignment by Modulus (%)


<identifier> must be an identifier under the NTGR and FLT

data type. <value> can be a numeric literal or identifier.

FORMAT:
<identifier> %= <value>:
EXAMPLE:
a%=4:

XV.
1.

I/O STATEMENTS
ECHO(COUT)

Used for output or displaying statements.

GREEK GODS COMPILER | 24

COMPUTER SCIENCE DEPARTMENT

<output>
mathematical expressions.

string

to

be

AUTOMATA & LANGUAGE


THEORY

displayed,

identifier

and

FORMAT:
ECHO"<output>":
EXAMPLE:
ECHO "Hello World:
ECHO "The total amount is ", <identifier>:
ECHO <identifier>:

2.

CIRCE(CIN)

Used to accept an input from the user.

FORMAT:
CIRCE <identifier>:
EXAMPLE:
CIRCE a:

XVI.MATHEMATICAL OPERATORS
1.

Addition Operator (+)

Val can be any NTGR and FLT literals, identifiers, or

combination of any valid mathematical expressions.

FORMAT:

<val1> + <val2>...<valn>
EXAMPLE:
GREEK GODS COMPILER | 25

1 + 3:
id + 2 +id1 + idn:

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

2.

Subtraction Operator (-)

Val can be any NTGR and FLT literals, identifiers, or

combination of any valid mathematical expressions.

FORMAT:
<val1> - <val2>...<valn>
EXAMPLE:
1 - 3:
id - 2 - id1 - idn:

3.

Multiplication Operator (*)

Val can be any NTGR and FLT literals, identifiers, or

combination of any valid mathematical expressions.

FORMAT:
<val1> * <val2>...<valn>
EXAMPLE:
1 * 3:
id * 2 * id1 * idn:

GREEK GODS COMPILER | 26

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

4.

Division Operator (/)

Val can be any NTGR and FLT literals, identifiers, or

combination of any valid mathematical expressions.

FORMAT:
<val1> /<val2>...<valn>
EXAMPLE:
1 / 3:
id / 2 / id1 / idn:

5.

Modulus Operator (%)

Val can be any NTGR and FLT literals, identifiers, or

combination of any valid mathematical expressions.

FORMAT:
<val1> % <val2>:
EXAMPLE:
12%2:
id%id2:

GREEK GODS COMPILER | 27

COMPUTER SCIENCE DEPARTMENT

XVII.

AUTOMATA & LANGUAGE


THEORY

GENERAL FORMAT FOR MATHEMATICAL

OPERATORS

term - any valid mathematical expression (NTGR and FLT

Literals, identifiers, zero)

<mathop> - any mathematical operator.

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

GREEK GODS COMPILER | 28

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

subtraction operator

multiplication operator

division operator

++

increment

--

decrement

modulus

+=

assignment by addition (compound assignment)

-=

assignment by subtraction (compound assignment)

*=

assignment by multiplication (compound assignment)

/=

assignment by division (compound assignment)

>

greater than operator

>=

greater than or equal operator

<

less than

<=

less than or equal operator

\*

comment open

*\

comment close

line terminator

GREEK GODS COMPILER | 29

AUTOMATA & LANGUAGE


THEORY

COMPUTER SCIENCE DEPARTMENT

grouping symbol open

grouping symbol close

Negative

XIX. DIFFERENT RESERVED WORDS


IN Mything GeeCs

ARES

IN OTHER
PL (C++)
END
NON-VOID
ELSE

ARTEMIS

NON VOID

ARROW

CASE

BACCHUS

NULL

CALYPSO

RETURN

CHAOS

END VOID

an exit status of 0 (zero) stands for successful


execution
end a sub function

CIRCE

CIN

for accepting input

CUPID

DEFAULT

holds the default value

ECHO

COUT

for displaying output

ENDYMION

WHILE

EROS

SWITCH

evaluates the expression which returns a


boolean value
statement allows a variable to be tested for
equality against a list of values

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

a repetition control structure that allows you


to efficiently write a loop that needs to
execute a specific number of times
GREEK GODS COMPILER | 30

COMPUTER SCIENCE DEPARTMENT

GAIA

AUTOMATA & LANGUAGE


THEORY

End of the program

HADES

VOID

used to start a sub-function

HERA

END MAIN

end of the main function

HERA

END MAIN

end of the main function

ORPHEUS
PSYCHE

RESUME
BREAK

SELENE

DO

used to end a loop even if the number of


iterations are not yet completed
executes the commands and statements

URANUS

Start of the program

VENUS

IF

ZEUS

MAIN

evaluates the expression which returns a


boolean value
used for the main function

DATA TYPES
IN Mything GeeCS

IN OTHER PL
(C++)

DEFINITION

NTGR

INTEGER

data type for whole number

FLT

FLOAT

data type for numeric values with


decimal

CHR

CHARACTER

data type for single character

STRNG

STRING

BLN

BOOLEAN

data type used for string of


characters
data type that holds a true or false
value

XX. REGULAR DEFINITION

GREEK GODS COMPILER | 31

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

DEFINITION

EXPRESSION USED

letter

a . z

digit

1 9

alpha

Az

ASCII
mathop

alpha, !, @, #, $, %, ^, &, [, ], <, >, ?, _, mathop, (, ), {,


}, comma, semicolon, digit, zero, ,
+, -, *, /

zero

space

colon

comma

semicolon

newline

\n

delim1

space, newline

delim2

space, (

delim3

digit, letter, space, (

delim4

colon, letter, )

delim5

alpha, space, digits, zero, (

delim6

letter, digit, zero, space, colon, mathop, newline, {

delim7

mathop, comma, colon, space, semicolon, =, (, )

delim8

comma, space, colon

delim9

space, colon

GREEK GODS COMPILER | 32

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

XXI. REGULAR EXPRESSIONS


Reserved Word

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

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

URANUS

(U)(R)(A)(N)(U)(S)

VENUS

(V)(E)(N)(U)(S)

ZEUS

(Z)(E)(U)(S)

(+)

(-)

(*)

(/)

(/)

(=)

+=

(+)(=)

-=

(-)(=)

*=

(*)(=)

/=

(/)(=)

==

(=)(=)

({)

(})

(:)

([)

(])

(()

())

>

(>)

<

(<)

>=

(>)(=)

<=

(<)(=)

++

(+)(+)

--

(-)(-)
GREEK GODS COMPILER | 34

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

(%)

(,)

IDENTIFIER
NTGR LITERAL

(letter/num)(letter/num/) (letter/num/) (letter/num/)


(letter/num/) (letter/num/) (letter/num/)
(letter/num/)
(^/)(digit)(digit/zero/)9

FLT LITERAL

(^/) (digit/zero/)9 (.)(digit/zero) (digit/zero/)9

CHR LITERAL

() (ASCII) ()

STRNG LITERAL

() (ASCII) (ASCII/ )+ ()

BLN LITERAL

XXI. TRANSITIONAL DIAGRAM

GREEK GODS COMPILER | 35

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

GREEK GODS COMPILER | 36

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

GREEK GODS COMPILER | 37

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

GREEK GODS COMPILER | 38

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

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> id <simdec_tail>: <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

COMPUTER SCIENCE DEPARTMENT

28

<object_tail>

29

<declaration>

30

<declaration>

31

<constant>

AUTOMATA & LANGUAGE


THEORY

<constant><simple_dec>

32

<constant>

OLYMPUS id = <literals>:<constant>

33

<body>

<main><subfunc>

34

<main>

ZEUS <simple_dec><statement> HERA

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

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

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

COMPUTER SCIENCE DEPARTMENT

AUTOMATA & LANGUAGE


THEORY

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>

FATES(id = INT lit; <condition>;id<crement>){<stmts>}

96

<ifelse>

VENUS(<condition>){<stmts>}<else>

97

<else>

ARES{<stmts>}

98

<else>

99

<switch>

EROS(switch_name){<case><default>}

100

<case>

ARROW id <stmts> PSYCHE; <case>

101

<case>

102

<default>

CUPID <stmts>:

103

<default>

104

<return>

CALYPSO <value>:

105

<return>

CALYPSO id:

106

<subfunc>

HADES func_name (<param><param><param><param>){stmts}

107

<param>

CHAOS
<datatype> id, <param>

108

<param>

109

<program_exit>

<program>GAIA

GREEK GODS COMPILER | 42

You might also like