libcpp backtrack lexer

Prathamesh Kulkarni bilbotheelffriend@gmail.com
Mon Feb 24 19:25:00 GMT 2014


How do I backtrack the lexer to restart lexing from a particular token
on the same
line ?
Shall this be correct: ?
cpp_token *cur_token = pfile->cur_token;
if (foo (pfile) == 0)  // foo advances pfile->cur_token
  pfile->cur_token = cur_token; // restart lexing from cur_token

foo does not advance pfile->cur_token beyond the same line, so I guess
cur_token shall still be pointing to a valid token (since tokens on
the same line are preserved) ?

Thanks and Regards,
Prathamesh



More information about the Gcc-help mailing list