Upgrade to Pro — share decks privately, control downloads, hide ads and more …

how-to-realize-a-velocity-template-interpreters

Avatar for eward eward
December 28, 2012

 how-to-realize-a-velocity-template-interpreters

how to realize a velocity template language interpreters, use Jison.

Avatar for eward

eward

December 28, 2012
Tweet

Other Decks in Programming

Transcript

  1. ⽅方案2 • jsVelocity • EJS • handlerbars • doT.js •

    Juice • Logic-less templates 6 12年12月28⽇日星期五
  2. ⽣生物链规则 • 为什么是猫吃⽼老⿏鼠,⽽而 不是Tom eat Jerry? • 编译器实现的是⼀一套语 法规则的解析 •

    语法规则和⾷食物链规则 类似 • 分为Grammer和Lex 22 12年12月28⽇日星期五
  3. 语法规则 • reference = $ + id + attributes •

    attributes = attribute | attributes + attribute • attribute = method | index | property • method = id + ( + param + ) • index = [ + reference + ] • property = dot + id 23 12年12月28⽇日星期五
  4. $hello.foo[0] { "type": "references", "id": "hello", "leader": "$", "path": [

    { "type": "property", "id": "foo" }, { "type": "index", "id": { "type": "integer", "value": "0" } } ] } 27 12年12月28⽇日星期五
  5. #if($foo > 10) { "type": "if", "condition": { "type": "math",

    "operator": ">", "expression": [ { "type": "references", "id": "foo", "leader": "$" }, { "type": "integer", "value": "10" } ] } } 28 12年12月28⽇日星期五
  6. #foreach($bar in [-2..4]) { "type": "foreach", "to": "bar", "from": {

    "type": "array", "isRange": true, "value": [-2, "4"] } } 29 12年12月28⽇日星期五