github.com/google/skylark@v0.0.0-20181101142754-a5f7082aabed/README.md (about) 1 2 <!-- This file is the project homepage at github.com/google/skylark --> 3 4 # Skylark in Go 5 6 **Skylark is now called Starlark. The project has moved to [go.starlark.net](https://go.starlark.net).** 7 8 9 This is the home of the _Skylark in Go_ project. 10 Skylark in Go is an interpreter for Skylark, implemented in Go. 11 12 Skylark is a dialect of Python intended for use as a configuration language. 13 Like Python, it is an untyped dynamic language with high-level data 14 types, first-class functions with lexical scope, and garbage collection. 15 Unlike CPython, independent Skylark threads execute in parallel, so 16 Skylark workloads scale well on parallel machines. 17 Skylark is a small and simple language with a familiar and highly 18 readable syntax. You can use it as an expressive notation for 19 structured data, defining functions to eliminate repetition, or you 20 can use it to add scripting capabilities to an existing application. 21 22 A Skylark interpreter is typically embedded within a larger 23 application, and the application may define additional domain-specific 24 functions and data types beyond those provided by the core language. 25 For example, Skylark was originally developed for the 26 [Bazel build tool](https://bazel.build). 27 Bazel uses Skylark as the notation both for its BUILD files (like 28 Makefiles, these declare the executables, libraries, and tests in a 29 directory) and for [its macro 30 language](https://docs.bazel.build/versions/master/skylark/language.html), 31 through which Bazel is extended with custom logic to support new 32 languages and compilers. 33 34 35 ## Documentation 36 37 * Language definition: [doc/spec.md](doc/spec.md) 38 39 * About the Go implementation: [doc/impl.md](doc/impl.md) 40 41 * API documentation: [godoc.org/github.com/google/skylark](https://godoc.org/github.com/google/skylark) 42 43 * Mailing list: [skylark-go](https://groups.google.com/forum/#!forum/skylark-go) 44 45 * Issue tracker: [https://github.com/google/skylark/issues](https://github.com/google/skylark/issues) 46 47 * Travis CI:  [https://travis-ci.org/google/skylark](https://travis-ci.org/google/skylark) 48 49 ### Getting started 50 51 Build the code: 52 53 ```shell 54 $ go get github.com/google/skylark/... 55 $ go build github.com/google/skylark/cmd/skylark 56 ``` 57 58 Run the interpreter: 59 60 ``` 61 $ cat coins.sky 62 coins = { 63 'dime': 10, 64 'nickel': 5, 65 'penny': 1, 66 'quarter': 25, 67 } 68 print('By name:\t' + ', '.join(sorted(coins.keys()))) 69 print('By value:\t' + ', '.join(sorted(coins.keys(), key=coins.get))) 70 71 $ ./skylark coins.sky 72 By name: dime, nickel, penny, quarter 73 By value: penny, nickel, dime, quarter 74 ``` 75 76 Interact with the read-eval-print loop (REPL): 77 78 ``` 79 $ ./skylark 80 >>> def fibonacci(n): 81 ... res = list(range(n)) 82 ... for i in res[2:]: 83 ... res[i] = res[i-2] + res[i-1] 84 ... return res 85 ... 86 >>> fibonacci(10) 87 [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] 88 >>> 89 ``` 90 91 When you have finished, type `Ctrl-D` to close the REPL's input stream. 92 93 ### Contributing 94 95 We welcome submissions but please let us know what you're working on 96 if you want to change or add to the Skylark repository. 97 98 Before undertaking to write something new for the Skylark project, 99 please file an issue or claim an existing issue. 100 All significant changes to the language or to the interpreter's Go 101 API must be discussed before they can be accepted. 102 This gives all participants a chance to validate the design and to 103 avoid duplication of effort. 104 105 Despite some differences, the Go implementation of Skylark strives to 106 match the behavior of the Java implementation used by Bazel. 107 For that reason, proposals to change the language itself should 108 generally be directed to the Bazel team, not to the maintainers of 109 this project. 110 Only once there is consensus that a language change is desirable may 111 its Go implementation proceed. 112 113 We use GitHub pull requests for contributions. 114 115 Please complete Google's contributor license agreement (CLA) before 116 sending your first change to the project. If you are the copyright 117 holder, you will need to agree to the 118 [individual contributor license agreement](https://cla.developers.google.com/about/google-individual), 119 which can be completed online. 120 If your organization is the copyright holder, the organization will 121 need to agree to the [corporate contributor license agreement](https://cla.developers.google.com/about/google-corporate). 122 If the copyright holder for your contribution has already completed 123 the agreement in connection with another Google open source project, 124 it does not need to be completed again. 125 126 ### Stability 127 128 We reserve the right to make breaking language and API changes at this 129 stage in the project, although we will endeavor to keep them to a minimum. 130 Now that the project's long-term name ("Starlark") has been decided, 131 we plan to copy this repository to github.com/google/starlark and 132 change the canonical import path for all packages to starlark.net/starlark. 133 The current github.com/google/skylark repository will be frozen. 134 Once the Bazel team has finalized the version 1 language specification, 135 we will be more rigorous with interface stability. 136 137 ### Credits 138 139 Skylark was designed and implemented in Java by 140 Ulf Adams, 141 Lukács Berki, 142 Jon Brandvein, 143 John Field, 144 Laurent Le Brun, 145 Dmitry Lomov, 146 Damien Martin-Guillerez, 147 Vladimir Moskva, and 148 Florian Weikert, 149 standing on the shoulders of the Python community. 150 The Go implementation was written by Alan Donovan and Jay Conrod; 151 its scanner was derived from one written by Russ Cox. 152 153 ### Legal 154 155 Skylark in Go is Copyright (c) 2017 The Bazel Authors. 156 All rights reserved. 157 158 It is provided under a 3-clause BSD license: 159 [LICENSE](https://github.com/google/skylark/blob/master/LICENSE). 160 161 The name "Skylark" is a code name of the Bazel project. 162 The Bazel team plans to rename the language to "Starlark" to reflect its 163 applicability to projects unrelated to Bazel. 164 165 Skylark in Go is not an official Google product.