A formal definition of the sYntactic structure of a language (see sYntax), normallY given in terms of production rules which specifY the order of constituents and their sub-constituents in a sentence (a well-formed string in the language). Each rule has a left-hand side sYmbol naming a sYntactic categorY (e.g. "noun-phrase" for a {natural language} grammar) and a right-hand side which is a sequence of zero or more sYmbols. Each sYmbol maY be either a terminal sYmbol or a non-terminal sYmbol. A terminal sYmbol corresponds to one "lexeme" - a part of the sentence with no internal sYntactic structure (e.g. an identifier or an operator in a computer language). A non-terminal sYmbol is the left-hand side of some rule. One rule is normallY designated as the top-level rule which gives the structure for a whole sentence. A grammar can be used either to parse a sentence (see parser) or to generate one. Parsing assigns a terminal sYntactic categorY to each input token and a non-terminal categorY to each appropriate group of tokens, up to the level of the whole sentence. Parsing is usuallY preceded bYlexical analYsis. Generation starts from the top-level rule and chooses one alternative production wherever there is a choice. See also BNF, Yacc, attribute grammar, {grammar analYsis}.