Sha256: a755ff45a3f0957c81fad77a1e6871e96c46600f37cff00a3d2fbe2cd907d13c
Contents?: true
Size: 1.82 KB
Versions: 1
Compression:
Stored size: 1.82 KB
Contents
require "racc/parser" module WMLAction class Parser < Racc::Parser options #debug macro OTAG /\[(\w+)\]/ CTAG /\[\/(\w+)\]/ ATTR /(\w+)=/ MACRO /\{.+\}/ ANUMBER /-?\d+(\.\d+)?/ ASTR /"[^"]*"/ APLAIN /.+/ SLASH /\// COMMENT /\#.*$/ BACKQ /\`/ VAR /[\w]+/ BLANK /[ \t]+/ rule /#{COMMENT}/ /#{OTAG}/ { [:OTAG, match[1]] } /#{CTAG}/ { [:CTAG, match[1]] } /#{ATTR}/ { @state = :INATTR; [:ATTR, match[1]] } /#{MACRO}/ { [:MACRO, text] } /#{SLASH}/ { [:SLASH, text] } /\-/ { [text,text] } /\+/ { [text,text] } :INATTR /\n/ { @state = nil } :INATTR /#{BLANK}/ :INATTR /#{ANUMBER}\s+/ { @state = nil; [:ANUMBER, text.to_i] } :INATTR /#{ASTR}/ { [:ASTR, text] } :INATTR /#{MACRO}/ { [:AMACRO, text] } :INATTR /_/ { [:UNDERSC, text] } :INATTR /\+/ { [:APLUS, text] } :INATTR /#{BACKQ}/ { @state = :INEXPR; [:BACKQ, text] } :INATTR /#{APLAIN}/ { [:APLAIN, text] } :INEXPR /#{BACKQ}/ { @state = nil; [:BACKQ, text] } :INEXPR /\+/ { [:EPLUS,text] } :INEXPR /\*/ { [:EMUL,text] } :INEXPR /\// { [:EDIV,text] } :INEXPR /\-/ { [:EMINUS,text] } :INEXPR /\./ { [:EDOT,text] } :INEXPR /\(/ { [text,text] } :INEXPR /\)/ { [text,text] } :INEXPR /#{ANUMBER}/ { [:ENUM,text.to_f] } :INEXPR /#{ASTR}/ { [:ESTR,text.slice(1..-2)] } :INEXPR /#{VAR}/ { [:EVAR,text] } /./ /\n/ inner end end #module
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wml_action-0.0.4 | lib/wml_action/lexer.rex |