This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type CharMatch struct { | |
fn func(rune) bool | |
} | |
func (cm CharMatch) Match(c rune) bool { | |
return cm.fn(c) | |
} | |
func Is(c rune) CharMatch { | |
return CharMatch{ func (c2 rune) bool { return c == c2 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type CharMatch interface { | |
Match(c rune) bool | |
} | |
type is_cm struct { | |
c rune | |
} | |
func (cm is_cm) Match(c rune) bool { | |
return c == cm.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Package lex implements the lexical scanner for Suneido | |
package lex | |
import ( | |
"bytes" | |
"strings" | |
"unicode" | |
"unicode/utf8" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
hamcrest implements very basic hamcrest style asserts | |
for example: | |
func TestStuff(t *testing.T) { | |
Assert(t).That(2 * 4, Equals(6)) | |
} | |
*/ | |
package hamcrest | |
import "fmt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Package float10 implements decimal floating point numbers | |
// using uint64 to hold the coefficient. | |
package float10 | |
import "strconv" | |
import "errors" | |
import "strings" | |
import "math" | |
// value is -1^sign * coef * 10^exp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
max_matches: 30 | |
GetMatches(prefix) | |
{ | |
list = Suneido.LibLocate.list | |
prefix = prefix.Tr("_").Lower() | |
from = list.LowerBound(prefix) | |
to = Min(from + .max_matches, list.LowerBound(prefix.RightTrim() $ "~")) | |
matches = list[from .. to] | |
matches.Map!({ it.AfterFirst("=") }) | |
matches.Sort!().Unique!() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getLibsNames(libs) | |
{ | |
list = Object() | |
for (i = 0; i < libs.Size(); ++i) | |
{ | |
lib = libs[i] | |
li = i.Pad(2) | |
for x in QueryList(lib $ " where group = -1", "name") | |
{ | |
list.Add(x.Tr("_").Lower() $ "=" $ x $ ":" $ li) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CommaStringBuilder csb = new CommaStringBuilder("("); | |
for (Object x : list) | |
csb.add(fn(x)); | |
return csb.append(")").toString(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CommaStringBuilder implements Appendable { | |
private final StringBuilder sb; | |
private boolean first = true; | |
public CommaStringBuilder() { | |
sb = new StringBuilder(); | |
} | |
public CommaStringBuilder(String s) { | |
sb = new StringBuilder(s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (list.isEmpty()) | |
return ""; | |
for (Object x : list) | |
sb.append(",").append(fn(x)); | |
return sb.substring(1); |