bp/grammars/builtins.bp
2021-05-22 13:28:33 -07:00

48 lines
1.1 KiB
Plaintext

# This file contains some default general-purpose definitions.
nodent: \N !(\t/` )
indent: \N (` /\t)
dedent: $ !(nodent/indent)
utf8-codepoint: (
\x00-x7f
/ \xc0-xdf 1\x80-xbf
/ \xe0-xef 2\x80-xbf
/ \xf0-xf7 3\x80-xbf
)
crlf: \r\n
cr: \r
anglebraces: `< ..%(\n/anglebraces/string) `>
brackets: `[ ..%(\n/brackets/string) `]
braces: `{ ..%(\n/braces/string) `}
parens: `( ..%(\n/parens/string) `)
string: `" ..%string-escape `" / `' ..%string-escape `'
string-escape: `\ (`x 2 Hex / 1-3 `0-7 / `u 1-4 Hex / .)
left-id-edge: !<id-char
right-id-edge: !id-char
id: left-id-edge !`0-9 !(keyword !id-char) +id-char
id-char: `a-z,A-Z,_,0-9
var: id
keyword: !"" # No keywords defined by default
left-word-edge: !<word-char
right-word-edge: !word-char
word-char: `a-z,A-Z,_,0-9,-,'
word: left-word-edge +word-char
HEX: `0-9,A-F
Hex: `0-9,a-f,A-F
hex: `0-9,a-f
number: +`0-9 [`. *`0-9] / `. +`0-9
int: +`0-9
digit: `0-9
Abc123: `a-z,A-Z,0-9
ABC123: `A-Z,0-9
abc123: `a-z,0-9
Abc: `a-z,A-Z
ABC: `A-Z
abc: `a-z
esc: \e
tab: \t
nl: \n; lf: \n
comment: !''; # No default definition, can be overridden
__: *(` /\t/\n/\r/comment)
_: *(` /\t)