aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/nix.sdf
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-01-29 14:24:53 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-01-29 14:24:53 +0000
commitabd1878b26200ba3fa75592637aa87e04f52100d (patch)
treea11ad40af7f35a49bd12969e87f48a2929312712 /src/libexpr/nix.sdf
parent3648d1c732379ef5d0f74cc3c2e5b876a7f2c9a2 (diff)
* Optimised the SDF grammar.
Diffstat (limited to 'src/libexpr/nix.sdf')
-rw-r--r--src/libexpr/nix.sdf105
1 files changed, 13 insertions, 92 deletions
diff --git a/src/libexpr/nix.sdf b/src/libexpr/nix.sdf
index b6bb23ebd..36fbef39c 100644
--- a/src/libexpr/nix.sdf
+++ b/src/libexpr/nix.sdf
@@ -15,9 +15,9 @@ imports Fix-Exprs Fix-Layout
%% Expressions.
module Fix-Exprs
-imports Fix-Lexicals URI
+imports Fix-Lexicals
exports
- sorts Expr Formal Bind Binds BindSemi ExprList
+ sorts Expr Formal Bind Binds ExprList
context-free syntax
Id -> Expr {cons("Var")}
@@ -44,10 +44,8 @@ exports
"let" "{" Binds "}" -> Expr {cons("LetRec")}
"{" Binds "}" -> Expr {cons("Attrs")}
- Id "=" Expr -> Bind {cons("Bind")}
- {Bind ";"}* -> Binds
- Bind ";" -> BindSemi
- BindSemi* -> Binds
+ Bind* -> Binds
+ Id "=" Expr ";" -> Bind {cons("Bind")}
"[" ExprList "]" -> Expr {cons("List")}
"" -> ExprList {cons("ExprNil")}
@@ -65,8 +63,6 @@ exports
Expr "||" Expr -> Expr {cons("OpOr"), right}
Expr "->" Expr -> Expr {cons("OpImpl"), right}
- Bool -> Expr {cons("Bool")}
-
context-free priorities
Expr "." Id -> Expr
@@ -87,7 +83,7 @@ exports
module Fix-Lexicals
exports
- sorts Id Int Str Path PathComp Bool
+ sorts Id Int Str Path PathComp Uri
lexical syntax
[a-zA-Z\_][a-zA-Z0-9\_\']* -> Id
"rec" -> Id {reject}
@@ -95,97 +91,24 @@ exports
"if" -> Id {reject}
"then" -> Id {reject}
"else" -> Id {reject}
- "true" -> Id {reject}
- "false" -> Id {reject}
"assert" -> Id {reject}
[0-9]+ -> Int
"\"" ~[\n\"]* "\"" -> Str
- PathComp ("/" PathComp)+ -> Path
+ "." ("/" PathComp)+ -> Path
+ ".." ("/" PathComp)+ -> Path
("/" PathComp)+ -> Path
[a-zA-Z0-9\.\_\-\+]+ -> PathComp
- "true" -> Bool
- "false" -> Bool
+ [a-zA-Z] [a-zA-Z0-9\+\-\.]* ":" [a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*\']* -> Uri
lexical restrictions
Id -/- [a-zA-Z0-9\_\']
Int -/- [0-9]
Path -/- [a-zA-Z0-9\.\_\-\+\/]
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% URIs (RFC 2396, appendix A).
-
-module URI
-exports
- sorts Uri Uhierpart Uopaquepart Uuricnoslash Unetpath Uabspath
- Urelpath Urelsegment Uscheme Uauthority Uregname Userver
- Uuserinfo Uhostport Uhost Uhostname Udomainlabel Utoplabel
- UIPv4address Uport Upath Upathsegments Usegment Uparam
- Upchar Uquery Ufragment Uuric Ureserved Uunreserved Umark
- Uescaped Uhex Ualphanum Ualpha Ulowalpha Uupalpha Udigit
- lexical syntax
- Uscheme ":" (Uhierpart | Uopaquepart) -> Uri
-
- (Unetpath | Uabspath) ("?" Uquery)? -> Uhierpart
- Uuricnoslash Uuric* -> Uopaquepart
-
- Uunreserved | Uescaped | [\;\?\:\@\&\=\+\$\,] -> Uuricnoslash
-
- "//" Uauthority Uabspath? -> Unetpath
- "/" Upathsegments -> Uabspath
- "//" Uuric* -> Uabspath {reject}
- Urelsegment Uabspath? -> Urelpath
-
- (Uunreserved | Uescaped | [\;\@\&\=\+\$\,])+ -> Urelsegment
-
- Ualpha (Ualpha | Udigit | [\+\-\.])* -> Uscheme
-
- Userver | Uregname -> Uauthority
-
- (Uunreserved | Uescaped | [\$\,\;\:\@\&\=\+])+ -> Uregname
-
- ((Uuserinfo "@") Uhostport) -> Userver
- (Uunreserved | Uescaped | [\;\:\&\=\+\$\,])* -> Uuserinfo
-
- Uhost (":" Uport)? -> Uhostport
- Uhostname | UIPv4address -> Uhost
- (Udomainlabel ".")+ Utoplabel "."? -> Uhostname
- Ualphanum | Ualphanum (Ualphanum | "-")* Ualphanum -> Udomainlabel
- Ualpha | Ualpha (Ualphanum | "-")* Ualphanum -> Utoplabel
- Udigit+ "." Udigit+ "." Udigit+ "." Udigit+ -> UIPv4address
- Udigit* -> Uport
-
- Uabspath | Uopaquepart -> Upath
- Usegment ("/" Usegment)* -> Upathsegments
- Upchar* (";" Uparam)* -> Usegment
- Upchar* -> Uparam
- Uunreserved | Uescaped | [\:\@\&\=\+\$\,] -> Upchar
-
- Uuric* -> Uquery
-
- Uuric* -> Ufragment
-
- Ureserved | Uunreserved | Uescaped -> Uuric
- [\;\/\?\:\@\&\=\+\$\,] -> Ureserved
- Ualphanum | Umark -> Uunreserved
- [\-\_\.\!\~\*\'\(\)] -> Umark
-
- "%" Uhex Uhex -> Uescaped
- Udigit | [A-Fa-f] -> Uhex
-
- Ualpha | Udigit -> Ualphanum
- Ulowalpha | Uupalpha -> Ualpha
-
- [a-z] -> Ulowalpha
- [A-Z] -> Uupalpha
- [0-9] -> Udigit
-
- lexical restrictions
- Uri -/- [a-zA-Z0-9\-\_\.\!\~\*\'\(\)\/]
+ Uri -/- [a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*\']
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -193,18 +116,16 @@ exports
module Fix-Layout
exports
- sorts HashComment Asterisk Comment EOF
+ sorts HashComment Asterisk Comment
lexical syntax
[\ \t\n] -> LAYOUT
HashComment -> LAYOUT
Comment -> LAYOUT
- "#" ~[\n]* ([\n] | EOF) -> HashComment
- "//" ~[\n]* ([\n] | EOF) -> HashComment
+ "#" ~[\n]* -> HashComment
"/*" ( ~[\*] | Asterisk )* "*/" -> Comment
[\*] -> Asterisk
- "" -> EOF
lexical restrictions
Asterisk -/- [\/]
- EOF -/- ~[]
+ HashComment -/- ~[\n]
context-free restrictions
- LAYOUT? -/- [\ \t\n] | [\#]
+ LAYOUT? -/- [\ \t\n]