aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md61
-rw-r--r--cmd/starlark/starlark.go (renamed from cmd/skylark/skylark.go)20
-rw-r--r--doc/impl.md34
-rw-r--r--doc/spec.md228
-rw-r--r--docs/index.html2
-rw-r--r--eval.go44
-rw-r--r--eval_test.go190
-rw-r--r--example_test.go76
-rw-r--r--hashtable.go4
-rw-r--r--hashtable_test.go2
-rw-r--r--int.go14
-rw-r--r--internal/compile/codegen_test.go6
-rw-r--r--internal/compile/compile.go20
-rw-r--r--internal/compile/compile_test.go28
-rw-r--r--internal/compile/serial.go6
-rw-r--r--interp.go6
-rw-r--r--library.go162
-rw-r--r--repl/repl.go42
-rw-r--r--resolve/resolve.go20
-rw-r--r--resolve/resolve_test.go14
-rw-r--r--resolve/testdata/resolve.star (renamed from resolve/testdata/resolve.sky)8
-rw-r--r--starlarkstruct/struct.go (renamed from skylarkstruct/struct.go)106
-rw-r--r--starlarkstruct/struct_test.go (renamed from skylarkstruct/struct_test.go)46
-rw-r--r--starlarkstruct/testdata/struct.star (renamed from skylarkstruct/testdata/struct.sky)6
-rw-r--r--starlarktest/assert.star (renamed from skylarktest/assert.sky)0
-rw-r--r--starlarktest/starlarktest.go (renamed from skylarktest/skylarktest.go)68
-rw-r--r--syntax/grammar.txt2
-rw-r--r--syntax/parse.go8
-rw-r--r--syntax/parse_test.go16
-rw-r--r--syntax/quote.go2
-rw-r--r--syntax/scan.go6
-rw-r--r--syntax/scan_test.go22
-rw-r--r--syntax/syntax.go14
-rw-r--r--syntax/testdata/errors.star (renamed from syntax/testdata/errors.sky)4
-rw-r--r--syntax/testdata/scan.star (renamed from syntax/testdata/scan.sky)12
-rw-r--r--testdata/assign.star (renamed from testdata/assign.sky)30
-rw-r--r--testdata/benchmark.star (renamed from testdata/benchmark.sky)2
-rw-r--r--testdata/bool.star (renamed from testdata/bool.sky)4
-rw-r--r--testdata/builtins.star (renamed from testdata/builtins.sky)4
-rw-r--r--testdata/control.star (renamed from testdata/control.sky)4
-rw-r--r--testdata/dict.star (renamed from testdata/dict.sky)4
-rw-r--r--testdata/float.star (renamed from testdata/float.sky)4
-rw-r--r--testdata/function.star (renamed from testdata/function.sky)18
-rw-r--r--testdata/int.star (renamed from testdata/int.sky)10
-rw-r--r--testdata/list.star (renamed from testdata/list.sky)4
-rw-r--r--testdata/misc.star (renamed from testdata/misc.sky)18
-rw-r--r--testdata/set.star (renamed from testdata/set.sky)10
-rw-r--r--testdata/string.star (renamed from testdata/string.sky)4
-rw-r--r--testdata/tuple.star (renamed from testdata/tuple.sky)4
-rw-r--r--value.go66
-rw-r--r--value_test.go14
51 files changed, 750 insertions, 749 deletions
diff --git a/README.md b/README.md
index 643cdcd..1b8e0f9 100644
--- a/README.md
+++ b/README.md
@@ -1,30 +1,31 @@
-<!-- This file is the project homepage at github.com/google/skylark -->
+<!-- This file is the project homepage at github.com/google/starlark -->
-# Skylark in Go
+# Starlark in Go
-This is the home of the _Skylark in Go_ project.
-Skylark in Go is an interpreter for Skylark, implemented in Go.
+This is the home of the _Starlark in Go_ project.
+Starlark in Go is an interpreter for Starlark, implemented in Go.
+Starlark was formerly known as Skylark.
-Skylark is a dialect of Python intended for use as a configuration language.
+Starlark is a dialect of Python intended for use as a configuration language.
Like Python, it is an untyped dynamic language with high-level data
types, first-class functions with lexical scope, and garbage collection.
-Unlike CPython, independent Skylark threads execute in parallel, so
-Skylark workloads scale well on parallel machines.
-Skylark is a small and simple language with a familiar and highly
+Unlike CPython, independent Starlark threads execute in parallel, so
+Starlark workloads scale well on parallel machines.
+Starlark is a small and simple language with a familiar and highly
readable syntax. You can use it as an expressive notation for
structured data, defining functions to eliminate repetition, or you
can use it to add scripting capabilities to an existing application.
-A Skylark interpreter is typically embedded within a larger
+A Starlark interpreter is typically embedded within a larger
application, and the application may define additional domain-specific
functions and data types beyond those provided by the core language.
-For example, Skylark was originally developed for the
+For example, Starlark was originally developed for the
[Bazel build tool](https://bazel.build).
-Bazel uses Skylark as the notation both for its BUILD files (like
+Bazel uses Starlark as the notation both for its BUILD files (like
Makefiles, these declare the executables, libraries, and tests in a
directory) and for [its macro
-language](https://docs.bazel.build/versions/master/skylark/language.html),
+language](https://docs.bazel.build/versions/master/starlark/language.html),
through which Bazel is extended with custom logic to support new
languages and compilers.
@@ -35,27 +36,27 @@ languages and compilers.
* About the Go implementation: [doc/impl.md](doc/impl.md)
-* API documentation: [godoc.org/github.com/google/skylark](https://godoc.org/github.com/google/skylark)
+* API documentation: [godoc.org/github.com/google/starlark](https://godoc.org/github.com/google/starlark)
-* Mailing list: [skylark-go](https://groups.google.com/forum/#!forum/skylark-go)
+* Mailing list: [starlark-go](https://groups.google.com/forum/#!forum/starlark-go)
-* Issue tracker: [https://github.com/google/skylark/issues](https://github.com/google/skylark/issues)
+* Issue tracker: [https://github.com/google/starlark/issues](https://github.com/google/starlark/issues)
-* Travis CI: ![Travis CI](https://travis-ci.org/google/skylark.svg) [https://travis-ci.org/google/skylark](https://travis-ci.org/google/skylark)
+* Travis CI: ![Travis CI](https://travis-ci.org/google/starlark.svg) [https://travis-ci.org/google/starlark](https://travis-ci.org/google/starlark)
### Getting started
Build the code:
```shell
-$ go get github.com/google/skylark/...
-$ go build github.com/google/skylark/cmd/skylark
+$ go get github.com/google/starlark/...
+$ go build github.com/google/starlark/cmd/starlark
```
Run the interpreter:
```
-$ cat coins.sky
+$ cat coins.star
coins = {
'dime': 10,
'nickel': 5,
@@ -65,7 +66,7 @@ coins = {
print('By name:\t' + ', '.join(sorted(coins.keys())))
print('By value:\t' + ', '.join(sorted(coins.keys(), key=coins.get)))
-$ ./skylark coins.sky
+$ ./starlark coins.star
By name: dime, nickel, penny, quarter
By value: penny, nickel, dime, quarter
```
@@ -73,7 +74,7 @@ By value: penny, nickel, dime, quarter
Interact with the read-eval-print loop (REPL):
```
-$ ./skylark
+$ ./starlark
>>> def fibonacci(n):
... res = list(range(n))
... for i in res[2:]:
@@ -90,16 +91,16 @@ When you have finished, type `Ctrl-D` to close the REPL's input stream.
### Contributing
We welcome submissions but please let us know what you're working on
-if you want to change or add to the Skylark repository.
+if you want to change or add to the Starlark repository.
-Before undertaking to write something new for the Skylark project,
+Before undertaking to write something new for the Starlark project,
please file an issue or claim an existing issue.
All significant changes to the language or to the interpreter's Go
API must be discussed before they can be accepted.
This gives all participants a chance to validate the design and to
avoid duplication of effort.
-Despite some differences, the Go implementation of Skylark strives to
+Despite some differences, the Go implementation of Starlark strives to
match the behavior of the Java implementation used by Bazel.
For that reason, proposals to change the language itself should
generally be directed to the Bazel team, not to the maintainers of
@@ -127,13 +128,13 @@ stage in the project, although we will endeavor to keep them to a minimum.
Now that the project's long-term name ("Starlark") has been decided,
we plan to copy this repository to github.com/google/starlark and
change the canonical import path for all packages to starlark.net/starlark.
-The current github.com/google/skylark repository will be frozen.
+The current github.com/google/starlark repository will be frozen.
Once the Bazel team has finalized the version 1 language specification,
we will be more rigorous with interface stability.
### Credits
-Skylark was designed and implemented in Java by
+Starlark was designed and implemented in Java by
Ulf Adams,
Lukács Berki,
Jon Brandvein,
@@ -149,14 +150,14 @@ its scanner was derived from one written by Russ Cox.
### Legal
-Skylark in Go is Copyright (c) 2017 The Bazel Authors.
+Starlark in Go is Copyright (c) 2017 The Bazel Authors.
All rights reserved.
It is provided under a 3-clause BSD license:
-[LICENSE](https://github.com/google/skylark/blob/master/LICENSE).
+[LICENSE](https://github.com/google/starlark/blob/master/LICENSE).
-The name "Skylark" is a code name of the Bazel project.
+The name "Starlark" is a code name of the Bazel project.
The Bazel team plans to rename the language to "Starlark" to reflect its
applicability to projects unrelated to Bazel.
-Skylark in Go is not an official Google product.
+Starlark in Go is not an official Google product.
diff --git a/cmd/skylark/skylark.go b/cmd/starlark/starlark.go
index c9270a9..3e74a75 100644
--- a/cmd/skylark/skylark.go
+++ b/cmd/starlark/starlark.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// The skylark command interprets a Skylark file.
+// The starlark command interprets a Starlark file.
// With no arguments, it starts a read-eval-print loop (REPL).
package main
@@ -15,9 +15,9 @@ import (
"sort"
"strings"
- "github.com/google/skylark"
- "github.com/google/skylark/repl"
- "github.com/google/skylark/resolve"
+ "github.com/google/starlark"
+ "github.com/google/starlark/repl"
+ "github.com/google/starlark/resolve"
)
// flags
@@ -36,7 +36,7 @@ func init() {
}
func main() {
- log.SetPrefix("skylark: ")
+ log.SetPrefix("starlark: ")
log.SetFlags(0)
flag.Parse()
@@ -51,24 +51,24 @@ func main() {
defer pprof.StopCPUProfile()
}
- thread := &skylark.Thread{Load: repl.MakeLoad()}
- globals := make(skylark.StringDict)
+ thread := &starlark.Thread{Load: repl.MakeLoad()}
+ globals := make(starlark.StringDict)
switch len(flag.Args()) {
case 0:
- fmt.Println("Welcome to Skylark (github.com/google/skylark)")
+ fmt.Println("Welcome to Starlark (github.com/google/starlark)")
repl.REPL(thread, globals)
case 1:
// Execute specified file.
filename := flag.Args()[0]
var err error
- globals, err = skylark.ExecFile(thread, filename, nil, nil)
+ globals, err = starlark.ExecFile(thread, filename, nil, nil)
if err != nil {
repl.PrintError(err)
os.Exit(1)
}
default:
- log.Fatal("want at most one Skylark file name")
+ log.Fatal("want at most one Starlark file name")
}
// Print the global environment.
diff --git a/doc/impl.md b/doc/impl.md
index 53ca121..380e2d6 100644
--- a/doc/impl.md
+++ b/doc/impl.md
@@ -1,8 +1,8 @@
-# Skylark in Go: Implementation
+# Starlark in Go: Implementation
This document (a work in progress) describes some of the design
-choices of the Go implementation of Skylark.
+choices of the Go implementation of Starlark.
* [Scanner](#scanner)
* [Parser](#parser)
@@ -40,7 +40,7 @@ cases would require additional lookahead.
The resolver reports structural errors in the program, such as the use
of `break` and `continue` outside of a loop.
-Skylark has stricter syntactic limitations than Python. For example,
+Starlark has stricter syntactic limitations than Python. For example,
it does not permit `for` loops or `if` statements at top level, nor
does it permit global variables to be bound more than once.
These limitations come from the Bazel project's desire to make it easy
@@ -66,7 +66,7 @@ any uses of dialect features that have not been enabled.
<b>Integers:</b> Integers are representing using `big.Int`, an
arbitrary precision integer. This representation was chosen because,
-for many applications, Skylark must be able to handle without loss
+for many applications, Starlark must be able to handle without loss
protocol buffer values containing signed and unsigned 64-bit integers,
which requires 65 bits of precision.
@@ -74,7 +74,7 @@ Small integers (<256) are preallocated, but all other values require
memory allocation. Integer performance is relatively poor, but it
matters little for Bazel-like workloads which depend much
more on lists of strings than on integers. (Recall that a typical loop
-over a list in Skylark does not materialize the loop index as an `int`.)
+over a list in Starlark does not materialize the loop index as an `int`.)
An optimization worth trying would be to represent integers using
either an `int32` or `big.Int`, with the `big.Int` used only when
@@ -95,11 +95,11 @@ greater than, or equal: it may also fail.
TODO: discuss UTF-8 and string.bytes method.
<b>Dictionaries and sets</b>:
-Skylark dictionaries have predictable iteration order.
-Furthermore, many Skylark values are hashable in Skylark even though
+Starlark dictionaries have predictable iteration order.
+Furthermore, many Starlark values are hashable in Starlark even though
the Go values that represent them are not hashable in Go: big
integers, for example.
-Consequently, we cannot use Go maps to implement Skylark's dictionary.
+Consequently, we cannot use Go maps to implement Starlark's dictionary.
We use a simple hash table whose buckets are linked lists, each
element of which holds up to 8 key/value pairs. In a well-distributed
@@ -108,13 +108,13 @@ key/value item is part of doubly-linked list that maintains the
insertion order of the elements for iteration.
<b>Struct:</b>
-The `skylarkstruct` Go package provides a non-standard Skylark
+The `starlarkstruct` Go package provides a non-standard Starlark
extension data type, `struct`, that maps field identifiers to
arbitrary values. Fields are accessed using dot notation: `y = s.f`.
This data type is extensively used in Bazel, but its specification is
currently evolving.
-Skylark has no `class` mechanism, nor equivalent of Python's
+Starlark has no `class` mechanism, nor equivalent of Python's
`namedtuple`, though it is likely that future versions will support
some way to define a record data type of several fields, with a
representation more efficient than a hash table.
@@ -123,8 +123,8 @@ representation more efficient than a hash table.
### Freezing
All mutable values created during module initialization are _frozen_
-upon its completion. It is this property that permits a Skylark module
-to be referenced by two Skylark threads running concurrently (such as
+upon its completion. It is this property that permits a Starlark module
+to be referenced by two Starlark threads running concurrently (such as
the initialization threads of two other modules) without the
possibility of a data race.
@@ -162,7 +162,7 @@ extra bookkeeping so that modification of the underlying collection
invalidates the iterator, and the next attempt to use it fails.
This often helps to detect subtle mistakes.
-Skylark takes this a step further. Instead of mutation of the
+Starlark takes this a step further. Instead of mutation of the
collection invalidating the iterator, the act of iterating makes the
collection temporarily immutable, so that an attempt to, say, delete a
dict element while looping over the dict, will fail. The error is
@@ -182,7 +182,7 @@ to call `Done` on each iterator once it is no longer needed.
```
TODO
-skylark.Value interface and subinterfaces
+starlark.Value interface and subinterfaces
argument passing to builtins: UnpackArgs, UnpackPositionalArgs.
```
@@ -207,7 +207,7 @@ array from a `make([]Value, n)` allocation always escapes
([Go issue 20533](https://github.com/golang/go/issues/20533)).
Because the bytecode interpreter's operand stack has a non-constant
length, it must be allocated with `make`. The resulting allocation
-adds to the cost of each Skylark function call; this can be tolerated
+adds to the cost of each Starlark function call; this can be tolerated
by amortizing one very large stack allocation across many calls.
More problematic appears to be the cost of the additional GC write
barriers incurred by every VM operation: every intermediate result is
@@ -227,9 +227,9 @@ Load
```
TODO
-skylarktest package
+starlarktest package
`assert` module
-skylarkstruct
+starlarkstruct
integration with Go testing.T
```
diff --git a/doc/spec.md b/doc/spec.md
index b7a611e..e69751f 100644
--- a/doc/spec.md
+++ b/doc/spec.md
@@ -1,17 +1,17 @@
-# Skylark in Go: Language definition
+# Starlark in Go: Language definition
-Skylark is a dialect of Python intended for use as a configuration
-language. A Skylark interpreter is typically embedded within a larger
+Starlark is a dialect of Python intended for use as a configuration
+language. A Starlark interpreter is typically embedded within a larger
application, and this application may define additional
domain-specific functions and data types beyond those provided by the
-core language. For example, Skylark is embedded within (and was
+core language. For example, Starlark is embedded within (and was
originally developed for) the [Bazel build tool](https://bazel.build),
-and [Bazel's build language](https://docs.bazel.build/versions/master/skylark/language.html) is based on Skylark.
+and [Bazel's build language](https://docs.bazel.build/versions/master/starlark/language.html) is based on Starlark.
-This document describes the Go implementation of Skylark
-at github.com/google/skylark.
+This document describes the Go implementation of Starlark
+at github.com/google/starlark.
The language it defines is similar but not identical to
-[the Java-based implementation](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/skylark/Skylark.java)
+[the Java-based implementation](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/starlark/Starlark.java)
used by Bazel.
We identify places where their behaviors differ, and an
[appendix](#dialect-differences) provides a summary of those
@@ -24,31 +24,31 @@ It was influenced by the Python specification,
Copyright 1990&ndash;2017, Python Software Foundation,
and the Go specification, Copyright 2009&ndash;2017, The Go Authors.
-Skylark was designed and implemented in Java by Laurent Le Brun,
+Starlark was designed and implemented in Java by Laurent Le Brun,
Dmitry Lomov, Jon Brandvin, and Damien Martin-Guillerez, standing on
the shoulders of the Python community.
The Go implementation was written by Alan Donovan and Jay Conrod;
its scanner was derived from one written by Russ Cox.
-The name "Skylark" is a code name of the Bazel project.
+The name "Starlark" is a code name of the Bazel project.
We plan to rename the language before the end of 2017 to reflect its
applicability to projects unrelated to Bazel.
## Overview
-Skylark is an untyped dynamic language with high-level data types,
+Starlark is an untyped dynamic language with high-level data types,
first-class functions with lexical scope, and automatic memory
management or _garbage collection_.
-Skylark is strongly influenced by Python, and is almost a subset of
+Starlark is strongly influenced by Python, and is almost a subset of
that language. In particular, its data types and syntax for
statements and expressions will be very familiar to any Python
programmer.
-However, Skylark is intended not for writing applications but for
+However, Starlark is intended not for writing applications but for
expressing configuration: its programs are short-lived and have no
external side effects and their main result is structured data or side
effects on the host application.
-As a result, Skylark has no need for classes, exceptions, reflection,
+As a result, Starlark has no need for classes, exceptions, reflection,
concurrency, and other such features of Python.
@@ -191,10 +191,10 @@ concurrency, and other such features of Python.
## Lexical elements
-A Skylark program consists of one or more modules.
+A Starlark program consists of one or more modules.
Each module is defined by a single UTF-8-encoded text file.
-A complete grammar of Skylark can be found in [grammar.txt](../syntax/grammar.txt).
+A complete grammar of Starlark can be found in [grammar.txt](../syntax/grammar.txt).
That grammar is presented piecemeal throughout this document
in boxes such as this one, which explains the notation:
@@ -210,7 +210,7 @@ Grammar notation
- The end of each declaration is marked with a period.
```
-The contents of a Skylark file are broken into a sequence of tokens of
+The contents of a Starlark file are broken into a sequence of tokens of
five kinds: white space, punctuation, keywords, identifiers, and literals.
Each token is formed from the longest sequence of characters that
would form a valid token of each kind.
@@ -287,7 +287,7 @@ None True len
x index starts_with arg0
```
-*Literals*: literals are tokens that denote specific values. Skylark
+*Literals*: literals are tokens that denote specific values. Starlark
has string, integer, and floating-point literals.
```text
@@ -345,7 +345,7 @@ list # a fixed-length sequence of values
tuple # a fixed-length sequence of values, unmodifiable
dict # a mapping from values to values
set # a set of values
-function # a function implemented in Skylark
+function # a function implemented in Starlark
builtin_function_or_method # a function or method implemented by the interpreter or host application
```
@@ -359,7 +359,7 @@ comparison, indexing, and function calls.
<!-- We needn't mention the stringIterable type here. -->
-Some operations can be applied to any Skylark value. For example,
+Some operations can be applied to any Starlark value. For example,
every value has a type string that can be obtained with the expression
`type(x)`, and any value may be converted to a string using the
expression `str(x)`, or to a Boolean truth value using the expression
@@ -385,7 +385,7 @@ There are two Boolean values, `True` and `False`, representing the
truth or falsehood of a predicate. The [type](#type) of a Boolean is `"bool"`.
Boolean values are typically used as conditions in `if`-statements,
-although any Skylark value used as a condition is implicitly
+although any Starlark value used as a condition is implicitly
interpreted as a Boolean.
For example, the values `None`, `0`, `0.0`, and the empty sequences
`""`, `()`, `[]`, and `{}` have a truth value of `False`, whereas non-zero
@@ -406,7 +406,7 @@ else:
### Integers
-The Skylark integer type represents integers. Its [type](#type) is `"int"`.
+The Starlark integer type represents integers. Its [type](#type) is `"int"`.
Integers may be positive or negative, and arbitrarily large.
Integer arithmetic is exact.
@@ -447,20 +447,20 @@ int("ffff", 16) # 65535, 0xffff
```
<b>Implementation note:</b>
-In the Go implementation of Skylark, integer representation and
+In the Go implementation of Starlark, integer representation and
arithmetic is exact, motivated by the need for lossless manipulation
of protocol messages which may contain signed and unsigned 64-bit
integers.
The Java implementation currently supports only signed 32-bit integers.
-The Go implementation of the Skylark REPL requires the `-bitwise` flag to
+The Go implementation of the Starlark REPL requires the `-bitwise` flag to
enable support for `&`, `|`, `^`, `~`, `<<`, and `>>` operations.
The Java implementation does not support `^`, `~`, `<<`, and `>>` operations.
### Floating-point numbers
-The Skylark floating-point data type represents an IEEE 754
+The Starlark floating-point data type represents an IEEE 754
double-precision floating-point number. Its [type](#type) is `"float"`.
Arithmetic on floats using the `+`, `-`, `*`, `/`, `//`, and `%`
@@ -504,10 +504,10 @@ float(3) / 2 # 1.5
```
<b>Implementation note:</b>
-The Go implementation of Skylark supports floating-point numbers as an
+The Go implementation of Starlark supports floating-point numbers as an
optional feature, motivated by the need for lossless manipulation of
protocol messages.
-The Go implementation of the Skylark REPL requires the `-fp` flag to
+The Go implementation of the Starlark REPL requires the `-fp` flag to
enable support for floating-point literals, the `float` built-in
function, and the real division operator `/`.
The Java implementation does not yet support floating-point numbers.
@@ -593,7 +593,7 @@ intractible; see Google Issue b/36360490.
<b>Implementation note:</b>
The Java implementation does not consistently treat strings as
-iterable; see `testdata/string.sky` in the test suite and Google Issue
+iterable; see `testdata/string.star` in the test suite and Google Issue
b/34385336 for further details.
### Lists
@@ -675,7 +675,7 @@ Observe that for the 1-tuple, the trailing comma is necessary to
distinguish it from the parenthesized expression `(1)`.
1-tuples are seldom used.
-Skylark, unlike Python, does not permit a trailing comma to appear in
+Starlark, unlike Python, does not permit a trailing comma to appear in
an unparenthesized tuple expression:
```python
@@ -788,7 +788,7 @@ for name in coins:
print(name, coins[name]) # prints "quarter 25", "dime 10", ...
```
-Like all mutable values in Skylark, a dictionary can be frozen, and
+Like all mutable values in Starlark, a dictionary can be frozen, and
once frozen, all subsequent operations that attempt to update it will
fail.
@@ -853,7 +853,7 @@ The only method of a set is `union`, which is equivalent to the `|` operator.
A set used in a Boolean context is considered true if it is non-empty.
<b>Implementation note:</b>
-The Go implementation of the Skylark REPL requires the `-set` flag to
+The Go implementation of the Starlark REPL requires the `-set` flag to
enable support for sets and the `-bitwise` flag to enable support for
the `&`, `|`, and `^` operators.
The Java implementation does not support sets.
@@ -861,7 +861,7 @@ The Java implementation does not support sets.
### Functions
-A function value represents a function defined in Skylark.
+A function value represents a function defined in Starlark.
Its [type](#type) is `"function"`.
A function value used in a Boolean context is always considered true.
@@ -871,7 +871,7 @@ functions defined by a [`lambda` expression](#lambda-expressions) are anonymous.
Function definitions may be nested, and an inner function may refer to a local variable of an outer function.
A function definition defines zero or more named parameters.
-Skylark has a rich mechanism for passing arguments to functions.
+Starlark has a rich mechanism for passing arguments to functions.
<!-- TODO break up this explanation into caller-side and callee-side
parts, and put the former under function calls and the latter
@@ -930,7 +930,7 @@ If the function becomes frozen, its parameters' default values become
frozen too.
```python
-# module a.sky
+# module a.star
def f(x, list=[]):
list.append(x)
return list
@@ -939,8 +939,8 @@ f(4, [1,2,3]) # [1, 2, 3, 4]
f(1) # [1]
f(2) # [1, 2], not [2]!
-# module b.sky
-load("a.sky", "f")
+# module b.star
+load("a.star", "f")
f(3) # error: cannot append to frozen list
```
@@ -1035,11 +1035,11 @@ fib(5)
```
This rule, combined with the invariant that all loops are iterations
-over finite sequences, implies that Skylark programs are not Turing-complete.
+over finite sequences, implies that Starlark programs are not Turing-complete.
-<!-- This rule is supposed to deter people from abusing Skylark for
+<!-- This rule is supposed to deter people from abusing Starlark for
inappropriate uses, especially in the build system.
- It may work for that purpose, but it doesn't stop Skylark programs
+ It may work for that purpose, but it doesn't stop Starlark programs
from consuming too much time or space. Perhaps it should be a
dialect option.
-->
@@ -1054,7 +1054,7 @@ or the application into which the interpreter is embedded.
The [type](#type) of a built-in function is `"builtin_function_or_method"`.
<b>Implementation note:</b>
The Java implementation of `type(x)` returns `"function"` for all
-functions, whether built in or defined in Skylark,
+functions, whether built in or defined in Starlark,
even though applications distinguish these two types.
A built-in function value used in a Boolean context is always considered true.
@@ -1062,7 +1062,7 @@ A built-in function value used in a Boolean context is always considered true.
Many built-in functions are predeclared in the environment
(see [Name Resolution](#name-resolution)).
Some built-in functions such as `len` are _universal_, that is,
-available to all Skylark programs.
+available to all Starlark programs.
The host application may predeclare additional built-in functions
in the environment of a specific module.
@@ -1071,8 +1071,8 @@ The parameter names serve merely as documentation.
## Name binding and variables
-After a Skylark file is parsed, but before its execution begins, the
-Skylark interpreter checks statically that the program is well formed.
+After a Starlark file is parsed, but before its execution begins, the
+Starlark interpreter checks statically that the program is well formed.
For example, `break` and `continue` statements may appear only within
a loop; `if`, `for`, and `return` statements may appear only within a
function; and `load` statements may appear only outside any function.
@@ -1085,7 +1085,7 @@ called _bindings_. A name may denote different bindings at different
places in the program. The region of text in which a particular name
refers to the same binding is called that binding's _scope_.
-Four Skylark constructs bind names, as illustrated in the example below:
+Four Starlark constructs bind names, as illustrated in the example below:
`load` statements (`a` and `b`),
`def` statements (`c`),
function parameters (`d`),
@@ -1094,7 +1094,7 @@ Variables may be assigned or re-assigned explicitly (`e`, `h`), or implicitly, a
in a `for`-loop (`f`) or comprehension (`g`, `i`).
```python
-load("lib.sky", "a", b="B")
+load("lib.star", "a", b="B")
def c(d):
e = 0
@@ -1105,7 +1105,7 @@ def c(d):
h = [2*i for i in a]
```
-The environment of a Skylark program is structured as a tree of
+The environment of a Starlark program is structured as a tree of
_lexical blocks_, each of which may contain name bindings.
The tree of blocks is parallel to the syntax tree.
Blocks are of four kinds.
@@ -1120,7 +1120,7 @@ these functions are immutable and stateless.
An application may pre-declare additional names
to provide domain-specific functions to that file, for example.
These additional functions may have side effects on the application.
-Skylark programs cannot change the set of predeclared bindings
+Starlark programs cannot change the set of predeclared bindings
or assign new values to them.
Nested beneath the predeclared block is the _module_ block, which
@@ -1186,7 +1186,7 @@ x = 2 # static error: cannot reassign global x declared on lin
documentation more useful, the designers assure me, but
I am skeptical that it's worth the trouble. -->
-If a name was pre-bound by the application, the Skylark program may
+If a name was pre-bound by the application, the Starlark program may
explicitly bind it, but only once.
<b>Implementation note</b>:
@@ -1237,7 +1237,7 @@ def squarer():
sq = squarer()
```
-(Skylark has no equivalent of Python's `nonlocal` or `global`
+(Starlark has no equivalent of Python's `nonlocal` or `global`
declarations, but as the first version of `squarer` showed, this
omission can be worked around by using a list of a single element.)
@@ -1250,9 +1250,9 @@ on the value returned by `get_filename()`.
## Value concepts {#value-concepts}
-Skylark has eleven core [data types](#data-types). An application
-that embeds the Skylark intepreter may define additional types that
-behave like Skylark values. All values, whether core or
+Starlark has eleven core [data types](#data-types). An application
+that embeds the Starlark intepreter may define additional types that
+behave like Starlark values. All values, whether core or
application-defined, implement a few basic behaviors:
```text
@@ -1264,7 +1264,7 @@ hash(x) -- return a hash code for x
### Identity and mutation
-Skylark is an imperative language: programs consist of sequences of
+Starlark is an imperative language: programs consist of sequences of
statements executed for their side effects.
For example, an assignment statement updates the value held by a
variable, and calls to some built-in functions such as `print` change
@@ -1273,7 +1273,7 @@ the state of the application that embeds the interpreter.
Values of some data types, such as `NoneType`, `bool`, `int`, `float`, and
`string`, are _immutable_; they can never change.
Immutable values have no notion of _identity_: it is impossible for a
-Skylark program to tell whether two integers, for instance, are
+Starlark program to tell whether two integers, for instance, are
represented by the same object; it can tell only whether they are
equal.
@@ -1281,7 +1281,7 @@ Values of other data types, such as `list`, `dict`, and `set`, are
_mutable_: they may be modified by a statement such as `a[i] = 0` or
`items.clear()`. Although `tuple` and `function` values are not
directly mutable, they may refer to mutable values indirectly, so for
-this reason we consider them mutable too. Skylark values of these
+this reason we consider them mutable too. Starlark values of these
types are actually _references_ to variables.
Copying a reference to a variable, using an assignment statement for
@@ -1296,7 +1296,7 @@ x.append(1) # changes the variable referred to by x
print(y) # "[1]"; y observes the mutation
```
-Skylark uses _call-by-value_ parameter passing: in a function call,
+Starlark uses _call-by-value_ parameter passing: in a function call,
argument values are assigned to function parameters as if by
assignment statements. If the values are references, the caller and
callee may refer to the same variables, so if the called function
@@ -1319,14 +1319,14 @@ refer, is crucial to writing correct programs.
### Freezing a value
-Skylark has a feature unusual among imperative programming languages:
+Starlark has a feature unusual among imperative programming languages:
a mutable value may be _frozen_ so that all subsequent attempts to
mutate it fail with a dynamic error; the value, and all other values
reachable from it, become _immutable_.
-Immediately after execution of a Skylark module, all values in its
+Immediately after execution of a Starlark module, all values in its
top-level environment are frozen. Because all the global variables of
-an initialized Skylark module are immutable, the module may be published to
+an initialized Starlark module are immutable, the module may be published to
and used by other threads in a parallel program without the need for
locks. For example, the Bazel build system loads and executes BUILD
and .bzl files in parallel, and two modules being executed
@@ -1364,7 +1364,7 @@ so their hash values are derived from their identity.
### Sequence types
-Many Skylark data types represent a _sequence_ of values: lists,
+Many Starlark data types represent a _sequence_ of values: lists,
tuples, and sets are sequences of arbitrary values, and in many
contexts dictionaries act like a sequence of their keys.
@@ -1385,18 +1385,18 @@ the interpreter's Go API.
element at a given integer index. Example: `list`.
* `Mapping`: a mapping is an association of keys to values. Example: `dict`.
-Although all of Skylark's core data types for sequences implement at
+Although all of Starlark's core data types for sequences implement at
least the `Sequence` contract, it's possible for an application
-that embeds the Skylark interpreter to define additional data types
+that embeds the Starlark interpreter to define additional data types
representing sequences of unknown length that implement only the `Iterable` contract.
Strings are not iterable, though they do support the `len(s)` and
-`s[i]` operations. Skylark deviates from Python here to avoid common
+`s[i]` operations. Starlark deviates from Python here to avoid common
pitfall in which a string is used by mistake where a list containing a
single string was intended, resulting in its interpretation as a sequence
of bytes.
-Most Skylark operators and built-in functions that need a sequence
+Most Starlark operators and built-in functions that need a sequence
of values will accept any iterable.
It is a dynamic error to mutate a sequence such as a list, set, or
@@ -1414,13 +1414,13 @@ increment_values(dict)
### Indexing
-Many Skylark operators and functions require an index operand `i`,
+Many Starlark operators and functions require an index operand `i`,
such as `a[i]` or `list.insert(i, x)`. Others require two indices `i`
and `j` that indicate the start and end of a sub-sequence, such as
`a[i:j]`, `list.index(x, i, j)`, or `string.find(x, i, j)`.
All such operations follow similar conventions, described here.
-Indexing in Skylark is *zero-based*. The first element of a string
+Indexing in Starlark is *zero-based*. The first element of a string
or list has index 0, the next 1, and so on. The last element of a
sequence of length `n` has index `n-1`.
@@ -1483,13 +1483,13 @@ This truncation step does not apply to indices of individual elements:
An expression specifies the computation of a value.
-The Skylark grammar defines several categories of expression.
+The Starlark grammar defines several categories of expression.
An _operand_ is an expression consisting of a single token (such as an
identifier or a literal), or a bracketed expression.
Operands are self-delimiting.
An operand may be followed by any number of dot, call, or slice
suffixes, to form a _primary_ expression.
-In some places in the Skylark grammar where an expression is expected,
+In some places in the Starlark grammar where an expression is expected,
it is legal to provide a comma-separated list of expressions denoting
a tuple.
The grammar uses `Expression` where a multiple-component expression is allowed,
@@ -1536,7 +1536,7 @@ Lookup of locals and globals may fail if not yet defined.
### Literals
-Skylark supports string literals of three different kinds:
+Starlark supports string literals of three different kinds:
```grammar {.good}
Primary = int | float | string
@@ -1584,7 +1584,7 @@ for x in 1, 2:
print(x)
```
-Skylark (like Python 3) does not accept an unparenthesized tuple
+Starlark (like Python 3) does not accept an unparenthesized tuple
expression as the operand of a list comprehension:
```python
@@ -1697,12 +1697,12 @@ The bitwise inversion of x is defined as -(x+1).
```
<b>Implementation note:</b>
-The parser in the Java implementation of Skylark does not accept unary
+The parser in the Java implementation of Starlark does not accept unary
`+` and `~` expressions.
### Binary operators
-Skylark has the following binary operators, arranged in order of increasing precedence:
+Starlark has the following binary operators, arranged in order of increasing precedence:
```text
or
@@ -1744,7 +1744,7 @@ conjunction of their arguments, which need not be Booleans.
The expression `x or y` yields the value of `x` if its truth value is `True`,
or the value of `y` otherwise.
-```skylark
+```starlark
False or False # False
False or True # True
True or False # True
@@ -1757,7 +1757,7 @@ True or True # True
Similarly, `x and y` yields the value of `x` if its truth value is
`False`, or the value of `y` otherwise.
-```skylark
+```starlark
False and False # False
False and True # False
True and False # False
@@ -1930,7 +1930,7 @@ set([1, 2]) ^ set([2, 3]) # set([1, 3])
```
<b>Implementation note:</b>
-The Go implementation of the Skylark REPL requires the `-set` flag to
+The Go implementation of the Starlark REPL requires the `-set` flag to
enable support for sets.
The Java implementation does not support sets, nor recognize `&` as a
token, nor support `int | int`.
@@ -1992,7 +1992,7 @@ which must be a tuple with exactly one component per conversion,
unless the format string contains only a single conversion, in which
case `args` itself is its operand.
-Skylark does not support the flag, width, and padding specifiers
+Starlark does not support the flag, width, and padding specifiers
supported by Python's `%` and other variants of C's `printf`.
After the optional `(key)` comes a single letter indicating what
@@ -2113,7 +2113,7 @@ assignment:
[x*y+z for (x, y), z in [((2, 3), 5), (("o", 2), "!")]] # [11, 'oo!']
```
-Skylark, following Python 3, does not accept an unparenthesized
+Starlark, following Python 3, does not accept an unparenthesized
tuple or lambda expression as the operand of a `for` clause:
```python
@@ -2121,7 +2121,7 @@ tuple or lambda expression as the operand of a `for` clause:
[x*x for x in lambda: 0] # parse error: unexpected lambda
```
-Comprehensions in Skylark, again following Python 3, define a new lexical
+Comprehensions in Starlark, again following Python 3, define a new lexical
block, so assignments to loop variables have no effect on variables of
the same name in an enclosing block:
@@ -2170,8 +2170,8 @@ Argument = Test | identifier '=' Test | '*' Test | '**' Test .
A value `f` of type `function` or `builtin_function_or_method` may be called using the expression `f(...)`.
Applications may define additional types whose values may be called in the same way.
-A method call such as `filename.endswith(".sky")` is the composition
-of two operations, `m = filename.endswith` and `m(".sky")`.
+A method call such as `filename.endswith(".star")` is the composition
+of two operations, `m = filename.endswith` and `m(".star")`.
The first, a dot operation, yields a _bound method_, a function value
that pairs a receiver value (the `filename` string) with a choice of
method ([string·endswith](#string·endswith)).
@@ -2185,7 +2185,7 @@ See [Functions](#functions) for an explanation of function parameter passing.
A dot expression `x.f` selects the attribute `f` (a field or method)
of the value `x`.
-Fields are possessed by none of the main Skylark [data types](#data-types),
+Fields are possessed by none of the main Starlark [data types](#data-types),
but some application-defined types have them.
Methods belong to the built-in types `string`, `list`, `dict`, and
`set`, and to many application-defined types.
@@ -2260,7 +2260,7 @@ if the dictionary contains no such key.
An index expression appearing on the left side of an assignment causes
the specified list or dictionary element to be updated:
-```skylark
+```starlark
a = range(3) # a == [0, 1, 2]
a[2] = 7 # a == [0, 1, 7]
@@ -2315,7 +2315,7 @@ nearest value in the range -1 to `n`-1, inclusive.
"banana"[4::-2] # "nnb" (select alternate elements in reverse, starting at index 4)
```
-Unlike Python, Skylark does not allow a slice expression on the left
+Unlike Python, Starlark does not allow a slice expression on the left
side of an assignment.
Slicing a tuple or string may be more efficient than slicing a list
@@ -2374,7 +2374,7 @@ twice = lambda(x): x * 2
```
<b>Implementation note:</b>
-The Go implementation of the Skylark REPL requires the `-lambda` flag
+The Go implementation of the Starlark REPL requires the `-lambda` flag
to enable support for lambda expressions.
The Java implementation does not support them.
See Google Issue b/36358844.
@@ -2478,7 +2478,7 @@ a name, an index expression, or a dot expression.
```python
x -= 1
-x.filename += ".sky"
+x.filename += ".star"
a[index()] *= 2
```
@@ -2488,7 +2488,7 @@ The first two assignments above are thus equivalent to:
```python
x = x - 1
-x.filename = x.filename + ".sky"
+x.filename = x.filename + ".star"
```
and the third assignment is similar in effect to the following two
@@ -2560,7 +2560,7 @@ current module.
<!-- this is too implementation-oriented; it's not a spec. -->
<b>Implementation note:</b>
-The Go implementation of the Skylark REPL requires the `-nesteddef`
+The Go implementation of the Starlark REPL requires the `-nesteddef`
flag to enable support for nested `def` statements.
The Java implementation does not permit a `def` expression to be
nested within the body of another function.
@@ -2675,7 +2675,7 @@ for a, i in [["a", 1], ["b", 2], ["c", 3]]:
print(a, i) # prints "a 1", "b 2", "c 3"
```
-Because Skylark loops always iterate over a finite sequence, they are
+Because Starlark loops always iterate over a finite sequence, they are
guaranteed to terminate, unlike loops in most languages which can
execute an arbitrary and perhaps unbounded number of iterations.
@@ -2683,7 +2683,7 @@ Within the body of a `for` loop, `break` and `continue` statements may
be used to stop the execution of the loop or advance to the next
iteration.
-In Skylark, a `for` loop is permitted only within a function definition.
+In Starlark, a `for` loop is permitted only within a function definition.
A `for` loop at top level results in a static error.
@@ -2716,14 +2716,14 @@ loop.
### Load statements
-The `load` statement loads another Skylark module, extracts one or
+The `load` statement loads another Starlark module, extracts one or
more values from it, and binds them to names in the current module.
<!--
The awkwardness of load statements is a consequence of staying a
strict subset of Python syntax, which allows reuse of existing tools
such as editor support. Python import statements are inadequate for
-Skylark because they don't allow arbitrary file names for module names.
+Starlark because they don't allow arbitrary file names for module names.
-->
Syntactically, a load statement looks like a function call `load(...)`.
@@ -2735,11 +2735,11 @@ LoadStmt = 'load' '(' string {',' [identifier '='] string} [','] ')' .
A load statement requires at least two "arguments".
The first must be a literal string; it identifies the module to load.
Its interpretation is determined by the application into which the
-Skylark interpreter is embedded, and is not specified here.
+Starlark interpreter is embedded, and is not specified here.
During execution, the application determines what action to take for a
load statement.
-A typical implementation locates and executes a Skylark file,
+A typical implementation locates and executes a Starlark file,
populating a cache of files executed so far to avoid duplicate work,
to obtain a module, which is a mapping from global names to values.
@@ -2753,8 +2753,8 @@ The name (`y`) specifies the local name;
if no name is given, the local name matches the quoted name.
```python
-load("module.sky", "x", "y", "z") # assigns x, y, and z
-load("module.sky", "x", y2="y", "z") # assigns x, y2, and z
+load("module.star", "x", "y", "z") # assigns x, y, and z
+load("module.star", "x", y2="y", "z") # assigns x, y2, and z
```
A load statement within a function is a static error.
@@ -2762,10 +2762,10 @@ A load statement within a function is a static error.
## Module execution
-Each Skylark file defines a _module_, which is a mapping from the
+Each Starlark file defines a _module_, which is a mapping from the
names of global variables to their values.
-When a Skylark file is executed, whether directly by the application
-or indirectly through a `load` statement, a new Skylark thread is
+When a Starlark file is executed, whether directly by the application
+or indirectly through a `load` statement, a new Starlark thread is
created, and this thread executes all the top-level statements in the
file.
Because if-statements and for-loops cannot appear outside of a function,
@@ -2775,12 +2775,12 @@ If execution reaches the end of the file, module initialization is
successful.
At that point, the value of each of the module's global variables is
frozen, rendering subsequent mutation impossible.
-The module is then ready for use by another Skylark thread, such as
+The module is then ready for use by another Starlark thread, such as
one executing a load statement.
Such threads may access values or call functions defined in the loaded
module.
-A Skylark thread may carry state on behalf of the application into
+A Starlark thread may carry state on behalf of the application into
which it is embedded, and application-defined functions may behave
differently depending on this thread state.
Because module initialization always occurs in a new thread, thread
@@ -2789,25 +2789,25 @@ one.
The initialization behavior of a module is thus independent of
whichever module triggered its initialization.
-If a Skylark thread encounters an error, execution stops and the error
+If a Starlark thread encounters an error, execution stops and the error
is reported to the application, along with a backtrace showing the
stack of active function calls at the time of the error.
-If an error occurs during initialization of a Skylark module, any
+If an error occurs during initialization of a Starlark module, any
active `load` statements waiting for initialization of the module also
fail.
-Skylark provides no mechanism by which errors can be handled within
+Starlark provides no mechanism by which errors can be handled within
the language.
## Built-in constants and functions
-The outermost block of the Skylark environment is known as the "predeclared" block.
-It defines a number of fundamental values and functions needed by all Skylark programs,
+The outermost block of the Starlark environment is known as the "predeclared" block.
+It defines a number of fundamental values and functions needed by all Starlark programs,
such as `None`, `True`, `False`, and `len`, and possibly additional
application-specific names.
-These names are not reserved words so Skylark programs are free to
+These names are not reserved words so Starlark programs are free to
redefine them in a smaller block such as a function body or even at
the top level of a module. However, doing so may be confusing to the
reader. Nonetheless, this rule permits names to be added to the
@@ -2924,7 +2924,7 @@ With no arguments, `float()` returns `0.0`.
<b>Implementation note:</b>
Floating-point numbers are an optional feature.
-The Go implementation of the Skylark REPL requires the `-fp` flag to
+The Go implementation of the Starlark REPL requires the `-fp` flag to
enable support for floating-point literals, the `float` built-in
function, and the real division operator `/`.
The Java implementation does not yet support floating-point numbers.
@@ -3051,7 +3051,7 @@ print(1, "hi", x=3) # "1 hi x=3\n"
```
Typically the formatted string is printed to the standard error file,
-but the exact behavior is a property of the Skylark thread and is
+but the exact behavior is a property of the Starlark thread and is
determined by the host application.
### range
@@ -3132,7 +3132,7 @@ set([3, 1, 4, 1, 5, 9]) # set([3, 1, 4, 5, 9])
```
<b>Implementation note:</b>
-Sets are an optional feature of the Go implementation of Skylark.
+Sets are an optional feature of the Go implementation of Starlark.
### sorted
@@ -3543,7 +3543,7 @@ See also: `string·codepoints`.
`S.count(sub[, start[, end]])` returns the number of occcurences of
`sub` within the string S, or, if the optional substring indices
`start` and `end` are provided, within the designated substring of S.
-They are interpreted according to Skylark's [indexing conventions](#indexing).
+They are interpreted according to Starlark's [indexing conventions](#indexing).
```python
"hello, world!".count("o") # 2
@@ -3557,7 +3557,7 @@ They are interpreted according to Skylark's [indexing conventions](#indexing).
`S[start:end]` has the specified suffix.
```python
-"filename.sky".endswith(".sky") # True
+"filename.star".endswith(".star") # True
```
The `suffix` argument may be a tuple of strings, in which case the
@@ -3576,7 +3576,7 @@ occurrence of the substring `sub` within S.
If either or both of `start` or `end` are specified,
they specify a subrange of S to which the search should be restricted.
-They are interpreted according to Skylark's [indexing conventions](#indexing).
+They are interpreted according to Starlark's [indexing conventions](#indexing).
If no occurrence is found, `found` returns -1.
@@ -3936,7 +3936,7 @@ the final element does not necessarily end with a line terminator.
`S[start:end]` has the specified prefix.
```python
-"filename.sky".startswith("filename") # True
+"filename.star".startswith("filename") # True
```
The `prefix` argument may be a tuple of strings, in which case the
@@ -3980,7 +3980,7 @@ Letters are converted to uppercase at the start of words, lowercase elsewhere.
## Dialect differences
The list below summarizes features of the Go implementation that are
-known to differ from the Java implementation of Skylark used by Bazel.
+known to differ from the Java implementation of Starlark used by Bazel.
Some of these features may be controlled by global options to allow
applications to mimic the Bazel dialect more closely. Our goal is
eventually to eliminate all such differences on a case-by-case basis.
diff --git a/docs/index.html b/docs/index.html
index 4233f6f..6741763 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -2,7 +2,7 @@
<!-- This file will be served by GitHub pages. -->
<head>
<!-- This is a placeholder for the upcoming Starlark renaming. -->
- <meta name="go-import" content="go.starlark.net git https://github.com/google/skylark"></meta>
+ <meta name="go-import" content="go.starlark.net git https://github.com/google/starlark"></meta>
</head>
<body>
</body>
diff --git a/eval.go b/eval.go
index 368f86c..ff1bc7e 100644
--- a/eval.go
+++ b/eval.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package skylark
+package starlark
import (
"bytes"
@@ -16,21 +16,21 @@ import (
"unicode"
"unicode/utf8"
- "github.com/google/skylark/internal/compile"
- "github.com/google/skylark/resolve"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/internal/compile"
+ "github.com/google/starlark/resolve"
+ "github.com/google/starlark/syntax"
)
const debug = false
-// A Thread contains the state of a Skylark thread,
+// A Thread contains the state of a Starlark thread,
// such as its call stack and thread-local storage.
// The Thread is threaded throughout the evaluator.
type Thread struct {
- // frame is the current Skylark execution frame.
+ // frame is the current Starlark execution frame.
frame *Frame
- // Print is the client-supplied implementation of the Skylark
+ // Print is the client-supplied implementation of the Starlark
// 'print' function. If nil, fmt.Fprintln(os.Stderr, msg) is
// used instead.
Print func(thread *Thread, msg string)
@@ -44,7 +44,7 @@ type Thread struct {
Load func(thread *Thread, module string) (StringDict, error)
// locals holds arbitrary "thread-local" Go values belonging to the client.
- // They are accessible to the client but not to any Skylark program.
+ // They are accessible to the client but not to any Starlark program.
locals map[string]interface{}
}
@@ -63,7 +63,7 @@ func (thread *Thread) Local(key string) interface{} {
}
// Caller returns the frame of the caller of the current function.
-// It should only be used in built-ins called from Skylark code.
+// It should only be used in built-ins called from Starlark code.
func (thread *Thread) Caller() *Frame { return thread.frame.parent }
// TopFrame returns the topmost stack frame.
@@ -71,7 +71,7 @@ func (thread *Thread) TopFrame() *Frame { return thread.frame }
// A StringDict is a mapping from names to values, and represents
// an environment such as the global variables of a module.
-// It is not a true skylark.Value.
+// It is not a true starlark.Value.
type StringDict map[string]Value
func (d StringDict) String() string {
@@ -105,7 +105,7 @@ func (d StringDict) Freeze() {
// Has reports whether the dictionary contains the specified key.
func (d StringDict) Has(key string) bool { _, ok := d[key]; return ok }
-// A Frame records a call to a Skylark function (including module toplevel)
+// A Frame records a call to a Starlark function (including module toplevel)
// or a built-in function or method.
type Frame struct {
parent *Frame // caller's frame (or nil)
@@ -143,7 +143,7 @@ func (fr *Frame) Callable() Callable { return fr.callable }
// Parent returns the frame of the enclosing function call, if any.
func (fr *Frame) Parent() *Frame { return fr.parent }
-// An EvalError is a Skylark evaluation error and its associated call stack.
+// An EvalError is a Starlark evaluation error and its associated call stack.
type EvalError struct {
Msg string
Frame *Frame
@@ -182,7 +182,7 @@ func (e *EvalError) Stack() []*Frame {
return stack
}
-// A Program is a compiled Skylark program.
+// A Program is a compiled Starlark program.
//
// Programs are immutable, and contain no Values.
// A Program may be created by parsing a source file (see SourceProgram)
@@ -211,10 +211,10 @@ func (prog *Program) Load(i int) (string, syntax.Position) {
// WriteTo writes the compiled module to the specified output stream.
func (prog *Program) Write(out io.Writer) error { return prog.compiled.Write(out) }
-// ExecFile parses, resolves, and executes a Skylark file in the
+// ExecFile parses, resolves, and executes a Starlark file in the
// specified global environment, which may be modified during execution.
//
-// Thread is the state associated with the Skylark thread.
+// Thread is the state associated with the Starlark thread.
//
// The filename and src parameters are as for syntax.Parse:
// filename is the name of the file to execute,
@@ -229,7 +229,7 @@ func (prog *Program) Write(out io.Writer) error { return prog.compiled.Write(out
// If ExecFile fails during evaluation, it returns an *EvalError
// containing a backtrace.
func ExecFile(thread *Thread, filename string, src interface{}, predeclared StringDict) (StringDict, error) {
- // Parse, resolve, and compile a Skylark source file.
+ // Parse, resolve, and compile a Starlark source file.
_, mod, err := SourceProgram(filename, src, predeclared.Has)
if err != nil {
return nil, err
@@ -241,7 +241,7 @@ func ExecFile(thread *Thread, filename string, src interface{}, predeclared Stri
}
// SourceProgram produces a new program by parsing, resolving,
-// and compiling a Skylark source file.
+// and compiling a Starlark source file.
// On success, it returns the parsed file and the compiled program.
// The filename and src parameters are as for syntax.Parse.
//
@@ -288,7 +288,7 @@ func (prog *Program) Init(thread *Thread, predeclared StringDict) (StringDict, e
}
func makeToplevelFunction(funcode *compile.Funcode, predeclared StringDict) *Function {
- // Create the Skylark value denoted by each program constant c.
+ // Create the Starlark value denoted by each program constant c.
constants := make([]Value, len(funcode.Prog.Constants))
for i, c := range funcode.Prog.Constants {
var v Value
@@ -502,7 +502,7 @@ func Binary(op syntax.Token, x, y Value) (Value, error) {
}
case *Dict:
// Python doesn't have dict+dict, and I can't find
- // it documented for Skylark. But it is used; see:
+ // it documented for Starlark. But it is used; see:
// tools/build_defs/haskell/def.bzl:448
// TODO(adonovan): clarify spec; see b/36360157.
if y, ok := y.(*Dict); ok {
@@ -857,7 +857,7 @@ func Call(thread *Thread, fn Value, args Tuple, kwargs []Tuple) (Value, error) {
result, err := c.CallInternal(thread, args, kwargs)
thread.frame = thread.frame.parent
- // Sanity check: nil is not a valid Skylark value.
+ // Sanity check: nil is not a valid Starlark value.
if result == nil && err == nil {
return nil, fmt.Errorf("internal error: nil (not None) returned from %s", fn)
}
@@ -1138,7 +1138,7 @@ func (is *intset) len() int {
return len(is.large)
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string-interpolation
+// https://github.com/google/starlark/blob/master/doc/spec.md#string-interpolation
func interpolate(format string, x Value) (Value, error) {
var buf bytes.Buffer
path := make([]Value, 0, 4)
@@ -1189,7 +1189,7 @@ func interpolate(format string, x Value) (Value, error) {
}
}
- // NOTE: Skylark does not support any of these optional Python features:
+ // NOTE: Starlark does not support any of these optional Python features:
// - optional conversion flags: [#0- +], etc.
// - optional minimum field width (number or *).
// - optional precision (.123 or *)
diff --git a/eval_test.go b/eval_test.go
index c026abb..04dc41f 100644
--- a/eval_test.go
+++ b/eval_test.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package skylark_test
+package starlark_test
import (
"bytes"
@@ -12,11 +12,11 @@ import (
"strings"
"testing"
- "github.com/google/skylark"
- "github.com/google/skylark/internal/chunkedfile"
- "github.com/google/skylark/resolve"
- "github.com/google/skylark/skylarktest"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark"
+ "github.com/google/starlark/internal/chunkedfile"
+ "github.com/google/starlark/resolve"
+ "github.com/google/starlark/starlarktest"
+ "github.com/google/starlark/syntax"
)
func init() {
@@ -29,10 +29,10 @@ func init() {
}
func TestEvalExpr(t *testing.T) {
- // This is mostly redundant with the new *.sky tests.
- // TODO(adonovan): move checks into *.sky files and
- // reduce this to a mere unit test of skylark.Eval.
- thread := new(skylark.Thread)
+ // This is mostly redundant with the new *.star tests.
+ // TODO(adonovan): move checks into *.star files and
+ // reduce this to a mere unit test of starlark.Eval.
+ thread := new(starlark.Thread)
for _, test := range []struct{ src, want string }{
{`123`, `123`},
{`-1`, `-1`},
@@ -81,7 +81,7 @@ func TestEvalExpr(t *testing.T) {
{`[x for x in range(3)]`, "[0, 1, 2]"},
} {
var got string
- if v, err := skylark.Eval(thread, "<expr>", test.src, nil); err != nil {
+ if v, err := starlark.Eval(thread, "<expr>", test.src, nil); err != nil {
got = err.Error()
} else {
got = v.String()
@@ -93,33 +93,33 @@ func TestEvalExpr(t *testing.T) {
}
func TestExecFile(t *testing.T) {
- testdata := skylarktest.DataFile("skylark", ".")
- thread := &skylark.Thread{Load: load}
- skylarktest.SetReporter(thread, t)
+ testdata := starlarktest.DataFile("starlark", ".")
+ thread := &starlark.Thread{Load: load}
+ starlarktest.SetReporter(thread, t)
for _, file := range []string{
- "testdata/assign.sky",
- "testdata/bool.sky",
- "testdata/builtins.sky",
- "testdata/control.sky",
- "testdata/dict.sky",
- "testdata/float.sky",
- "testdata/function.sky",
- "testdata/int.sky",
- "testdata/list.sky",
- "testdata/misc.sky",
- "testdata/set.sky",
- "testdata/string.sky",
- "testdata/tuple.sky",
+ "testdata/assign.star",
+ "testdata/bool.star",
+ "testdata/builtins.star",
+ "testdata/control.star",
+ "testdata/dict.star",
+ "testdata/float.star",
+ "testdata/function.star",
+ "testdata/int.star",
+ "testdata/list.star",
+ "testdata/misc.star",
+ "testdata/set.star",
+ "testdata/string.star",
+ "testdata/tuple.star",
} {
filename := filepath.Join(testdata, file)
for _, chunk := range chunkedfile.Read(filename, t) {
- predeclared := skylark.StringDict{
- "hasfields": skylark.NewBuiltin("hasfields", newHasFields),
+ predeclared := starlark.StringDict{
+ "hasfields": starlark.NewBuiltin("hasfields", newHasFields),
"fibonacci": fib{},
}
- _, err := skylark.ExecFile(thread, filename, chunk.Source, predeclared)
+ _, err := starlark.ExecFile(thread, filename, chunk.Source, predeclared)
switch err := err.(type) {
- case *skylark.EvalError:
+ case *starlark.EvalError:
found := false
for _, fr := range err.Stack() {
posn := fr.Position()
@@ -148,32 +148,32 @@ type fib struct{}
func (t fib) Freeze() {}
func (t fib) String() string { return "fib" }
func (t fib) Type() string { return "fib" }
-func (t fib) Truth() skylark.Bool { return true }
+func (t fib) Truth() starlark.Bool { return true }
func (t fib) Hash() (uint32, error) { return 0, fmt.Errorf("fib is unhashable") }
-func (t fib) Iterate() skylark.Iterator { return &fibIterator{0, 1} }
+func (t fib) Iterate() starlark.Iterator { return &fibIterator{0, 1} }
type fibIterator struct{ x, y int }
-func (it *fibIterator) Next(p *skylark.Value) bool {
- *p = skylark.MakeInt(it.x)
+func (it *fibIterator) Next(p *starlark.Value) bool {
+ *p = starlark.MakeInt(it.x)
it.x, it.y = it.y, it.x+it.y
return true
}
func (it *fibIterator) Done() {}
// load implements the 'load' operation as used in the evaluator tests.
-func load(thread *skylark.Thread, module string) (skylark.StringDict, error) {
- if module == "assert.sky" {
- return skylarktest.LoadAssertModule()
+func load(thread *starlark.Thread, module string) (starlark.StringDict, error) {
+ if module == "assert.star" {
+ return starlarktest.LoadAssertModule()
}
// TODO(adonovan): test load() using this execution path.
filename := filepath.Join(filepath.Dir(thread.Caller().Position().Filename()), module)
- return skylark.ExecFile(thread, filename, nil, nil)
+ return starlark.ExecFile(thread, filename, nil, nil)
}
-func newHasFields(thread *skylark.Thread, _ *skylark.Builtin, args skylark.Tuple, kwargs []skylark.Tuple) (skylark.Value, error) {
- return &hasfields{attrs: make(map[string]skylark.Value)}, nil
+func newHasFields(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
+ return &hasfields{attrs: make(map[string]starlark.Value)}, nil
}
// hasfields is a test-only implementation of HasAttrs.
@@ -181,18 +181,18 @@ func newHasFields(thread *skylark.Thread, _ *skylark.Builtin, args skylark.Tuple
// Clients will likely want to provide their own implementation,
// so we don't have any public implementation.
type hasfields struct {
- attrs skylark.StringDict
+ attrs starlark.StringDict
frozen bool
}
var (
- _ skylark.HasAttrs = (*hasfields)(nil)
- _ skylark.HasBinary = (*hasfields)(nil)
+ _ starlark.HasAttrs = (*hasfields)(nil)
+ _ starlark.HasBinary = (*hasfields)(nil)
)
func (hf *hasfields) String() string { return "hasfields" }
func (hf *hasfields) Type() string { return "hasfields" }
-func (hf *hasfields) Truth() skylark.Bool { return true }
+func (hf *hasfields) Truth() starlark.Bool { return true }
func (hf *hasfields) Hash() (uint32, error) { return 42, nil }
func (hf *hasfields) Freeze() {
@@ -204,9 +204,9 @@ func (hf *hasfields) Freeze() {
}
}
-func (hf *hasfields) Attr(name string) (skylark.Value, error) { return hf.attrs[name], nil }
+func (hf *hasfields) Attr(name string) (starlark.Value, error) { return hf.attrs[name], nil }
-func (hf *hasfields) SetField(name string, val skylark.Value) error {
+func (hf *hasfields) SetField(name string, val starlark.Value) error {
if hf.frozen {
return fmt.Errorf("cannot set field on a frozen hasfields")
}
@@ -222,12 +222,12 @@ func (hf *hasfields) AttrNames() []string {
return names
}
-func (hf *hasfields) Binary(op syntax.Token, y skylark.Value, side skylark.Side) (skylark.Value, error) {
+func (hf *hasfields) Binary(op syntax.Token, y starlark.Value, side starlark.Side) (starlark.Value, error) {
// This method exists so we can exercise 'list += x'
// where x is not Iterable but defines list+x.
if op == syntax.PLUS {
- if _, ok := y.(*skylark.List); ok {
- return skylark.MakeInt(42), nil // list+hasfields is 42
+ if _, ok := y.(*starlark.List); ok {
+ return starlark.MakeInt(42), nil // list+hasfields is 42
}
}
return nil, nil
@@ -250,8 +250,8 @@ def f(a, b=42, *args, **kwargs):
return a, b, args, kwargs
`
- thread := new(skylark.Thread)
- globals, err := skylark.ExecFile(thread, filename, src, nil)
+ thread := new(starlark.Thread)
+ globals, err := starlark.ExecFile(thread, filename, src, nil)
if err != nil {
t.Fatal(err)
}
@@ -298,11 +298,11 @@ def f(a, b=42, *args, **kwargs):
{`f(0, b=1)`, `(0, 1, (), {})`},
{`f(0, a=1)`, `function f got multiple values for keyword argument "a"`},
{`f(0, b=1, c=2)`, `(0, 1, (), {"c": 2})`},
- {`f(0, 1, x=2, *[3, 4], y=5, **dict(z=6))`, // github.com/google/skylark/issues/135
+ {`f(0, 1, x=2, *[3, 4], y=5, **dict(z=6))`, // github.com/google/starlark/issues/135
`(0, 1, (3, 4), {"x": 2, "y": 5, "z": 6})`},
} {
var got string
- if v, err := skylark.Eval(thread, "<expr>", test.src, globals); err != nil {
+ if v, err := starlark.Eval(thread, "<expr>", test.src, globals); err != nil {
got = err.Error()
} else {
got = v.String()
@@ -313,7 +313,7 @@ def f(a, b=42, *args, **kwargs):
}
}
-// TestPrint ensures that the Skylark print function calls
+// TestPrint ensures that the Starlark print function calls
// Thread.Print, if provided.
func TestPrint(t *testing.T) {
const src = `
@@ -322,13 +322,13 @@ def f(): print("world")
f()
`
buf := new(bytes.Buffer)
- print := func(thread *skylark.Thread, msg string) {
+ print := func(thread *starlark.Thread, msg string) {
caller := thread.Caller()
fmt.Fprintf(buf, "%s: %s: %s\n",
caller.Position(), caller.Callable().Name(), msg)
}
- thread := &skylark.Thread{Print: print}
- if _, err := skylark.ExecFile(thread, "foo.go", src, nil); err != nil {
+ thread := &starlark.Thread{Print: print}
+ if _, err := starlark.ExecFile(thread, "foo.go", src, nil); err != nil {
t.Fatal(err)
}
want := "foo.go:2: <toplevel>: hello\n" +
@@ -339,26 +339,26 @@ f()
}
func Benchmark(b *testing.B) {
- testdata := skylarktest.DataFile("skylark", ".")
- thread := new(skylark.Thread)
+ testdata := starlarktest.DataFile("starlark", ".")
+ thread := new(starlark.Thread)
for _, file := range []string{
- "testdata/benchmark.sky",
+ "testdata/benchmark.star",
// ...
} {
filename := filepath.Join(testdata, file)
// Evaluate the file once.
- globals, err := skylark.ExecFile(thread, filename, nil, nil)
+ globals, err := starlark.ExecFile(thread, filename, nil, nil)
if err != nil {
reportEvalError(b, err)
}
// Repeatedly call each global function named bench_* as a benchmark.
for name, value := range globals {
- if fn, ok := value.(*skylark.Function); ok && strings.HasPrefix(name, "bench_") {
+ if fn, ok := value.(*starlark.Function); ok && strings.HasPrefix(name, "bench_") {
b.Run(name, func(b *testing.B) {
for i := 0; i < b.N; i++ {
- _, err := skylark.Call(thread, fn, nil, nil)
+ _, err := starlark.Call(thread, fn, nil, nil)
if err != nil {
reportEvalError(b, err)
}
@@ -370,7 +370,7 @@ func Benchmark(b *testing.B) {
}
func reportEvalError(tb testing.TB, err error) {
- if err, ok := err.(*skylark.EvalError); ok {
+ if err, ok := err.(*starlark.EvalError); ok {
tb.Fatal(err.Backtrace())
}
tb.Fatal(err)
@@ -379,21 +379,21 @@ func reportEvalError(tb testing.TB, err error) {
// TestInt exercises the Int.Int64 and Int.Uint64 methods.
// If we can move their logic into math/big, delete this test.
func TestInt(t *testing.T) {
- one := skylark.MakeInt(1)
+ one := starlark.MakeInt(1)
for _, test := range []struct {
- i skylark.Int
+ i starlark.Int
wantInt64 string
wantUint64 string
}{
- {skylark.MakeInt64(math.MinInt64).Sub(one), "error", "error"},
- {skylark.MakeInt64(math.MinInt64), "-9223372036854775808", "error"},
- {skylark.MakeInt64(-1), "-1", "error"},
- {skylark.MakeInt64(0), "0", "0"},
- {skylark.MakeInt64(1), "1", "1"},
- {skylark.MakeInt64(math.MaxInt64), "9223372036854775807", "9223372036854775807"},
- {skylark.MakeUint64(math.MaxUint64), "error", "18446744073709551615"},
- {skylark.MakeUint64(math.MaxUint64).Add(one), "error", "error"},
+ {starlark.MakeInt64(math.MinInt64).Sub(one), "error", "error"},
+ {starlark.MakeInt64(math.MinInt64), "-9223372036854775808", "error"},
+ {starlark.MakeInt64(-1), "-1", "error"},
+ {starlark.MakeInt64(0), "0", "0"},
+ {starlark.MakeInt64(1), "1", "1"},
+ {starlark.MakeInt64(math.MaxInt64), "9223372036854775807", "9223372036854775807"},
+ {starlark.MakeUint64(math.MaxUint64), "error", "18446744073709551615"},
+ {starlark.MakeUint64(math.MaxUint64).Add(one), "error", "error"},
} {
gotInt64, gotUint64 := "error", "error"
if i, ok := test.i.Int64(); ok {
@@ -412,7 +412,7 @@ func TestInt(t *testing.T) {
}
func TestBacktrace(t *testing.T) {
- // This test ensures continuity of the stack of active Skylark
+ // This test ensures continuity of the stack of active Starlark
// functions, including propagation through built-ins such as 'min'
// (though min does not itself appear in the stack).
const src = `
@@ -422,19 +422,19 @@ def h(): return min([1, 2, 0], key=g)
def i(): return h()
i()
`
- thread := new(skylark.Thread)
- _, err := skylark.ExecFile(thread, "crash.sky", src, nil)
+ thread := new(starlark.Thread)
+ _, err := starlark.ExecFile(thread, "crash.star", src, nil)
switch err := err.(type) {
- case *skylark.EvalError:
+ case *starlark.EvalError:
got := err.Backtrace()
// Compiled code currently has no column information.
const want = `Traceback (most recent call last):
- crash.sky:6: in <toplevel>
- crash.sky:5: in i
- crash.sky:4: in h
+ crash.star:6: in <toplevel>
+ crash.star:5: in i
+ crash.star:4: in h
<builtin>:1: in min
- crash.sky:3: in g
- crash.sky:2: in f
+ crash.star:3: in g
+ crash.star:2: in f
Error: floored division by zero`
if got != want {
t.Errorf("error was %s, want %s", got, want)
@@ -449,24 +449,24 @@ Error: floored division by zero`
// TestRepeatedExec parses and resolves a file syntax tree once then
// executes it repeatedly with different values of its predeclared variables.
func TestRepeatedExec(t *testing.T) {
- predeclared := skylark.StringDict{"x": skylark.None}
- _, prog, err := skylark.SourceProgram("repeat.sky", "y = 2 * x", predeclared.Has)
+ predeclared := starlark.StringDict{"x": starlark.None}
+ _, prog, err := starlark.SourceProgram("repeat.star", "y = 2 * x", predeclared.Has)
if err != nil {
t.Fatal(err)
}
for _, test := range []struct {
- x, want skylark.Value
+ x, want starlark.Value
}{
- {x: skylark.MakeInt(42), want: skylark.MakeInt(84)},
- {x: skylark.String("mur"), want: skylark.String("murmur")},
- {x: skylark.Tuple{skylark.None}, want: skylark.Tuple{skylark.None, skylark.None}},
+ {x: starlark.MakeInt(42), want: starlark.MakeInt(84)},
+ {x: starlark.String("mur"), want: starlark.String("murmur")},
+ {x: starlark.Tuple{starlark.None}, want: starlark.Tuple{starlark.None, starlark.None}},
} {
predeclared["x"] = test.x // update the values in dictionary
- thread := new(skylark.Thread)
+ thread := new(starlark.Thread)
if globals, err := prog.Init(thread, predeclared); err != nil {
t.Errorf("x=%v: %v", test.x, err) // exec error
- } else if eq, err := skylark.Equal(globals["y"], test.want); err != nil {
+ } else if eq, err := starlark.Equal(globals["y"], test.want); err != nil {
t.Errorf("x=%v: %v", test.x, err) // comparison error
} else if !eq {
t.Errorf("x=%v: got y=%v, want %v", test.x, globals["y"], test.want)
@@ -475,12 +475,12 @@ func TestRepeatedExec(t *testing.T) {
}
// TestUnpackUserDefined tests that user-defined
-// implementations of skylark.Value may be unpacked.
+// implementations of starlark.Value may be unpacked.
func TestUnpackUserDefined(t *testing.T) {
// success
want := new(hasfields)
var x *hasfields
- if err := skylark.UnpackArgs("unpack", skylark.Tuple{want}, nil, "x", &x); err != nil {
+ if err := starlark.UnpackArgs("unpack", starlark.Tuple{want}, nil, "x", &x); err != nil {
t.Errorf("UnpackArgs failed: %v", err)
}
if x != want {
@@ -488,7 +488,7 @@ func TestUnpackUserDefined(t *testing.T) {
}
// failure
- err := skylark.UnpackArgs("unpack", skylark.Tuple{skylark.MakeInt(42)}, nil, "x", &x)
+ err := starlark.UnpackArgs("unpack", starlark.Tuple{starlark.MakeInt(42)}, nil, "x", &x)
if want := "unpack: for parameter 1: got int, want hasfields"; fmt.Sprint(err) != want {
t.Errorf("unpack args error = %q, want %q", err, want)
}
diff --git a/example_test.go b/example_test.go
index 1879fa8..81edcfc 100644
--- a/example_test.go
+++ b/example_test.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package skylark_test
+package starlark_test
import (
"fmt"
@@ -13,11 +13,11 @@ import (
"sync/atomic"
"unsafe"
- "github.com/google/skylark"
+ "github.com/google/starlark"
)
// ExampleExecFile demonstrates a simple embedding
-// of the Skylark interpreter into a Go program.
+// of the Starlark interpreter into a Go program.
func ExampleExecFile() {
const data = `
print(greeting + ", world")
@@ -25,15 +25,15 @@ print(greeting + ", world")
squares = [x*x for x in range(10)]
`
- thread := &skylark.Thread{
- Print: func(_ *skylark.Thread, msg string) { fmt.Println(msg) },
+ thread := &starlark.Thread{
+ Print: func(_ *starlark.Thread, msg string) { fmt.Println(msg) },
}
- predeclared := skylark.StringDict{
- "greeting": skylark.String("hello"),
+ predeclared := starlark.StringDict{
+ "greeting": starlark.String("hello"),
}
- globals, err := skylark.ExecFile(thread, "apparent/filename.sky", data, predeclared)
+ globals, err := starlark.ExecFile(thread, "apparent/filename.star", data, predeclared)
if err != nil {
- if evalErr, ok := err.(*skylark.EvalError); ok {
+ if evalErr, ok := err.(*starlark.EvalError); ok {
log.Fatal(evalErr.Backtrace())
}
log.Fatal(err)
@@ -62,20 +62,20 @@ squares = [x*x for x in range(10)]
// implementation of 'load' that works sequentially.
func ExampleThread_Load_sequential() {
fakeFilesystem := map[string]string{
- "c.sky": `load("b.sky", "b"); c = b + "!"`,
- "b.sky": `load("a.sky", "a"); b = a + ", world"`,
- "a.sky": `a = "Hello"`,
+ "c.star": `load("b.star", "b"); c = b + "!"`,
+ "b.star": `load("a.star", "a"); b = a + ", world"`,
+ "a.star": `a = "Hello"`,
}
type entry struct {
- globals skylark.StringDict
+ globals starlark.StringDict
err error
}
cache := make(map[string]*entry)
- var load func(_ *skylark.Thread, module string) (skylark.StringDict, error)
- load = func(_ *skylark.Thread, module string) (skylark.StringDict, error) {
+ var load func(_ *starlark.Thread, module string) (starlark.StringDict, error)
+ load = func(_ *starlark.Thread, module string) (starlark.StringDict, error) {
e, ok := cache[module]
if e == nil {
if ok {
@@ -88,8 +88,8 @@ func ExampleThread_Load_sequential() {
// Load and initialize the module in a new thread.
data := fakeFilesystem[module]
- thread := &skylark.Thread{Load: load}
- globals, err := skylark.ExecFile(thread, module, data, nil)
+ thread := &starlark.Thread{Load: load}
+ globals, err := starlark.ExecFile(thread, module, data, nil)
e = &entry{globals, err}
// Update the cache.
@@ -98,8 +98,8 @@ func ExampleThread_Load_sequential() {
return e.globals, e.err
}
- thread := &skylark.Thread{Load: load}
- globals, err := load(thread, "c.sky")
+ thread := &starlark.Thread{Load: load}
+ globals, err := load(thread, "c.star")
if err != nil {
log.Fatal(err)
}
@@ -115,9 +115,9 @@ func ExampleThread_Load_parallel() {
cache := &cache{
cache: make(map[string]*entry),
fakeFilesystem: map[string]string{
- "c.sky": `load("a.sky", "a"); c = a * 2`,
- "b.sky": `load("a.sky", "a"); b = a * 3`,
- "a.sky": `a = 1; print("loaded a")`,
+ "c.star": `load("a.star", "a"); c = a * 2`,
+ "b.star": `load("a.star", "a"); b = a * 3`,
+ "a.star": `a = 1; print("loaded a")`,
},
}
@@ -129,7 +129,7 @@ func ExampleThread_Load_parallel() {
ch := make(chan string)
for _, name := range []string{"b", "c"} {
go func(name string) {
- globals, err := cache.Load(name + ".sky")
+ globals, err := cache.Load(name + ".star")
if err != nil {
log.Fatal(err)
}
@@ -152,9 +152,9 @@ func ExampleThread_Load_parallelCycle() {
cache := &cache{
cache: make(map[string]*entry),
fakeFilesystem: map[string]string{
- "c.sky": `load("b.sky", "b"); c = b * 2`,
- "b.sky": `load("a.sky", "a"); b = a * 3`,
- "a.sky": `load("c.sky", "c"); a = c * 5; print("loaded a")`,
+ "c.star": `load("b.star", "b"); c = b * 2`,
+ "b.star": `load("a.star", "a"); b = a * 3`,
+ "a.star": `load("c.star", "c"); a = c * 5; print("loaded a")`,
},
}
@@ -162,9 +162,9 @@ func ExampleThread_Load_parallelCycle() {
for _, name := range "bc" {
name := string(name)
go func() {
- _, err := cache.Load(name + ".sky")
+ _, err := cache.Load(name + ".star")
if err == nil {
- log.Fatalf("Load of %s.sky succeeded unexpectedly", name)
+ log.Fatalf("Load of %s.star succeeded unexpectedly", name)
}
ch <- err.Error()
}()
@@ -174,8 +174,8 @@ func ExampleThread_Load_parallelCycle() {
fmt.Println(strings.Join(got, "\n"))
// Output:
- // cannot load a.sky: cannot load c.sky: cycle in load graph
- // cannot load b.sky: cannot load a.sky: cannot load c.sky: cycle in load graph
+ // cannot load a.star: cannot load c.star: cycle in load graph
+ // cannot load b.star: cannot load a.star: cannot load c.star: cycle in load graph
}
// cache is a concurrency-safe, duplicate-suppressing,
@@ -191,17 +191,17 @@ type cache struct {
type entry struct {
owner unsafe.Pointer // a *cycleChecker; see cycleCheck
- globals skylark.StringDict
+ globals starlark.StringDict
err error
ready chan struct{}
}
-func (c *cache) Load(module string) (skylark.StringDict, error) {
+func (c *cache) Load(module string) (starlark.StringDict, error) {
return c.get(new(cycleChecker), module)
}
// get loads and returns an entry (if not already loaded).
-func (c *cache) get(cc *cycleChecker, module string) (skylark.StringDict, error) {
+func (c *cache) get(cc *cycleChecker, module string) (starlark.StringDict, error) {
c.cacheMu.Lock()
e := c.cache[module]
if e != nil {
@@ -233,16 +233,16 @@ func (c *cache) get(cc *cycleChecker, module string) (skylark.StringDict, error)
return e.globals, e.err
}
-func (c *cache) doLoad(cc *cycleChecker, module string) (skylark.StringDict, error) {
- thread := &skylark.Thread{
- Print: func(_ *skylark.Thread, msg string) { fmt.Println(msg) },
- Load: func(_ *skylark.Thread, module string) (skylark.StringDict, error) {
+func (c *cache) doLoad(cc *cycleChecker, module string) (starlark.StringDict, error) {
+ thread := &starlark.Thread{
+ Print: func(_ *starlark.Thread, msg string) { fmt.Println(msg) },
+ Load: func(_ *starlark.Thread, module string) (starlark.StringDict, error) {
// Tunnel the cycle-checker state for this "thread of loading".
return c.get(cc, module)
},
}
data := c.fakeFilesystem[module]
- return skylark.ExecFile(thread, module, data, nil)
+ return starlark.ExecFile(thread, module, data, nil)
}
// -- concurrent cycle checking --
diff --git a/hashtable.go b/hashtable.go
index 531dba9..f63f5c5 100644
--- a/hashtable.go
+++ b/hashtable.go
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package skylark
+package starlark
import (
"fmt"
_ "unsafe" // for go:linkname hack
)
-// hashtable is used to represent Skylark dict and set values.
+// hashtable is used to represent Starlark dict and set values.
// It is a hash table whose key/value entries form a doubly-linked list
// in the order the entries were inserted.
type hashtable struct {
diff --git a/hashtable_test.go b/hashtable_test.go
index 8894af6..96782bc 100644
--- a/hashtable_test.go
+++ b/hashtable_test.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package skylark
+package starlark
import (
"fmt"
diff --git a/int.go b/int.go
index 8987cf2..c5ebacd 100644
--- a/int.go
+++ b/int.go
@@ -2,23 +2,23 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package skylark
+package starlark
import (
"fmt"
"math"
"math/big"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/syntax"
)
-// Int is the type of a Skylark int.
+// Int is the type of a Starlark int.
type Int struct{ bigint *big.Int }
-// MakeInt returns a Skylark int for the specified signed integer.
+// MakeInt returns a Starlark int for the specified signed integer.
func MakeInt(x int) Int { return MakeInt64(int64(x)) }
-// MakeInt64 returns a Skylark int for the specified int64.
+// MakeInt64 returns a Starlark int for the specified int64.
func MakeInt64(x int64) Int {
if 0 <= x && x < int64(len(smallint)) {
if !smallintok {
@@ -29,10 +29,10 @@ func MakeInt64(x int64) Int {
return Int{new(big.Int).SetInt64(x)}
}
-// MakeUint returns a Skylark int for the specified unsigned integer.
+// MakeUint returns a Starlark int for the specified unsigned integer.
func MakeUint(x uint) Int { return MakeUint64(uint64(x)) }
-// MakeUint64 returns a Skylark int for the specified uint64.
+// MakeUint64 returns a Starlark int for the specified uint64.
func MakeUint64(x uint64) Int {
if x < uint64(len(smallint)) {
if !smallintok {
diff --git a/internal/compile/codegen_test.go b/internal/compile/codegen_test.go
index 6539946..359d3bb 100644
--- a/internal/compile/codegen_test.go
+++ b/internal/compile/codegen_test.go
@@ -5,8 +5,8 @@ import (
"fmt"
"testing"
- "github.com/google/skylark/resolve"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/resolve"
+ "github.com/google/starlark/syntax"
)
// TestPlusFolding ensures that the compiler generates optimized code for
@@ -54,7 +54,7 @@ func TestPlusFolding(t *testing.T) {
`return`,
},
} {
- expr, err := syntax.ParseExpr("in.sky", test.src, 0)
+ expr, err := syntax.ParseExpr("in.star", test.src, 0)
if err != nil {
t.Errorf("#%d: %v", i, err)
continue
diff --git a/internal/compile/compile.go b/internal/compile/compile.go
index 6b69fd5..32c2307 100644
--- a/internal/compile/compile.go
+++ b/internal/compile/compile.go
@@ -1,5 +1,5 @@
-// The compile package defines the Skylark bytecode compiler.
-// It is an internal package of the Skylark interpreter and is not directly accessible to clients.
+// The compile package defines the Starlark bytecode compiler.
+// It is an internal package of the Starlark interpreter and is not directly accessible to clients.
//
// The compiler generates byte code with optional uint32 operands for a
// virtual machine with the following components:
@@ -30,8 +30,8 @@ import (
"path/filepath"
"strconv"
- "github.com/google/skylark/resolve"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/resolve"
+ "github.com/google/starlark/syntax"
)
const debug = false // TODO(adonovan): use a bitmap of options; and regexp to match files
@@ -276,7 +276,7 @@ func (op Opcode) String() string {
return fmt.Sprintf("illegal op (%d)", op)
}
-// A Program is a Skylark file in executable form.
+// A Program is a Starlark file in executable form.
//
// Programs are serialized by the gobProgram function,
// which must be updated whenever this declaration is changed.
@@ -289,7 +289,7 @@ type Program struct {
Toplevel *Funcode // module initialization function
}
-// A Funcode is the code of a compiled Skylark function.
+// A Funcode is the code of a compiled Starlark function.
//
// Funcodes are serialized by the gobFunc function,
// which must be updated whenever this declaration is changed.
@@ -804,7 +804,7 @@ func (fcomp *fcomp) emit1(op Opcode, arg uint32) {
// On return, the current block is unset.
func (fcomp *fcomp) jump(b *block) {
if b == fcomp.block {
- panic("self-jump") // unreachable: Skylark has no arbitrary looping constructs
+ panic("self-jump") // unreachable: Starlark has no arbitrary looping constructs
}
fcomp.block.jmp = b
fcomp.block = nil
@@ -1530,16 +1530,16 @@ func (fcomp *fcomp) args(call *syntax.CallExpr) (op Opcode, arg uint32) {
p++
}
- // Python2, Python3, and Skylark-in-Java all permit named arguments
+ // Python2, Python3, and Starlark-in-Java all permit named arguments
// to appear both before and after a *args argument:
// f(1, 2, x=3, *[4], y=5, **dict(z=6))
//
// However all three implement different argument evaluation orders:
// Python2: 1 2 3 5 4 6 (*args and **kwargs evaluated last)
// Python3: 1 2 4 3 5 6 (positional args evaluated before named args)
- // Skylark-in-Java: 1 2 3 4 5 6 (lexical order)
+ // Starlark-in-Java: 1 2 3 4 5 6 (lexical order)
//
- // The Skylark-in-Java semantics are clean but hostile to a
+ // The Starlark-in-Java semantics are clean but hostile to a
// compiler-based implementation because they require that the
// compiler emit code for positional, named, *args, more named,
// and *kwargs arguments and provide the callee with a map of
diff --git a/internal/compile/compile_test.go b/internal/compile/compile_test.go
index a545817..dea51c8 100644
--- a/internal/compile/compile_test.go
+++ b/internal/compile/compile_test.go
@@ -5,15 +5,15 @@ import (
"strings"
"testing"
- "github.com/google/skylark"
+ "github.com/google/starlark"
)
// TestSerialization verifies that a serialized program can be loaded,
// deserialized, and executed.
func TestSerialization(t *testing.T) {
- predeclared := skylark.StringDict{
- "x": skylark.String("mur"),
- "n": skylark.MakeInt(2),
+ predeclared := starlark.StringDict{
+ "x": starlark.String("mur"),
+ "n": starlark.MakeInt(2),
}
const src = `
def mul(a, b):
@@ -21,7 +21,7 @@ def mul(a, b):
y = mul(x, n)
`
- _, oldProg, err := skylark.SourceProgram("mul.sky", src, predeclared.Has)
+ _, oldProg, err := starlark.SourceProgram("mul.star", src, predeclared.Has)
if err != nil {
t.Fatal(err)
}
@@ -31,31 +31,31 @@ y = mul(x, n)
t.Fatalf("oldProg.WriteTo: %v", err)
}
- newProg, err := skylark.CompiledProgram(buf)
+ newProg, err := starlark.CompiledProgram(buf)
if err != nil {
t.Fatalf("CompiledProgram: %v", err)
}
- thread := new(skylark.Thread)
+ thread := new(starlark.Thread)
globals, err := newProg.Init(thread, predeclared)
if err != nil {
t.Fatalf("newProg.Init: %v", err)
}
- if got, want := globals["y"], skylark.String("murmur"); got != want {
+ if got, want := globals["y"], starlark.String("murmur"); got != want {
t.Errorf("Value of global was %s, want %s", got, want)
t.Logf("globals: %v", globals)
}
// Verify stack frame.
- predeclared["n"] = skylark.None
+ predeclared["n"] = starlark.None
_, err = newProg.Init(thread, predeclared)
- evalErr, ok := err.(*skylark.EvalError)
+ evalErr, ok := err.(*starlark.EvalError)
if !ok {
t.Fatalf("newProg.Init call returned err %v, want *EvalError", err)
}
const want = `Traceback (most recent call last):
- mul.sky:5: in <toplevel>
- mul.sky:3: in mul
+ mul.star:5: in <toplevel>
+ mul.star:3: in mul
Error: unknown binary op: string * NoneType`
if got := evalErr.Backtrace(); got != want {
t.Fatalf("got <<%s>>, want <<%s>>", got, want)
@@ -63,8 +63,8 @@ Error: unknown binary op: string * NoneType`
}
func TestGarbage(t *testing.T) {
- const garbage = "This is not a compiled Skylark program."
- _, err := skylark.CompiledProgram(strings.NewReader(garbage))
+ const garbage = "This is not a compiled Starlark program."
+ _, err := starlark.CompiledProgram(strings.NewReader(garbage))
if err == nil {
t.Fatalf("CompiledProgram did not report an error when decoding garbage")
}
diff --git a/internal/compile/serial.go b/internal/compile/serial.go
index 706456f..4d2e01e 100644
--- a/internal/compile/serial.go
+++ b/internal/compile/serial.go
@@ -13,7 +13,7 @@ import (
"fmt"
"io"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/syntax"
)
const magic = "!sky"
@@ -45,7 +45,7 @@ type gobIdent struct {
Line, Col int32 // the filename is gobProgram.Filename
}
-// Write writes a compiled Skylark program to out.
+// Write writes a compiled Starlark program to out.
func (prog *Program) Write(out io.Writer) error {
out.Write([]byte(magic))
@@ -94,7 +94,7 @@ func (prog *Program) Write(out io.Writer) error {
return gob.NewEncoder(out).Encode(gp)
}
-// ReadProgram reads a compiled Skylark program from in.
+// ReadProgram reads a compiled Starlark program from in.
func ReadProgram(in io.Reader) (*Program, error) {
magicBuf := []byte(magic)
n, err := in.Read(magicBuf)
diff --git a/interp.go b/interp.go
index 5b5f6b9..df4beb1 100644
--- a/interp.go
+++ b/interp.go
@@ -1,4 +1,4 @@
-package skylark
+package starlark
// This file defines the bytecode interpreter.
@@ -6,8 +6,8 @@ import (
"fmt"
"os"
- "github.com/google/skylark/internal/compile"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/internal/compile"
+ "github.com/google/starlark/syntax"
)
const vmdebug = false // TODO(adonovan): use a bitfield of specific kinds of error.
diff --git a/library.go b/library.go
index 1ba6ca9..f2c732f 100644
--- a/library.go
+++ b/library.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package skylark
+package starlark
// This file defines the library of built-ins.
//
@@ -22,19 +22,19 @@ import (
"unicode"
"unicode/utf8"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/syntax"
)
// Universe defines the set of universal built-ins, such as None, True, and len.
//
// The Go application may add or remove items from the
-// universe dictionary before Skylark evaluation begins.
+// universe dictionary before Starlark evaluation begins.
// All values in the dictionary must be immutable.
-// Skylark programs cannot modify the dictionary.
+// Starlark programs cannot modify the dictionary.
var Universe StringDict
func init() {
- // https://github.com/google/skylark/blob/master/doc/spec.md#built-in-constants-and-functions
+ // https://github.com/google/starlark/blob/master/doc/spec.md#built-in-constants-and-functions
Universe = StringDict{
"None": None,
"True": True,
@@ -72,7 +72,7 @@ func init() {
type builtinMethod func(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error)
// methods of built-in types
-// https://github.com/google/skylark/blob/master/doc/spec.md#built-in-methods
+// https://github.com/google/starlark/blob/master/doc/spec.md#built-in-methods
var (
dictMethods = map[string]builtinMethod{
"clear": dict_clear,
@@ -188,7 +188,7 @@ func builtinAttrNames(methods map[string]builtinMethod) []string {
// its Type() method while constructing the error message.
//
// Beware: an optional *List, *Dict, Callable, Iterable, or Value variable that is
-// not assigned is not a valid Skylark Value, so the caller must
+// not assigned is not a valid Starlark Value, so the caller must
// explicitly handle such cases by interpreting nil as None or some
// computed default.
func UnpackArgs(fnname string, args Tuple, kwargs []Tuple, pairs ...interface{}) error {
@@ -342,7 +342,7 @@ func unpackOneArg(v Value, ptr interface{}) error {
// ---- built-in functions ----
-// https://github.com/google/skylark/blob/master/doc/spec.md#all
+// https://github.com/google/starlark/blob/master/doc/spec.md#all
func all(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var iterable Iterable
if err := UnpackPositionalArgs("all", args, kwargs, 1, &iterable); err != nil {
@@ -359,7 +359,7 @@ func all(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error)
return True, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#any
+// https://github.com/google/starlark/blob/master/doc/spec.md#any
func any(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var iterable Iterable
if err := UnpackPositionalArgs("all", args, kwargs, 1, &iterable); err != nil {
@@ -376,7 +376,7 @@ func any(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error)
return False, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#bool
+// https://github.com/google/starlark/blob/master/doc/spec.md#bool
func bool_(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var x Value = False
if err := UnpackPositionalArgs("bool", args, kwargs, 0, &x); err != nil {
@@ -385,7 +385,7 @@ func bool_(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error
return x.Truth(), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#chr
+// https://github.com/google/starlark/blob/master/doc/spec.md#chr
func chr(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
if len(kwargs) > 0 {
return nil, fmt.Errorf("chr does not accept keyword arguments")
@@ -406,7 +406,7 @@ func chr(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error)
return String(string(i)), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#dict
+// https://github.com/google/starlark/blob/master/doc/spec.md#dict
func dict(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
if len(args) > 1 {
return nil, fmt.Errorf("dict: got %d arguments, want at most 1", len(args))
@@ -418,7 +418,7 @@ func dict(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error)
return dict, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#dir
+// https://github.com/google/starlark/blob/master/doc/spec.md#dir
func dir(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
if len(kwargs) > 0 {
return nil, fmt.Errorf("dir does not accept keyword arguments")
@@ -438,7 +438,7 @@ func dir(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error)
return NewList(elems), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#enumerate
+// https://github.com/google/starlark/blob/master/doc/spec.md#enumerate
func enumerate(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var iterable Iterable
var start int
@@ -509,7 +509,7 @@ func float(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error
}
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#getattr
+// https://github.com/google/starlark/blob/master/doc/spec.md#getattr
func getattr(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var object, dflt Value
var name string
@@ -537,7 +537,7 @@ func getattr(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, err
return nil, fmt.Errorf("%s has no .%s field or method", object.Type(), name)
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#hasattr
+// https://github.com/google/starlark/blob/master/doc/spec.md#hasattr
func hasattr(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var object Value
var name string
@@ -563,7 +563,7 @@ func hasattr(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, err
return False, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#hash
+// https://github.com/google/starlark/blob/master/doc/spec.md#hash
func hash(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var x Value
if err := UnpackPositionalArgs("hash", args, kwargs, 1, &x); err != nil {
@@ -573,7 +573,7 @@ func hash(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error)
return MakeUint(uint(h)), err
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#int
+// https://github.com/google/starlark/blob/master/doc/spec.md#int
func int_(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var x Value = zero
var base Value
@@ -673,7 +673,7 @@ func int_(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error)
return i, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#len
+// https://github.com/google/starlark/blob/master/doc/spec.md#len
func len_(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var x Value
if err := UnpackPositionalArgs("len", args, kwargs, 1, &x); err != nil {
@@ -686,7 +686,7 @@ func len_(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error)
return MakeInt(len), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#list
+// https://github.com/google/starlark/blob/master/doc/spec.md#list
func list(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var iterable Iterable
if err := UnpackPositionalArgs("list", args, kwargs, 0, &iterable); err != nil {
@@ -707,7 +707,7 @@ func list(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error)
return NewList(elems), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#min
+// https://github.com/google/starlark/blob/master/doc/spec.md#min
func minmax(thread *Thread, fn *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
if len(args) == 0 {
return nil, fmt.Errorf("%s requires at least one positional argument", fn.Name())
@@ -775,7 +775,7 @@ func minmax(thread *Thread, fn *Builtin, args Tuple, kwargs []Tuple) (Value, err
return extremum, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#ord
+// https://github.com/google/starlark/blob/master/doc/spec.md#ord
func ord(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
if len(kwargs) > 0 {
return nil, fmt.Errorf("ord does not accept keyword arguments")
@@ -795,7 +795,7 @@ func ord(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error)
return MakeInt(int(r)), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#print
+// https://github.com/google/starlark/blob/master/doc/spec.md#print
func print(thread *Thread, fn *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var buf bytes.Buffer
path := make([]Value, 0, 4)
@@ -829,7 +829,7 @@ func print(thread *Thread, fn *Builtin, args Tuple, kwargs []Tuple) (Value, erro
return None, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#range
+// https://github.com/google/starlark/blob/master/doc/spec.md#range
func range_(thread *Thread, fn *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var start, stop, step int
step = 1
@@ -960,7 +960,7 @@ func (it *rangeIterator) Next(p *Value) bool {
}
func (*rangeIterator) Done() {}
-// https://github.com/google/skylark/blob/master/doc/spec.md#repr
+// https://github.com/google/starlark/blob/master/doc/spec.md#repr
func repr(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var x Value
if err := UnpackPositionalArgs("repr", args, kwargs, 1, &x); err != nil {
@@ -969,7 +969,7 @@ func repr(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error)
return String(x.String()), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#reversed
+// https://github.com/google/starlark/blob/master/doc/spec.md#reversed
func reversed(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var iterable Iterable
if err := UnpackPositionalArgs("reversed", args, kwargs, 1, &iterable); err != nil {
@@ -992,7 +992,7 @@ func reversed(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, er
return NewList(elems), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#set
+// https://github.com/google/starlark/blob/master/doc/spec.md#set
func set(thread *Thread, fn *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var iterable Iterable
if err := UnpackPositionalArgs("set", args, kwargs, 0, &iterable); err != nil {
@@ -1012,7 +1012,7 @@ func set(thread *Thread, fn *Builtin, args Tuple, kwargs []Tuple) (Value, error)
return set, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#sorted
+// https://github.com/google/starlark/blob/master/doc/spec.md#sorted
func sorted(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var iterable Iterable
var key Callable
@@ -1083,7 +1083,7 @@ func (s *sortSlice) Swap(i, j int) {
s.values[i], s.values[j] = s.values[j], s.values[i]
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#str
+// https://github.com/google/starlark/blob/master/doc/spec.md#str
func str(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
if len(kwargs) > 0 {
return nil, fmt.Errorf("str does not accept keyword arguments")
@@ -1098,7 +1098,7 @@ func str(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error)
return x, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#tuple
+// https://github.com/google/starlark/blob/master/doc/spec.md#tuple
func tuple(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
var iterable Iterable
if err := UnpackPositionalArgs("tuple", args, kwargs, 0, &iterable); err != nil {
@@ -1120,7 +1120,7 @@ func tuple(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error
return elems, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#type
+// https://github.com/google/starlark/blob/master/doc/spec.md#type
func type_(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
if len(kwargs) > 0 {
return nil, fmt.Errorf("type does not accept keyword arguments")
@@ -1131,7 +1131,7 @@ func type_(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error
return String(args[0].Type()), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#zip
+// https://github.com/google/starlark/blob/master/doc/spec.md#zip
func zip(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
if len(kwargs) > 0 {
return nil, fmt.Errorf("zip does not accept keyword arguments")
@@ -1187,7 +1187,7 @@ func zip(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error)
// ---- methods of built-in types ---
-// https://github.com/google/skylark/blob/master/doc/spec.md#dict·get
+// https://github.com/google/starlark/blob/master/doc/spec.md#dict·get
func dict_get(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
var key, dflt Value
if err := UnpackPositionalArgs(fnname, args, kwargs, 1, &key, &dflt); err != nil {
@@ -1203,7 +1203,7 @@ func dict_get(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, err
return None, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#dict·clear
+// https://github.com/google/starlark/blob/master/doc/spec.md#dict·clear
func dict_clear(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1211,7 +1211,7 @@ func dict_clear(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, e
return None, recv.(*Dict).Clear()
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#dict·items
+// https://github.com/google/starlark/blob/master/doc/spec.md#dict·items
func dict_items(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1224,7 +1224,7 @@ func dict_items(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, e
return NewList(res), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#dict·keys
+// https://github.com/google/starlark/blob/master/doc/spec.md#dict·keys
func dict_keys(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1232,7 +1232,7 @@ func dict_keys(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, er
return NewList(recv.(*Dict).Keys()), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#dict·pop
+// https://github.com/google/starlark/blob/master/doc/spec.md#dict·pop
func dict_pop(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
recv := recv_.(*Dict)
var k, d Value
@@ -1249,7 +1249,7 @@ func dict_pop(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, er
return nil, fmt.Errorf("pop: missing key")
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#dict·popitem
+// https://github.com/google/starlark/blob/master/doc/spec.md#dict·popitem
func dict_popitem(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1266,7 +1266,7 @@ func dict_popitem(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value
return Tuple{k, v}, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#dict·setdefault
+// https://github.com/google/starlark/blob/master/doc/spec.md#dict·setdefault
func dict_setdefault(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
var key, dflt Value = nil, None
if err := UnpackPositionalArgs(fnname, args, kwargs, 1, &key, &dflt); err != nil {
@@ -1282,7 +1282,7 @@ func dict_setdefault(fnname string, recv Value, args Tuple, kwargs []Tuple) (Val
}
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#dict·update
+// https://github.com/google/starlark/blob/master/doc/spec.md#dict·update
func dict_update(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
if len(args) > 1 {
return nil, fmt.Errorf("update: got %d arguments, want at most 1", len(args))
@@ -1293,7 +1293,7 @@ func dict_update(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value,
return None, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#dict·update
+// https://github.com/google/starlark/blob/master/doc/spec.md#dict·update
func dict_values(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1306,7 +1306,7 @@ func dict_values(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value,
return NewList(res), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#list·append
+// https://github.com/google/starlark/blob/master/doc/spec.md#list·append
func list_append(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
recv := recv_.(*List)
var object Value
@@ -1320,7 +1320,7 @@ func list_append(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value,
return None, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#list·clear
+// https://github.com/google/starlark/blob/master/doc/spec.md#list·clear
func list_clear(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1328,7 +1328,7 @@ func list_clear(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value,
return None, recv_.(*List).Clear()
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#list·extend
+// https://github.com/google/starlark/blob/master/doc/spec.md#list·extend
func list_extend(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
recv := recv_.(*List)
var iterable Iterable
@@ -1342,7 +1342,7 @@ func list_extend(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value,
return None, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#list·index
+// https://github.com/google/starlark/blob/master/doc/spec.md#list·index
func list_index(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
recv := recv_.(*List)
var value, start_, end_ Value
@@ -1365,7 +1365,7 @@ func list_index(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value,
return nil, fmt.Errorf("index: value not in list")
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#list·insert
+// https://github.com/google/starlark/blob/master/doc/spec.md#list·insert
func list_insert(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
recv := recv_.(*List)
var index int
@@ -1395,7 +1395,7 @@ func list_insert(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value,
return None, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#list·remove
+// https://github.com/google/starlark/blob/master/doc/spec.md#list·remove
func list_remove(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
recv := recv_.(*List)
var value Value
@@ -1416,7 +1416,7 @@ func list_remove(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value,
return nil, fmt.Errorf("remove: element not found")
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#list·pop
+// https://github.com/google/starlark/blob/master/doc/spec.md#list·pop
func list_pop(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
list := recv.(*List)
index := list.Len() - 1
@@ -1434,7 +1434,7 @@ func list_pop(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, err
return res, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·capitalize
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·capitalize
func string_capitalize(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1458,7 +1458,7 @@ func string_iterable(fnname string, recv Value, args Tuple, kwargs []Tuple) (Val
}, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·count
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·count
func string_count(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
recv := string(recv_.(String))
@@ -1480,7 +1480,7 @@ func string_count(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value
return MakeInt(strings.Count(slice, sub)), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·isalnum
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·isalnum
func string_isalnum(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1494,7 +1494,7 @@ func string_isalnum(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Val
return Bool(recv != ""), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·isalpha
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·isalpha
func string_isalpha(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1508,7 +1508,7 @@ func string_isalpha(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Val
return Bool(recv != ""), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·isdigit
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·isdigit
func string_isdigit(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1522,7 +1522,7 @@ func string_isdigit(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Val
return Bool(recv != ""), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·islower
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·islower
func string_islower(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1541,7 +1541,7 @@ func isCasedString(s string) bool {
return false
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·isspace
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·isspace
func string_isspace(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1555,7 +1555,7 @@ func string_isspace(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Val
return Bool(recv != ""), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·istitle
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·istitle
func string_istitle(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1586,7 +1586,7 @@ func string_istitle(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Val
return Bool(cased), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·isupper
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·isupper
func string_isupper(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1595,12 +1595,12 @@ func string_isupper(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Val
return Bool(isCasedString(recv) && recv == strings.ToUpper(recv)), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·find
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·find
func string_find(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
return string_find_impl(fnname, string(recv.(String)), args, kwargs, true, false)
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·format
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·format
func string_format(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
format := string(recv_.(String))
var auto, manual bool // kinds of positional indexing used
@@ -1705,7 +1705,7 @@ func string_format(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Valu
}
}
if arg == nil {
- // Skylark does not support Python's x.y or a[i] syntaxes,
+ // Starlark does not support Python's x.y or a[i] syntaxes,
// or nested use of {...}.
if strings.Contains(name, ".") {
return nil, fmt.Errorf("attribute syntax x.y is not supported in replacement fields: %s", name)
@@ -1721,7 +1721,7 @@ func string_format(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Valu
}
if spec != "" {
- // Skylark does not support Python's format_spec features.
+ // Starlark does not support Python's format_spec features.
return nil, fmt.Errorf("format spec features not supported in replacement fields: %s", spec)
}
@@ -1741,12 +1741,12 @@ func string_format(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Valu
return String(buf.String()), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·index
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·index
func string_index(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
return string_find_impl(fnname, string(recv.(String)), args, kwargs, false, false)
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·join
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·join
func string_join(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
recv := string(recv_.(String))
var iterable Iterable
@@ -1770,7 +1770,7 @@ func string_join(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value,
return String(buf.String()), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·lower
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·lower
func string_lower(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1778,7 +1778,7 @@ func string_lower(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value,
return String(strings.ToLower(string(recv.(String)))), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·lstrip
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·lstrip
func string_lstrip(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1786,7 +1786,7 @@ func string_lstrip(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value
return String(strings.TrimLeftFunc(string(recv.(String)), unicode.IsSpace)), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·partition
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·partition
func string_partition(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
recv := string(recv_.(String))
var sep string
@@ -1815,7 +1815,7 @@ func string_partition(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (V
return tuple, nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·replace
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·replace
func string_replace(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
recv := string(recv_.(String))
var old, new string
@@ -1826,17 +1826,17 @@ func string_replace(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Val
return String(strings.Replace(recv, old, new, count)), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·rfind
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·rfind
func string_rfind(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
return string_find_impl(fnname, string(recv.(String)), args, kwargs, true, true)
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·rindex
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·rindex
func string_rindex(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
return string_find_impl(fnname, string(recv.(String)), args, kwargs, false, true)
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·rstrip
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·rstrip
func string_rstrip(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1844,8 +1844,8 @@ func string_rstrip(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value
return String(strings.TrimRightFunc(string(recv.(String)), unicode.IsSpace)), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·startswith
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·endswith
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·startswith
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·endswith
func string_startswith(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
var x Value
var start, end Value = None, None
@@ -1888,9 +1888,9 @@ func string_startswith(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (
return nil, fmt.Errorf("%s: got %s, want string or tuple of string", fnname, x.Type())
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·strip
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·lstrip
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·rstrip
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·strip
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·lstrip
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·rstrip
func string_strip(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
var chars string
if err := UnpackPositionalArgs(fnname, args, kwargs, 0, &chars); err != nil {
@@ -1921,7 +1921,7 @@ func string_strip(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value
return String(s), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·title
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·title
func string_title(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1929,7 +1929,7 @@ func string_title(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value,
return String(strings.Title(strings.ToLower(string(recv.(String))))), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·upper
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·upper
func string_upper(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
return nil, err
@@ -1937,8 +1937,8 @@ func string_upper(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value,
return String(strings.ToUpper(string(recv.(String)))), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·split
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·rsplit
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·split
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·rsplit
func string_split(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
recv := string(recv_.(String))
var sep_ Value
@@ -2041,7 +2041,7 @@ func splitspace(s string, max int) []string {
return res
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#string·splitlines
+// https://github.com/google/starlark/blob/master/doc/spec.md#string·splitlines
func string_splitlines(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
var keepends bool
if err := UnpackPositionalArgs(fnname, args, kwargs, 0, &keepends); err != nil {
@@ -2065,7 +2065,7 @@ func string_splitlines(fnname string, recv Value, args Tuple, kwargs []Tuple) (V
return NewList(list), nil
}
-// https://github.com/google/skylark/blob/master/doc/spec.md#set·union.
+// https://github.com/google/starlark/blob/master/doc/spec.md#set·union.
func set_union(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
var iterable Iterable
if err := UnpackPositionalArgs(fnname, args, kwargs, 0, &iterable); err != nil {
diff --git a/repl/repl.go b/repl/repl.go
index f6f5a90..3b44402 100644
--- a/repl/repl.go
+++ b/repl/repl.go
@@ -1,4 +1,4 @@
-// The repl package provides a read/eval/print loop for Skylark.
+// The repl package provides a read/eval/print loop for Starlark.
//
// It supports readline-style command editing,
// and interrupts through Control-C.
@@ -31,20 +31,20 @@ import (
"strings"
"github.com/chzyer/readline"
- "github.com/google/skylark"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark"
+ "github.com/google/starlark/syntax"
)
var interrupted = make(chan os.Signal, 1)
// REPL executes a read, eval, print loop.
//
-// Before evaluating each expression, it sets the Skylark thread local
+// Before evaluating each expression, it sets the Starlark thread local
// variable named "context" to a context.Context that is cancelled by a
// SIGINT (Control-C). Client-supplied global functions may use this
// context to make long-running operations interruptable.
//
-func REPL(thread *skylark.Thread, globals skylark.StringDict) {
+func REPL(thread *starlark.Thread, globals starlark.StringDict) {
signal.Notify(interrupted, os.Interrupt)
defer signal.Stop(interrupted)
@@ -69,8 +69,8 @@ func REPL(thread *skylark.Thread, globals skylark.StringDict) {
// rep reads, evaluates, and prints one item.
//
// It returns an error (possibly readline.ErrInterrupt)
-// only if readline failed. Skylark errors are printed.
-func rep(rl *readline.Instance, thread *skylark.Thread, globals skylark.StringDict) error {
+// only if readline failed. Starlark errors are printed.
+func rep(rl *readline.Instance, thread *starlark.Thread, globals starlark.StringDict) error {
// Each item gets its own context,
// which is cancelled by a SIGINT.
//
@@ -100,9 +100,9 @@ func rep(rl *readline.Instance, thread *skylark.Thread, globals skylark.StringDi
// If the line contains a well-formed expression, evaluate it.
if _, err := syntax.ParseExpr("<stdin>", line, 0); err == nil {
- if v, err := skylark.Eval(thread, "<stdin>", line, globals); err != nil {
+ if v, err := starlark.Eval(thread, "<stdin>", line, globals); err != nil {
PrintError(err)
- } else if v != skylark.None {
+ } else if v != starlark.None {
fmt.Println(v)
}
return nil
@@ -145,9 +145,9 @@ func rep(rl *readline.Instance, thread *skylark.Thread, globals skylark.StringDi
// 2
// )
if _, err := syntax.ParseExpr("<stdin>", text, 0); err == nil {
- if v, err := skylark.Eval(thread, "<stdin>", text, globals); err != nil {
+ if v, err := starlark.Eval(thread, "<stdin>", text, globals); err != nil {
PrintError(err)
- } else if v != skylark.None {
+ } else if v != starlark.None {
fmt.Println(v)
}
return nil
@@ -161,9 +161,9 @@ func rep(rl *readline.Instance, thread *skylark.Thread, globals skylark.StringDi
return nil
}
-// execFileNoFreeze is skylark.ExecFile without globals.Freeze().
-func execFileNoFreeze(thread *skylark.Thread, src interface{}, globals skylark.StringDict) error {
- _, prog, err := skylark.SourceProgram("<stdin>", src, globals.Has)
+// execFileNoFreeze is starlark.ExecFile without globals.Freeze().
+func execFileNoFreeze(thread *starlark.Thread, src interface{}, globals starlark.StringDict) error {
+ _, prog, err := starlark.SourceProgram("<stdin>", src, globals.Has)
if err != nil {
return err
}
@@ -183,9 +183,9 @@ func execFileNoFreeze(thread *skylark.Thread, src interface{}, globals skylark.S
}
// PrintError prints the error to stderr,
-// or its backtrace if it is a Skylark evaluation error.
+// or its backtrace if it is a Starlark evaluation error.
func PrintError(err error) {
- if evalErr, ok := err.(*skylark.EvalError); ok {
+ if evalErr, ok := err.(*starlark.EvalError); ok {
fmt.Fprintln(os.Stderr, evalErr.Backtrace())
} else {
fmt.Fprintln(os.Stderr, err)
@@ -195,15 +195,15 @@ func PrintError(err error) {
// MakeLoad returns a simple sequential implementation of module loading
// suitable for use in the REPL.
// Each function returned by MakeLoad accesses a distinct private cache.
-func MakeLoad() func(thread *skylark.Thread, module string) (skylark.StringDict, error) {
+func MakeLoad() func(thread *starlark.Thread, module string) (starlark.StringDict, error) {
type entry struct {
- globals skylark.StringDict
+ globals starlark.StringDict
err error
}
var cache = make(map[string]*entry)
- return func(thread *skylark.Thread, module string) (skylark.StringDict, error) {
+ return func(thread *starlark.Thread, module string) (starlark.StringDict, error) {
e, ok := cache[module]
if e == nil {
if ok {
@@ -215,8 +215,8 @@ func MakeLoad() func(thread *skylark.Thread, module string) (skylark.StringDict,
cache[module] = nil
// Load it.
- thread := &skylark.Thread{Load: thread.Load}
- globals, err := skylark.ExecFile(thread, module, nil, nil)
+ thread := &starlark.Thread{Load: thread.Load}
+ globals, err := starlark.ExecFile(thread, module, nil, nil)
e = &entry{globals, err}
// Update the cache.
diff --git a/resolve/resolve.go b/resolve/resolve.go
index 4c1e8f9..3aa0a21 100644
--- a/resolve/resolve.go
+++ b/resolve/resolve.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package resolve defines a name-resolution pass for Skylark abstract
+// Package resolve defines a name-resolution pass for Starlark abstract
// syntax trees.
//
// The resolver sets the Locals and FreeVars arrays of each DefStmt and
@@ -48,9 +48,9 @@ package resolve
// function. At that point, we can distinguish local from global names
// (and this is when Python would compute free variables).
//
-// However, Skylark additionally requires that all references to global
+// However, Starlark additionally requires that all references to global
// names are satisfied by some declaration in the current module;
-// Skylark permits a function to forward-reference a global that has not
+// Starlark permits a function to forward-reference a global that has not
// been declared yet so long as it is declared before the end of the
// module. So, instead of re-resolving the unresolved references after
// each top-level function, we defer this until the end of the module
@@ -67,7 +67,7 @@ package resolve
// We resolve all uses of locals in the module (due to comprehensions)
// in a similar way and compute the set of its local variables.
//
-// Skylark enforces that all global names are assigned at most once on
+// Starlark enforces that all global names are assigned at most once on
// all control flow paths by forbidding if/else statements and loops at
// top level. A global may be used before it is defined, leading to a
// dynamic error.
@@ -79,14 +79,14 @@ import (
"log"
"strings"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/syntax"
)
const debug = false
-const doesnt = "this Skylark dialect does not "
+const doesnt = "this Starlark dialect does not "
// global options
-// These features are either not standard Skylark (yet), or deprecated
+// These features are either not standard Starlark (yet), or deprecated
// features of the BUILD language, so we put them behind flags.
var (
AllowNestedDef = false // allow def statements within function bodies
@@ -103,11 +103,11 @@ var (
// a pre-declared identifier (visible in the current module) or a
// universal identifier (visible in every module).
// Clients should typically pass predeclared.Has for the first and
-// skylark.Universe.Has for the second, where predeclared is the
-// module's StringDict of predeclared names and skylark.Universe is the
+// starlark.Universe.Has for the second, where predeclared is the
+// module's StringDict of predeclared names and starlark.Universe is the
// standard set of built-ins.
// The isUniverse predicate is supplied a parameter to avoid a cyclic
-// dependency upon skylark.Universe, not because users should ever need
+// dependency upon starlark.Universe, not because users should ever need
// to redefine it.
func File(file *syntax.File, isPredeclared, isUniversal func(name string) bool) error {
r := newResolver(isPredeclared, isUniversal)
diff --git a/resolve/resolve_test.go b/resolve/resolve_test.go
index b19e16c..203815d 100644
--- a/resolve/resolve_test.go
+++ b/resolve/resolve_test.go
@@ -8,14 +8,14 @@ import (
"strings"
"testing"
- "github.com/google/skylark/internal/chunkedfile"
- "github.com/google/skylark/resolve"
- "github.com/google/skylark/skylarktest"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/internal/chunkedfile"
+ "github.com/google/starlark/resolve"
+ "github.com/google/starlark/starlarktest"
+ "github.com/google/starlark/syntax"
)
func TestResolve(t *testing.T) {
- filename := skylarktest.DataFile("skylark/resolve", "testdata/resolve.sky")
+ filename := starlarktest.DataFile("starlark/resolve", "testdata/resolve.star")
for _, chunk := range chunkedfile.Read(filename, t) {
f, err := syntax.Parse(filename, chunk.Source, 0)
if err != nil {
@@ -45,7 +45,7 @@ func option(chunk, name string) bool {
func TestDefVarargsAndKwargsSet(t *testing.T) {
source := "def f(*args, **kwargs): pass\n"
- file, err := syntax.Parse("foo.sky", source, 0)
+ file, err := syntax.Parse("foo.star", source, 0)
if err != nil {
t.Fatal(err)
}
@@ -64,7 +64,7 @@ func TestDefVarargsAndKwargsSet(t *testing.T) {
func TestLambdaVarargsAndKwargsSet(t *testing.T) {
resolve.AllowLambda = true
source := "f = lambda *args, **kwargs: 0\n"
- file, err := syntax.Parse("foo.sky", source, 0)
+ file, err := syntax.Parse("foo.star", source, 0)
if err != nil {
t.Fatal(err)
}
diff --git a/resolve/testdata/resolve.sky b/resolve/testdata/resolve.star
index bbad8e0..754882b 100644
--- a/resolve/testdata/resolve.sky
+++ b/resolve/testdata/resolve.star
@@ -2,7 +2,7 @@
#
# The initial environment contains the predeclared names "M"
# (module-specific) and "U" (universal). This distinction
-# should be unobservable to the Skylark program.
+# should be unobservable to the Starlark program.
# use of declared global
x = 1
@@ -20,7 +20,7 @@ _ = x ### "undefined: x"
---
# redeclaration of global
x = 1
-x = 2 ### "cannot reassign global x declared at .*resolve.sky:22:1"
+x = 2 ### "cannot reassign global x declared at .*resolve.star:22:1"
---
# Redeclaration of predeclared names is allowed.
@@ -30,11 +30,11 @@ x = 2 ### "cannot reassign global x declared at .*resolve.sky:22:1"
# module-specific predeclared name
M = 1 # ok
-M = 2 ### "cannot reassign global M declared at .*/resolve.sky"
+M = 2 ### "cannot reassign global M declared at .*/resolve.star"
# universal predeclared name
U = 1 # ok
-U = 1 ### "cannot reassign global U declared at .*/resolve.sky"
+U = 1 ### "cannot reassign global U declared at .*/resolve.star"
---
# A global declaration shadows all references to a predeclared; see issue 116.
diff --git a/skylarkstruct/struct.go b/starlarkstruct/struct.go
index 468f8ef..2c2e8f1 100644
--- a/skylarkstruct/struct.go
+++ b/starlarkstruct/struct.go
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package skylarkstruct defines the Skylark 'struct' type,
+// Package starlarkstruct defines the Starlark 'struct' type,
// an optional language extension.
-package skylarkstruct
+package starlarkstruct
// It is tempting to introduce a variant of Struct that is a wrapper
// around a Go struct value, for stronger typing guarantees and more
// efficient and convenient field lookup. However:
-// 1) all fields of Skylark structs are optional, so we cannot represent
+// 1) all fields of Starlark structs are optional, so we cannot represent
// them using more specific types such as String, Int, *Depset, and
// *File, as such types give no way to represent missing fields.
// 2) the efficiency gain of direct struct field access is rather
@@ -27,20 +27,20 @@ import (
"fmt"
"sort"
- "github.com/google/skylark"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark"
+ "github.com/google/starlark/syntax"
)
// Make is the implementation of a built-in function that instantiates
// an immutable struct from the specified keyword arguments.
//
-// An application can add 'struct' to the Skylark environment like so:
+// An application can add 'struct' to the Starlark environment like so:
//
-// globals := skylark.StringDict{
-// "struct": skylark.NewBuiltin("struct", skylarkstruct.Make),
+// globals := starlark.StringDict{
+// "struct": starlark.NewBuiltin("struct", starlarkstruct.Make),
// }
//
-func Make(_ *skylark.Thread, _ *skylark.Builtin, args skylark.Tuple, kwargs []skylark.Tuple) (skylark.Value, error) {
+func Make(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
if len(args) > 0 {
return nil, fmt.Errorf("struct: unexpected positional arguments")
}
@@ -48,8 +48,8 @@ func Make(_ *skylark.Thread, _ *skylark.Builtin, args skylark.Tuple, kwargs []sk
}
// FromKeywords returns a new struct instance whose fields are specified by the
-// key/value pairs in kwargs. (Each kwargs[i][0] must be a skylark.String.)
-func FromKeywords(constructor skylark.Value, kwargs []skylark.Tuple) *Struct {
+// key/value pairs in kwargs. (Each kwargs[i][0] must be a starlark.String.)
+func FromKeywords(constructor starlark.Value, kwargs []starlark.Tuple) *Struct {
if constructor == nil {
panic("nil constructor")
}
@@ -58,7 +58,7 @@ func FromKeywords(constructor skylark.Value, kwargs []skylark.Tuple) *Struct {
entries: make(entries, 0, len(kwargs)),
}
for _, kwarg := range kwargs {
- k := string(kwarg[0].(skylark.String))
+ k := string(kwarg[0].(starlark.String))
v := kwarg[1]
s.entries = append(s.entries, entry{k, v})
}
@@ -68,7 +68,7 @@ func FromKeywords(constructor skylark.Value, kwargs []skylark.Tuple) *Struct {
// FromStringDict returns a whose elements are those of d.
// The constructor parameter specifies the constructor; use Default for an ordinary struct.
-func FromStringDict(constructor skylark.Value, d skylark.StringDict) *Struct {
+func FromStringDict(constructor starlark.Value, d starlark.StringDict) *Struct {
if constructor == nil {
panic("nil constructor")
}
@@ -83,7 +83,7 @@ func FromStringDict(constructor skylark.Value, d skylark.StringDict) *Struct {
return s
}
-// Struct is an immutable Skylark type that maps field names to values.
+// Struct is an immutable Starlark type that maps field names to values.
// It is not iterable and does not support len.
//
// A struct has a constructor, a distinct value that identifies a class
@@ -99,13 +99,13 @@ func FromStringDict(constructor skylark.Value, d skylark.StringDict) *Struct {
//
// Use Attr to access its fields and AttrNames to enumerate them.
type Struct struct {
- constructor skylark.Value
+ constructor starlark.Value
entries entries // sorted by name
}
// Default is the default constructor for structs.
// It is merely the string "struct".
-const Default = skylark.String("struct")
+const Default = starlark.String("struct")
type entries []entry
@@ -115,16 +115,16 @@ func (a entries) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
type entry struct {
name string // not to_{proto,json}
- value skylark.Value
+ value starlark.Value
}
var (
- _ skylark.HasAttrs = (*Struct)(nil)
- _ skylark.HasBinary = (*Struct)(nil)
+ _ starlark.HasAttrs = (*Struct)(nil)
+ _ starlark.HasBinary = (*Struct)(nil)
)
// ToStringDict adds a name/value entry to d for each field of the struct.
-func (s *Struct) ToStringDict(d skylark.StringDict) {
+func (s *Struct) ToStringDict(d starlark.StringDict) {
for _, e := range s.entries {
d[e.name] = e.value
}
@@ -153,15 +153,15 @@ func (s *Struct) String() string {
}
// Constructor returns the constructor used to create this struct.
-func (s *Struct) Constructor() skylark.Value { return s.constructor }
+func (s *Struct) Constructor() starlark.Value { return s.constructor }
func (s *Struct) Type() string { return "struct" }
-func (s *Struct) Truth() skylark.Bool { return true } // even when empty
+func (s *Struct) Truth() starlark.Bool { return true } // even when empty
func (s *Struct) Hash() (uint32, error) {
// Same algorithm as Tuple.hash, but with different primes.
var x, m uint32 = 8731, 9839
for _, e := range s.entries {
- namehash, _ := skylark.String(e.name).Hash()
+ namehash, _ := starlark.String(e.name).Hash()
x = x ^ 3*namehash
y, err := e.value.Hash()
if err != nil {
@@ -178,13 +178,13 @@ func (s *Struct) Freeze() {
}
}
-func (x *Struct) Binary(op syntax.Token, y skylark.Value, side skylark.Side) (skylark.Value, error) {
+func (x *Struct) Binary(op syntax.Token, y starlark.Value, side starlark.Side) (starlark.Value, error) {
if y, ok := y.(*Struct); ok && op == syntax.PLUS {
- if side == skylark.Right {
+ if side == starlark.Right {
x, y = y, x
}
- if eq, err := skylark.Equal(x.constructor, y.constructor); err != nil {
+ if eq, err := starlark.Equal(x.constructor, y.constructor); err != nil {
return nil, fmt.Errorf("in %s + %s: error comparing constructors: %v",
x.constructor, y.constructor, err)
} else if !eq {
@@ -192,7 +192,7 @@ func (x *Struct) Binary(op syntax.Token, y skylark.Value, side skylark.Side) (sk
x.constructor, y.constructor)
}
- z := make(skylark.StringDict, x.len()+y.len())
+ z := make(starlark.StringDict, x.len()+y.len())
for _, e := range x.entries {
z[e.name] = e.value
}
@@ -208,7 +208,7 @@ func (x *Struct) Binary(op syntax.Token, y skylark.Value, side skylark.Side) (sk
// Attr returns the value of the specified field,
// or deprecated method if the name is "to_json" or "to_proto"
// and the struct has no field of that name.
-func (s *Struct) Attr(name string) (skylark.Value, error) {
+func (s *Struct) Attr(name string) (starlark.Value, error) {
// Binary search the entries.
// This implementation is a specialization of
// sort.Search that avoids dynamic dispatch.
@@ -227,13 +227,13 @@ func (s *Struct) Attr(name string) (skylark.Value, error) {
}
// TODO(adonovan): there may be a nice feature for core
- // skylark.Value here, especially for JSON, but the current
+ // starlark.Value here, especially for JSON, but the current
// features are incomplete and underspecified.
//
// to_{json,proto} are deprecated, appropriately; see Google issue b/36412967.
switch name {
case "to_json", "to_proto":
- return skylark.NewBuiltin(name, func(thread *skylark.Thread, fn *skylark.Builtin, args skylark.Tuple, kwargs []skylark.Tuple) (skylark.Value, error) {
+ return starlark.NewBuiltin(name, func(thread *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var buf bytes.Buffer
var err error
if name == "to_json" {
@@ -246,7 +246,7 @@ func (s *Struct) Attr(name string) (skylark.Value, error) {
// to show the path through the object graph.
return nil, err
}
- return skylark.String(buf.String()), nil
+ return starlark.String(buf.String()), nil
}), nil
}
@@ -266,7 +266,7 @@ func writeProtoStruct(out *bytes.Buffer, depth int, s *Struct) error {
return nil
}
-func writeProtoField(out *bytes.Buffer, depth int, field string, v skylark.Value) error {
+func writeProtoField(out *bytes.Buffer, depth int, field string, v starlark.Value) error {
if depth > 16 {
return fmt.Errorf("to_proto: depth limit exceeded")
}
@@ -280,10 +280,10 @@ func writeProtoField(out *bytes.Buffer, depth int, field string, v skylark.Value
fmt.Fprintf(out, "%*s}\n", 2*depth, "")
return nil
- case *skylark.List, skylark.Tuple:
- iter := skylark.Iterate(v)
+ case *starlark.List, starlark.Tuple:
+ iter := starlark.Iterate(v)
defer iter.Done()
- var elem skylark.Value
+ var elem starlark.Value
for iter.Next(&elem) {
if err := writeProtoField(out, depth, field, elem); err != nil {
return err
@@ -295,17 +295,17 @@ func writeProtoField(out *bytes.Buffer, depth int, field string, v skylark.Value
// scalars
fmt.Fprintf(out, "%*s%s: ", 2*depth, "", field)
switch v := v.(type) {
- case skylark.Bool:
+ case starlark.Bool:
fmt.Fprintf(out, "%t", v)
- case skylark.Int:
+ case starlark.Int:
// TODO(adonovan): limits?
out.WriteString(v.String())
- case skylark.Float:
+ case starlark.Float:
fmt.Fprintf(out, "%g", v)
- case skylark.String:
+ case starlark.String:
fmt.Fprintf(out, "%q", string(v))
default:
@@ -315,22 +315,22 @@ func writeProtoField(out *bytes.Buffer, depth int, field string, v skylark.Value
return nil
}
-// writeJSON writes the JSON representation of a Skylark value to out.
-// TODO(adonovan): there may be a nice feature for core skylark.Value here,
+// writeJSON writes the JSON representation of a Starlark value to out.
+// TODO(adonovan): there may be a nice feature for core starlark.Value here,
// but the current feature is incomplete and underspecified.
-func writeJSON(out *bytes.Buffer, v skylark.Value) error {
+func writeJSON(out *bytes.Buffer, v starlark.Value) error {
switch v := v.(type) {
- case skylark.NoneType:
+ case starlark.NoneType:
out.WriteString("null")
- case skylark.Bool:
+ case starlark.Bool:
fmt.Fprintf(out, "%t", v)
- case skylark.Int:
+ case starlark.Int:
// TODO(adonovan): test large numbers.
out.WriteString(v.String())
- case skylark.Float:
+ case starlark.Float:
// TODO(adonovan): test.
fmt.Fprintf(out, "%g", v)
- case skylark.String:
+ case starlark.String:
s := string(v)
if goQuoteIsSafe(s) {
fmt.Fprintf(out, "%q", s)
@@ -339,9 +339,9 @@ func writeJSON(out *bytes.Buffer, v skylark.Value) error {
data, _ := json.Marshal(s)
out.Write(data)
}
- case skylark.Indexable: // Tuple, List
+ case starlark.Indexable: // Tuple, List
out.WriteByte('[')
- for i, n := 0, skylark.Len(v); i < n; i++ {
+ for i, n := 0, starlark.Len(v); i < n; i++ {
if i > 0 {
out.WriteString(", ")
}
@@ -356,7 +356,7 @@ func writeJSON(out *bytes.Buffer, v skylark.Value) error {
if i > 0 {
out.WriteString(", ")
}
- if err := writeJSON(out, skylark.String(e.name)); err != nil {
+ if err := writeJSON(out, starlark.String(e.name)); err != nil {
return err
}
out.WriteString(": ")
@@ -400,7 +400,7 @@ func (s *Struct) AttrNames() []string {
return names
}
-func (x *Struct) CompareSameType(op syntax.Token, y_ skylark.Value, depth int) (bool, error) {
+func (x *Struct) CompareSameType(op syntax.Token, y_ starlark.Value, depth int) (bool, error) {
y := y_.(*Struct)
switch op {
case syntax.EQL:
@@ -418,7 +418,7 @@ func structsEqual(x, y *Struct, depth int) (bool, error) {
return false, nil
}
- if eq, err := skylark.Equal(x.constructor, y.constructor); err != nil {
+ if eq, err := starlark.Equal(x.constructor, y.constructor); err != nil {
return false, fmt.Errorf("error comparing struct constructors %v and %v: %v",
x.constructor, y.constructor, err)
} else if !eq {
@@ -428,7 +428,7 @@ func structsEqual(x, y *Struct, depth int) (bool, error) {
for i, n := 0, x.len(); i < n; i++ {
if x.entries[i].name != y.entries[i].name {
return false, nil
- } else if eq, err := skylark.EqualDepth(x.entries[i].value, y.entries[i].value, depth-1); err != nil {
+ } else if eq, err := starlark.EqualDepth(x.entries[i].value, y.entries[i].value, depth-1); err != nil {
return false, err
} else if !eq {
return false, nil
diff --git a/skylarkstruct/struct_test.go b/starlarkstruct/struct_test.go
index e650093..6df352b 100644
--- a/skylarkstruct/struct_test.go
+++ b/starlarkstruct/struct_test.go
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package skylarkstruct_test
+package starlarkstruct_test
import (
"fmt"
"path/filepath"
"testing"
- "github.com/google/skylark"
- "github.com/google/skylark/resolve"
- "github.com/google/skylark/skylarkstruct"
- "github.com/google/skylark/skylarktest"
+ "github.com/google/starlark"
+ "github.com/google/starlark/resolve"
+ "github.com/google/starlark/starlarkstruct"
+ "github.com/google/starlark/starlarktest"
)
func init() {
@@ -24,16 +24,16 @@ func init() {
}
func Test(t *testing.T) {
- testdata := skylarktest.DataFile("skylark/skylarkstruct", ".")
- thread := &skylark.Thread{Load: load}
- skylarktest.SetReporter(thread, t)
- filename := filepath.Join(testdata, "testdata/struct.sky")
- predeclared := skylark.StringDict{
- "struct": skylark.NewBuiltin("struct", skylarkstruct.Make),
- "gensym": skylark.NewBuiltin("gensym", gensym),
+ testdata := starlarktest.DataFile("starlark/starlarkstruct", ".")
+ thread := &starlark.Thread{Load: load}
+ starlarktest.SetReporter(thread, t)
+ filename := filepath.Join(testdata, "testdata/struct.star")
+ predeclared := starlark.StringDict{
+ "struct": starlark.NewBuiltin("struct", starlarkstruct.Make),
+ "gensym": starlark.NewBuiltin("gensym", gensym),
}
- if _, err := skylark.ExecFile(thread, filename, nil, predeclared); err != nil {
- if err, ok := err.(*skylark.EvalError); ok {
+ if _, err := starlark.ExecFile(thread, filename, nil, predeclared); err != nil {
+ if err, ok := err.(*starlark.EvalError); ok {
t.Fatal(err.Backtrace())
}
t.Fatal(err)
@@ -41,17 +41,17 @@ func Test(t *testing.T) {
}
// load implements the 'load' operation as used in the evaluator tests.
-func load(thread *skylark.Thread, module string) (skylark.StringDict, error) {
- if module == "assert.sky" {
- return skylarktest.LoadAssertModule()
+func load(thread *starlark.Thread, module string) (starlark.StringDict, error) {
+ if module == "assert.star" {
+ return starlarktest.LoadAssertModule()
}
return nil, fmt.Errorf("load not implemented")
}
// gensym is a built-in function that generates a unique symbol.
-func gensym(thread *skylark.Thread, _ *skylark.Builtin, args skylark.Tuple, kwargs []skylark.Tuple) (skylark.Value, error) {
+func gensym(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var name string
- if err := skylark.UnpackArgs("gensym", args, kwargs, "name", &name); err != nil {
+ if err := starlark.UnpackArgs("gensym", args, kwargs, "name", &name); err != nil {
return nil, err
}
return &symbol{name: name}, nil
@@ -61,18 +61,18 @@ func gensym(thread *skylark.Thread, _ *skylark.Builtin, args skylark.Tuple, kwar
// struct instances, like a class symbol in Python or a "provider" in Bazel.
type symbol struct{ name string }
-var _ skylark.Callable = (*symbol)(nil)
+var _ starlark.Callable = (*symbol)(nil)
func (sym *symbol) Name() string { return sym.name }
func (sym *symbol) String() string { return sym.name }
func (sym *symbol) Type() string { return "symbol" }
func (sym *symbol) Freeze() {} // immutable
-func (sym *symbol) Truth() skylark.Bool { return skylark.True }
+func (sym *symbol) Truth() starlark.Bool { return starlark.True }
func (sym *symbol) Hash() (uint32, error) { return 0, fmt.Errorf("unhashable: %s", sym.Type()) }
-func (sym *symbol) CallInternal(thread *skylark.Thread, args skylark.Tuple, kwargs []skylark.Tuple) (skylark.Value, error) {
+func (sym *symbol) CallInternal(thread *starlark.Thread, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
if len(args) > 0 {
return nil, fmt.Errorf("%s: unexpected positional arguments", sym)
}
- return skylarkstruct.FromKeywords(sym, kwargs), nil
+ return starlarkstruct.FromKeywords(sym, kwargs), nil
}
diff --git a/skylarkstruct/testdata/struct.sky b/starlarkstruct/testdata/struct.star
index 88c4cc1..12d2a6f 100644
--- a/skylarkstruct/testdata/struct.sky
+++ b/starlarkstruct/testdata/struct.star
@@ -1,7 +1,7 @@
-# Tests of Skylark 'struct' extension.
-# This is not a standard feature and the Go and Skylark APIs may yet change.
+# Tests of Starlark 'struct' extension.
+# This is not a standard feature and the Go and Starlark APIs may yet change.
-load('assert.sky', 'assert')
+load('assert.star', 'assert')
assert.eq(str(struct), '<built-in function struct>')
diff --git a/skylarktest/assert.sky b/starlarktest/assert.star
index f453aac..f453aac 100644
--- a/skylarktest/assert.sky
+++ b/starlarktest/assert.star
diff --git a/skylarktest/skylarktest.go b/starlarktest/starlarktest.go
index ea714d1..d1d38fe 100644
--- a/skylarktest/skylarktest.go
+++ b/starlarktest/starlarktest.go
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package skylarktest defines utilities for testing Skylark programs.
+// Package starlarktest defines utilities for testing Starlark programs.
//
// Clients can call LoadAssertModule to load a module that defines
-// several functions useful for testing. See assert.sky for its
+// several functions useful for testing. See assert.star for its
// definition.
//
// The assert.error function, which reports errors to the current Go
// testing.T, requires that clients call SetTest(thread, t) before use.
-package skylarktest
+package starlarktest
import (
"bytes"
@@ -20,8 +20,8 @@ import (
"regexp"
"sync"
- "github.com/google/skylark"
- "github.com/google/skylark/skylarkstruct"
+ "github.com/google/starlark"
+ "github.com/google/starlark/starlarkstruct"
)
const localKey = "Reporter"
@@ -33,91 +33,91 @@ type Reporter interface {
}
// SetReporter associates an error reporter (such as a testing.T in
-// a Go test) with the Skylark thread so that Skylark programs may
+// a Go test) with the Starlark thread so that Starlark programs may
// report errors to it.
-func SetReporter(thread *skylark.Thread, r Reporter) {
+func SetReporter(thread *starlark.Thread, r Reporter) {
thread.SetLocal(localKey, r)
}
-// GetReporter returns the Skylark thread's error reporter.
+// GetReporter returns the Starlark thread's error reporter.
// It must be preceded by a call to SetReporter.
-func GetReporter(thread *skylark.Thread) Reporter {
+func GetReporter(thread *starlark.Thread) Reporter {
r, ok := thread.Local(localKey).(Reporter)
if !ok {
- panic("internal error: skylarktest.SetReporter was not called")
+ panic("internal error: starlarktest.SetReporter was not called")
}
return r
}
var (
once sync.Once
- assert skylark.StringDict
+ assert starlark.StringDict
assertErr error
)
// LoadAssertModule loads the assert module.
// It is concurrency-safe and idempotent.
-func LoadAssertModule() (skylark.StringDict, error) {
+func LoadAssertModule() (starlark.StringDict, error) {
once.Do(func() {
- predeclared := skylark.StringDict{
- "error": skylark.NewBuiltin("error", error_),
- "catch": skylark.NewBuiltin("catch", catch),
- "matches": skylark.NewBuiltin("matches", matches),
- "struct": skylark.NewBuiltin("struct", skylarkstruct.Make),
- "_freeze": skylark.NewBuiltin("freeze", freeze),
+ predeclared := starlark.StringDict{
+ "error": starlark.NewBuiltin("error", error_),
+ "catch": starlark.NewBuiltin("catch", catch),
+ "matches": starlark.NewBuiltin("matches", matches),
+ "struct": starlark.NewBuiltin("struct", starlarkstruct.Make),
+ "_freeze": starlark.NewBuiltin("freeze", freeze),
}
- filename := DataFile("skylark/skylarktest", "assert.sky")
- thread := new(skylark.Thread)
- assert, assertErr = skylark.ExecFile(thread, filename, nil, predeclared)
+ filename := DataFile("starlark/starlarktest", "assert.star")
+ thread := new(starlark.Thread)
+ assert, assertErr = starlark.ExecFile(thread, filename, nil, predeclared)
})
return assert, assertErr
}
// catch(f) evaluates f() and returns its evaluation error message
// if it failed or None if it succeeded.
-func catch(thread *skylark.Thread, _ *skylark.Builtin, args skylark.Tuple, kwargs []skylark.Tuple) (skylark.Value, error) {
- var fn skylark.Callable
- if err := skylark.UnpackArgs("catch", args, kwargs, "fn", &fn); err != nil {
+func catch(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
+ var fn starlark.Callable
+ if err := starlark.UnpackArgs("catch", args, kwargs, "fn", &fn); err != nil {
return nil, err
}
- if _, err := skylark.Call(thread, fn, nil, nil); err != nil {
- return skylark.String(err.Error()), nil
+ if _, err := starlark.Call(thread, fn, nil, nil); err != nil {
+ return starlark.String(err.Error()), nil
}
- return skylark.None, nil
+ return starlark.None, nil
}
// matches(pattern, str) reports whether string str matches the regular expression pattern.
-func matches(thread *skylark.Thread, _ *skylark.Builtin, args skylark.Tuple, kwargs []skylark.Tuple) (skylark.Value, error) {
+func matches(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var pattern, str string
- if err := skylark.UnpackArgs("matches", args, kwargs, "pattern", &pattern, "str", &str); err != nil {
+ if err := starlark.UnpackArgs("matches", args, kwargs, "pattern", &pattern, "str", &str); err != nil {
return nil, err
}
ok, err := regexp.MatchString(pattern, str)
if err != nil {
return nil, fmt.Errorf("matches: %s", err)
}
- return skylark.Bool(ok), nil
+ return starlark.Bool(ok), nil
}
// error(x) reports an error to the Go test framework.
-func error_(thread *skylark.Thread, _ *skylark.Builtin, args skylark.Tuple, kwargs []skylark.Tuple) (skylark.Value, error) {
+func error_(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
if len(args) != 1 {
return nil, fmt.Errorf("error: got %d arguments, want 1", len(args))
}
var buf bytes.Buffer
thread.Caller().WriteBacktrace(&buf)
buf.WriteString("Error: ")
- if s, ok := skylark.AsString(args[0]); ok {
+ if s, ok := starlark.AsString(args[0]); ok {
buf.WriteString(s)
} else {
buf.WriteString(args[0].String())
}
GetReporter(thread).Error(buf.String())
- return skylark.None, nil
+ return starlark.None, nil
}
// freeze(x) freezes its operand.
-func freeze(thread *skylark.Thread, _ *skylark.Builtin, args skylark.Tuple, kwargs []skylark.Tuple) (skylark.Value, error) {
+func freeze(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
if len(kwargs) > 0 {
return nil, fmt.Errorf("freeze does not accept keyword arguments")
}
diff --git a/syntax/grammar.txt b/syntax/grammar.txt
index fffc8ad..8c90272 100644
--- a/syntax/grammar.txt
+++ b/syntax/grammar.txt
@@ -1,5 +1,5 @@
-Grammar of Skylark
+Grammar of Starlark
==================
File = {Statement | newline} eof .
diff --git a/syntax/parse.go b/syntax/parse.go
index 2bcc6f2..d8d3b33 100644
--- a/syntax/parse.go
+++ b/syntax/parse.go
@@ -4,8 +4,8 @@
package syntax
-// This file defines a recursive-descent parser for Skylark.
-// The LL(1) grammar of Skylark and the names of many productions follow Python 2.7.
+// This file defines a recursive-descent parser for Starlark.
+// The LL(1) grammar of Starlark and the names of many productions follow Python 2.7.
//
// TODO(adonovan): use syntax.Error more systematically throughout the
// package. Verify that error positions are correct using the
@@ -47,7 +47,7 @@ func Parse(filename string, src interface{}, mode Mode) (f *File, err error) {
return f, nil
}
-// ParseExpr parses a Skylark expression.
+// ParseExpr parses a Starlark expression.
// See Parse for explanation of parameters.
func ParseExpr(filename string, src interface{}, mode Mode) (expr Expr, err error) {
in, err := newScanner(filename, src, mode&RetainComments != 0)
@@ -589,7 +589,7 @@ var precedence [maxToken]int8
// preclevels groups operators of equal precedence.
// Comparisons are nonassociative; other binary operators associate to the left.
// Unary MINUS, unary PLUS, and TILDE have higher precedence so are handled in parsePrimary.
-// See https://github.com/google/skylark/blob/master/doc/spec.md#binary-operators
+// See https://github.com/google/starlark/blob/master/doc/spec.md#binary-operators
var preclevels = [...][]Token{
{OR}, // or
{AND}, // and
diff --git a/syntax/parse_test.go b/syntax/parse_test.go
index bee9388..5c69db3 100644
--- a/syntax/parse_test.go
+++ b/syntax/parse_test.go
@@ -11,9 +11,9 @@ import (
"strings"
"testing"
- "github.com/google/skylark/internal/chunkedfile"
- "github.com/google/skylark/skylarktest"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/internal/chunkedfile"
+ "github.com/google/starlark/starlarktest"
+ "github.com/google/starlark/syntax"
)
func TestExprParseTrees(t *testing.T) {
@@ -105,9 +105,9 @@ func TestExprParseTrees(t *testing.T) {
{`a and not b`,
`(BinaryExpr X=a Op=and Y=(UnaryExpr Op=not X=b))`},
{`[e for x in y if cond1 if cond2]`,
- `(Comprehension Body=e Clauses=((ForClause Vars=x X=y) (IfClause Cond=cond1) (IfClause Cond=cond2)))`}, // github.com/google/skylark issue 53
+ `(Comprehension Body=e Clauses=((ForClause Vars=x X=y) (IfClause Cond=cond1) (IfClause Cond=cond2)))`}, // github.com/google/starlark issue 53
} {
- e, err := syntax.ParseExpr("foo.sky", test.input, 0)
+ e, err := syntax.ParseExpr("foo.star", test.input, 0)
if err != nil {
t.Errorf("parse `%s` failed: %v", test.input, stripPos(err))
continue
@@ -176,7 +176,7 @@ def h():
pass`,
`(DefStmt Name=f Function=(Function Body=((DefStmt Name=g Function=(Function Body=((BranchStmt Token=pass)))) (BranchStmt Token=pass))))`},
} {
- f, err := syntax.Parse("foo.sky", test.input, 0)
+ f, err := syntax.Parse("foo.star", test.input, 0)
if err != nil {
t.Errorf("parse `%s` failed: %v", test.input, stripPos(err))
continue
@@ -225,7 +225,7 @@ pass`,
+ 2`,
`(AssignStmt Op== LHS=x RHS=(BinaryExpr X=1 Op=+ Y=2))`},
} {
- f, err := syntax.Parse("foo.sky", test.input, 0)
+ f, err := syntax.Parse("foo.star", test.input, 0)
if err != nil {
t.Errorf("parse `%s` failed: %v", test.input, stripPos(err))
continue
@@ -332,7 +332,7 @@ func writeTree(out *bytes.Buffer, x reflect.Value) {
}
func TestParseErrors(t *testing.T) {
- filename := skylarktest.DataFile("skylark/syntax", "testdata/errors.sky")
+ filename := starlarktest.DataFile("starlark/syntax", "testdata/errors.star")
for _, chunk := range chunkedfile.Read(filename, t) {
_, err := syntax.Parse(filename, chunk.Source, 0)
switch err := err.(type) {
diff --git a/syntax/quote.go b/syntax/quote.go
index 0a8321a..e08d780 100644
--- a/syntax/quote.go
+++ b/syntax/quote.go
@@ -4,7 +4,7 @@
package syntax
-// Skylark quoted string utilities.
+// Starlark quoted string utilities.
import (
"bytes"
diff --git a/syntax/scan.go b/syntax/scan.go
index d38db8d..0ddb3aa 100644
--- a/syntax/scan.go
+++ b/syntax/scan.go
@@ -4,7 +4,7 @@
package syntax
-// A lexical scanner for Skylark.
+// A lexical scanner for Starlark.
import (
"fmt"
@@ -18,7 +18,7 @@ import (
"unicode/utf8"
)
-// A Token represents a Skylark lexical token.
+// A Token represents a Starlark lexical token.
type Token int8
const (
@@ -798,7 +798,7 @@ func (sc *scanner) scanString(val *tokenValue, quote rune) Token {
}
func (sc *scanner) scanNumber(val *tokenValue, c rune) Token {
- // https://github.com/google/skylark/blob/master/doc/spec.md#lexical-elements
+ // https://github.com/google/starlark/blob/master/doc/spec.md#lexical-elements
//
// Python features not supported:
// - integer literals of >64 bits of precision
diff --git a/syntax/scan_test.go b/syntax/scan_test.go
index dd1c286..14a9308 100644
--- a/syntax/scan_test.go
+++ b/syntax/scan_test.go
@@ -14,7 +14,7 @@ import (
)
func scan(src interface{}) (tokens string, err error) {
- sc, err := newScanner("foo.sky", src, false)
+ sc, err := newScanner("foo.star", src, false)
if err != nil {
return "", err
}
@@ -161,16 +161,16 @@ pass`, "pass newline pass EOF"}, // consecutive newlines are consolidated
// hex
{"0xA", `10 EOF`},
{"0xAAG", `170 G EOF`},
- {"0xG", `foo.sky:1:1: invalid hex literal`},
+ {"0xG", `foo.star:1:1: invalid hex literal`},
{"0XA", `10 EOF`},
- {"0XG", `foo.sky:1:1: invalid hex literal`},
+ {"0XG", `foo.star:1:1: invalid hex literal`},
{"0xA.", `10 . EOF`},
{"0xA.e1", `10 . e1 EOF`},
{"0x12345678deadbeef12345678", `5634002672576678570168178296 EOF`},
// binary
{"0b1010", `10 EOF`},
{"0B111101", `61 EOF`},
- {"0b3", `foo.sky:1:3: invalid binary literal`},
+ {"0b3", `foo.star:1:3: invalid binary literal`},
{"0b1010201", `10 201 EOF`},
{"0b1010.01", `10 1.000000e-02 EOF`},
{"0b0000", `0 EOF`},
@@ -186,14 +186,14 @@ pass`, "pass newline pass EOF"}, // consecutive newlines are consolidated
// TODO(adonovan): reenable later.
// {"0123", `obsolete form of octal literal; use 0o123`},
{"0123", `83 EOF`},
- {"012834", `foo.sky:1:1: invalid int literal`},
- {"012934", `foo.sky:1:1: invalid int literal`},
- {"i = 012934", `foo.sky:1:5: invalid int literal`},
+ {"012834", `foo.star:1:1: invalid int literal`},
+ {"012934", `foo.star:1:1: invalid int literal`},
+ {"i = 012934", `foo.star:1:5: invalid int literal`},
// octal escapes in string literals
{`"\037"`, `"\x1f" EOF`},
{`"\377"`, `"\xff" EOF`},
{`"\378"`, `"\x1f8" EOF`}, // = '\37' + '8'
- {`"\400"`, `foo.sky:1:1: invalid escape sequence \400`}, // unlike Python 2 and 3
+ {`"\400"`, `foo.star:1:1: invalid escape sequence \400`}, // unlike Python 2 and 3
// Backslashes that are not part of escapes are treated literally,
// but this behavior will change; see b/34519173.
{`"\+"`, `"\\+" EOF`},
@@ -205,7 +205,7 @@ pass`, "pass newline pass EOF"}, // consecutive newlines are consolidated
{"0123.", `1.230000e+02 EOF`},
{"0123.1", `1.231000e+02 EOF`},
// issue #16
- {"x ! 0", "foo.sky:1:3: unexpected input character '!'"},
+ {"x ! 0", "foo.star:1:3: unexpected input character '!'"},
} {
got, err := scan(test.input)
if err != nil {
@@ -217,14 +217,14 @@ pass`, "pass newline pass EOF"}, // consecutive newlines are consolidated
}
}
-// dataFile is the same as skylarktest.DataFile.
+// dataFile is the same as starlarktest.DataFile.
// We make a copy to avoid a dependency cycle.
var dataFile = func(pkgdir, filename string) string {
return filepath.Join(build.Default.GOPATH, "src/github.com/google", pkgdir, filename)
}
func BenchmarkScan(b *testing.B) {
- filename := dataFile("skylark/syntax", "testdata/scan.sky")
+ filename := dataFile("starlark/syntax", "testdata/scan.star")
b.StopTimer()
data, err := ioutil.ReadFile(filename)
if err != nil {
diff --git a/syntax/syntax.go b/syntax/syntax.go
index 99548b1..d40d10e 100644
--- a/syntax/syntax.go
+++ b/syntax/syntax.go
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package syntax provides a Skylark parser and abstract syntax tree.
+// Package syntax provides a Starlark parser and abstract syntax tree.
package syntax
-// A Node is a node in a Skylark syntax tree.
+// A Node is a node in a Starlark syntax tree.
type Node interface {
// Span returns the start and end position of the expression.
Span() (start, end Position)
@@ -64,7 +64,7 @@ func End(n Node) Position {
return end
}
-// A File represents a Skylark file.
+// A File represents a Starlark file.
type File struct {
commentsRef
Path string
@@ -84,7 +84,7 @@ func (x *File) Span() (start, end Position) {
return start, end
}
-// A Stmt is a Skylark statement.
+// A Stmt is a Starlark statement.
type Stmt interface {
Node
stmt()
@@ -183,7 +183,7 @@ func (x *IfStmt) Span() (start, end Position) {
// load(Module, "x", y="foo").
//
// The AST is slightly unfaithful to the concrete syntax here because
-// Skylark's load statement, so that it can be implemented in Python,
+// Starlark's load statement, so that it can be implemented in Python,
// binds some names (like y above) with an identifier and some (like x)
// without. For consistency we create fake identifiers for all the
// strings.
@@ -229,7 +229,7 @@ func (x *ReturnStmt) Span() (start, end Position) {
return x.Return, end
}
-// An Expr is a Skylark expression.
+// An Expr is a Starlark expression.
type Expr interface {
Node
expr()
@@ -407,7 +407,7 @@ func (x *DictEntry) Span() (start, end Position) {
// A LambdaExpr represents an inline function abstraction.
//
// Although they may be added in future, lambda expressions are not
-// currently part of the Skylark spec, so their use is controlled by the
+// currently part of the Starlark spec, so their use is controlled by the
// resolver.AllowLambda flag.
type LambdaExpr struct {
commentsRef
diff --git a/syntax/testdata/errors.sky b/syntax/testdata/errors.star
index ff1b49c..558845c 100644
--- a/syntax/testdata/errors.sky
+++ b/syntax/testdata/errors.star
@@ -70,13 +70,13 @@ def f():
pass
---
# This is a well known parsing ambiguity in Python.
-# Python 2.7 accepts it but Python3 and Skylark reject it.
+# Python 2.7 accepts it but Python3 and Starlark reject it.
_ = [x for x in lambda: True, lambda: False if x()] ### "got lambda, want primary"
_ = [x for x in (lambda: True, lambda: False) if x()] # ok in all dialects
---
-# Skylark, following Python 3, allows an unparenthesized
+# Starlark, following Python 3, allows an unparenthesized
# tuple after 'in' only in a for statement but not in a comprehension.
# (Python 2.7 allows both.)
for x in 1, 2, 3:
diff --git a/syntax/testdata/scan.sky b/syntax/testdata/scan.star
index 22b1902..3b87c63 100644
--- a/syntax/testdata/scan.sky
+++ b/syntax/testdata/scan.star
@@ -78,7 +78,7 @@ def go_environment_vars(ctx):
otherwise.
Args:
- The skylark Context.
+ The starlark Context.
Returns:
A dict of environment variables for running Go tool commands that build for
@@ -124,7 +124,7 @@ def _emit_go_asm_action(ctx, source, hdrs, out_obj):
"""Construct the command line for compiling Go Assembly code.
Constructs a symlink tree to accomodate for workspace name.
Args:
- ctx: The skylark Context.
+ ctx: The starlark Context.
source: a source code artifact
hdrs: list of .h files that may be included
out_obj: the artifact (configured target?) that should be produced
@@ -149,7 +149,7 @@ def _go_importpath(ctx):
"""Returns the expected importpath of the go_library being built.
Args:
- ctx: The skylark Context
+ ctx: The starlark Context
Returns:
Go importpath of the library
@@ -174,7 +174,7 @@ def _emit_go_compile_action(ctx, sources, deps, libpaths, out_object, gc_goopts)
"""Construct the command line for compiling Go code.
Args:
- ctx: The skylark Context.
+ ctx: The starlark Context.
sources: an iterable of source code artifacts (or CTs? or labels?)
deps: an iterable of dependencies. Each dependency d should have an
artifact in d.transitive_go_libraries representing all imported libraries.
@@ -215,7 +215,7 @@ def _emit_go_pack_action(ctx, out_lib, objects):
"""Construct the command line for packing objects together.
Args:
- ctx: The skylark Context.
+ ctx: The starlark Context.
out_lib: the archive that should be produced
objects: an iterable of object files to be added to the output archive file.
"""
@@ -232,7 +232,7 @@ def _emit_go_cover_action(ctx, sources):
"""Construct the command line for test coverage instrument.
Args:
- ctx: The skylark Context.
+ ctx: The starlark Context.
sources: an iterable of Go source files.
Returns:
diff --git a/testdata/assign.sky b/testdata/assign.star
index fd87073..99a7e10 100644
--- a/testdata/assign.sky
+++ b/testdata/assign.star
@@ -1,9 +1,9 @@
-# Tests of Skylark assignment.
+# Tests of Starlark assignment.
# This is a "chunked" file: each "---" effectively starts a new file.
# tuple assignment
-load("assert.sky", "assert")
+load("assert.star", "assert")
a, b, c = 1, 2, 3
assert.eq(a, 1)
@@ -23,7 +23,7 @@ assert.fails(f5, "too many values to unpack")
---
# list assignment
-load("assert.sky", "assert")
+load("assert.star", "assert")
[a, b, c] = [1, 2, 3]
assert.eq(a, 1)
@@ -41,7 +41,7 @@ assert.fails(f4, "too few values to unpack")
---
# list-tuple assignment
-load("assert.sky", "assert")
+load("assert.star", "assert")
[a, b, c] = (1, 2, 3)
assert.eq(a, 1)
@@ -67,7 +67,7 @@ assert.eq(n, 4)
---
# misc assignment
-load("assert.sky", "assert")
+load("assert.star", "assert")
def assignment():
a = [1, 2, 3]
@@ -88,7 +88,7 @@ assignment()
---
# augmented assignment
-load("assert.sky", "assert")
+load("assert.star", "assert")
def f():
x = 1
@@ -101,7 +101,7 @@ f()
---
# effects of evaluating LHS occur only once
-load("assert.sky", "assert")
+load("assert.star", "assert")
count = [0] # count[0] is the number of calls to f
@@ -118,7 +118,7 @@ assert.eq(count[0], 1) # f was called only once
---
# Order of evaluation.
-load("assert.sky", "assert")
+load("assert.star", "assert")
calls = []
@@ -161,7 +161,7 @@ def f():
f()
---
-load("assert.sky", "assert")
+load("assert.star", "assert")
printok = [False]
@@ -191,7 +191,7 @@ f()
z += 3 ### "global variable z referenced before assignment"
---
-load("assert.sky", "assert")
+load("assert.star", "assert")
# It's ok to define a global that shadows a built-in...
list = []
@@ -199,14 +199,14 @@ assert.eq(type(list), "list")
# ...but then all uses refer to the global,
# even if they occur before the binding use.
-# See github.com/google/skylark/issues/116.
+# See github.com/google/starlark/issues/116.
assert.fails(lambda: tuple, "global variable tuple referenced before assignment")
tuple = ()
---
# Same as above, but set and float are dialect-specific;
# we shouldn't notice any difference.
-load("assert.sky", "assert")
+load("assert.star", "assert")
float = 1.0
assert.eq(type(float), "float")
@@ -229,7 +229,7 @@ x = [1, 2]
_ = [x for _ in [3] for x in x] ### "local variable x referenced before assignment"
---
-load("assert.sky", "assert")
+load("assert.star", "assert")
# assign singleton sequence to 1-tuple
(x,) = (1,)
@@ -245,7 +245,7 @@ assert.eq(z[0], 1)
---
# assignment to/from fields.
-load("assert.sky", "assert", "freeze")
+load("assert.star", "assert", "freeze")
hf = hasfields()
hf.x = 1
@@ -263,7 +263,7 @@ assert.fails(lambda: setY(hf), "cannot set field on a frozen hasfields")
---
# destucturing assignment in a for loop.
-load("assert.sky", "assert")
+load("assert.star", "assert")
def f():
res = []
diff --git a/testdata/benchmark.sky b/testdata/benchmark.star
index e0d260a..d0fb97e 100644
--- a/testdata/benchmark.sky
+++ b/testdata/benchmark.star
@@ -1,4 +1,4 @@
-# Benchmarks of Skylark execution
+# Benchmarks of Starlark execution
def bench_range():
return range(200)
diff --git a/testdata/bool.sky b/testdata/bool.star
index f6adf06..326f869 100644
--- a/testdata/bool.sky
+++ b/testdata/bool.star
@@ -1,6 +1,6 @@
-# Tests of Skylark 'bool'
+# Tests of Starlark 'bool'
-load("assert.sky", "assert")
+load("assert.star", "assert")
# truth
assert.true(True)
diff --git a/testdata/builtins.sky b/testdata/builtins.star
index 89baecd..58e99c9 100644
--- a/testdata/builtins.sky
+++ b/testdata/builtins.star
@@ -1,6 +1,6 @@
-# Tests of Skylark built-in functions
+# Tests of Starlark built-in functions
-load("assert.sky", "assert")
+load("assert.star", "assert")
# len
assert.eq(len([1, 2, 3]), 3)
diff --git a/testdata/control.sky b/testdata/control.star
index 9affacf..554ab25 100644
--- a/testdata/control.sky
+++ b/testdata/control.star
@@ -1,6 +1,6 @@
-# Tests of Skylark control flow
+# Tests of Starlark control flow
-load("assert.sky", "assert")
+load("assert.star", "assert")
def controlflow():
# elif
diff --git a/testdata/dict.sky b/testdata/dict.star
index e6ec762..4eec1cf 100644
--- a/testdata/dict.sky
+++ b/testdata/dict.star
@@ -1,6 +1,6 @@
-# Tests of Skylark 'dict'
+# Tests of Starlark 'dict'
-load("assert.sky", "assert", "freeze")
+load("assert.star", "assert", "freeze")
# literals
assert.eq({}, {})
diff --git a/testdata/float.sky b/testdata/float.star
index fab9b56..b7ba8fe 100644
--- a/testdata/float.sky
+++ b/testdata/float.star
@@ -1,6 +1,6 @@
-# Tests of Skylark 'float'
+# Tests of Starlark 'float'
-load("assert.sky", "assert")
+load("assert.star", "assert")
# TODO(adonovan): more tests:
# - precision
diff --git a/testdata/function.sky b/testdata/function.star
index fa8c5d6..742ccd8 100644
--- a/testdata/function.sky
+++ b/testdata/function.star
@@ -1,11 +1,11 @@
-# Tests of Skylark 'function'
+# Tests of Starlark 'function'
# TODO(adonovan):
# - add some introspection functions for looking at function values
# and test that functions have correct position, free vars, names of locals, etc.
# - move the hard-coded tests of parameter passing from eval_test.go to here.
-load("assert.sky", "assert", "freeze")
+load("assert.star", "assert", "freeze")
# Test lexical scope and closures:
def outer(x):
@@ -104,7 +104,7 @@ assert.eq(len(hashes), 1)
---
# Default values of function parameters are mutable.
-load("assert.sky", "assert", "freeze")
+load("assert.star", "assert", "freeze")
def f(x=[0]):
return x
@@ -120,7 +120,7 @@ assert.fails(lambda: f().append(2), "cannot append to frozen list")
---
# This is a well known corner case of parsing in Python.
-load("assert.sky", "assert")
+load("assert.star", "assert")
f = lambda x: 1 if x else 0
assert.eq(f(True), 1)
@@ -140,7 +140,7 @@ assert.true(not tf[1]())
# (This tests a corner case of the implementation:
# we avoid a map allocation for <64 parameters)
-load("assert.sky", "assert")
+load("assert.star", "assert")
def f(a, b, c, d, e, f, g, h,
i, j, k, l, m, n, o, p,
@@ -178,7 +178,7 @@ assert.fails(lambda: f(
---
# Regression test for a bug in CALL_VAR_KW.
-load("assert.sky", "assert")
+load("assert.star", "assert")
def f(a, b, x, y):
return a+b+x+y
@@ -186,8 +186,8 @@ def f(a, b, x, y):
assert.eq(f(*("a", "b"), **dict(y="y", x="x")) + ".", 'abxy.')
---
# Order of evaluation of function arguments.
-# Regression test for github.com/google/skylark/issues/135.
-load("assert.sky", "assert")
+# Regression test for github.com/google/starlark/issues/135.
+load("assert.star", "assert")
r = []
@@ -201,7 +201,7 @@ def f(*args, **kwargs):
y = f(id(1), id(2), x=id(3), *[id(4)], y=id(5), **dict(z=id(6)))
assert.eq(y, ((1, 2, 4), dict(x=3, y=5, z=6)))
-# This matches Python2, but not Skylark-in-Java:
+# This matches Python2, but not Starlark-in-Java:
# *args and *kwargs are evaluated last.
# See github.com/bazelbuild/starlark#13 for pending spec change.
assert.eq(r, [1, 2, 3, 5, 4, 6])
diff --git a/testdata/int.sky b/testdata/int.star
index f964c14..52e8af8 100644
--- a/testdata/int.sky
+++ b/testdata/int.star
@@ -1,6 +1,6 @@
-# Tests of Skylark 'int'
+# Tests of Starlark 'int'
-load("assert.sky", "assert")
+load("assert.star", "assert")
# basic arithmetic
assert.eq(0 - 1, -1)
@@ -16,7 +16,7 @@ assert.true(-1)
assert.true(not 0)
# floored division
-# (For real division, see float.sky.)
+# (For real division, see float.star.)
assert.eq(100 // 7, 14)
assert.eq(100 // -7, -15)
assert.eq(-100 // 7, -15) # NB: different from Go/Java
@@ -67,7 +67,7 @@ def compound():
compound()
# int conversion
-# See float.sky for float-to-int conversions.
+# See float.star for float-to-int conversions.
# We follow Python 3 here, but I can't see the method in its madness.
# int from bool/int/float
assert.fails(int, 'missing argument') # int()
@@ -134,7 +134,7 @@ assert.fails(lambda: int("-0123", 0), "invalid literal.*base 0")
# bitwise union (int|int), intersection (int&int), XOR (int^int), unary not (~int),
# left shift (int<<int), and right shift (int>>int).
# use resolve.AllowBitwise to enable the ops.
-# TODO(adonovan): this is not yet in the Skylark spec,
+# TODO(adonovan): this is not yet in the Starlark spec,
# but there is consensus that it should be.
assert.eq(1|2, 3)
assert.eq(3|6, 7)
diff --git a/testdata/list.sky b/testdata/list.star
index fca92de..dd84225 100644
--- a/testdata/list.sky
+++ b/testdata/list.star
@@ -1,6 +1,6 @@
-# Tests of Skylark 'list'
+# Tests of Starlark 'list'
-load("assert.sky", "assert", "freeze")
+load("assert.star", "assert", "freeze")
# literals
assert.eq([], [])
diff --git a/testdata/misc.sky b/testdata/misc.star
index e0b46f7..702026a 100644
--- a/testdata/misc.sky
+++ b/testdata/misc.star
@@ -1,4 +1,4 @@
-# Miscellaneous tests of Skylark evaluation.
+# Miscellaneous tests of Starlark evaluation.
# This is a "chunked" file: each "---" effectively starts a new file.
# TODO(adonovan): move these tests into more appropriate files.
@@ -36,7 +36,7 @@
# tuple slice
# interpolate with %c, %%
-load("assert.sky", "assert")
+load("assert.star", "assert")
# Ordered comparisons require values of the same type.
assert.fails(lambda: None < False, "not impl")
@@ -53,7 +53,7 @@ assert.lt(2.0, 3)
---
# cyclic data structures
-load("assert.sky", "assert")
+load("assert.star", "assert")
cyclic = [1, 2, 3] # list cycle
cyclic[1] = cyclic
@@ -81,7 +81,7 @@ assert.fails(lambda: cyclic5 == cyclic6, "maximum recursion")
---
# regression
-load("assert.sky", "assert")
+load("assert.star", "assert")
# was a parse error:
assert.eq(("ababab"[2:]).replace("b", "c"), "acac")
@@ -100,22 +100,22 @@ _ = {}.get(1, default=2) ### "get: unexpected keyword arguments"
---
# Load exposes explicitly declared globals from other modules.
-load('assert.sky', 'assert', 'freeze')
+load('assert.star', 'assert', 'freeze')
assert.eq(str(freeze), '<built-in function freeze>')
---
# Load does not expose pre-declared globals from other modules.
-# See github.com/google/skylark/issues/75.
-load('assert.sky', 'assert', 'matches') ### "matches not found in module"
+# See github.com/google/starlark/issues/75.
+load('assert.star', 'assert', 'matches') ### "matches not found in module"
---
# Load does not expose universals accessible in other modules.
-load('assert.sky', 'len') ### "len not found in module"
+load('assert.star', 'len') ### "len not found in module"
---
# Test plus folding optimization.
-load('assert.sky', 'assert')
+load('assert.star', 'assert')
s = "s"
l = [4]
diff --git a/testdata/set.sky b/testdata/set.star
index fcaf1fd..6f0957d 100644
--- a/testdata/set.sky
+++ b/testdata/set.star
@@ -1,6 +1,6 @@
-# Tests of Skylark 'set'
+# Tests of Starlark 'set'
-# Sets are not (yet) a standard part of Skylark, so the features
+# Sets are not (yet) a standard part of Starlark, so the features
# tested in this file must be enabled in the application by setting
# resolve.AllowSet. (All sets are created by calls to the 'set'
# built-in or derived from operations on existing sets.)
@@ -14,15 +14,15 @@
# - set += iterable, perhaps?
# Test iterator invalidation.
-load("assert.sky", "assert")
+load("assert.star", "assert")
# literals
# Parser does not currently support {1, 2, 3}.
-# TODO(adonovan): add test to syntax/testdata/errors.sky.
+# TODO(adonovan): add test to syntax/testdata/errors.star.
# set comprehensions
# Parser does not currently support {x for x in y}.
-# See syntax/testdata/errors.sky.
+# See syntax/testdata/errors.star.
# set constructor
assert.eq(type(set()), "set")
diff --git a/testdata/string.sky b/testdata/string.star
index 7325bae..eaec461 100644
--- a/testdata/string.sky
+++ b/testdata/string.star
@@ -1,6 +1,6 @@
-# Tests of Skylark 'string'
+# Tests of Starlark 'string'
-load("assert.sky", "assert")
+load("assert.star", "assert")
# raw string literals:
assert.eq(r'a\bc', "a\\bc")
diff --git a/testdata/tuple.sky b/testdata/tuple.star
index 7038115..547b8ea 100644
--- a/testdata/tuple.sky
+++ b/testdata/tuple.star
@@ -1,6 +1,6 @@
-# Tests of Skylark 'tuple'
+# Tests of Starlark 'tuple'
-load("assert.sky", "assert")
+load("assert.star", "assert")
# literal
assert.eq((), ())
diff --git a/value.go b/value.go
index 131b3e1..01ca0b4 100644
--- a/value.go
+++ b/value.go
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package skylark provides a Skylark interpreter.
+// Package starlark provides a Starlark interpreter.
//
-// Skylark values are represented by the Value interface.
+// Starlark values are represented by the Value interface.
// The following built-in Value types are known to the evaluator:
//
// NoneType -- NoneType
@@ -16,7 +16,7 @@
// Tuple -- tuple
// *Dict -- dict
// *Set -- set
-// *Function -- function (implemented in Skylark)
+// *Function -- function (implemented in Starlark)
// *Builtin -- builtin_function_or_method (function or method implemented in Go)
//
// Client applications may define new data types that satisfy at least
@@ -36,14 +36,14 @@
// HasSetKey -- value supports map update using x[k]=v
//
// Client applications may also define domain-specific functions in Go
-// and make them available to Skylark programs. Use NewBuiltin to
+// and make them available to Starlark programs. Use NewBuiltin to
// construct a built-in value that wraps a Go function. The
// implementation of the Go function may use UnpackArgs to make sense of
// the positional and keyword arguments provided by the caller.
//
-// Skylark's None value is not equal to Go's nil, but nil may be
-// assigned to a Skylark Value. Be careful to avoid allowing Go nil
-// values to leak into Skylark data structures.
+// Starlark's None value is not equal to Go's nil, but nil may be
+// assigned to a Starlark Value. Be careful to avoid allowing Go nil
+// values to leak into Starlark data structures.
//
// The Compare operation requires two arguments of the same
// type, but this constraint cannot be expressed in Go's type system.
@@ -53,17 +53,17 @@
// Use the package's standalone Compare (or Equal) function to compare
// an arbitrary pair of values.
//
-// To parse and evaluate a Skylark source file, use ExecFile. The Eval
+// To parse and evaluate a Starlark source file, use ExecFile. The Eval
// function evaluates a single expression. All evaluator functions
// require a Thread parameter which defines the "thread-local storage"
-// of a Skylark thread and may be used to plumb application state
+// of a Starlark thread and may be used to plumb application state
// through Sklyark code and into callbacks. When evaluation fails it
// returns an EvalError from which the application may obtain a
-// backtrace of active Skylark calls.
+// backtrace of active Starlark calls.
//
-package skylark
+package starlark
-// This file defines the data types of Skylark and their basic operations.
+// This file defines the data types of Starlark and their basic operations.
import (
"bytes"
@@ -75,14 +75,14 @@ import (
"strings"
"unicode/utf8"
- "github.com/google/skylark/internal/compile"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/internal/compile"
+ "github.com/google/starlark/syntax"
)
-// Value is a value in the Skylark interpreter.
+// Value is a value in the Starlark interpreter.
type Value interface {
// String returns the string representation of the value.
- // Skylark string values are quoted as if by Python's repr.
+ // Starlark string values are quoted as if by Python's repr.
String() string
// Type returns a short string describing the value's type.
@@ -93,7 +93,7 @@ type Value interface {
// marked as frozen. All subsequent mutations to the data
// structure through this API will fail dynamically, making the
// data structure immutable and safe for publishing to other
- // Skylark interpreters running concurrently.
+ // Starlark interpreters running concurrently.
Freeze()
// Truth returns the truth value of an object.
@@ -159,7 +159,7 @@ var (
// An Iterable abstracts a sequence of values.
// An iterable value may be iterated over by a 'for' loop or used where
-// any other Skylark iterable is allowed. Unlike a Sequence, the length
+// any other Starlark iterable is allowed. Unlike a Sequence, the length
// of an Iterable is not necessarily known in advance of iteration.
type Iterable interface {
Value
@@ -317,7 +317,7 @@ func (NoneType) CompareSameType(op syntax.Token, y Value, depth int) (bool, erro
return threeway(op, 0), nil
}
-// Bool is the type of a Skylark bool.
+// Bool is the type of a Starlark bool.
type Bool bool
const (
@@ -341,7 +341,7 @@ func (x Bool) CompareSameType(op syntax.Token, y_ Value, depth int) (bool, error
return threeway(op, b2i(bool(x))-b2i(bool(y))), nil
}
-// Float is the type of a Skylark float.
+// Float is the type of a Starlark float.
type Float float64
func (f Float) String() string { return strconv.FormatFloat(float64(f), 'g', 6, 64) }
@@ -401,7 +401,7 @@ func AsFloat(x Value) (f float64, ok bool) {
func (x Float) Mod(y Float) Float { return Float(math.Mod(float64(x), float64(y))) }
-// String is the type of a Skylark string.
+// String is the type of a Starlark string.
//
// A String encapsulates an an immutable sequence of bytes,
// but strings are not directly iterable. Instead, iterate
@@ -409,10 +409,10 @@ func (x Float) Mod(y Float) Float { return Float(math.Mod(float64(x), float64(y)
// codepoints, codepoint_ords, elems, elem_ords.
//
// Warning: the contract of the Value interface's String method is that
-// it returns the value printed in Skylark notation,
+// it returns the value printed in Starlark notation,
// so s.String() or fmt.Sprintf("%s", s) returns a quoted string.
// Use string(s) or s.GoString() or fmt.Sprintf("%#v", s) to obtain the raw contents
-// of a Skylark string as a Go string.
+// of a Starlark string as a Go string.
type String string
func (s String) String() string { return strconv.Quote(string(s)) }
@@ -515,8 +515,8 @@ func (it *stringIterator) Next(p *Value) bool {
func (*stringIterator) Done() {}
-// A Function is a function defined by a Skylark def statement or lambda expression.
-// The initialization behavior of a Skylark module is also represented by a Function.
+// A Function is a function defined by a Starlark def statement or lambda expression.
+// The initialization behavior of a Starlark module is also represented by a Function.
type Function struct {
funcode *compile.Funcode
defaults Tuple
@@ -607,7 +607,7 @@ func (b *Builtin) BindReceiver(recv Value) *Builtin {
return &Builtin{name: b.name, fn: b.fn, recv: recv}
}
-// A *Dict represents a Skylark dictionary.
+// A *Dict represents a Starlark dictionary.
type Dict struct {
ht hashtable
}
@@ -664,7 +664,7 @@ func dictsEqual(x, y *Dict, depth int) (bool, error) {
return true, nil
}
-// A *List represents a Skylark list value.
+// A *List represents a Starlark list value.
type List struct {
elems []Value
frozen bool
@@ -807,7 +807,7 @@ func (l *List) Clear() error {
return nil
}
-// A Tuple represents a Skylark tuple value.
+// A Tuple represents a Starlark tuple value.
type Tuple []Value
func (t Tuple) Len() int { return len(t) }
@@ -868,7 +868,7 @@ func (it *tupleIterator) Next(p *Value) bool {
func (it *tupleIterator) Done() {}
-// A Set represents a Skylark set value.
+// A Set represents a Starlark set value.
type Set struct {
ht hashtable // values are all None
}
@@ -1041,7 +1041,7 @@ func pathContains(path []Value, x Value) bool {
const maxdepth = 10
-// Equal reports whether two Skylark values are equal.
+// Equal reports whether two Starlark values are equal.
func Equal(x, y Value) (bool, error) {
if x, ok := x.(String); ok {
return x == y, nil // fast path for an important special case
@@ -1049,7 +1049,7 @@ func Equal(x, y Value) (bool, error) {
return EqualDepth(x, y, maxdepth)
}
-// EqualDepth reports whether two Skylark values are equal.
+// EqualDepth reports whether two Starlark values are equal.
//
// Recursive comparisons by implementations of Value.CompareSameType
// should use EqualDepth to prevent infinite recursion.
@@ -1057,7 +1057,7 @@ func EqualDepth(x, y Value, depth int) (bool, error) {
return CompareDepth(syntax.EQL, x, y, depth)
}
-// Compare compares two Skylark values.
+// Compare compares two Starlark values.
// The comparison operation must be one of EQL, NEQ, LT, LE, GT, or GE.
// Compare returns an error if an ordered comparison was
// requested for a type that does not support it.
@@ -1068,7 +1068,7 @@ func Compare(op syntax.Token, x, y Value) (bool, error) {
return CompareDepth(op, x, y, maxdepth)
}
-// CompareDepth compares two Skylark values.
+// CompareDepth compares two Starlark values.
// The comparison operation must be one of EQL, NEQ, LT, LE, GT, or GE.
// CompareDepth returns an error if an ordered comparison was
// requested for a pair of values that do not support it.
diff --git a/value_test.go b/value_test.go
index b1fddae..45cd09a 100644
--- a/value_test.go
+++ b/value_test.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package skylark_test
+package starlark_test
// This file defines tests of the Value API.
@@ -10,11 +10,11 @@ import (
"fmt"
"testing"
- "github.com/google/skylark"
+ "github.com/google/starlark"
)
func TestStringMethod(t *testing.T) {
- s := skylark.String("hello")
+ s := starlark.String("hello")
for i, test := range [][2]string{
// quoted string:
{s.String(), `"hello"`},
@@ -34,11 +34,11 @@ func TestStringMethod(t *testing.T) {
}
func TestListAppend(t *testing.T) {
- l := skylark.NewList(nil)
- l.Append(skylark.String("hello"))
- res, ok := skylark.AsString(l.Index(0))
+ l := starlark.NewList(nil)
+ l.Append(starlark.String("hello"))
+ res, ok := starlark.AsString(l.Index(0))
if !ok {
- t.Errorf("failed list.Append() got: %s, want: skylark.String", l.Index(0).Type())
+ t.Errorf("failed list.Append() got: %s, want: starlark.String", l.Index(0).Type())
}
if res != "hello" {
t.Errorf("failed list.Append() got: %+v, want: hello", res)