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
- Host: GitHub
- URL: https://github.com/blad/lain-syntax-web
- Owner: blad
- License: mit
- Created: 2023-08-06T19:05:46.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-28T03:16:09.000Z (almost 3 years ago)
- Last Synced: 2025-02-06T05:19:01.100Z (over 1 year ago)
- Language: TypeScript
- Size: 53.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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;
}
```