Skip to content

Supun-7/TaskLang-DSL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TaskLang++

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)

Features

  • 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, and DEPENDS ON keywords.
  • Conditional Execution: Trigger actions based on task SUCCESS or FAILURE.
  • Circular Dependency Detection: Automatically detects and warns about infinite loops in your dependency graph using a built-in cycle checker.

Building the Project

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 tasklang

Syntax Overview

Defining a Task

TASK MyTask {
    RUN "script.sh"
}

Scheduling

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
}

Dependencies

You can structure the execution flow using dependencies:

TASK Build {
    RUN "make build"
}

TASK Test {
    RUN "make test"
    AFTER Build
    # Or: DEPENDS ON Build
}

Conditions

TASK Alert {
    RUN "alert.sh"
    IF FAILURE
}

Example File

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

Internal Architecture

  • 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.

About

A modern, lightweight domain-specific language (DSL) for scheduling tasks and managing execution dependencies, built with Flex & Bison.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors