Make sure alternate tags have at least two elements

This change allows adding single words with a 50% probability like
'[word]' (instead of '[word|]').
common grammar: Make compatible with AMD/CommonJS
common grammar: Update rules
git grammar: Make compatible with AMD/CommonJS
common grammar: Create common function for regexp search/replace