Cardboard is a lexer language for Minecraft syntax.
@bind(brigadier:string)
lexer String {
lexer Quoted {
(
text = "[\\\']+";
escape = '\\\\[tbrn\'\"\\\\]';
)*
close = "'" -> pop;
}
lexer DoubleQuoted {
(
text = "[\\\"]+";
escape = '\\\\[tbrn\'\"\\\\]';
)*
double_quoted_close = '"' -> pop;
}
@if("'"){
open = "'" -> push(Quoted);
} -> end
double_quoted_open = '"' -> push(DoubleQuoted);
}
keywords cannot be used as identifiers:
- lexer
- @bind
- @if
syntax in regex:
[_\w]\[_\w\d]*
used as lexer name and token name
Example:
hello
syntax in regex:
\@(?:[_\w][_\w\d]*)(?:\.(?:[_\w][_\w\d]*))*
Example:
@registries.block
qouted string syntax:
'
.*
'
double qouted string syntax:
"
.*
"
Example:
"hi this is cardboard"
'cardboard built with pulpboard'
syntax:
name
=
(strings
,lexer name
,cardboard meta
,group
,wrapper
);
Example
hi = "HI" hello @registries.block
read once syntax:
(
token
)
read once or repeat syntax:
(
token
)+
read once or null syntax:
(
token
)?
read null or repeat syntax:
(
token
)*
lexer will read items in a group and stoped when find the available index
read once syntax:
[
token
]
read once or repeat syntax:
[
token
]+
read once or null syntax:
[
token
]?
read null or repeat syntax:
[
token
]*
lexer will read items in a wrapper and stoped when reached the last index
Not ended syntax:
@if
(
strings
as a condition)
{
if-context
}
Ended syntax:
@if
(
strings
as a condition)
{
if-context
}
-> end
Ended means cardboard will not continue on next token in lexer
syntax:
token
|if-statement
|group
|wrapper
syntax:
lexer
name
{
lexer-context
}
syntax:
lexer
|token
|if-statement
|group
|wrapper