Module: Nydp::Helper
- Includes:
- Converter
- Included in:
- Hash, Assignment, Builtin::Apply, Builtin::Base, Builtin::Date, Builtin::Ensuring, Builtin::HandleError, Builtin::Hash, Builtin::HashGet, Builtin::HashKeyPresent, Builtin::HashKeys, Builtin::HashMerge, Builtin::HashSet, Builtin::HashSlice, Builtin::HashToArray, Builtin::ThreadLocals, Builtin::Time, Compiler, Cond, Cond, CondBase, CondBase, Date, FunctionInvocation, InterpretedFunction, InterpretedFunction, Invocation::Base, LexicalContext, LexicalContextBuilder, Literal, Loop, Loop, Namespace, Pair, Pair, SymbolLookup
- Defined in:
- lib/nydp/helper.rb
Instance Method Summary collapse
- #cons(a = nil, b = nil) ⇒ Object
- #list(*args) ⇒ Object
- #literal?(expr) ⇒ Boolean
- #pair?(expr) ⇒ Boolean
- #sig(klass) ⇒ Object
- #sym(name, ns) ⇒ Object
- #sym?(expr, name) ⇒ Boolean
Methods included from Converter
Instance Method Details
#cons(a = nil, b = nil) ⇒ Object
79 80 81 |
# File 'lib/nydp/helper.rb', line 79 def cons a=nil, b=nil Nydp::Pair.new a, b end |
#list(*args) ⇒ Object
83 84 85 |
# File 'lib/nydp/helper.rb', line 83 def list *args Nydp::Pair.from_list args end |
#literal?(expr) ⇒ Boolean
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/nydp/helper.rb', line 91 def literal? expr case expr # when String, Float, Integer, Integer, Symbol, Nydp::Truth, Nydp::Nil # when String, Float, Integer, Integer, Symbol, Nydp::Truth, NilClass when String, Float, Integer, Integer, Symbol, TrueClass, FalseClass, NilClass true else false end end |
#pair?(expr) ⇒ Boolean
75 76 77 |
# File 'lib/nydp/helper.rb', line 75 def pair? expr expr.is_a?(Nydp::Pair) end |
#sig(klass) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/nydp/helper.rb', line 55 def sig klass case klass when Nydp::Symbol ; "SYM" when Nydp::ContextSymbol ; "LEX" when Nydp::Literal ; "LIT" when Nydp::FunctionInvocation ; "NVK" when Nydp::Invocation::Base ; "NVB" when Nydp::InterpretedFunction ; "IFN" when Nydp::Cond ; "CND" when Nydp::CondBase ; "CND" when Nydp::Assignment ; "ASN" else ; raise "no sig for #{klass.class.name}" end end |
#sym(name, ns) ⇒ Object
87 88 89 |
# File 'lib/nydp/helper.rb', line 87 def sym name, ns name.to_s.to_sym end |
#sym?(expr, name) ⇒ Boolean
70 71 72 73 |
# File 'lib/nydp/helper.rb', line 70 def sym? expr, name # expr.is_a?(Nydp::Symbol) && (expr.is? name) expr.is_a?(::Symbol) && (expr == name.to_sym) end |