aboutsummaryrefslogtreecommitdiff
path: root/syntax
diff options
context:
space:
mode:
authorAlan Donovan <adonovan@google.com>2018-10-23 11:05:09 -0400
committerAlan Donovan <adonovan@google.com>2018-10-23 11:05:09 -0400
commite3deafefac22db7bfd4877d37614fe5db4b03881 (patch)
treee3de93e8b63abffb95767055fb392714cc8cc8a1 /syntax
parentce5c2fa1ad6a8fa4beb4eacdbd3bf9997162d144 (diff)
downloadstarlark-go-e3deafefac22db7bfd4877d37614fe5db4b03881.tar.gz
rename skylark -> starlark
Change-Id: Iebd0e040ff674b2f9da39bf5242c8afaa7f4ddc8
Diffstat (limited to 'syntax')
-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
9 files changed, 43 insertions, 43 deletions
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: