An open API service indexing awesome lists of open source software.

https://github.com/blad/lain-syntax-web

Lain Syntax Highlighter for Browser
https://github.com/blad/lain-syntax-web

Last synced: about 1 year ago
JSON representation

Lain Syntax Highlighter for Browser

Awesome Lists containing this project

README

          

# Lain Syntax for Web

This library provides a lexer and parser that aids in generating an AST (Abstract Syntax Tree)
representation that can then be used to create a syntax highlighting or other
code-analysis tools.

## Grammar

```
::= + | -
::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
::= |
::= []
::= .
::= |

::= /* any-character */

::= A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z
::= _
::= | | | ε

::= | | - | _ | ε
::= |

# Lang Features:
::= " "

::= if []

::= ( ) [binding-expression]
::= ( binding-expression )
::= let

::= []
::= ( [] )

::= lambda

::= def

::= defn

::=
|
|

::= []
| []
| []

::= []

::=
|
|
|
|
|
|
|

::=
| :
| :

::=
|

::= ( ) []
|

```

### Example CSS for Generated HTML

```
.token-comment {
color: #bbb;
}

.token-parenthesis {
color: #999;
}

.token-name {
color: #0A0;
}

.token-access {
color: #aa0;
}

.token-number {
color: #0AA;
}

.token-string {
color: #AA0;
}

.token-invalidtoken {
color: #F00;
display: inline-block;
position: relative;
}

.token-invalidtoken:before {
content: "~~~~~~~~~~~~";
font-size: 0.6em;
font-weight: 700;
font-family: Times New Roman, Serif;
color: #F00;
width: 100%;
position: absolute;
top: 10px;
left: -1px;
overflow: hidden;
}
```