c++ - Going from parsing/reading an entire text file to parsing/reading line by line -
i making basic interpreter (using own language) functions of set theory (union, intersection, etc.). i'm coding c++ , doing reading , parsing .txt file. however, i'm trying make code can executed in "command-by-command" way, without having command window close. i'm hoping able have multiple functions read , performed 1 after using carriage return.
is there way can change parser keep accepting commands/function instead of reading entire .txt file @ 1 time?
generally, when "parsing" something, idea read token @ time, , not care lines , other such things.
if language structured way, read language stream, , when see call function (or whatever want call it), execute function go along [assuming don't compile machine code requires entire thing compiled @ once, of course - if that's case, you're in bit of work...]
but if want read line @ time, use istream& getline(istream&, std::string&)
method. reads single line. parse line , whatever makes sense result of parsing.
Comments
Post a Comment