A "grammar" is a set of rules that speakers implicitly agree to use so they can understand each other. Linguists distinguish between descriptive and prescriptive grammars. Most languages have a written form and a spoken form.
A grammar does not have to describe sound or text: visual language also has a grammar and even a phonology! These hand-icons are used to establish hand-shape for an ASL word, "snow-boarding."