Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9013143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:11:10+00:00 2026-06-16T03:11:10+00:00

How do I parse the standard input (without buffering)? If I understand correctly, phrase/2

  • 0

How do I parse the standard input (without buffering)? If I understand correctly, phrase/2 needs a list, and phrase_from_file/2 from library(pure_input) needs a file.

I solved my problem using normal predicates (not DCG) and using built-ins like get_char/2 and read_line_to_codes/2, but at the end the implementation looks suspiciously similar to the solution I would have written in C.

And if I can sneak a very much related question: what is standard input in SWI-Prolog? read_line_to_codes (library(readutil)) needs an input stream (unlike get/1, for example). I get it with the following predicate:

input_stream(Stream) :-
    current_stream(Object, read, Stream),
    integer(Object).

. . . which of course works, but feels a bit hacked. Is it possible to have more than one open input stream? How am I going to know which one is the standard input of the operating system (Linux in my case)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:11:12+00:00Added an answer on June 16, 2026 at 3:11 am

    I think you are looking for the proper naming of streams. Here a sample that could be useful:

    ?- read_line_to_codes(user_input,L).
    |: a line
    L = [97, 32, 108, 105, 110, 101].
    

    The most detailed explanation page I found is here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a perl script to parse tab delimited data from standard input.
I parse some values from an xml file. There is a @25-12-2010'T'23:40:00 string with
I need to read a string from standard input, perform some operations and meanwhile
void PDA::parse(vector<string> words){ for(int i=0; i<words.size();i++){//for each string in the input file string token=words[i];
My input file is actually multiple XML files appending to one file. (It's from
I parse an xml file containing books, for each new node I go: Book
I parse xml file in android. I copypasted example... It works with english words,
I'm trying to parse a CSV file in C#. Split on commas (,). I
The text file below is the standard I am dealing with. Basically I want
I would like to parse the .ssh/config file for proxy information contained therein and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.