TaskLang++ is a lightweight domain-specific language (DSL) created to define and schedule tasks along with their execution dependencies. Built with Flex and Bison, it allows you to clearly specify task execution times, conditional runs, and dependency graphs, while automatically detecting any circular dependencies.
Created by: Supun Dharmaratne (IT24101504)
- Task Definition: Easily define tasks and their run scripts.
- Scheduling: Schedule tasks to run daily, weekly on specific days, or at specific times.
- Dependency Management: Define complex execution orders using
AFTER,BEFORE, andDEPENDS ONkeywords. - Conditional Execution: Trigger actions based on task
SUCCESSorFAILURE. - Circular Dependency Detection: Automatically detects and warns about infinite loops in your dependency graph using a built-in cycle checker.
Ensure you have flex, bison, and gcc installed on your system.
To build the parser:
# 1. Generate the parser code with Bison
bison -d parser.y
# 2. Generate the lexer code with Flex
flex lexer.l
# 3. Compile the generated C code
gcc parser.tab.c lex.yy.c -o tasklangTASK MyTask {
RUN "script.sh"
}
You can schedule tasks using EVERY, ON, and AT:
TASK DailyBackup {
RUN "backup.sh"
EVERY DAY AT 02:00
}
TASK WeeklyReport {
RUN "report.py"
EVERY WEEK ON MONDAY AT 09:00
}
TASK OneTime {
RUN "echo hello"
AT 15:30
}
You can structure the execution flow using dependencies:
TASK Build {
RUN "make build"
}
TASK Test {
RUN "make test"
AFTER Build
# Or: DEPENDS ON Build
}
TASK Alert {
RUN "alert.sh"
IF FAILURE
}
Save the following in a file (e.g., input.txt):
TASK Compile {
RUN "gcc main.c"
}
TASK Test {
RUN "./test"
DEPENDS ON Compile
}
Then run it through the compiled parser:
./tasklang < input.txt- Lexer (
lexer.l): Defines the tokens (keywords, identifiers, time values, strings) for TaskLang++ using regular expressions. - Parser (
parser.y): Defines the grammar rules, builds a task graph, and includes the DFS-based cycle detection algorithm to ensure dependency graphs are valid.