Mind structures declarative language

  1. 4 months ago
    Edited 4 months ago by Zero
       namespace prefix : "filename"
    
       item name -> [ meta | data ]
    
       item name -> relation type { slot1: item1, item2, ... ; slot2: item3; }
    
       item name -> ( behavior node, ... , ... )
    
    
    
    
    
       EBNF
    
       (proposed ISO/IEC 14977 standard, by R. S. Scowen)
    
       Usage             Notation
       -----             --------
       definition        =
       concatenation     ,
       termination       ;
       alternation       |
       optional          [ ... ]
       repetition        { ... }
       grouping          ( ... )
       terminal string   " ... "
       terminal string   ' ... '
       comment           (* ... *)
       special sequence  ? ... ?
       exception         -
    
    
    (* White spaces are not shown here. They're allowed anywhere. *)
    
    
    source file =
    { namespace declaration } , { item definition } ;
    
    
    item identifier =
    text where special characters are escaped ;
    
    
    namespace declaration =
    item identifier , ":" , '"' , filename , '"' ;
    
    
    item definition =
    item identifier { "/" item identifier } , arrow , item value ;
    
    
    arrow =
    "->" ;
    
    
    item value =
    meta/data | relation | behavior ;
    
    
    meta/data =
    "[" , { meta/data content } , "|" , { meta/data content } , "]" ;
    
    
    meta/data content =
    text where special characters are escaped | item value ;
    
    
    relation =
    relation type , "{" , { slot description } , "}" ;
    
    
    relation type
    = text where special characters are escaped ;
    
    
    slot description
    = slot name , ":" , slot value , { additional slot value } , ";" ;
    
    
    slot name
    = text where special characters are escaped ;
    
    
    slot value
    = item identifier | item value ;
    
    
    additional slot value
    = "," , slot value ;
    
    
    behavior
    = "(" , atomic EventAct , { additional behavior content } , ")" ;
    
    
    atomic EventAct
    = text where special characters are escaped ;
    
    
    additional behavior content
    = "," , behavior content ;
    
    
    behavior content
    = behavior | item identifier | item value ;
  2. item name -> [ meta | data ]

    This is the semi-structured data format. The meta part contains meta-information about the data part.

    In XML, the equivalent of the meta part would be the attributes of an element. In XML, attributes are merely associative arrays. But here, the meta part can be a tree containing other nested meta|data boxes.

  3. Edited 4 months ago by Zero
    item name -> relation type { slot1: item1, item2, ... ; slot2: item3; }

    This is the relationship format. The relation type identifies the kind of relationship we're using, and slots are roles that items play in this relation. Several items can have the same role.

    It looks a bit like CSS at first. In fact, it's a simple way to link things together, with a possibility to link links themselves.

  4. item name -> ( behavior node, ... , ... )

    This is the behavior format. Syntactically, it is equivalent to s-expression, except elements are separated be commas instead of white spaces.

    Its purpose is to describe task trees, as used in video games, where tree nodes represent either atomic tasks, or control flow for sub-tasks.

  5. Edited 4 months ago by Zero
    namespace prefix : "filepath"

    This is the namespace format. It allows the declaration of a namespace for importing and using definitions from other files, without name conflict.

    If another file containing a foo -> [meta|data] item is imported here with bar: "another file.txt", then we can access foo from here with bar/foo . The slash separates namespaces and the item identifier.

  6. PEGjs syntax:

    sourceCode
    = ns:namespace* id:itemDef* _ { return { namespaces:ns, definitions:id }; }
    
    
    _
    = [ \t\r\n]*
    
    
    namespace
    = _ ns:namespaceId _ ":" _ '"' fp:filepath '"' { return { namespace: ns, filepath: fp }; }
    
    
    itemDef
    = _ id:localItemId _ "->" _ iv:itemValue { return { item:id, value:iv }; }
    
    
    namespaceId
    = c:normalChar* { return c.join('').trim(); }
    
    
    filepath
    = c:[^"\t\r\n]* { return c.join('').trim(); }
    
    
    itemValue
    = metadata / relationship / behavior
    
    
    localItemId
    = c:normalChar+ { return c.join('').trim(); }
    
    
    itemId
    = fns:namespaceId nns:nextItemPath* {
    
      var whole = [fns].concat(nns);
      var id = whole.pop();
      
      return { type:"item", id:id, path:whole };
    }
    
    
    nextItemPath
    = "/" ns:namespaceId { return ns; }
    
    
    metadata
    = _ "[" meta:metadataContent+ "|" data:metadataContent+ "]" {
    
    	return { type:"meta/data", content:{ meta:meta, data:data } };
    }
    
    
    relationship
    = _ ri:relationshipId _ "{" _ sd:slotDef* _ "}" {
    
    	return { type:"relation", name:ri, content:sd };
    }
    
    
    behavior
    = _ "(" fb:behaviorContent nb:nextBehaviorContent* ")" {
    
    	return { type:"behavior", content:[fb].concat(nb)};
    }
    
    
    metadataContent
    = itemValue
    / textContent
    
    
    textContent
    = c:normalChar+ { return { type:"text", content:c.join('') }; }
    
    
    relationshipId
    = c:normalChar+ { return c.join('').trim(); }
    
    
    slotDef
    = _ si:slotId _ ":" _ fi:slotValue _ ni:nextSlotValue* _ ";" {
    
        return { slot:si, value:[fi].concat(ni) };
    }
    
    
    behaviorContent
    = itemValue / itemId
    
    
    nextBehaviorContent
    = _ "," _ b:behaviorContent { return b; }
    
    
    slotId
    = c:normalChar+ { return c.join('').trim(); }
    
    
    slotValue
    = itemId / itemValue
    
    
    nextSlotValue
    = _ "," _ v:slotValue { return v; }
    
    
    normalChar
    = c:[^\-\<\>\{\}\[\]\(\)\:\/\,\;\|\\] { return c; }
    / "-" c:[^>] { return "-"+c; }
    / "\\" c:. { return c; }
 

or Sign Up to reply!