1
1
mirror of https://github.com/kanaka/mal.git synced 2024-10-26 14:22:25 +03:00
mal/impls/vb/printer.vb
Joel Martin 8a19f60386 Move implementations into impls/ dir
- Reorder README to have implementation list after "learning tool"
  bullet.

- This also moves tests/ and libs/ into impls. It would be preferrable
  to have these directories at the top level.  However, this causes
  difficulties with the wasm implementations which need pre-open
  directories and have trouble with paths starting with "../../". So
  in lieu of that, symlink those directories to the top-level.

- Move the run_argv_test.sh script into the tests directory for
  general hygiene.
2020-02-10 23:50:16 -06:00

53 lines
2.0 KiB
VB.net

Imports System
Imports System.Collections.Generic
Imports System.Text.RegularExpressions
Imports Mal
Imports MalVal = Mal.types.MalVal
Imports MalList = Mal.types.MalList
Namespace Mal
Public Class printer
Shared Function join(value As List(Of MalVal),
delim As String,
print_readably As Boolean) As String
Dim strs As New List(Of String)
For Each mv As MalVal In value
strs.Add(mv.ToString(print_readably))
Next
return String.Join(delim, strs.ToArray())
End Function
Shared Function join(value As Dictionary(Of String, MalVal),
delim As String,
print_readably As Boolean) As String
Dim strs As New List(Of String)
For Each entry As KeyValuePair(Of String, MalVal) In value
If entry.Key.Length > 0 and entry.Key(0) = ChrW(&H029e) Then
strs.Add(":" & entry.Key.Substring(1))
Else If print_readably Then
strs.Add("""" & entry.Key.ToString() & """")
Else
strs.Add(entry.Key.ToString())
End If
strs.Add(entry.Value.ToString(print_readably))
Next
return String.Join(delim, strs.ToArray())
End Function
Shared Function _pr_str(mv As MalVal,
print_readably As Boolean) As String
return mv.ToString(print_readably)
End Function
Shared Function _pr_str_args(args As MalList,
sep As String,
print_readably As Boolean) As String
return join(args.getValue(), sep, print_readably)
End Function
Shared Function escapeString(str As String) As String
return Regex.Escape(str)
End Function
End Class
End Namespace