Sha256: ae477e98609ca1f8cc59803e852fd9eea1d4f75a8be78eb85ea1f1099c7d2edb

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

module CEML
grammar Instructions
    include Lexer

    rule basic_statement
        (ask_stmt / tell_stmt / assign_stmt / record_stmt / set_stmt) {

            def delay
                if parent.respond_to? :later and not parent.later.empty?
                    parent.later.duration.seconds
                end
            end

            def role;  id.text_value.to_sym; end
            def text;  super.text_value; end
            def var
                return varname.text_value if cmd == :record or cmd == :set
                (!defined?(:about) || about.empty?) ? nil : about.varname.text_value;
            end
            def key;   var || text; end
            def cmd;
              text_value =~ /^ask/      and return :ask
              text_value =~ /^tell/     and return :tell
              text_value =~ /^assign/   and return :assign
              text_value =~ /^record/   and return :record
              text_value =~ /^set/      and return :set
            end
        }
    end

    rule instruction_stmt
        later:later? basic_statement
    end

    rule later
        duration ws 'later' ws
    end

    rule record_stmt
        'record' ws id ws varname:id
    end

    rule tell_stmt
        'tell' ws id ':' ws? text
    end

    rule assign_stmt
        'assign' ws id ':' ws? text
    end

    rule ask_stmt
        'ask' ws id about:(ws 're' ws varname:id)? ':' ws? text
    end

    rule set_stmt
        'set' ws id ws varname:id ':' ws? text
    end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ceml-0.6.3 lib/ceml/tt/instructions.treetop