jamesjuett / lobster

Interactive Program Visualization Tools
8 stars 3 forks source link

cin and stream improvements #275

Closed jamesjuett closed 2 years ago

jamesjuett commented 3 years ago

This PR adds functionality for input streams (i.e. cin) and in particular implements stream iostates.

It adds these member functions to istream:

It fixes some non-standard behavior on the >> operator, including:

It adds a label to the UI to show whether the the fail, eof, or bad bits are set on cin.

It also adds a bunch of regression tests for input parsing and iostates.

It also includes some internal refactoring that should make implementing file streams easier. To support this, the ability to attach auxiliary data to a CPPObject is added. For example, for cin, this is used to tie the StandardInputStream object (in typescript) to the CPP istream in the simulated program. It can also be used to tie the TS representation of a file input stream to the CPP ifstream object.

This PR does NOT implement anything that can cause the standard input stream to actually enter a bad or EOF state.

Closes #261.