DCG to read Prolog terms

Hi and welcome!

Since no one answered yet, I can give it a try.

First, you should try and format your code as code. See here.

To your question. I wouldn’t worry about efficiency at first.

More important: is there a simple delimiter you can test for? End of line, tab, anything? Then just do like you did already:

string_without(Delimiters, S),
{ read_term_from_atom(S, T, []) }

(Don’t forget you still need to consume the delimiter!)

If this isn’t good enough for your input, I’d first try making sure that the input is such that it makes it easy to test for a delimiter.

If this isn’t good enough either: what does your input really look like?