*** empty log message *** XML-AFTER-XEX
authornisikimi <nisikimi>
Thu, 4 Mar 2010 04:33:07 +0000 (04:33 +0000)
committernisikimi <nisikimi>
Thu, 4 Mar 2010 04:33:07 +0000 (04:33 +0000)
MIM/expr.rnc [new file with mode: 0644]
MIM/expr.rng [new file with mode: 0644]
MIM/mim.rnc [new file with mode: 0644]

diff --git a/MIM/expr.rnc b/MIM/expr.rnc
new file mode 100644 (file)
index 0000000..5b5498c
--- /dev/null
@@ -0,0 +1,175 @@
+default namespace = "http://www.m17n.org/MIM"
+namespace xi = "http://www.w3.org/1999/XML/xinclude"
+
+start |= expr
+expr = defun | defmacro | defvar | term
+term |= integer | \string | symbol | \list | error | varref | funcall
+defun =
+  element defun {
+    attribute fname { xsd:ID },
+    (args)?,
+    term*
+  }
+defmacro =
+  element defmacro {
+    attribute fname { xsd:ID },
+    (args)?,
+    term*
+  }
+args =
+  element args {
+    element fixed {
+      attribute vname { xsd:Name }
+    }*,
+    element optional {
+      attribute vname { xsd:Name }
+    }*,
+    element rest {
+      attribute vname { xsd:Name }
+    }*
+  }
+defvar =
+  element defvar {
+    attribute vname { xsd:ID },
+    description?,
+    ((integer,
+      element possible-value {
+        (integer
+         | element range { integer, integer })+
+      }?)
+     | (\string,
+        element possible-value { \string+ }?)
+     | (symbol,
+        element possible-value { symbol+ }?))?
+  }
+description =
+  element description {
+    element gettext { text }
+    | text
+  }
+integer =
+  element integer {
+    xsd:integer
+    | xsd:string { pattern = "\?." }
+    | xsd:string { pattern = "[0#]x[0-9A-F]{1,6}" }
+  }
+\string = element string { xsd:string }
+symbol = element symbol { xsd:string }
+\list = element list { term* }
+error =
+  element error {
+    attribute ename { xsd:Name }?,
+    \string
+  }
+varref =
+  element varref {
+    attribute vname { xsd:Name },
+    empty
+  }
+funcall =
+  element funcall {
+    attribute fname { xsd:IDREF },
+    term*
+  }
+  | predefined
+predefined =
+  element set {
+    attribute vname { xsd:Name },
+    term
+  }
+  | element and { term+ }
+  | element or { term+ }
+  | element not { term }
+  | element eq { term+ }
+  | element noteq { term, term }
+  | element equal { term, term }
+  | element match { term, term }
+  | element lt { intterm, intterm }
+  | element le { intterm, intterm }
+  | element ge { intterm, intterm }
+  | element gt { intterm, intterm }
+  | element add {
+      attribute vname { text }?,
+      intterm+
+    }
+  | element sub {
+      attribute vname { text }?,
+      intterm+
+    }
+  | element mul {
+      attribute vname { text }?,
+      intterm+
+    }
+  | element div {
+      attribute vname { text }?,
+      intterm+
+    }
+  | element mod {
+      (attribute vname { text },
+       intterm)
+      | (intterm, intterm)
+    }
+  | element logand {
+      attribute vname { text }?,
+      intterm+
+    }
+  | element logior {
+      attribute vname { text }?,
+      intterm+
+    }
+  | element logxor {
+      attribute vname { text }?,
+      intterm+
+    }
+  | element lsh {
+      (attribute vname { text },
+       intterm)
+      | (intterm, intterm)
+    }
+  | element append {
+      attribute vname { text }?,
+      term+
+    }
+  | element concat {
+      attribute vname { text }?,
+      (intterm | strterm | listterm)+
+    }
+  | element length { strterm | listterm }
+  | element nth { intterm, (strterm | listterm) }
+  | element copy { listterm }
+  | element ins {
+      attribute vname { text },
+      intterm,
+      (strterm | listterm)
+    }
+  | element del {
+      attribute vname { text },
+      intterm,
+      intterm
+    }
+  | element progn { term* }
+  | element if { term, term, term? }
+  | element when { term+ }
+  | element cond { \list+ }
+  | element loop { term+ }
+  | element while { term+ }
+  | element foreach {
+      attribute vname { text },
+      (strterm | listterm),
+      term+
+    }
+  | element break { term? }
+  | element return { term? }
+  | element catch {
+      attribute vname { xsd:Name }?,
+      (symbol | error),
+      term+
+    }
+  | element throw { (symbol, term?) | error }
+  | element quote { term }
+  | element eval { term }
+  | element type { term }
+intterm |= varref | integer | funcall
+strterm = varref | \string | funcall
+symterm = varref | symbol | funcall
+listterm = varref | \list | funcall
diff --git a/MIM/expr.rng b/MIM/expr.rng
new file mode 100644 (file)
index 0000000..75c9857
--- /dev/null
@@ -0,0 +1,307 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<grammar 
+        datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
+         xmlns:xi="http://www.w3.org/1999/XML/xinclude"
+        xmlns="http://relaxng.org/ns/structure/1.0"
+        ns="http://www.m17n.org/MIM">
+
+<start combine="choice">
+  <ref name="expr"/>
+</start>
+
+<define name="expr">
+      <choice>
+       <ref name="defun"/>
+       <ref name="defmacro"/>
+       <ref name="defvar"/>
+       <ref name="term"/>
+      </choice>
+</define>
+
+<define name="term" combine="choice">
+  <choice>
+    <ref name="integer"/>
+    <ref name="string"/>
+    <ref name="symbol"/>
+    <ref name="list"/>
+    <ref name="error"/>
+    <ref name="varref"/>
+    <ref name="funcall"/>
+  </choice>
+</define>
+
+<define name="defun">
+  <element name="defun">
+    <attribute name="fname"><data type="ID"/></attribute>
+    <optional>
+      <choice><ref name="args"/></choice>
+    </optional>
+    <zeroOrMore><ref name="term"/></zeroOrMore>
+  </element>
+</define>
+
+<define name="defmacro">
+  <element name="defmacro">
+    <attribute name="fname"><data type="ID"/></attribute>
+    <optional>
+      <choice><ref name="args"/></choice>
+    </optional>
+    <zeroOrMore><ref name="term"/></zeroOrMore>
+  </element>
+</define>
+
+<define name="args">
+  <element name="args">
+    <zeroOrMore>
+      <element name="fixed">
+       <attribute name="vname"><data type="Name"/></attribute>
+      </element>
+    </zeroOrMore>
+    <zeroOrMore>
+      <element name="optional">
+       <attribute name="vname"><data type="Name"/></attribute>
+      </element>
+    </zeroOrMore>
+    <zeroOrMore>
+      <element name="rest">
+       <attribute name="vname"><data type="Name"/></attribute>
+      </element>
+    </zeroOrMore>
+  </element>
+</define>
+
+<define name="defvar">
+  <element name="defvar">
+    <attribute name="vname"><data type="ID"/></attribute>
+    <optional>
+      <ref name="description"/>
+    </optional>
+    <optional>
+      <choice>
+       <group>
+         <ref name="integer"/>
+         <optional>
+           <element name="possible-value">
+             <oneOrMore>
+               <choice>
+                 <ref name="integer"/>
+                 <element name="range"><ref name="integer"/><ref name="integer"/></element>
+               </choice>
+             </oneOrMore>
+           </element>
+         </optional>
+       </group>
+       <group>
+         <ref name="string"/>
+         <optional>
+           <element name="possible-value">
+             <oneOrMore>
+               <ref name="string"/>
+             </oneOrMore>
+           </element>
+           </optional>
+       </group>
+       <group>
+         <ref name="symbol"/>
+         <optional>
+           <element name="possible-value">
+             <oneOrMore>
+               <ref name="symbol"/>
+             </oneOrMore>
+           </element>
+           </optional>
+       </group>
+      </choice>
+    </optional>
+  </element>
+</define>
+
+<define name="description">
+  <element name="description">
+    <choice>
+      <element name="gettext"><text/></element>
+      <text/>
+    </choice>
+  </element>
+</define>
+
+<define name="integer">
+  <element name="integer">
+    <choice>
+      <data type="integer"/>
+      <data type="string"><param name="pattern">\?.</param></data>
+      <data type="string"><param name="pattern">[0#]x[0-9a-fA-F]{1,6}</param></data>
+    </choice>
+  </element>
+</define>
+
+<define name="string">
+  <element name="string"><data type="string"/></element>
+</define>
+
+<define name="symbol">
+  <element name="symbol"><data type="string"/></element>
+</define>
+
+<define name="list">
+  <element name="list">
+    <zeroOrMore><ref name="term"/></zeroOrMore>
+  </element>
+</define>
+
+<define name="error">
+  <element name="error">
+    <optional><attribute name="ename"><data type="Name"/></attribute></optional>
+    <ref name="string"/>
+  </element>
+</define>
+
+<define name="varref">
+  <element name="varref">
+   <attribute name="vname"><data type="Name"/></attribute><empty/>
+  </element>
+</define>
+
+<define name="funcall">
+  <choice>
+    <element name="funcall">
+      <attribute name="fname">
+       <data type="IDREF"/>
+      </attribute>
+      <zeroOrMore><ref name="term"/></zeroOrMore>
+    </element>
+    <ref name="predefined"/>
+  </choice>
+</define>
+
+<define name="predefined">
+  <choice>
+    <element name="set"><attribute name="vname"><data type="Name"/></attribute><ref name="term"/></element>
+
+    <element name="and"><oneOrMore><ref name="term"/></oneOrMore></element>
+    <element name="or"><oneOrMore><ref name="term"/></oneOrMore></element>
+    <element name="not"><ref name="term"/></element>
+    <element name="eq"><oneOrMore><ref name="term"/></oneOrMore></element>
+    <element name="noteq"><ref name="term"/><ref name="term"/></element>
+    <element name="equal"><ref name="term"/><ref name="term"/></element>
+    <element name="match"><ref name="term"/><ref name="term"/></element>
+
+    <element name="lt"><ref name="intterm"/><ref name="intterm"/></element>
+    <element name="le"><ref name="intterm"/><ref name="intterm"/></element>
+    <element name="ge"><ref name="intterm"/><ref name="intterm"/></element>
+    <element name="gt"><ref name="intterm"/><ref name="intterm"/></element>
+
+    <element name="add">
+      <optional><attribute name="vname"/></optional><oneOrMore><ref name="intterm"/></oneOrMore>
+    </element>
+    <element name="sub">
+      <optional><attribute name="vname"/></optional><oneOrMore><ref name="intterm"/></oneOrMore>
+    </element>
+    <element name="mul">
+      <optional><attribute name="vname"/></optional><oneOrMore><ref name="intterm"/></oneOrMore>
+    </element>
+    <element name="div">
+      <optional><attribute name="vname"/></optional><oneOrMore><ref name="intterm"/></oneOrMore>
+    </element>
+    <element name="mod">
+      <choice><group><attribute name="vname"/><ref name="intterm"/></group>
+              <group><ref name="intterm"/><ref name="intterm"/></group></choice>
+    </element>
+
+    <element name="logand">
+      <optional><attribute name="vname"/></optional><oneOrMore><ref name="intterm"/></oneOrMore>
+    </element>
+    <element name="logior">
+      <optional><attribute name="vname"/></optional><oneOrMore><ref name="intterm"/></oneOrMore>
+    </element>
+    <element name="logxor">
+      <optional><attribute name="vname"/></optional><oneOrMore><ref name="intterm"/></oneOrMore>
+    </element>
+    <element name="lsh">
+      <choice><group><attribute name="vname"/><ref name="intterm"/></group>
+              <group><ref name="intterm"/><ref name="intterm"/></group></choice>
+    </element>
+
+    <element name="append">
+      <optional><attribute name="vname"/></optional>
+      <oneOrMore><ref name="term"/></oneOrMore>
+    </element>
+    <element name="concat">
+      <optional><attribute name="vname"/></optional>
+      <oneOrMore><choice><ref name="intterm"/><ref name="strterm"/><ref name="listterm"/></choice></oneOrMore>
+    </element>
+    <element name="length"><choice><ref name="strterm"/><ref name="listterm"/></choice></element>
+    <element name="nth"><ref name="intterm"/><choice><ref name="strterm"/><ref name="listterm"/></choice></element>
+    <element name="copy"><ref name="listterm"/></element>
+    <element name="ins"><attribute name="vname"/>
+      <ref name="intterm"/><choice><ref name="strterm"/><ref name="listterm"/></choice>
+    </element>
+    <element name="del"><attribute name="vname"/>
+      <ref name="intterm"/><ref name="intterm"/>
+    </element>
+
+    <element name="progn"><zeroOrMore><ref name="term"/></zeroOrMore></element>
+    <element name="if"><ref name="term"/><ref name="term"/><optional><ref name="term"/></optional></element>
+    <element name="when"><oneOrMore><ref name="term"/></oneOrMore></element>
+    <element name="cond"><oneOrMore><ref name="list"/></oneOrMore></element>
+
+    <element name="loop"><oneOrMore><ref name="term"/></oneOrMore></element>
+    <element name="while"><oneOrMore><ref name="term"/></oneOrMore></element>
+    <element name="foreach"><attribute name="vname"/>
+       <choice><ref name="strterm"/><ref name="listterm"/></choice>
+       <oneOrMore><ref name="term"/></oneOrMore>
+    </element>
+    <element name="break"><optional><ref name="term"/></optional></element>
+    <element name="return"><optional><ref name="term"/></optional></element>
+    <element name="catch">
+      <optional><attribute name="vname"><data type="Name"/></attribute></optional>
+      <choice><ref name="symbol"/><ref name="error"/></choice>
+      <oneOrMore><ref name="term"/></oneOrMore>
+    </element>
+    <element name="throw">
+      <choice>
+       <group><ref name="symbol"/><optional><ref name="term"/></optional></group>
+       <ref name="error"/>
+      </choice>
+    </element>
+    <element name="quote"><ref name="term"/></element>
+    <element name="eval"><ref name="term"/></element>
+    <element name="type"><ref name="term"/></element>
+  </choice>
+</define>
+
+<define name="intterm" combine="choice">
+  <choice>
+    <ref name="varref"/>
+    <ref name="integer"/>
+    <ref name="funcall"/>
+  </choice>
+</define>
+
+<define name="strterm">
+  <choice>
+    <ref name="varref"/>
+    <ref name="string"/>
+    <ref name="funcall"/>
+  </choice>
+</define>
+
+<define name="symterm">
+  <choice>
+    <ref name="varref"/>
+    <ref name="symbol"/>
+    <ref name="funcall"/>
+  </choice>
+</define>
+
+<define name="listterm">
+  <choice>
+    <ref name="varref"/>
+    <ref name="list"/>
+    <ref name="funcall"/>
+  </choice>
+</define>
+
+</grammar>
diff --git a/MIM/mim.rnc b/MIM/mim.rnc
new file mode 100644 (file)
index 0000000..297abb8
--- /dev/null
@@ -0,0 +1,125 @@
+default namespace = "http://www.m17n.org/MIM"
+namespace xi = "http://www.w3.org/1999/XML/xinclude"
+
+include "expr.rnc"
+start |=
+  element input-method {
+    im-declaration,
+    description?,
+    element title { xsd:string }?,
+    variable-list?,
+    command-list?,
+    module-list?,
+    macro-list?,
+    map-list?,
+    state-list?
+  }
+# =====input method details====================================
+im-declaration =
+  element tags {
+    element language {
+      "t"
+      | xsd:string { pattern = "[a-z]{2,3}" }
+    },
+    ((element name { "nil" },
+      element extra-id { xsd:ID })
+     | (element name {
+          xsd:string { pattern = "[^n][^i][^l]" }
+          | xsd:string { pattern = ".{1,2}" }
+          | xsd:string { pattern = "....+" }
+        },
+        element extra-id { xsd:ID }?))
+  },
+  element m17n-version {
+    xsd:string { pattern = "[0-9]+\.[0-9]+\.[0-9]+" }
+  }?
+# setups
+variable-list = element variable-list { defvar+ }
+command-list =
+  element command-list {
+    element defcmd {
+      attribute cname {
+        xsd:ID { pattern = "command-.*" }
+      },
+      description?,
+      keyseq*
+    }+
+  }
+module-list =
+  element module-list {
+    element module {
+      attribute id { xsd:string },
+      element defun {
+        attribute fname {
+          xsd:ID { pattern = ".*-function-.*" }
+        },
+        empty
+      }+
+    }+
+  }
+macro-list = element macro-list { defun+ }
+# the real work
+map-list =
+  element map-list {
+    element map {
+      attribute mname {
+        xsd:ID { pattern = "map-.*" }
+      },
+      element rule { (keyseq | command-reference), funcall* }*
+    }+
+  }
+command-reference =
+  element command {
+    attribute cname { xsd:IDREF }
+  }
+keyseq = element keyseq { (listterm | strterm)+ }
+marker = element marker { xsd:string }
+selector =
+  element selector {
+    "@first"
+    | "@current"
+    | "@last"
+    | "@previous"
+    | "@next"
+    | "@previous-candidate-change"
+    | "@next-candidate-change"
+  }
+state-list =
+  element state-list {
+    element state {
+      attribute sname {
+        xsd:ID { pattern = "state-.*" }
+      },
+      element title { xsd:string }?,
+      (element state-hook { funcall+ }?
+       & element catch-all-branch { funcall* }?
+       & element branch {
+           attribute mname { xsd:IDREF },
+           funcall*
+         }*)
+    }*
+  }
+# ===MIM original terms and functions ======================================
+keyseqterm = keyseq | funcall | varref
+markerterm = marker | funcall | varref
+selectorterm = selector | funcall | varref
+term |= keyseq | marker | selector
+funcall |=
+  element insert { intterm | strterm }
+  | element insert-candidates { (listterm | strterm)+ }
+  | element delete { markerterm | intterm }
+  | element select { selectorterm | intterm }
+  | element show-candidates { empty }
+  | element hide-candidates { empty }
+  | element move { markerterm | intterm }
+  | element mark { markerterm }
+  | element pushback { keyseqterm | intterm }
+  | element pop { empty }
+  | element undo { intterm? }
+  | element commit { empty }
+  | element unhandle { empty }
+  | element shift { symterm }
+  | element shiftback { empty }
+  | element char-at { markerterm }
+  | element key-count { empty }
+  | element surrounding-text-flag { empty }