File tree Expand file tree Collapse file tree 3 files changed +54
-2
lines changed Expand file tree Collapse file tree 3 files changed +54
-2
lines changed Original file line number Diff line number Diff 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
8687git clone https://github.com/aditya-raj-arora/MASProgramming.git
8788cd MASProgramming/mas
88- gcc -o mas main.c lexer.c parser.c interpreter.c -lm
89+ make
8990```
9091
9192### Run a Program
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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+
129def add(a,b):
230 give a+b
331end
You can’t perform that action at this time.
0 commit comments