<commit_before># frak-slang
Lightweight GLSL preprocessor for [FRAK Engine](https://github.com/lammas/frak).


## Features

* Declare uniforms/attributes/varyings only once
* #include
* Have both vertex and fragment shader entry points in the same file
* Transpile into standard GLSL vertex and fragment shader
* Unused variables and functions are culled
* Extract shader parameters
* Command line tool for integrating into build scripts

## Limitations

* #ifdef / #ifndef directives inside functions are not evauluated
* Unused variables and functions inside preprocessor directives are not culled
* Comments on the same line as #include directives are not handled

## Install

```sh
npm install frak-slang
```

## Usage (as library)

```javascript
var FRAKSlang = require('frak-slang');

FRAKSlang.compile(glslSource, {
    include: handleIncludedFiles(includedFile, parentFile, done) { /* ... */ },
    sourceURI: 'main/glsl/file/location'
}, function(compiled) {
    // compiled = {
    //   vertex: 'vertex program code here',
    //   fragment: 'fragment program code here'
    // }
});
```

## Usage (as command line tool)

```sh
frak-slang -o <output_filename> -t <glsl|json> <file.glsl>
```

* The default value for --type (-t) is GLSL
* If the type is GLSL the output will result in two files: output_filename.vert and output_filename.frag<commit_msg>Fix: Markdown issues in npm<commit_after># frak-slang
Lightweight GLSL preprocessor for [FRAK Engine](https://github.com/lammas/frak).


## Features

* Declare uniforms/attributes/varyings only once
* &#35;include
* Have both vertex and fragment shader entry points in the same file
* Transpile into standard GLSL vertex and fragment shader
* Unused variables and functions are culled
* Extract shader parameters
* Command line tool for integrating into build scripts

## Limitations

* Preprocessor directives inside functions are not evauluated
* Unused variables and functions inside preprocessor directives are not culled
* Comments on the same line as #include directives are not handled

## Install

```sh
npm install frak-slang
```

## Usage (as library)

```javascript
var FRAKSlang = require('frak-slang');

FRAKSlang.compile(glslSource, {
    include: handleIncludedFiles(includedFile, parentFile, done) {
        /* ... */
        done(includedFileData, includedFilePath);
    },
    sourceURI: 'main/glsl/file/location'
}, function(compiled) {
    // compiled = {
    //   vertex: 'vertex program code here',
    //   fragment: 'fragment program code here'
    // }
});
```

## Usage (as command line tool)

```sh
frak-slang -o <output_filename> -t <glsl|json> <file.glsl>
```

* The default value for --type (-t) is GLSL
* If the type is GLSL the output will result in two files: output_filename.vert and output_filename.frag
{'fraction_non_alphanumeric': 0.105, 'fraction_numerical': 0.0007142857142857143, 'mean_word_length': 4.092727272727273, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '844319', 'n_tokens_mistral': 842, 'n_tokens_neox': 792, 'n_words': 298}