Sha256: 0d2061c14a150f2c3ac64760c175ee010f5b374070166fa03a48c9409c2af354

Contents?: true

Size: 1.72 KB

Versions: 4

Compression:

Stored size: 1.72 KB

Contents

grammar PersonifyLanguage

  ##################
  # Template parts
  
  rule template
    (parts_including_tail)* <Template>
  end
  
  rule parts_including_tail
    part / tail_part
  end
  
  rule part
    text / substitutable
  end
  
  rule tail_part
    '[' part <TailPart>
  end

  
  ##################
  # Substitutable
    
  rule substitutable
    '[' space expressions space ']' <Substitutable>
  end
  
  ##################
  # Blocks
  
  rule block
    'DO' space ']' block_content '[' space 'END' <Block>
  end
  
  rule block_content
    (part)* <Literal>
  end
  
  ##################
  # Expressions
  
  rule expressions
     expression alternatives:(space "|" space expression_or_string)* <Expressions>
  end
  
  rule expression
    function / logical / key / string
  end
  
  rule expression_or_string
    expression / implicit_string
  end
  
  ##################
  # Functions  
  
  rule function
    key space "(" space parameters space ")" space block:(block)? <Function>
  end
      
  rule parameters 
    first_param:(expression_or_string)? more_expressions:(space "," space expression_or_string)* <Parameter>
  end
  
  ##################
  # Logical  
  
  rule logical
    first_expression:(function / key / string) space operator:("||" / "&&") space next_expression:(expression) <Logical>
  end
  
  ##################
  # Keys  
  
  rule key
    !reserved ([A-Z0-9] [A-Z0-9._]*) <Key>      
  end
  
  rule reserved
   "END" / "DO"
  end
  
  ##################
  # Literals
  
  rule string
    '"' string_value '"' <PString>
  end
  
  rule implicit_string
    [^|\],)]+ <Literal>
  end
  
  rule string_value
    [^"]* <Literal>
  end
  
  rule text
    [^\[] [^\[]* <Literal>
  end
  
  rule space
    [ \n]*
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
personify-1.1.2 lib/personify/parser/personify.treetop
personify-1.1.1 lib/personify/parser/personify.treetop
personify-1.1.0 lib/personify/parser/personify.treetop
personify-1.0.0 lib/personify/parser/personify.treetop