boost::spirit::lex, how does one generate a end of file token? -


the question rather simple, i've written lexer, using boost::spirit, can't seem find way, generate eof token. - how 1 go doing this?

what eof token?

historically, platforms have associated special 'eof' (ascii 26, e.g.) characters text files. use of 0x15 newline character, such uses largely defunct. end of file better defined absense of further input, in other words: stream state, not character.

the token iterators spirit lex signal 'eof' returning end iterator.

both tokenizer api (lex::tokenize(...)) spirit qi understand behaviour (by exiting tokenizing loop (lex) and/or making qi::eoi parser succeed match).

e.g. if need assert parsing reached end of input, you'd say

 myrule = subrule1 >> subrule2 > qi::eoi; 

or if want assert presence of (say, closing ;) unless @ end of input:

 myrule = subrule1 >> subrule2 >> (qi::eoi | ';'); 

did miss question isn't addressed this?


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -