I was hoping that you could help me with a little issue I am working on.

I am trying to write a utility that will analyse a makefile, and create a
target 'tree' from it.

In preparation for this, I thought I would write out the Backus-Nour Fom of
the various elements of a makefile, so that I could structure my app
efficiently.

I have enclosed my best analysis of the make document from the GNU manuals
online.
Below is the result of the first stab at BNF for an explicit rule.
Could you kindly have a look at it,, and tell me if you see any errors.

Many Thanks,

Jack


Explicit Rule Syntax

rule:  how to work with a target ( note: a rule may contain zero to many
targets )

from http://www.gnu.org/manual/make-3.77/html_mono/make.html#SEC20

        In general, a rule looks like this: 

        targets : dependencies
                command
                ...
        or like this: 

        targets : dependencies ; command
                command
                ...


So from this we infer the following BNF statement

        (* a rule must start at the first character on a new line - no
whitespace may proceed the identifier name of the rule*)
        rule = whitespace-, name,":",[dependancy-list],
([command-seperator], [command-list])

        dependancy-list =  [name], { (dependancy-seperator, name) };
        
        (* when a command starts on a new line, it must be proceeded by a
horizontal tabulation character*)
        command-list = command, {(command-seperator, command)};

        command = name, [argument-list];

        command-seperator = ";" | (new-line-char, horiz-tab-char);

        dependancy-seperator = {whitespace}, ",", {whitespace};
  
        argument-list = name; {(whitespace, name)}

        name = letter, {letter | decimal-digit | full-stop };

        whitespace = " " | horiz-tab-char;
        
        full-stop = ".";

This message is for the named person's use only.  It may contain 
confidential, proprietary or legally privileged information.  No 
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please immediately delete it and all
copies of it from your system, destroy any hard copies of it and notify the
sender.  You must not, directly or indirectly, use, disclose, distribute, 
print, or copy any part of this message if you are not the intended 
recipient. CREDIT SUISSE GROUP and each of its subsidiaries each reserve
the right to monitor all e-mail communications through its networks.  Any
views expressed in this message are those of the individual sender, except
where the message states otherwise and the sender is authorised to state 
them to be the views of any such entity.



Reply via email to