Quote Originally Posted by mickey View Post
hoping it's LL1: the parser must accept things like this below
Qt Code:
  1. <send>
  2. <target>
  3. <string name="find"> Primer </string>
  4. </target>
  5. </send>
To copy to clipboard, switch view to plain text mode 
Hello,
here I did something like this:
Qt Code:
  1. Token nextToken() {
  2. while ( done ) {
  3. char = (char) _data[_pos++]; // I read the entire file into a block of memory
  4. switch (state) {
  5. case 0 : if (ch == '<') state = 1; break;
  6. case 1 : if (ch == 's') state = 2; break;
  7. case 2 : if (ch == 'e') state = 3; break;
  8. case 3 : if (ch == 'n') state = 4; break;
  9. case 4 : if (ch == 'd') state = 5; break;
  10. case 5 : if (ch == '>') state = 6; return OpenSend;
  11. case 6: .......// all other
  12. case n: if (ch == '<') state = n+1; break;
  13. case n+1 : if (ch == '/') state = n+2; break;
  14. //and so on to recognize "send" and ">"
  15. }
  16. }
  17. }
To copy to clipboard, switch view to plain text mode 
I wonder: Must I to reconize in the scanner two time the string "send". Is there any tricks to avoid this? ( I mean, I'd like to avoid to write states that recognizes the same "string". I have the same problem with <string></string> and <target></target>).
Hope it's clear...
thanks,