* EBNF grammar for the Nix expression language.
This commit is contained in:
		
							parent
							
								
									153429520a
								
							
						
					
					
						commit
						b0c9baf1b5
					
				
					 4 changed files with 198 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -64,6 +64,11 @@ AC_ARG_WITH(docbook-catalog, AC_HELP_STRING([--with-docbook-catalog=PATH],
 | 
			
		|||
  docbookcatalog=$withval, docbookcatalog=/docbook-dtd-missing)
 | 
			
		||||
AC_SUBST(docbookcatalog)
 | 
			
		||||
 | 
			
		||||
AC_ARG_WITH(docbook-ebnf-catalog, AC_HELP_STRING([--with-docbook-ebnf-catalog=PATH],
 | 
			
		||||
  [path of the DocBook XML EBNF module DTD]),
 | 
			
		||||
  docbookebnfcatalog=$withval, docbookcatalog=/docbook-ebnf-dtd-missing)
 | 
			
		||||
AC_SUBST(docbookebnfcatalog)
 | 
			
		||||
 | 
			
		||||
AC_ARG_WITH(docbook-xsl, AC_HELP_STRING([--with-docbook-xsl=PATH],
 | 
			
		||||
  [path of the DocBook XSL stylesheets]),
 | 
			
		||||
  docbookxsl=$withval, docbookxsl=/docbook-xsl-missing)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
ENV = SGML_CATALOG_FILES=$(docbookcatalog)
 | 
			
		||||
ENV = SGML_CATALOG_FILES=$(docbookcatalog):$(docbookebnfcatalog)
 | 
			
		||||
 | 
			
		||||
XMLLINT = $(ENV) $(xmllint) $(xmlflags) --catalogs
 | 
			
		||||
XSLTPROC = $(ENV) $(xsltproc) $(xmlflags) --catalogs \
 | 
			
		||||
| 
						 | 
				
			
			@ -13,7 +13,7 @@ man1_MANS = nix-env.1 nix-store.1 nix-instantiate.1 \
 | 
			
		|||
SOURCES = manual.xml introduction.xml installation.xml overview.xml \
 | 
			
		||||
 $(man1_MANS:.1=.xml) \
 | 
			
		||||
 troubleshooting.xml bugs.xml opt-common.xml opt-common-syn.xml \
 | 
			
		||||
 quick-start.xml style.css images
 | 
			
		||||
 quick-start.xml nix-lang-ref.xml style.css images
 | 
			
		||||
 | 
			
		||||
manual.is-valid: $(SOURCES) version.xml
 | 
			
		||||
	$(XMLLINT) --noout --valid manual.xml
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,11 @@
 | 
			
		|||
<?xml version="1.0"?>
 | 
			
		||||
<!DOCTYPE book
 | 
			
		||||
    PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
 | 
			
		||||
    "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
 | 
			
		||||
    PUBLIC "-//OASIS//DTD DocBook EBNF Module V1.0//EN"
 | 
			
		||||
    "http://www.oasis-open.org/docbook/xml/ebnf/1.0/dbebnf.dtd"
 | 
			
		||||
[
 | 
			
		||||
<!-- <!DOCTYPE book
 | 
			
		||||
    PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
 | 
			
		||||
    "http://www.docbook.org/xml/4.3/docbook-xml-4.3.zip" -->
 | 
			
		||||
<!ENTITY introduction SYSTEM "introduction.xml">
 | 
			
		||||
<!ENTITY quick-start SYSTEM "quick-start.xml">
 | 
			
		||||
<!ENTITY installation SYSTEM "installation.xml">
 | 
			
		||||
| 
						 | 
				
			
			@ -16,6 +19,7 @@
 | 
			
		|||
<!ENTITY nix-push SYSTEM "nix-push.xml">
 | 
			
		||||
<!ENTITY nix-pull SYSTEM "nix-pull.xml">
 | 
			
		||||
<!ENTITY nix-prefetch-url SYSTEM "nix-prefetch-url.xml">
 | 
			
		||||
<!ENTITY nix-lang-ref SYSTEM "nix-lang-ref.xml">
 | 
			
		||||
<!ENTITY troubleshooting SYSTEM "troubleshooting.xml">
 | 
			
		||||
<!ENTITY bugs SYSTEM "bugs.xml">
 | 
			
		||||
<!ENTITY version SYSTEM "version.xml">
 | 
			
		||||
| 
						 | 
				
			
			@ -74,6 +78,8 @@
 | 
			
		|||
    </sect1>
 | 
			
		||||
  </appendix>
 | 
			
		||||
 | 
			
		||||
  &nix-lang-ref;
 | 
			
		||||
 | 
			
		||||
  &troubleshooting;
 | 
			
		||||
  &bugs;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										183
									
								
								doc/manual/nix-lang-ref.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										183
									
								
								doc/manual/nix-lang-ref.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,183 @@
 | 
			
		|||
<chapter>
 | 
			
		||||
  <title>Nix Language Reference</title>
 | 
			
		||||
 | 
			
		||||
  <sect1>
 | 
			
		||||
    <title>Grammar</title>
 | 
			
		||||
 | 
			
		||||
    <para>
 | 
			
		||||
    </para>
 | 
			
		||||
 | 
			
		||||
    <productionset>
 | 
			
		||||
      <title>Expressions</title>
 | 
			
		||||
      
 | 
			
		||||
      <production id="nix.expr">
 | 
			
		||||
        <lhs>Expr</lhs>
 | 
			
		||||
        <rhs>
 | 
			
		||||
          <nonterminal def="#nix.expr_function" />
 | 
			
		||||
        </rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
      
 | 
			
		||||
      <production id="nix.expr_function">
 | 
			
		||||
        <lhs>ExprFunction</lhs>
 | 
			
		||||
        <rhs>
 | 
			
		||||
          '{' <nonterminal def="#nix.formals" /> '}' ':' <nonterminal def="#nix.expr_function" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_assert" />
 | 
			
		||||
        </rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
      
 | 
			
		||||
      <production id="nix.expr_assert">
 | 
			
		||||
        <lhs>ExprAssert</lhs>
 | 
			
		||||
        <rhs>
 | 
			
		||||
          'assert' <nonterminal def="#nix.expr" /> ';' <nonterminal def="#nix.expr_assert" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_if" />
 | 
			
		||||
        </rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
      
 | 
			
		||||
      <production id="nix.expr_if">
 | 
			
		||||
        <lhs>ExprIf</lhs>
 | 
			
		||||
        <rhs>
 | 
			
		||||
          'if' <nonterminal def="#nix.expr" /> 'then' <nonterminal def="#nix.expr" />
 | 
			
		||||
          'else' <nonterminal def="#nix.expr" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_op" />
 | 
			
		||||
        </rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
      
 | 
			
		||||
      <production id="nix.expr_op">
 | 
			
		||||
        <lhs>ExprOp</lhs>
 | 
			
		||||
        <rhs>
 | 
			
		||||
          '!' <nonterminal def="#nix.expr_op" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_op" /> '==' <nonterminal def="#nix.expr_op" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_op" /> '!=' <nonterminal def="#nix.expr_op" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_op" /> '&&' <nonterminal def="#nix.expr_op" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_op" /> '||' <nonterminal def="#nix.expr_op" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_op" /> '->' <nonterminal def="#nix.expr_op" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_op" /> '//' <nonterminal def="#nix.expr_op" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_op" /> '~' <nonterminal def="#nix.expr_op" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_op" /> '?' <nonterminal def="#nix.id" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_app" />
 | 
			
		||||
        </rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
      
 | 
			
		||||
      <production id="nix.expr_app">
 | 
			
		||||
        <lhs>ExprApp</lhs>
 | 
			
		||||
        <rhs>
 | 
			
		||||
          <nonterminal def="#nix.expr_app" /> '.' <nonterminal def="#nix.expr_select" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_select" />
 | 
			
		||||
        </rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
      
 | 
			
		||||
      <production id="nix.expr_select">
 | 
			
		||||
        <lhs>ExprSelect</lhs>
 | 
			
		||||
        <rhs>
 | 
			
		||||
          <nonterminal def="#nix.expr_select" /> <nonterminal def="#nix.id" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.expr_simple" />
 | 
			
		||||
        </rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
      
 | 
			
		||||
      <production id="nix.expr_simple">
 | 
			
		||||
        <lhs>ExprSimple</lhs>
 | 
			
		||||
        <rhs>
 | 
			
		||||
          <nonterminal def="#nix.id" /> |
 | 
			
		||||
          <nonterminal def="#nix.int" /> |
 | 
			
		||||
          <nonterminal def="#nix.str" /> |
 | 
			
		||||
          <nonterminal def="#nix.path" /> |
 | 
			
		||||
          <nonterminal def="#nix.uri" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          '(' <nonterminal def="#nix.expr" /> ')'
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          '{' <nonterminal def="#nix.bind" />* '}'
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          'let' '{' <nonterminal def="#nix.bind" />* '}'
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          'rec' '{' <nonterminal def="#nix.bind" />* '}'
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          '[' <nonterminal def="#nix.expr_select" />* ']'
 | 
			
		||||
        </rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
 | 
			
		||||
      <production id="nix.bind">
 | 
			
		||||
        <lhs>Bind</lhs>
 | 
			
		||||
        <rhs>
 | 
			
		||||
          <nonterminal def="#nix.id" /> '=' <nonterminal def="#nix.expr" /> ';'
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          'inherit' ('(' <nonterminal def="#nix.expr" /> ')')? <nonterminal def="#nix.id" />* ';'
 | 
			
		||||
        </rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
 | 
			
		||||
      <production id="nix.formals">
 | 
			
		||||
        <lhs>Formals</lhs>
 | 
			
		||||
        <rhs>
 | 
			
		||||
          <nonterminal def="#nix.formal" /> ',' <nonterminal def="#nix.formals" />
 | 
			
		||||
          | <nonterminal def="#nix.formal" />
 | 
			
		||||
        </rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
          
 | 
			
		||||
      <production id="nix.formal">
 | 
			
		||||
        <lhs>Formal</lhs>
 | 
			
		||||
        <rhs>
 | 
			
		||||
          <nonterminal def="#nix.id" />
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          <nonterminal def="#nix.id" /> '?' <nonterminal def="#nix.expr" />
 | 
			
		||||
        </rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
          
 | 
			
		||||
    </productionset>
 | 
			
		||||
 | 
			
		||||
    <productionset>
 | 
			
		||||
      <title>Terminals</title>
 | 
			
		||||
 | 
			
		||||
      <production id="nix.id">
 | 
			
		||||
        <lhs>Id</lhs>
 | 
			
		||||
        <rhs>[a-zA-Z\_][a-zA-Z0-9\_\']*</rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
    
 | 
			
		||||
      <production id="nix.int">
 | 
			
		||||
        <lhs>Int</lhs>
 | 
			
		||||
        <rhs>[0-9]+</rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
    
 | 
			
		||||
      <production id="nix.str">
 | 
			
		||||
        <lhs>Str</lhs>
 | 
			
		||||
        <rhs>\"[^\n\"]*\"</rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
 | 
			
		||||
      <production id="nix.path">
 | 
			
		||||
        <lhs>Path</lhs>
 | 
			
		||||
        <rhs>[a-zA-Z0-9\.\_\-\+]*(\/[a-zA-Z0-9\.\_\-\+]+)+</rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
    
 | 
			
		||||
      <production id="nix.uri">
 | 
			
		||||
        <lhs>Uri</lhs>
 | 
			
		||||
        <rhs>[a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*\']+</rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
 | 
			
		||||
      <production id="nix.ws">
 | 
			
		||||
        <lhs>Whitespace</lhs>
 | 
			
		||||
        <rhs>
 | 
			
		||||
          [ \t\n]+
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          \#[^\n]*
 | 
			
		||||
          <sbr />|
 | 
			
		||||
          \/\*(.|\n)*\*\/
 | 
			
		||||
        </rhs>
 | 
			
		||||
      </production>
 | 
			
		||||
 | 
			
		||||
    </productionset>
 | 
			
		||||
    
 | 
			
		||||
  </sect1>
 | 
			
		||||
  
 | 
			
		||||
</chapter>
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue