Module: Nydp::Helper
- Includes:
- Converter
- Included in:
- Hash, Assignment, Builtin::Apply, Builtin::Base, Builtin::Date, Builtin::Ensuring, Builtin::HandleError, Builtin::HandleError::CatchError, Builtin::Hash, Builtin::HashGet, Builtin::HashKeyPresent, Builtin::HashKeys, Builtin::HashMerge, Builtin::HashSet, Builtin::HashSlice, Builtin::ThreadLocals, Builtin::Time, Compiler, Cond, Cond, CondBase, CondBase, Date, ExecuteConditionalInstruction, FunctionInvocation, Hash, InterpretedFunction, InterpretedFunction, Invocation::Base, LexicalContext, LexicalContextBuilder, Literal, Pair, Pair, SymbolLookup, VM
- Defined in:
- lib/nydp/helper.rb
Instance Method Summary collapse
- #cons(a, b = Nydp::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, b = Nydp::NIL) ⇒ Object
72 73 74 |
# File 'lib/nydp/helper.rb', line 72 def cons a, b=Nydp::NIL Nydp::Pair.new a, b end |
#list(*args) ⇒ Object
76 77 78 |
# File 'lib/nydp/helper.rb', line 76 def list *args Nydp::Pair.from_list args end |
#literal?(expr) ⇒ Boolean
84 85 86 87 88 89 90 91 |
# File 'lib/nydp/helper.rb', line 84 def literal? expr case expr when String, Float, Integer, Integer, Nydp::Symbol, Nydp::Truth, Nydp::Nil true else false end end |
#pair?(expr) ⇒ Boolean
68 69 70 |
# File 'lib/nydp/helper.rb', line 68 def pair? expr expr.is_a?(Nydp::Pair) end |
#sig(klass) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/nydp/helper.rb', line 49 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 |