LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Which source file contains the lexer (scanner) for make file? (https://www.linuxquestions.org/questions/programming-9/which-source-file-contains-the-lexer-scanner-for-make-file-4175733513/)

ajiten 02-04-2024 02:30 AM

Which source file contains the lexer (scanner) for make file?
 
Like Python, 'make' files need indentation.
'make' needs that the indented line be spaced by a tab, and putting instead spaces (for getting the same number of spaces, as a tab) wouldn't work.
I assume that this task of checking if a tab is there before any indented line, is done by the scanner (lexer/lexical analyzer) for the 'make' utility.
Please tell where to locate the same in the source code of the make utility.
Am working in cygwin, but assume that the path of the file would be the same as in Linux.

pan64 02-04-2024 03:57 AM

no, that is not indentation, but anyway if you wish you can call it indentation. The tab (one tab character) at the beginning of the lines is a requirement, otherwise the indentation (or spacing) is irrelevant.
It is explained here: https://www.gnu.org/software/make/ma...le-Syntax.html

The source code can be found here: https://git.savannah.gnu.org/cgit/ma...c?h=4.4.1#n570
It has its own solution, it doesn't use lexer.

ajiten 02-04-2024 10:41 AM

Quote:

Originally Posted by pan64 (Post 6481192)
no, that is not indentation, but anyway if you wish you can call it indentation. The tab (one tab character) at the beginning of the lines is a requirement, otherwise the indentation (or spacing) is irrelevant.
It is explained here: https://www.gnu.org/software/make/ma...le-Syntax.html

The source code can be found here: https://git.savannah.gnu.org/cgit/ma...c?h=4.4.1#n570
It has its own solution, it doesn't use lexer.

Thanks, but still till line #1340, am still trying to find the closing that started at the line #570.
Please tell why the line #1008 (&, at line #1162), starts with an opening brace, when there is no function's start for the same.
It seems like a scope, which have forgotten; i.e. one without a function definition.

P.S.: Also, seems the code block ends at the line #1982, as by putting in VS, could see the ending of the opening brace there.
So, if am correct, it is a 1412 lines of code block.

P.S.(1) : Might be am wrong, as seems the end of the block is further down. Please indicate, where the end lies, as difficult to check just by using VS editor.

astrogeek 02-04-2024 11:21 AM

Quote:

Originally Posted by ajiten (Post 6481282)
Thanks, but still till line #1340, am still trying to find the closing that started at the line #570.
Please tell why the line #1008 (&, at line #1162), starts with an opening brace, when there is no function's start for the same.
It seems like a scope, which have forgotten; i.e. one without a function definition.

Good old Vim says that block runs from #570 to #1359.

The block from #1008 to #1346 is for scope (see comment preceeding it).

pan64 02-05-2024 01:05 AM

Quote:

Originally Posted by astrogeek (Post 6481300)
Good old Vim says that block runs from #570 to #1359.

The block from #1008 to #1346 is for scope (see comment preceeding it).

Yes, that is the answer. scope means variables defined inside { } do not exist outside, they are local to that scope. You can find it everywhere, within if, else, for, while and other statements, and you can also use it alone (see line 784 too).

ajiten 02-05-2024 04:29 AM

Quote:

Originally Posted by astrogeek (Post 6481300)
Good old Vim says that block runs from #570 to #1359.

The block from #1008 to #1346 is for scope (see comment preceeding it).

Request a tool that helps find the (matching) ending parenthesis, as don't think vim helps in that.
Even VS seems to not help, as easily got confused by that to go much further (i.e., till the line #1982), than the end of the block stated by you.
Have read something here, that states to make own lexer, for the makefiles, in the response by @gstavi; but couldn't make much sense out of it.
Anyway, am amazed how you found out so quickly, as where the code block correctly ends.

pan64 02-05-2024 04:37 AM

Quote:

Originally Posted by ajiten (Post 6481463)
Request a tool that helps find the (matching) ending parenthesis, as don't think vim helps in that.

Request to do at least minimal research on that, vim has a feature to do that, just press %.

ajiten 02-05-2024 07:29 AM

1 Attachment(s)
Quote:

Originally Posted by pan64 (Post 6481465)
Request to do at least minimal research on that, vim has a feature to do that, just press %.

Sorry, failed completely. Tried here, but could not gather anything. Also, saw through the user manual too.
Also, looked here; but not helped again.

Tried youtube video, but didn't help.

Tried WSL for running ubuntu on windows.
But, still didn't help though vim works.
The result is attached herewith (though am suggested here to not attach), in order to ask for help; which feel is lesser than what is needed by me.

pan64 02-05-2024 07:43 AM

I don't understand. Can't you just press the % key?

NevemTeve 02-05-2024 10:38 AM

How would that help with anything? Anyways, if vim is problematic, try mcedit, it has an ESC b sequence for this (or Alt+b)

ajiten 02-05-2024 07:57 PM

Quote:

Originally Posted by pan64 (Post 6481511)
I don't understand. Can't you just press the % key?

Please, if possible, show what the pressing the % key achieves, as for me makes no show of matching parenthesis.
Am also confused as why nowhere (book, webpage, youtube) is shown the 'actual' effect of pressing %; at least a video could have shown it.
I tried many times, by placing the cursor at the line #571, & pressing % key; but failed to see what happens. Just the cursor disappears, but how to go down so much below is really an issue; that too by pressing the 'down' key!

Wish if you could please show what it achieves.

Have tried for hundreds of times, but of no avail.

ajiten 02-05-2024 08:08 PM

1 Attachment(s)
Quote:

Originally Posted by NevemTeve (Post 6481552)
How would that help with anything? Anyways, if vim is problematic, try mcedit, it has an ESC b sequence for this (or Alt+b)

I wished if you could help in making a solution like the one suggested by @gstavi, in my post (#6).
That would have opened the path for future needs being satisfied myself.

Also, mcedit (if am not wrong) is an acronym for 'MidNight Commander', which am unsure of still. The site here hope is in correct direction, please vindicate.

-----

P.S. : Have installed mcedit, but seems that need to see the line numbers at the top (as the option for adding the line number, as stated here does make no difference; in terms of adding line numbers to the left end, as in vim), rather than at the left end of each line, as in vim. But, still don't know how to see the matching close brace line by using 'Alt+b'.

NevemTeve 02-05-2024 09:42 PM

First move the cursor onto a { or } character, then press Alt+b
You can practice with another key combination: Alt+n (or Esc n) toggles line numbers on/off.

ajiten 02-05-2024 11:19 PM

1 Attachment(s)
Quote:

Originally Posted by NevemTeve (Post 6481700)
First move the cursor onto a { or } character, then press Alt+b
You can practice with another key combination: Alt+n (or Esc n) toggles line numbers on/off.

Thanks a lot, but the same feature should have been elsewhere (other editors) too. Regarding vim, it might be the case that it is not correctly working on the WSL ubuntu (over Windows).
Also, please help (if possible) in implementing the idea of @gstavi in (my) post #6.

pan64 02-06-2024 12:08 AM

First try another file or location, where you can see both the opening and closing bracket/paren and press %. You will see how the cursor is moving.
Your case is almost the same, just the cursor is moving out of the display (probably).
see https://www.youtube.com/watch?v=K05TpcntFXs&t=320s


All times are GMT -5. The time now is 06:12 PM.