/* OPTIONS */

options_defaultstring ::= "OPTIONS" "DEFAULTSRING" ("TEXT" | "GRAPHEMES" | "CODEPOINTS" | "BYTES" | "NONE")

options_coercions ::= "OPTIONS" "COERCIONS" ("PROMOTE" | "DEMOTE" | "LEFT" | "RIGHT" | "NONE")


/* TUTOR BIMS */

bytes_c2u ::= "c2u(" format? ")"

bytes_c2x ::= "c2u(" encoding? ")"

bytes_center ::= ( "center(" | "centre(" ) length ( "," pad)? ")"

bytes_copies ::= "copies(" n ")"

bytes_datatype ::= "datatype(" type? ")"

bytes_left ::= "left(" length ( "," pad)? ")"

bytes_length ::= "length"

bytes_lower ::= "lower(" n? ("," length)? ")"

bytes_pos ::= "pos(" needle "," start? ("," length)? ")"

bytes_reverse ::= "reverse"

bytes_right ::= "right(" length ( "," pad)? ")"

bytes_stringtype ::= "stringtype(" type? ")"

bytes_substr ::= "substr(" n "," length? ("," pad)? ")"

bytes_upper ::= "upper(" n? ("," length)? ")"

bytes_uc2 ::= "u2c"

/* Utility classes */

MultiStageTable_compress ::= "compress(" buffer ("," chunk_size)? ")"

MultiStageTable_index ::= "[" n "]"

MultiStageTable_class_new ::= "new(" offset "," chunks "," table_size? "," chunk_size? "," width? "," big_values? ")"

PersistentStringTable_load ::= "load(" source ")"

PersistentStringTable_save ::= "save(" target ")"

/* TUTOR BIFS */

BIF_BYTES ::= "BYTES(" string ")"

BIF_CODEPOINTS ::= "CODEPOINTS(" string ")"

BIF_C2U ::= "C2U(" string ( | "," format) ")"

BIF_C2X ::= "C2X(" string ")"

BIF_CHARIN ::= "CHARIN(" (| name) "," (| start) (|"," length) ")"

BIF_CHAROUT ::= "CHAROUT(" (| name) "," (| string) (|"," start) ")"

BIF_CHARS ::= "CHARS(" (|name) ")"

BIF_CENTER ::= ( "CENTER(" | "CENTRE(" ) string "," length (| "," pad) ")"

BIF_COPIES ::= "COPIES(" string "," n ")"

BIF_DATATYPE ::= "DATATYPE(" string (| "," type) ")"

BIF_DECODE ::= "DECODE(" string "," encoding (|"," ( |format) (| "," error_handling)) ")"

BIF_ENCODE ::= "ENCODE(" string "," encoding (| "," error_handling) ")"

BIF_GRAPHEMES ::= "GRAPHEMES(" string ")"

BIF_LEFT ::= "LEFT(" string "," length (| "," pad) ")"

BIF_LENGTH ::= "LENGTH(" string ")"

BIF_LINEIN ::= "LINEIN(" (| name) "," (| line) (|"," count) ")"

BIF_LINEOUT ::= "LINEOUT(" (| name) "," (| string) (|"," line) ")"

BIF_LINES ::= "LINES(" (| name) (| "," '"Normal"' | "," '"Count"') ")"

BIF_LOWER ::= "LOWER(" string "," (| n) (|"," length) ")"

BIF_N2P ::= "N2P(" name ")"

BIF_P2N ::= "P2N(" codepoint ")"

BIF_POS ::= "POS(" needle "," haystack "," (| start) (| "," length) ")"

BIF_REVERSE ::= "REVERSE(" string ")"

BIF_RIGHT ::= "RIGHT(" string "," length (| "," pad) ")"

BIF_STREAM ::= "STREAM(" name "," '"Command"' "," stream_command ")"

BIF_STREAM_COMMAND_OPEN ::= "Open" (| (("BOth" | "Write") ("APpend" | "REPlace")) | "REAd") (OPTIONS - fragment) (ENCODING - fragment)

BIF_STREAM_COMMAND_OPEN_ENCODING ::= (| "ENCODING" encoding (| "TEXT" | "GRAPHEMES" | "CODEPOINTS") (| "REPLACE" | "SYNTAX"))

BIF_STREAM_QUERY_ENCODING ::= "Query" "ENCODING" (| "NAME" | "TARGET" | "ERROR" | "LASTERROR")

BIF_STRINGTYPE ::= "STRINGTYPE(" string ( | "," type) ")"

BIF_SUBSTR ::= "SUBSTR(" string "," n "," (| length) (| "," pad) ")"

BIF_TEXT ::= "TEXT(" string ")"

BIF_U2C ::= "U2C(" u-string ")"

BIF_UNICODE_FUNCTIONAL ::= "UNICODE(" string "," function ")"

BIF_UNICODE_PROPERTY ::= "UNICODE(" code "," '"PROPERTY"' "," name ")"

BIF_UPPER ::= "UPPER(" string "," (| n) (|"," length) ")"

BIF_UTF8 ::= "UTF8(" string (|"," ( |format) (| "," target (| "," error_handling)) )")"