Skip to content

Commit

Permalink
update number parsing and fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Apr 23, 2017
1 parent 82a8a3d commit 1b36471
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ CI|status
:---|:---:
Travis CI|[![Build Status](https://travis-ci.org/lice-lang/lice.svg?branch=master)](https://travis-ci.org/lice-lang/lice)
AppVeyor|[![Build status](https://ci.appveyor.com/api/projects/status/7d6lyinb0xr6hagn?svg=true)](https://ci.appveyor.com/project/ice1000/lice/branch/master)
CodeShip|[![CodeShip](https://codeship.com/projects/ce3500b0-0a1d-0135-8b3c-6ed4d7e33e57/status?branch=master)](https://app.codeship.com/projects/214703)

[![JitPack](https://jitpack.io/v/lice-lang/lice.svg)](https://jitpack.io/#lice-lang/lice)
[![Gitter](https://badges.gitter.im/lice-lang/lice.svg)](https://gitter.im/lice-lang/lice)
[![Dependency Status](https://www.versioneye.com/user/projects/58df5b1c24ef3e00425cf73f/badge.svg?style=square)](https://www.versioneye.com/user/projects/58df5b1c24ef3e00425cf73f)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)
[![JitPack](https://jitpack.io/v/lice-lang/lice.svg)](https://jitpack.io/#lice-lang/lice)<br/>
[![Gitter](https://badges.gitter.im/lice-lang/lice.svg)](https://gitter.im/lice-lang/lice)<br/>
[![Dependency Status](https://www.versioneye.com/user/projects/58df5b1c24ef3e00425cf73f/badge.svg?style=square)](https://www.versioneye.com/user/projects/58df5b1c24ef3e00425cf73f)<br/>
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)<br/>
[![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin)<br/>

This is an interpreter for a dialect of lisp, running on JVM.

Expand Down
9 changes: 8 additions & 1 deletion src/main/kotlin/org/lice/compiler/parse/Number.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,14 @@ fun String.toBinInt(): Int {
return ret
}

fun String.toBigInt() = BigInteger(this.substring(0, length - 1))
fun String.toBigInt() = BigInteger(this.substring(0, length - 1).run {
when {
isHexInt() -> toHexInt()
isBinInt() -> toBinInt()
isOctInt() -> toOctInt()
else -> toInt()
}
}.toString())

fun String.toBigDec() = BigDecimal(this.substring(0, length - 1))

Expand Down
21 changes: 19 additions & 2 deletions src/main/kotlin/org/lice/lang/hooks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,33 @@ package org.lice.lang

import org.lice.compiler.model.Node

typealias Output = Any?.() -> Unit

object Echoer {
var printer: Any?.() -> Unit = ::print
val stdout: Output = ::print
var printer: Output = stdout
get
var printerErr: Any?.() -> Unit = System.out::print

var stderr: Output = System.out::print
var printerErr: Output = stderr
get

val nothing: Output = { }

fun echo(a: Any? = "") = printer(a)
fun echoln(a: Any? = "") = echo("$a\n")
fun echoErr(a: Any? = "") = printerErr(a)
fun echolnErr(a: Any? = "") = printerErr("$a\n")

fun closeOutput() {
printer = nothing
printerErr = nothing
}

fun openOutput() {
printer = stdout
printerErr = stderr
}
}

object BeforeEval {
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/org/lice/repl/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ object Main {
@JvmStatic
fun main(args: Array<String>) {
if (args.isEmpty()) {
Echoer.closeOutput()
val sl = SymbolList()
Echoer.openOutput()
sl.provideFunction("help", {
"""This is the repl for org.lice language.
Expand Down

0 comments on commit 1b36471

Please sign in to comment.