proh14 / crap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CRAPLang - CSS Really is a Programming Language

Developed by Badge Powerd by Badge

not to be confused with crablang, which is a completely different thing.

CRAP is a general purpose programming language inspired by CSS🔥.

Getting Started💫

  • No Comments, who needs them anyway. just write self-documenting code.
  • Selectors are used to define functions.
  • Attributes are used to define parameters.
  • Custom properties are used to define variables.
  • declarations are function calls with values as parameters.
  • @if, @elif, @else, @return are used for control flow.
  • Nested selectors are supported.
  • print is used to print values to the console.
  • () is used as a placeholder for default values in function calls. If there is no default value, the parameter is required.
  • No null values but also no optional types either, because...sir this is CRAP.
  • Check out the examples below for more information.

Usage📔

  • Clone the repository
git clone https://github.com/shreyassanthu77/crap.git
cd crap
  • Make sure you have go installed
  • Build main.go
go build -o crap main.go
  • Run the examples
./crap examples/*.css

Docker

  • Build the docker image
docker build -t crap . && docker run -it crap

this will open a shell inside the container, you can run the examples from there.

  • Run the examples
./crap examples/*

Examples📝

Hello World

main {
    print: "Hello World!";
}

Factorial

factorial[n] {
    @if $n == 0 || $n == 1 {
        @return 1;
    }

    @return $n * factorial($n - 1);
}

main {
    print: factorial(5);
}

Fibonacci

fibonacci.rec[n][a=0][b=1] {
	@if $n == 0 {
		@return $a;
	}
	print: $a;
	@return fibonacci.rec($n - 1, $b, $a + $b);
}

fibonacci[n] {
	@return fibonacci.rec($n, (), ());
}

main {
	fibonacci: 10;
}

Progress

  • Lexer
  • Parser
  • Interpreter
  • Compiler

About

License:MIT License


Languages

Language:Go 99.8%Language:Dockerfile 0.2%