Parsing Command Line Arguments for Bison [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 days ago.
Improve this question
I am creating my own compiler for a college class. The current project is asking me to edit a bison file (parser.y) to accept command line arguments to the function header, such as:
function main a: integer, b: integer returns integer;
Using the execution method (using linux): $ ./compile < test.txt 2 4, a
would have a value of 2 and b would have a value of 4.
I don't know how to modify a bison file to accept command line parameters. Any advice? (Below is the function heading in my parser.y file)
Parser.y Header Snapshot
I've tried searching online for explanations like yy_scan_strings, but don't seem to be making progress.

Related

Fortran temporary files [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I've noticed that when my fortran code is running, the executable generates several temporary files with the name patter fort* where * is a 6 digit alpha numeric. The number of files generated corresponds to the number of threads the program is running on. The files are cleared once the program exits.
What are these files? And what is stored in them?
Edits: The program has no commands that generate these files.

Read specific line from a file using c++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I need to read just 1 specific line from a text file using c++. The file doesn't change it's content, the lines are always the same. I need to be able to read line 37 for example, without having to read the previous 36 lines. Is this even possible?
If you know the count of characters preceeding line 37 use std::istream::seekg() to set the file pointer to the begin of line 37 and use std::getline() to read it.
OTOH, if said file never changes there is no need to read it at all. Just define the string in your code.

Get total number of lines of code in translation unit [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Example:
#include <iostream>
int main() {
return 0;
}
I want to know total number of LOC, including everything included from iostream.
You could use GCC's -E-option, which does preprocessor only compilation, so all makros and includes will be expanded and the resulting code is sent to console output. Feeding this into a word count / line count should give the desired result:
gcc -E main.cpp | wc -l

what does this stanford lirbrary mean? C++ simpio.h getInteger() [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i'm trying to understand this library that stanford uses for their CS course but i can't just use this feature in my CS course back in my home. How do i emulate this feature? i was wondering is this a getline(cin, integer)? or is this something to do with fstream? The reason being, i'm trying to go through the lecture series at UDEMY.
Here is the definition.
int getInteger(string prompt = "");
Reads a complete line from cin and scans it as an integer. If the scan
succeeds, the integer value is returned. If the argument is not a
legal integer or if extraneous characters (other than whitespace)
appear in the string, the user is given a chance to reenter the value.
If supplied, the optional prompt string is printed before reading the
value.
Usage:
int n = getInteger(prompt);
You can download simpio.h here: http://www.eecs.wsu.edu/~cs150/prog/libs.htm
If you can't or don't want to use the library, you could study its source code.

How to check multiple files for duplicates in C++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I need to compare 5 files by their file paths: a,b,c,d,e and find duplicates if exists.
How can I do this in c++ via md5sum comparison of files?
You'd need to compute a checksum for each file (write it yourself or call an external program), get hold of each file, ... This depends on the operating system. It is much easier to do something like this in a scripting language.