Bug 51457: Avoid some backtracking when tokenizing table attributes

Parsing of table cell attributes in the row syntax involves a lot of
backtracking. This patch avoids some of that backtracking by applying a
conservative heuristic for valid attribute names first.

This drops the parse time on pathological pages like
http://el.wikipedia.org/wiki/%CE%A0%CE%BF%CF%81%CE%B5%CE%AF%CE%B1_%CF%84%CF%89%CE%BD_%CE%BA%CF%85%CF%80%CF%81%CE%B9%CE%B1%CE%BA%CF%8E%CE%BD_%CE%BF%CE%BC%CE%AC%CE%B4%CF%89%CE%BD_%CF%83%CF%84%CE%B1_%CE%BA%CF%8D%CF%80%CE%B5%CE%BB%CE%BB%CE%B1_%CE%95%CF%85%CF%81%CF%8E%CF%80%CE%B7%CF%82
from hours to a few minutes.

It is likely not yet a complete fix for bug 51457, but at least avoids
blocking workers for hours.

TODO:
- Investigate whether there is a bug in memoization keys based on syntax
  flags
- Further speed up attribute parsing, in particular for heavily quoted values
  like | '''foo''' || '''bar''' || ..

Change-Id: I093a9d908097835c3797b746b41d22e16f9251af
Merge "Bug 51457: Avoid some backtracking when tokenizing table attributes"