<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -16,6 +16,12 @@ let vocabulary =
         (FuzzySet.create_triangle 90.0 110.0)
     in
     voc
+    (* TODO complete the parser for vocabulary
+    Builder.vocabulary_from_string &quot;
+        DEF BIG  TRIANGLE 5.0 15.0
+        DEF FAST TRIANGLE 90 110
+    &quot;
+    *)
 
 let create_model voc =
     let rules = Builder.rules_from_string voc &quot;</diff>
      <filename>example/ex2.ml</filename>
    </modified>
    <modified>
      <diff>@@ -8,6 +8,14 @@ type is_t =
 type rule_t = 
     | Imply of is_t * is_t
 
+type def_t = 
+    | DefByFun of
+        symb_t       (* vocabulary term *)
+        * symb_t     (* function name to build the fuzzy set *)
+        * float list (* parameters to define the term through the funtion *)
+    | DefByPoints of
+        symb_t       (* vocabulary term *)
+        * (float * float) list (* list of points *)
 
 let indented_string indent s =
     Printf.sprintf &quot;%s%s&quot; (String.make indent ' ') s</diff>
      <filename>fuzlog/ast.ml</filename>
    </modified>
    <modified>
      <diff>@@ -29,11 +29,15 @@ let to_rule voc t = match t with
             (to_premisse voc s1)
             (to_conclusion voc s2)
 
-
 let rule_ast_from_string s =
     let lexbuf = Lexing.from_string s in
-    Parser.rules Lexer.tokens lexbuf
+    Parser.rules Lexer.rule_tokens lexbuf
 
 let rules_from_string voc s =
     List.map (to_rule voc) (rule_ast_from_string s)
 
+
+let voc_ast_from_string s =
+    let lexbuf = Lexing.from_string s in
+    Parser.vocabulary Lexer.voc_tokens lexbuf
+</diff>
      <filename>fuzlog/builder.ml</filename>
    </modified>
    <modified>
      <diff>@@ -11,13 +11,29 @@ let incr_lineno lexbuf =
 }
 
 let alphanum = ['_''a'-'z''A'-'Z''0'-'9']
+let digit = ['0'-'9']
 
-rule tokens = parse
-  | [' ' '\t']      { tokens lexbuf }
-  | ['\n']          { incr_lineno lexbuf; tokens lexbuf }
+rule rule_tokens = parse
+  | [' ' '\t']      { rule_tokens lexbuf }
+  | ['\n']          { incr_lineno lexbuf; rule_tokens lexbuf }
   | &quot;IF&quot;|&quot;if&quot;       { IF }
   | &quot;THEN&quot;|&quot;then&quot;   { THEN }
   | &quot;IS&quot;|&quot;is&quot;       { IS }
   | &quot;AND&quot;|&quot;and&quot;     { AND }
   | alphanum+ as s  { SYMB(s) }
   | eof             { EOF }
+
+and voc_tokens = parse
+  | [' ' '\t']      { voc_tokens lexbuf }
+  | ['\n']          { incr_lineno lexbuf; voc_tokens lexbuf }
+  | &quot;DEF&quot;|&quot;def&quot;     { DEF }
+  | &quot;[&quot;             { OPENSB }
+  | &quot;]&quot;             { CLOSESB }
+  | &quot;(&quot;             { OPENB }
+  | &quot;)&quot;             { CLOSEB }
+  | &quot;-&quot;? digit+
+  | &quot;-&quot;? digit* &quot;.&quot; digit+
+  | &quot;-&quot;? digit+ &quot;.&quot; digit* as num
+                    { NUMBER(num) }
+  | alphanum+ as s  { SYMB(s) }
+  | eof             { EOF }</diff>
      <filename>fuzlog/lexer.mll</filename>
    </modified>
    <modified>
      <diff>@@ -7,11 +7,16 @@ open Ast
 %token IS
 %token AND
 %token SEP
+%token DEF
+%token OPENB CLOSEB
+%token OPENSB CLOSESB
 %token EOF
 %token &lt;string&gt; SYMB
+%token &lt;string&gt; NUMBER
 
-%start rules
+%start rules vocabulary
 %type &lt;Ast.rule_t list&gt; rules
+%type &lt;Ast.def_t list&gt; vocabulary
 
 %%
 
@@ -43,9 +48,68 @@ is:
         { Is($1, $3) }
 ;
 
+vocabulary:
+    vocabulary_
+        { List.rev $1 }
+;
+
+vocabulary_:
+    def
+        { [ $1 ] }
+    | vocabulary_ def
+        { $2 :: $1 }
+;
+
+def:
+    DEF symb vocfun numbers
+        { DefByFun($2, $3, $4) }
+    | DEF symb OPENSB points CLOSESB
+        { DefByPoints($2, $4) }
+;
+
+vocfun:
+    symb
+        { $1 }
+;
+
+points:
+    points_
+        { List.rev $1 }
+;
+
+points_:
+    point
+        { [ $1 ] }
+    | points_ point
+        { $2 :: $1 }
+;
+
+point:
+    OPENB number number CLOSEB
+        { ($2, $3) }
+;
+
+numbers:
+    numbers_
+        { List.rev $1 }
+;
+
+numbers_:
+    number
+        { [ $1 ] }
+    | numbers_ number
+        { $2 :: $1 }
+;
+
+number:
+    NUMBER
+        { float_of_string $1 }
+;
+
 symb:
     SYMB
         { Symb $1 }
 ;
+
 %%
 </diff>
      <filename>fuzlog/parser.mly</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,25 @@ open Fuzlog
 open Inference
 open Ast
 
+let _ = Tests.register &quot;Build AST for vocabulary&quot; (fun () -&gt;
+    let nodes = Builder.voc_ast_from_string &quot;
+        DEF BIG  TRIANGLE 5.0 15.0
+        DEF SMURGL [ (1 0.1) (2 0.4) ]
+    &quot; in
+    ignore(OUnit.assert_equal 2 (List.length nodes));
+    let result = match nodes with
+        |
+            (DefByFun(Symb &quot;BIG&quot;, Symb &quot;TRIANGLE&quot;, [5.0; 15.0;]))
+            ::
+            (DefByPoints(Symb &quot;SMURGL&quot;, [(1.0, 0.1); (2.0, 0.4);]))
+            ::
+            []
+            -&gt; true
+        | _ -&gt; false
+    in
+    OUnit.assert_bool &quot;Not expected AST for vocabulary&quot; result
+)
+
 let _ = Tests.register &quot;Build AST for rules&quot; (fun () -&gt;
     let nodes = Builder.rule_ast_from_string &quot;
         IF in10 IS big THEN ou10 IS fast</diff>
      <filename>test/builderTest.ml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>cacb060455e134b7245a593f838cd4a5ee58aa57</id>
    </parent>
  </parents>
  <author>
    <name>Ludovic Coquelle</name>
    <email>lcoquelle@gmail.com</email>
  </author>
  <url>http://github.com/khigia/ocaml-fuzlog/commit/3d1d4baea69438d9a9434078da0d2bd74067a9dd</url>
  <id>3d1d4baea69438d9a9434078da0d2bd74067a9dd</id>
  <committed-date>2008-04-10T03:33:50-07:00</committed-date>
  <authored-date>2008-04-10T03:33:50-07:00</authored-date>
  <message>added parser rule and AST for vocabulary definition.</message>
  <tree>49bba57895254fe1d01d98dda3ae9b11ea9650bf</tree>
  <committer>
    <name>Ludovic Coquelle</name>
    <email>lcoquelle@gmail.com</email>
  </committer>
</commit>
