Gri: How synonyms are parsed

Chapters: 1: Introduction 2: Simple example 3: Invocation 4: Finer Control 5: X-Y Plots 6: Contour Plots 7: Image Plots 8: Examples 9: Gri Commands 10: Programming 11: Environment 12: Emacs Mode 13: History 14: Installation 15: Gri Bugs 16: Test Suite 17: Gri in Press 18: Acknowledgments 19: License Indices: Concepts Commands Variables | ### 10.11.2: How Gri parses commands Whenever Gri reads a command line, it compares it with its list of commands. This list is searched in this order: (1) the universal ``gri.cmd`' file (see Invoking Gri), (2) your resource file (see Resource File), if it exists, and then (3) your command file itself. Gri stops searching when it finds a Gri command that matches the command line. "Matching" means that the command line is identical in all words in a Gri command, scanning from the left, until it encounters a word containing A quote (e.g. ``"string"`') A synonym name (e.g. ``\file`') A variable name (e.g. ``.number.`') An opening square bracket (e.g. ``[option]`') An opening brace (e.g. ``{a|b}`') A choice between two items (e.g. ``first|second`') A variable-name with a ``&`' character immediately to the left (e.g. ``&.var.`'). This is a signal that the variable may be changed inside the newcommand (see The Ampersand Syntax). A synonym-name with a ``&`' character immediately to the left (e.g. ``&\syn`'). This is a signal that the synonym may be changed inside the newcommand (see The Ampersand Syntax). When Gri finds a command that matches your command line, it assumes that this is the intended command, and searches no further. This means that you must be careful not to have your command hidden by other commands. For example, if your resource file contained these lines, Gri would never execute the second new command, because calls to it match the first command. To avoid this, you may either reverse the order of the definitions, so that Gri will find the proper routine, or rename one of the routines.
    `Draw foo'
    Draw a foo.
    {
      show "drawing a foo"
    }
    `Draw foo bar'
    Draw a foo bar.
    {
      show "drawing a foo bar"
    }
Gri searches the ``gri.cmd`' file first, so any new command that you create that clashes with built-in commands will be ignored by Gri (see Invoking Gri). Gri will warn you of this, and proceed, ignoring your newer definition. To get around this, you can use capital letters to begin the words of your new command. By convention, Gri never uses capital letters in this way, so a clash is impossible (except with any similar command you might have defined previously, such as in your ``~/.grirc`' file).