Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Transform Ideas into Executable Brilliance.

NotificationsYou must be signed in to change notification settings

ahmedihabb2/MangaCC

Repository files navigation

GUI

Language Descriptions

Tokens

1- Variable and constant Declaration

int x;int x = 5;const int x = 5;string x = "Hello";string x = "c";
  • Available types
    • int
    • float
    • string
    • bool

2- Mathematical and Logical expressions

  • Mathematical operator
    • +, -, *, /, %,
  • Logical operator
    • ==, !=, >, <, >=, <=
    • and , or , not , xor

3 - Assignment statement

x = 5;x = "Hello";x = 5.5;x = true;

4 - If else statement

if (x == 5 and y == 10) {  x = 10;} endif
if (x >= 5 or y <= 10) {  x = x +1 ;} else {  x = x - 1;}
if (x < 5 and y > 10) {  x = x + 1;} else if (x > 5) {  x = x - 1;} else {  x = 0;}

5 - While loop

while (x < 5) {  x = x + 1;}

6 - Repeat until

repeat {  x = x + 1;} until (x == 5);

7 - For loop

for (int i = 0; i < 5; i = i + 1) {  x = x + 1;}

8 - Switch case

switch (x) {  case 1:    x = 1;    break;  case 2:    x = 2;    break;  default:    x = 0;}

9 - Function declaration

int func1(int x, int y) {  return x + y;}
void func2(int x) {  x = x + 1;}
int func3() {  return 5;}

10 - Function call

int x = func1(5, 10);func2(5);int y = func3();

11 - Block structure

{  int x = 5;  {    x = x + 1;  }}

12- Comments

// This is a comment

13- Print

print("Hello World");print(x);print(5);print(5+6);

14- Enum

enum Color {  RED,  GREEN,  BLUE}enum Color c = RED;

How to run

  • There is a script namedbuild.sh that generates the parser and lexer and takes test file from you as input argurmnt.

  • You can run the script by typing the following command in the terminal:

    ./build.sh if_test.c
  • Note: the test file should be in the test_cases folder.

  • It will print the tokens with its line number.

Quadraples Description

QuadrapleDescription
PUSH (value)Pushing (value) to stack
POP (ID)Pop value from stack to the (ID)
NOT (value)Getting complement of (value)
ADD (arg1) (arg2) (result)Adding (arg1) (arg2) and save value to (result)
SUB (arg1) (arg2) (result)Substracting (arg1) (arg2) and save value to (result)
MULMultiply (arg1) (arg2) and save value to (result)
DIVDivide (arg1) (arg2) and save value to (result)
MODCalculate the modules of (arg1) (arg2) and save value to (result)
ANDPerform logical and between (arg1) (arg2) and save value to (result)
ORPerform logical or between (arg1) (arg2) and save value to (result)
XORPerform logical xor between (arg1) (arg2) and save value to (result)
EQCheck the equality of the two operands and store the comparsion result in temp reg
NECheck the inequality of the two operands and store the comparsion result in temp reg
LTCheck if the first operand is less than the second and store the comparison result in temp reg
GTCheck if the first operand is greater than the second and store the comparison result in temp reg
LECheck if the first operand is less than or equal the second and store the comparison result in temp reg
GECheck if the first operand is greater than or equal the second and store the comparison result in temp reg
JMP L():Unconditional Jump to label
JUMPZERO L():Jump if the zero flag from previous command is zero
JMPNONZERO L():Jump if the zero flag from previous command is non-zero
Convi (var/value)Convert float to integer
Convf (var/value)Convert integer to float

Contributors


[8]ページ先頭

©2009-2025 Movatter.jp