about summary refs log tree commit diff
path: root/src/fix-ng/fix.sdf
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-10-29T16·05+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-10-29T16·05+0000
commitb95a3dc45bcbbe8a0985bab82146ed00afcf0239 (patch)
tree75ec3e901b3af65a814770aae807c790d20eff1d /src/fix-ng/fix.sdf
parent4d728f6a36c83ff684426788df775b385fae9e88 (diff)
* Basic grammar and parser for the Fix language. We use libsglr and
  friends to do the parsing.  The parse table is embedded in the Fix
  executable using bin2c, which converts an arbitrary file into a C
  character array.

Diffstat (limited to 'src/fix-ng/fix.sdf')
-rw-r--r--src/fix-ng/fix.sdf163
1 files changed, 163 insertions, 0 deletions
diff --git a/src/fix-ng/fix.sdf b/src/fix-ng/fix.sdf
new file mode 100644
index 000000000000..72f3e694d02e
--- /dev/null
+++ b/src/fix-ng/fix.sdf
@@ -0,0 +1,163 @@
+definition
+
+module Main
+imports Fix
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Top level syntax.
+
+module Fix
+imports Fix-Exprs Fix-Layout
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Expressions.
+
+module Fix-Exprs
+imports Fix-Lexicals URI
+exports
+  sorts Expr Bind
+  context-free syntax
+
+    Id
+    -> Expr {cons("Var")}
+
+    Int
+    -> Expr {cons("Int")}
+
+    Str
+    -> Expr {cons("Str")}
+
+    Uri
+    -> Expr {cons("Uri")}
+
+    Path
+    -> Expr {cons("Path")}
+
+    "(" Expr ")"
+    -> Expr {bracket}
+
+    Expr Expr
+    -> Expr {cons("Call"), left}
+
+    "{" {Id ","}* "}" ":" Expr
+    -> Expr {cons("Function"), right}
+
+    "{" {Bind ","}+ "}"
+    -> Expr {cons("Attrs")}
+
+    Id "=" Expr
+    -> Bind {cons("Bind")}
+
+    "[" {Expr ","}* "]"
+    -> Expr {cons("List")}
+
+  context-free priorities
+
+    Expr Expr -> Expr
+  > "{" {Id ","}* "}" ":" Expr -> Expr
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Lexical syntax.
+
+module Fix-Lexicals
+exports
+  sorts Id Path
+  lexical syntax
+    [a-zA-Z\_][a-zA-Z0-9\_\']* -> Id
+    [0-9]+ -> Int
+    "\"" ~[\n\"]* "\"" -> Str
+    PathComp ("/" PathComp)+ -> Path
+    [a-zA-Z0-9\.\_\-]+ -> PathComp
+  lexical restrictions
+    Id -/- [a-zA-Z0-9\_\']
+    Int -/- [0-9]
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% URIs (RFC 2396, appendix A).
+
+module URI
+exports
+  sorts Uri
+  lexical syntax
+    Uscheme ":" (Uhierpath | Uopaquepath) -> Uri
+
+    (Unetpath | Uabspath) ("?" Uquery)? -> Uhierpath
+    Uuricnoslash Uuric* -> Uopaquepath
+
+    Uunreserved | Uescaped | [\;\?\:\@\&\=\+\$\,] -> Uuricnoslash
+
+    "//" Uauthority Uabspath? -> Unetpath
+    "/" Upathsegments -> Uabspath
+    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\-\_\.\!\~\*\'\(\)]
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Layout.
+
+module Fix-Layout
+exports
+  lexical syntax
+    [\ \t\n] -> LAYOUT
+    HashComment -> LAYOUT
+    Comment -> LAYOUT
+    "#" ~[\n]* [\n] -> HashComment
+    "//" ~[\n]* [\n] -> HashComment
+    "/*" ( ~[\*] | Asterisk )* "*/" -> Comment
+    [\*] -> Asterisk
+  lexical restrictions
+    Asterisk -/- [\/]
+  context-free restrictions
+    LAYOUT? -/- [\ \t\n] | [\#]
+  syntax
+    HashComment <START> -> <START>