It's basically the mnemonics, elements, and valid ranges documented in the PLC User Manual for each instruction.
Chapter 3 has PLC Memory Map tables that describe all the various element tables. Chapter 5 and a few others show each instruction, and a list of valid elements for each parameter.
Here's the link to the 405 User Manual page:
http://www.automationdirect.com/static/manuals/d4user/d4user.htmlSpecific grammars for scripting instructions like MATH* IBoxes, PRINT, ECEMAIL, etc. are in those specific instructions' Help topic (I don't think those are documented in the manual).
The grammar for Nickname records are basically double-quoted fields
"element", "nickname", "wiring info", "description"
and if any of those contain a double quote, just use two double quotes, e.g. the text for the description
Fred said, "Hello"would be
"X0", "PumpA", "xyzzy", "Fred said, ""Hello"""
If you have any specific questions on any specific instruction or element, please post it.
If you use any nicknames with spaces, commas, or quotes in the program/mnemonic portion of your program, make sure you enclose the nickname in double quotes (and replace double quotes within nicknames with two double quotes, similar to the Description example above).
Also, you may want to try
exporting some of the example projects to get a good feel for the grammar. You can also generate your own gnarly examples in DirectSOFT and export that to get a better feel for the various grammars. The export operation generates importable text.