Sha256: 64712dd99b709a6bed1cfd86c7d001890783785f1f3aadb5a276db6d850e04cd

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require "racc/parser"

module WMLAction

class Parser < Racc::Parser

options
    #debug

macro
    OTAG    /\[(\w+)\]/
    CTAG    /\[\/(\w+)\]/
    ATTR    /(\w+)=/
    MACRO   /\{.+\}/
    ANUMBER /-?\d+/
    ASTR    /"[^"]*"/
    APLAIN  /.+/
    SLASH   /\//
    COMMENT /\#.*$/

    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 /#{APLAIN}/         { [:APLAIN, text] }

            /./
            /\n/

inner
end

end #module

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wml_action-0.0.2 lib/wml_action/lexer.rex