I\'d like to use the same flex/bison scanner/parser for an interpreter and for loading a file to be interpreted. I can not get the newline parsing to work correctly in both
If pressing ENTER terminates a command then the lexer should return a token for \n. Returning 0 tells the parser the input source is complete (end of file for a file or ^D for a terminal). Add an end-of-line token to your grammar and have the lexer return that when it sees \n.
ETA: But don't forget to handle the case of the last line not ending in ENTER. Have your lexer return an end-of-line token at the end of file unless the last character is \n.