Arc is a small programming language project written in C. It focuses on building a clean and reliable frontend pipeline, along with a simple interpreter for evaluating expressions and basic variable assignments.
- Interactive REPL (
src/repl) withclearandexitcommands - File execution (supports
.arcfiles) - Lexer for arithmetic expressions, identifiers, and string literals
- Parser with AST generation, supporting multiple statements
- Expression evaluation (interpreter)
- Integer and floating-point number support
- String literal support
- Support for operations on strings:
+(concatenation),*(repetition)
- Variables and identifiers (using
VARkeyword) - Conditional statements:
IF,THEN,ELIF,ELSE - Basic arithmetic operators:
+,-,*,/,^- Parentheses
()
- Comparison operators:
==,!=,<,>,<=,>=
- Logical operators:
AND,OR
- Assignment operator
= - Token system (
include/token.h) - Structured error handling with position tracking:
- File name
- Line number
- Column number
- Debug mode for inspecting tokens and AST
- Configurable floating-point precision
- Execute code from string via CLI
- Option to disable colored output
- Focus on memory-safe design
Arc > VAR x = 5
5
Arc > x * 10
50
Arc > VAR name = "Arc Language"
Arc Language
Arc > IF x == 5 THEN "Matched" ELSE "No Match"
Matched
Arc > VAR y = (x + 2) ^ 2
49.000000
Arc > y / 7
7.000000
Arc > x == 5
1
Arc > x > 10 OR x == 5
1
Arc provides access to command-line arguments through built-in variables:
argc: The number of positional arguments (including the script file).arg0: The path to the file (e.g test.arc) or path to Arc interpreter.arg1,arg2, ...,argN: The positional arguments passed to the script.- The argument list is terminated by a variable
argN(whereNis the value ofargc) which is set to0.
Example usage in a script:
VAR i = 1
IF argc > 1 THEN
arg1
ELSE
"No arguments provided"
If you run arc script.arc hello world:
argcwill be3arg0will be"arc"(or the path to the executable)arg1will be"hello"arg2will be"world"arg3will be0
Run with:
arc -d
# or
arc --debugExample session:
Arc > 1-1
Tokens: INT MINUS INT
AST tree: (1 MINUS 1)
0
Arc > VAR a = 10
Tokens: KEYWORD IDENTIFIER EQ INT
AST tree: [a = 10]
10
Arc > s
Name Error: Undefined variable "s"
File <stdin>, line 1, column 1
s
^
Arc is intentionally designed to stay simple and easy to reason about. The main goals are:
- No external dependencies
- Clear separation of components:
- Lexer
- Tokens
- Parser
- AST nodes (including support for multiple statements)
- Interpreter
- Symbol table (for variables)
- Error handling
- Position tracking
- REPL
- Predictable memory ownership
- Debuggability over cleverness
.
├── include
│ ├── ansi-colors.h
│ ├── error.h
│ ├── interpretator.h
│ ├── lexer.h
│ ├── node.h
│ ├── object.h
│ ├── parser.h
│ ├── position.h
│ ├── repl
│ │ ├── help.h
│ │ ├── input.h
│ │ ├── printast.h
│ │ └── repl.h
│ ├── symbol-table.h
│ ├── token.h
│ └── utils.h
├── LICENSE
├── makefile
├── README.md
└── src
├── error.c
├── interpretator.c
├── lexer.c
├── node.c
├── object.c
├── objects
│ ├── number.c
│ └── string.c
├── parser.c
├── position.c
├── repl
│ ├── help.c
│ ├── input.c
│ ├── main.c
│ └── printast.c
├── symbol-table.c
├── token.c
└── utils.c
makeArc can be run using the arc command if installed, or via the local executable.
arc
# or
./arc-
Debug mode:
arc -d # or arc --debug -
Float precision:
arc -p 10 # or arc --float-precision 10 -
Execute code:
arc -c "5 + 5" # or arc --code "VAR x = 10"
-
Disable colors:
arc -n # or arc --disable-colored-formatting -
Run a file:
arc script.arc
sudo make installArc is regularly tested with Valgrind to ensure:
- No memory leaks
- No invalid reads or writes
- Clear and consistent ownership rules
valgrind --leak-check=full --show-leak-kinds=all arc- Lexer
- Token system
- REPL
- Error reporting with position tracking
- Parser (AST generation)
- Expression evaluation
- Variables and identifiers
- String literals
- Comparison and Logical operators
-
IF,THEN,ELIF,ELSEstatements - Logical
NOToperator - Scoped environments
- Functions
- Basic runtime system
- Bytecode virtual machine (long-term goal)
Arc is still early in development. The current focus is correctness, memory safety, and building a solid foundation for parsing and evaluation before moving toward more advanced language features.
GPL-3.0