LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-04-2024, 02:30 AM   #1
ajiten
Member
 
Registered: Jun 2023
Posts: 375

Rep: Reputation: 4
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.
 
Old 02-04-2024, 03:57 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,855

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
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.
 
2 members found this post helpful.
Old 02-04-2024, 10:41 AM   #3
ajiten
Member
 
Registered: Jun 2023
Posts: 375

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by pan64 View Post
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.

Last edited by ajiten; 02-04-2024 at 11:03 AM.
 
Old 02-04-2024, 11:21 AM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,266
Blog Entries: 24

Rep: Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195
Quote:
Originally Posted by ajiten View Post
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).

Last edited by astrogeek; 02-04-2024 at 12:08 PM. Reason: Add relevant quote
 
Old 02-05-2024, 01:05 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,855

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
Quote:
Originally Posted by astrogeek View Post
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).
 
Old 02-05-2024, 04:29 AM   #6
ajiten
Member
 
Registered: Jun 2023
Posts: 375

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by astrogeek View Post
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.

Last edited by ajiten; 02-05-2024 at 06:01 AM.
 
Old 02-05-2024, 04:37 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,855

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
Quote:
Originally Posted by ajiten View Post
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 %.
 
Old 02-05-2024, 07:29 AM   #8
ajiten
Member
 
Registered: Jun 2023
Posts: 375

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by pan64 View Post
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.
Attached Thumbnails
Click image for larger version

Name:	Screenshot (241).png
Views:	9
Size:	159.9 KB
ID:	42518  

Last edited by ajiten; 02-05-2024 at 07:31 AM.
 
Old 02-05-2024, 07:43 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,855

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
I don't understand. Can't you just press the % key?
 
Old 02-05-2024, 10:38 AM   #10
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,865
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
How would that help with anything? Anyways, if vim is problematic, try mcedit, it has an ESC b sequence for this (or Alt+b)
 
Old 02-05-2024, 07:57 PM   #11
ajiten
Member
 
Registered: Jun 2023
Posts: 375

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by pan64 View Post
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.

Last edited by ajiten; 02-05-2024 at 08:09 PM.
 
Old 02-05-2024, 08:08 PM   #12
ajiten
Member
 
Registered: Jun 2023
Posts: 375

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by NevemTeve View Post
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'.
Attached Thumbnails
Click image for larger version

Name:	Screenshot (243).png
Views:	8
Size:	218.0 KB
ID:	42522  

Last edited by ajiten; 02-05-2024 at 09:05 PM.
 
Old 02-05-2024, 09:42 PM   #13
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,865
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
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.
 
1 members found this post helpful.
Old 02-05-2024, 11:19 PM   #14
ajiten
Member
 
Registered: Jun 2023
Posts: 375

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by NevemTeve View Post
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.
Attached Thumbnails
Click image for larger version

Name:	Screenshot (256).png
Views:	6
Size:	226.8 KB
ID:	42523  

Last edited by ajiten; 02-05-2024 at 11:28 PM.
 
Old 02-06-2024, 12:08 AM   #15
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,855

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
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

Last edited by pan64; 02-06-2024 at 12:17 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Handling space in lexer. ajiten Programming 5 11-28-2023 07:46 AM
Does lexer tool need be coded in the same language, as the source language? ajiten Programming 12 07-09-2023 11:18 PM
Where to post lexer file related issues. ajiten Programming 5 07-04-2023 02:06 AM
list all contains and subdirectories' contains babis Linux - Newbie 2 10-22-2004 09:40 PM
Command to find out which package contains which file ? javeree Slackware 6 07-10-2004 06:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration