Add string escape sequences

- reorganize rules
- fix a few bugs