Sha256: 18fb54021517bd95e998be2e003246e042775901ddf478827c27d7b5fe227037

Contents?: true

Size: 975 Bytes

Versions: 3

Compression:

Stored size: 975 Bytes

Contents

grammar WLang::Grammar
  
  rule template
    (strconcat !.){
      [:template, [:fn, strconcat.value]]
    }
  end
  
  rule strconcat
    (non_static | static)* {
      if matches.size == 1
        matches.first.value
      else
        [:strconcat] + matches.map(&:value)
      end
    }
  end
  
  rule static
    (!stop_char .)+ { 
      [:static, to_s] 
    }
  end
  
  rule non_static
    block | wlang
  end
  
  rule block
    (fn_start strconcat fn_stop){
      [:static, to_s]
    }
  end
  
  rule wlang
    (symbols functions){
      [:wlang, symbols.to_s] + functions.value
    }
  end
  
  rule functions
    function+ { matches.map{|fn| [:fn, fn.value]} }
  end
  
  rule function
    (fn_start strconcat fn_stop){
      strconcat.value
    }
  end
  
  rule stop_char
    fn_start | fn_stop | (symbols fn_start)
  end
  
  rule symbols
    /[!\^%"\$&'\*\+\?@~\#,\-\.\/:;=<>\|_]+/
  end
  
  rule fn_start
    '{'
  end
  
  rule fn_stop
    '}'
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wlang-2.0.1 lib/wlang/compiler/grammar.citrus
wlang-2.0.0 lib/wlang/compiler/grammar.citrus
wlang-2.0.0.beta lib/wlang/compiler/grammar.citrus