public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* libcpp backtrack lexer
@ 2014-02-24 19:25 Prathamesh Kulkarni
  2014-02-26 19:30 ` Prathamesh Kulkarni
  0 siblings, 1 reply; 2+ messages in thread
From: Prathamesh Kulkarni @ 2014-02-24 19:25 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: libcpp backtrack lexer
  2014-02-24 19:25 libcpp backtrack lexer Prathamesh Kulkarni
@ 2014-02-26 19:30 ` Prathamesh Kulkarni
  0 siblings, 0 replies; 2+ messages in thread
From: Prathamesh Kulkarni @ 2014-02-26 19:30 UTC (permalink / raw)
  To: gcc-help

Ping ?

On Tue, Feb 25, 2014 at 12:55 AM, Prathamesh Kulkarni
<bilbotheelffriend@gmail.com> wrote:
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-26 19:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-24 19:25 libcpp backtrack lexer Prathamesh Kulkarni
2014-02-26 19:30 ` Prathamesh Kulkarni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).