[−][src]Macro alphabet::alphabet
alphabet!() { /* proc-macro */ }
Declares a constant alphabet. You can choose any valid identifier as the name for the alphabet.
Examples
Basic usage:
use alphabet_macro::alphabet; alphabet!(BINARY = "01"); alphabet!(ENGLISH = "abcdefghijklmnopqrstuvwxyz"); alphabet!(GERMAN = "aäbcdefghijklmnoöpqrstuüvwxyzß"); alphabet!(HEBREW = "אבגדהוזחטיכלמנסעפצקרשת"); assert_eq!(BINARY.len(), 2); assert_eq!(ENGLISH.len(), 26); assert_eq!(GERMAN.len(), 30); assert_eq!(HEBREW.len(), 22);
You can also specify a visibility for the generated alphabet:
use alphabet_macro::alphabet; alphabet!(pub BINARY = "01");
You can pass attributes to the generated alphabet as well. This includes doc comments, which internally use attributes:
use alphabet_macro::alphabet; alphabet! { /// An alphabet for binary strings. pub BINARY = "01"; }
Syntax
Alphabets follow the following syntax, with the nonterminal alphabet
being the contents of the alphabet! macro:
alphabet ::= attribute* visibility? identifier "=" literal-string ";"?