Skip to content

Commit d4abcaf

Browse files
make support
1 parent c09e8ed commit d4abcaf

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ Count: 3
7979

8080
### Prerequisites
8181
- A C compiler (GCC or Clang)
82-
- Make (optional)
82+
- Make
8383

8484
### Build
85+
8586
```bash
8687
git clone https://github.com/aditya-raj-arora/MASProgramming.git
8788
cd MASProgramming/mas
88-
gcc -o mas main.c lexer.c parser.c interpreter.c -lm
89+
make
8990
```
9091

9192
### Run a Program
@@ -106,6 +107,7 @@ mas/
106107
├── parser.c # Recursive descent parser (builds AST)
107108
├── interpreter.c # Tree-walking interpreter (executes AST)
108109
├── main.c # Entry point and driver
110+
├── Makefile # Build script
109111
└── test.mas # Example MAS program
110112
```
111113

mas/Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Compiler and flags
2+
CC = gcc
3+
CFLAGS = -Wall -Wextra
4+
5+
# Target executable
6+
TARGET = mas.exe
7+
8+
# Source files
9+
SRCS = lexer.c parser.c interpreter.c main.c
10+
11+
# Default target
12+
all: $(TARGET)
13+
14+
# Link object files into executable
15+
$(TARGET): $(SRCS)
16+
$(CC) $(CFLAGS) -o $@ $^
17+
18+
# Clean generated files
19+
clean:
20+
del $(TARGET) 2> NUL || rm -f $(TARGET)
21+
22+
.PHONY: all clean

mas/test.mas

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
# Hello World
2+
print "Hello, MAS!"
3+
4+
# Variables and math
5+
x = 10
6+
y = x * 2 + 5
7+
print "Result:", y
8+
9+
# Lists
10+
fruits = ["apple", "banana", "cherry"]
11+
print fruits
12+
13+
# Loop
14+
i = 0
15+
loop i < 3:
16+
print "Count:", i
17+
i = i + 1
18+
end
19+
20+
# For-each loop
21+
each f in fruits:
22+
print "Fruit:", f
23+
end
24+
25+
each i in 1 to 3:
26+
print "Count:", i
27+
end
28+
129
def add(a,b):
230
give a+b
331
end

0 commit comments

Comments
 (0)