diff --git a/.gitignore b/.gitignore index b539d0d978..e8aa172a77 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ test/acs-engine-test/acs-engine-test.exe pkg/operations/junit.xml pkg/operations/kubernetesupgrade/junit.xml pkg/acsengine/templates.go +pkg/i18n/translations.go diff --git a/Dockerfile b/Dockerfile index 2dc54e42d4..3441e2d172 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM buildpack-deps:xenial RUN apt-get update \ && apt-get -y upgrade \ - && apt-get -y install python-pip make build-essential curl openssl vim jq \ + && apt-get -y install python-pip make build-essential curl openssl vim jq gettext \ && rm -rf /var/lib/apt/lists/* ENV GO_VERSION 1.8 @@ -34,6 +34,10 @@ RUN git clone https://github.com/akesterson/cmdarg.git /tmp/cmdarg \ RUN git clone https://github.com/akesterson/shunit.git /tmp/shunit \ && cd /tmp/shunit && make install && rm -rf /tmp/shunit +# Go tool for internationalization and localization +RUN go get github.com/JiangtianLi/gettext/... \ + && go install github.com/JiangtianLi/gettext/... + # Used by some CI jobs ADD ./test/bootstrap/checkout-pr.sh /tmp/checkout-pr.sh diff --git a/cmd/deploy.go b/cmd/deploy.go index 591dff74e9..ab34d50bd3 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -9,6 +9,7 @@ import ( "time" log "github.com/Sirupsen/logrus" + "github.com/leonelquinteros/gotext" "github.com/spf13/cobra" "encoding/json" @@ -16,6 +17,7 @@ import ( "github.com/Azure/acs-engine/pkg/acsengine" "github.com/Azure/acs-engine/pkg/api" "github.com/Azure/acs-engine/pkg/armhelpers" + "github.com/Azure/acs-engine/pkg/i18n" ) const ( @@ -40,6 +42,7 @@ type deployCmd struct { // derived containerService *api.ContainerService apiVersion string + locale *gotext.Locale client armhelpers.ACSEngineClient resourceGroup string @@ -78,6 +81,11 @@ func newDeployCmd() *cobra.Command { func (dc *deployCmd) validate(cmd *cobra.Command, args []string) { var err error + dc.locale, err = i18n.LoadTranslations() + if err != nil { + log.Fatalf("error loading translation files: %s", err.Error()) + } + if dc.apimodelPath == "" { if len(args) > 0 { dc.apimodelPath = args[0] @@ -94,8 +102,13 @@ func (dc *deployCmd) validate(cmd *cobra.Command, args []string) { log.Fatalf("specified api model does not exist (%s)", dc.apimodelPath) } + apiloader := &api.Apiloader{ + Translator: &i18n.Translator{ + Locale: dc.locale, + }, + } // skip validating the model fields for now - dc.containerService, dc.apiVersion, err = api.LoadContainerServiceFromFile(dc.apimodelPath, false) + dc.containerService, dc.apiVersion, err = apiloader.LoadContainerServiceFromFile(dc.apimodelPath, false) if err != nil { log.Fatalf("error parsing the api model: %s", err.Error()) } @@ -112,7 +125,7 @@ func (dc *deployCmd) validate(cmd *cobra.Command, args []string) { // autofillApimodel calls log.Fatal() directly and does not return errors autofillApimodel(dc) - _, _, err = revalidateApimodel(dc.containerService, dc.apiVersion) + _, _, err = revalidateApimodel(apiloader, dc.containerService, dc.apiVersion) if err != nil { log.Fatalf("Failed to validate the apimodel after populating values: %s", err) } @@ -162,7 +175,12 @@ func autofillApimodel(dc *deployCmd) { if dc.containerService.Properties.LinuxProfile.SSH.PublicKeys == nil || len(dc.containerService.Properties.LinuxProfile.SSH.PublicKeys) == 0 || dc.containerService.Properties.LinuxProfile.SSH.PublicKeys[0].KeyData == "" { - _, publicKey, err := acsengine.CreateSaveSSH(dc.containerService.Properties.LinuxProfile.AdminUsername, dc.outputDirectory) + creator := &acsengine.SSHCreator{ + Translator: &i18n.Translator{ + Locale: dc.locale, + }, + } + _, publicKey, err := creator.CreateSaveSSH(dc.containerService.Properties.LinuxProfile.AdminUsername, dc.outputDirectory) if err != nil { log.Fatal("Failed to generate SSH Key") } @@ -211,17 +229,23 @@ func autofillApimodel(dc *deployCmd) { } } -func revalidateApimodel(containerService *api.ContainerService, apiVersion string) (*api.ContainerService, string, error) { +func revalidateApimodel(apiloader *api.Apiloader, containerService *api.ContainerService, apiVersion string) (*api.ContainerService, string, error) { // This isn't terribly elegant, but it's the easiest way to go for now w/o duplicating a bunch of code - rawVersionedAPIModel, err := api.SerializeContainerService(containerService, apiVersion) + rawVersionedAPIModel, err := apiloader.SerializeContainerService(containerService, apiVersion) if err != nil { return nil, "", err } - return api.DeserializeContainerService(rawVersionedAPIModel, true) + return apiloader.DeserializeContainerService(rawVersionedAPIModel, true) } func (dc *deployCmd) run() error { - templateGenerator, err := acsengine.InitializeTemplateGenerator(dc.classicMode) + ctx := acsengine.Context{ + Translator: &i18n.Translator{ + Locale: dc.locale, + }, + } + + templateGenerator, err := acsengine.InitializeTemplateGenerator(ctx, dc.classicMode) if err != nil { log.Fatalln("failed to initialize template generator: %s", err.Error()) } @@ -240,7 +264,12 @@ func (dc *deployCmd) run() error { log.Fatalf("error pretty printing template parameters: %s \n", err.Error()) } - if err = acsengine.WriteTLSArtifacts(dc.containerService, dc.apiVersion, template, parametersFile, dc.outputDirectory, certsgenerated, dc.parametersOnly); err != nil { + writer := &acsengine.ArtifactWriter{ + Translator: &i18n.Translator{ + Locale: dc.locale, + }, + } + if err = writer.WriteTLSArtifacts(dc.containerService, dc.apiVersion, template, parametersFile, dc.outputDirectory, certsgenerated, dc.parametersOnly); err != nil { log.Fatalf("error writing artifacts: %s \n", err.Error()) } diff --git a/cmd/deploy_test.go b/cmd/deploy_test.go index b455f2019e..436f6fe1c2 100644 --- a/cmd/deploy_test.go +++ b/cmd/deploy_test.go @@ -47,8 +47,12 @@ func TestAutofillApimodelAllowsPrespecifiedCreds(t *testing.T) { } func testAutodeployCredentialHandling(t *testing.T, useManagedIdentity bool, clientID, clientSecret string) { + apiloader := &api.Apiloader{ + Translator: nil, + } + apimodel := getExampleAPIModel(useManagedIdentity, clientID, clientSecret) - cs, ver, err := api.DeserializeContainerService([]byte(apimodel), false) + cs, ver, err := apiloader.DeserializeContainerService([]byte(apimodel), false) if err != nil { t.Fatalf("unexpected error deserializing the example apimodel: %s", err) } @@ -73,7 +77,7 @@ func testAutodeployCredentialHandling(t *testing.T, useManagedIdentity bool, cli // cleanup, since auto-populations creates dirs and saves the SSH private key that it might create defer os.RemoveAll(deployCmd.outputDirectory) - cs, _, err = revalidateApimodel(cs, ver) + cs, _, err = revalidateApimodel(apiloader, cs, ver) if err != nil { log.Fatalf("unexpected error validating apimodel after populating defaults: %s", err) } diff --git a/cmd/generate.go b/cmd/generate.go index 0972878b45..fca9d964ee 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -7,7 +7,9 @@ import ( "github.com/Azure/acs-engine/pkg/acsengine" "github.com/Azure/acs-engine/pkg/api" + "github.com/Azure/acs-engine/pkg/i18n" log "github.com/Sirupsen/logrus" + "github.com/leonelquinteros/gotext" "github.com/spf13/cobra" ) @@ -29,6 +31,7 @@ type generateCmd struct { // derived containerService *api.ContainerService apiVersion string + locale *gotext.Locale } func newGenerateCmd() *cobra.Command { @@ -61,6 +64,11 @@ func (gc *generateCmd) validate(cmd *cobra.Command, args []string) { var caKeyBytes []byte var err error + gc.locale, err = i18n.LoadTranslations() + if err != nil { + log.Fatalf("error loading translation files: %s", err.Error()) + } + if gc.apimodelPath == "" { if len(args) > 0 { gc.apimodelPath = args[0] @@ -77,7 +85,12 @@ func (gc *generateCmd) validate(cmd *cobra.Command, args []string) { log.Fatalf("specified api model does not exist (%s)", gc.apimodelPath) } - gc.containerService, gc.apiVersion, err = api.LoadContainerServiceFromFile(gc.apimodelPath, true) + apiloader := &api.Apiloader{ + Translator: &i18n.Translator{ + Locale: gc.locale, + }, + } + gc.containerService, gc.apiVersion, err = apiloader.LoadContainerServiceFromFile(gc.apimodelPath, true) if err != nil { log.Fatalf("error parsing the api model: %s", err.Error()) } @@ -111,7 +124,12 @@ func (gc *generateCmd) validate(cmd *cobra.Command, args []string) { func (gc *generateCmd) run() error { log.Infoln("Generating assets...") - templateGenerator, err := acsengine.InitializeTemplateGenerator(gc.classicMode) + ctx := acsengine.Context{ + Translator: &i18n.Translator{ + Locale: gc.locale, + }, + } + templateGenerator, err := acsengine.InitializeTemplateGenerator(ctx, gc.classicMode) if err != nil { log.Fatalln("failed to initialize template generator: %s", err.Error()) } @@ -131,7 +149,12 @@ func (gc *generateCmd) run() error { } } - if err = acsengine.WriteTLSArtifacts(gc.containerService, gc.apiVersion, template, parameters, gc.outputDirectory, certsGenerated, gc.parametersOnly); err != nil { + writer := &acsengine.ArtifactWriter{ + Translator: &i18n.Translator{ + Locale: gc.locale, + }, + } + if err = writer.WriteTLSArtifacts(gc.containerService, gc.apiVersion, template, parameters, gc.outputDirectory, certsGenerated, gc.parametersOnly); err != nil { log.Fatalf("error writing artifacts: %s \n", err.Error()) } diff --git a/cmd/upgrade.go b/cmd/upgrade.go index 5f100accb1..31aebb5706 100644 --- a/cmd/upgrade.go +++ b/cmd/upgrade.go @@ -9,7 +9,9 @@ import ( "github.com/Azure/acs-engine/pkg/api" "github.com/Azure/acs-engine/pkg/armhelpers" + "github.com/Azure/acs-engine/pkg/i18n" "github.com/Azure/acs-engine/pkg/operations/kubernetesupgrade" + "github.com/leonelquinteros/gotext" log "github.com/Sirupsen/logrus" "github.com/spf13/cobra" @@ -35,6 +37,7 @@ type upgradeCmd struct { upgradeContainerService *api.UpgradeContainerService upgradeAPIVersion string client armhelpers.ACSEngineClient + locale *gotext.Locale nameSuffix string } @@ -65,6 +68,11 @@ func (uc *upgradeCmd) validate(cmd *cobra.Command, args []string) { var err error + uc.locale, err = i18n.LoadTranslations() + if err != nil { + log.Fatalf("error loading translation files: %s", err.Error()) + } + if uc.resourceGroupName == "" { cmd.Usage() log.Fatal("--resource-group must be specified") @@ -92,7 +100,12 @@ func (uc *upgradeCmd) validate(cmd *cobra.Command, args []string) { log.Fatalf("specified api model does not exist (%s)", apiModelPath) } - uc.containerService, uc.apiVersion, err = api.LoadContainerServiceFromFile(apiModelPath, true) + apiloader := &api.Apiloader{ + Translator: &i18n.Translator{ + Locale: uc.locale, + }, + } + uc.containerService, uc.apiVersion, err = apiloader.LoadContainerServiceFromFile(apiModelPath, true) if err != nil { log.Fatalf("error parsing the api model: %s", err.Error()) } @@ -101,7 +114,12 @@ func (uc *upgradeCmd) validate(cmd *cobra.Command, args []string) { log.Fatalf("specified upgrade model file does not exist (%s)", uc.upgradeModelFile) } - uc.upgradeContainerService, uc.upgradeAPIVersion, err = api.LoadUpgradeContainerServiceFromFile(uc.upgradeModelFile) + upgradeapiloader := &api.UpgradeApiloader{ + Translator: &i18n.Translator{ + Locale: uc.locale, + }, + } + uc.upgradeContainerService, uc.upgradeAPIVersion, err = upgradeapiloader.LoadUpgradeContainerServiceFromFile(uc.upgradeModelFile) if err != nil { log.Fatalf("error parsing the upgrade api model: %s", err.Error()) } @@ -134,6 +152,9 @@ func (uc *upgradeCmd) run(cmd *cobra.Command, args []string) error { uc.validate(cmd, args) upgradeCluster := kubernetesupgrade.UpgradeCluster{ + Translator: &i18n.Translator{ + Locale: uc.locale, + }, Client: uc.client, } diff --git a/glide.lock b/glide.lock index f61e52e3f2..e8712c6a23 100644 --- a/glide.lock +++ b/glide.lock @@ -36,6 +36,14 @@ imports: version: b32fa301c9fe55953584134cb6853a13c87ec0a1 - name: github.com/inconshreveable/mousetrap version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 +- name: github.com/leonelquinteros/gotext + version: a735812a72672008b3902f8b2bc1302166a9a8ea +- name: github.com/mattn/anko + version: a8c68fa2983e7dd5d3472992b1fbe2f7c44261f0 + subpackages: + - ast + - parser + - vm - name: github.com/mitchellh/go-homedir version: b8bc1bf767474819792c23f32d8286a45736f1c6 - name: github.com/prometheus/common diff --git a/glide.yaml b/glide.yaml index 52af75adce..fc3b82d5dc 100644 --- a/glide.yaml +++ b/glide.yaml @@ -32,6 +32,8 @@ import: - package: github.com/spf13/cobra version: 4cdb38c072b86bf795d2c81de50784d9fdd6eb77 - package: github.com/spf13/pflag +- package: github.com/leonelquinteros/gotext + version: v1.1.1 version: e57e3eeb33f795204c1ca35f56c44f83227c6e66 - package: gopkg.in/go-playground/validator.v9 version: v9.4.0 diff --git a/pkg/acsengine/engine.go b/pkg/acsengine/engine.go index 09a124559b..2158b311d7 100644 --- a/pkg/acsengine/engine.go +++ b/pkg/acsengine/engine.go @@ -16,6 +16,7 @@ import ( "text/template" "github.com/Azure/acs-engine/pkg/api" + "github.com/Azure/acs-engine/pkg/i18n" "github.com/ghodss/yaml" ) @@ -193,7 +194,7 @@ func (t *TemplateGenerator) verifyFiles() error { allFiles = append(allFiles, swarmTemplateFiles...) for _, file := range allFiles { if _, err := Asset(file); err != nil { - return fmt.Errorf("template file %s does not exist", file) + return t.Translator.Errorf("template file %s does not exist", file) } } return nil @@ -202,12 +203,14 @@ func (t *TemplateGenerator) verifyFiles() error { // TemplateGenerator represents the object that performs the template generation. type TemplateGenerator struct { ClassicMode bool + Translator *i18n.Translator } // InitializeTemplateGenerator creates a new template generator object -func InitializeTemplateGenerator(classicMode bool) (*TemplateGenerator, error) { +func InitializeTemplateGenerator(ctx Context, classicMode bool) (*TemplateGenerator, error) { t := &TemplateGenerator{ ClassicMode: classicMode, + Translator: ctx.Translator, } if err := t.verifyFiles(); err != nil { @@ -234,7 +237,7 @@ func (t *TemplateGenerator) GenerateTemplate(containerService *api.ContainerServ templ = template.New("acs template").Funcs(t.getTemplateFuncMap(containerService)) - files, baseFile, e := prepareTemplateFiles(properties) + files, baseFile, e := t.prepareTemplateFiles(properties) if e != nil { return "", "", false, e } @@ -242,7 +245,7 @@ func (t *TemplateGenerator) GenerateTemplate(containerService *api.ContainerServ for _, file := range files { bytes, e := Asset(file) if e != nil { - err = fmt.Errorf("Error reading file %s, Error: %s", file, e.Error()) + err = t.Translator.Errorf("Error reading file %s, Error: %s", file, e.Error()) return templateRaw, parametersRaw, certsGenerated, err } if _, err = templ.New(file).Parse(string(bytes)); err != nil { @@ -309,7 +312,7 @@ func GenerateKubeConfig(properties *api.Properties, location string) (string, er return kubeconfig, nil } -func prepareTemplateFiles(properties *api.Properties) ([]string, string, error) { +func (t *TemplateGenerator) prepareTemplateFiles(properties *api.Properties) ([]string, string, error) { var files []string var baseFile string if properties.OrchestratorProfile.OrchestratorType == api.DCOS { @@ -325,7 +328,7 @@ func prepareTemplateFiles(properties *api.Properties) ([]string, string, error) files = append(commonTemplateFiles, swarmModeTemplateFiles...) baseFile = swarmBaseFile } else { - return nil, "", fmt.Errorf("orchestrator '%s' is unsupported", properties.OrchestratorProfile.OrchestratorType) + return nil, "", t.Translator.Errorf("orchestrator '%s' is unsupported", properties.OrchestratorProfile.OrchestratorType) } return files, baseFile, nil @@ -1209,18 +1212,18 @@ func getSecurityRules(ports []int) string { func (t *TemplateGenerator) getSingleLineForTemplate(textFilename string, cs *api.ContainerService, profile interface{}) (string, error) { b, err := Asset(textFilename) if err != nil { - return "", fmt.Errorf("yaml file %s does not exist", textFilename) + return "", t.Translator.Errorf("yaml file %s does not exist", textFilename) } // use go templates to process the text filename templ := template.New("customdata template").Funcs(t.getTemplateFuncMap(cs)) if _, err = templ.New(textFilename).Parse(string(b)); err != nil { - return "", fmt.Errorf("error parsing file %s: %v", textFilename, err) + return "", t.Translator.Errorf("error parsing file %s: %v", textFilename, err) } var buffer bytes.Buffer if err = templ.ExecuteTemplate(&buffer, textFilename, profile); err != nil { - return "", fmt.Errorf("error executing template for file %s: %v", textFilename, err) + return "", t.Translator.Errorf("error executing template for file %s: %v", textFilename, err) } expandedTemplate := buffer.String() diff --git a/pkg/acsengine/engine_test.go b/pkg/acsengine/engine_test.go index 7271d49128..3e98331aba 100644 --- a/pkg/acsengine/engine_test.go +++ b/pkg/acsengine/engine_test.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "io/ioutil" + "path" "path/filepath" "strings" "testing" @@ -11,6 +12,8 @@ import ( "github.com/Azure/acs-engine/pkg/api" "github.com/Azure/acs-engine/pkg/api/v20160330" "github.com/Azure/acs-engine/pkg/api/vlabs" + "github.com/Azure/acs-engine/pkg/i18n" + "github.com/leonelquinteros/gotext" . "github.com/onsi/gomega" ) @@ -19,6 +22,15 @@ const ( ) func TestExpected(t *testing.T) { + // Initialize locale for translation + locale := gotext.NewLocale(path.Join("..", "..", "translations"), "en_US") + i18n.Initialize(locale) + + apiloader := &api.Apiloader{ + Translator: &i18n.Translator{ + Locale: locale, + }, + } // iterate the test data directory apiModelTestFiles := &[]APIModelTestFile{} if e := IterateTestFilesDirectory(TestDataDir, apiModelTestFiles); e != nil { @@ -27,7 +39,7 @@ func TestExpected(t *testing.T) { } for _, tuple := range *apiModelTestFiles { - containerService, version, err := api.LoadContainerServiceFromFile(tuple.APIModelFilename, true) + containerService, version, err := apiloader.LoadContainerServiceFromFile(tuple.APIModelFilename, true) if err != nil { t.Errorf("Loading file %s got error: %s", tuple.APIModelFilename, err.Error()) continue @@ -51,7 +63,12 @@ func TestExpected(t *testing.T) { // 1. first time tests loaded containerService // 2. second time tests generated containerService // 3. third time tests the generated containerService from the generated containerService - templateGenerator, e3 := InitializeTemplateGenerator(isClassicMode) + ctx := Context{ + Translator: &i18n.Translator{ + Locale: locale, + }, + } + templateGenerator, e3 := InitializeTemplateGenerator(ctx, isClassicMode) if e3 != nil { t.Error(e3.Error()) continue @@ -118,11 +135,11 @@ func TestExpected(t *testing.T) { t.Errorf("generated parameters different from expected for model %s: '%s'", tuple.APIModelFilename, diffstr) } - b, err := api.SerializeContainerService(containerService, version) + b, err := apiloader.SerializeContainerService(containerService, version) if err != nil { t.Error(err) } - containerService, version, err = api.DeserializeContainerService(b, true) + containerService, version, err = apiloader.DeserializeContainerService(b, true) if err != nil { t.Error(err) } diff --git a/pkg/acsengine/filesaver.go b/pkg/acsengine/filesaver.go new file mode 100644 index 0000000000..049fb784fb --- /dev/null +++ b/pkg/acsengine/filesaver.go @@ -0,0 +1,38 @@ +package acsengine + +import ( + "io/ioutil" + "os" + "path" + + "github.com/Azure/acs-engine/pkg/i18n" + log "github.com/Sirupsen/logrus" +) + +// FileSaver represents the object that save string or byte data to file +type FileSaver struct { + Translator *i18n.Translator +} + +// SaveFileString saves string to file +func (f *FileSaver) SaveFileString(dir string, file string, data string) error { + return f.SaveFile(dir, file, []byte(data)) +} + +// SaveFile saves binary data to file +func (f *FileSaver) SaveFile(dir string, file string, data []byte) error { + if _, err := os.Stat(dir); os.IsNotExist(err) { + if e := os.MkdirAll(dir, 0700); e != nil { + return f.Translator.Errorf("error creating directory '%s': %s", dir, e.Error()) + } + } + + path := path.Join(dir, file) + if err := ioutil.WriteFile(path, []byte(data), 0600); err != nil { + return err + } + + log.Debugf("output: wrote %s", path) + + return nil +} diff --git a/pkg/acsengine/output.go b/pkg/acsengine/output.go index c0d5e096d0..ef4d6df4a1 100644 --- a/pkg/acsengine/output.go +++ b/pkg/acsengine/output.go @@ -2,41 +2,51 @@ package acsengine import ( "fmt" - "io/ioutil" - "os" "path" "github.com/Azure/acs-engine/pkg/api" - log "github.com/Sirupsen/logrus" + "github.com/Azure/acs-engine/pkg/i18n" ) +// ArtifactWriter represents the object that writes artifacts +type ArtifactWriter struct { + Translator *i18n.Translator +} + // WriteTLSArtifacts saves TLS certificates and keys to the server filesystem -func WriteTLSArtifacts(containerService *api.ContainerService, apiVersion, template, parameters, artifactsDir string, certsGenerated bool, parametersOnly bool) error { +func (w *ArtifactWriter) WriteTLSArtifacts(containerService *api.ContainerService, apiVersion, template, parameters, artifactsDir string, certsGenerated bool, parametersOnly bool) error { if len(artifactsDir) == 0 { artifactsDir = fmt.Sprintf("%s-%s", containerService.Properties.OrchestratorProfile.OrchestratorType, GenerateClusterID(containerService.Properties)) artifactsDir = path.Join("_output", artifactsDir) } + f := &FileSaver{ + Translator: w.Translator, + } + // convert back the API object, and write it var b []byte var err error if !parametersOnly { - b, err = api.SerializeContainerService(containerService, apiVersion) + apiloader := &api.Apiloader{ + Translator: w.Translator, + } + b, err = apiloader.SerializeContainerService(containerService, apiVersion) if err != nil { return err } - if e := saveFile(artifactsDir, "apimodel.json", b); e != nil { + if e := f.SaveFile(artifactsDir, "apimodel.json", b); e != nil { return e } - if e := saveFileString(artifactsDir, "azuredeploy.json", template); e != nil { + if e := f.SaveFileString(artifactsDir, "azuredeploy.json", template); e != nil { return e } } - if e := saveFileString(artifactsDir, "azuredeploy.parameters.json", parameters); e != nil { + if e := f.SaveFileString(artifactsDir, "azuredeploy.parameters.json", parameters); e != nil { return e } @@ -56,59 +66,38 @@ func WriteTLSArtifacts(containerService *api.ContainerService, apiVersion, templ if gkcerr != nil { return gkcerr } - if e := saveFileString(directory, fmt.Sprintf("kubeconfig.%s.json", location), b); e != nil { + if e := f.SaveFileString(directory, fmt.Sprintf("kubeconfig.%s.json", location), b); e != nil { return e } } } - if e := saveFileString(artifactsDir, "ca.key", properties.CertificateProfile.CaPrivateKey); e != nil { + if e := f.SaveFileString(artifactsDir, "ca.key", properties.CertificateProfile.CaPrivateKey); e != nil { return e } - if e := saveFileString(artifactsDir, "ca.crt", properties.CertificateProfile.CaCertificate); e != nil { + if e := f.SaveFileString(artifactsDir, "ca.crt", properties.CertificateProfile.CaCertificate); e != nil { return e } - if e := saveFileString(artifactsDir, "apiserver.key", properties.CertificateProfile.APIServerPrivateKey); e != nil { + if e := f.SaveFileString(artifactsDir, "apiserver.key", properties.CertificateProfile.APIServerPrivateKey); e != nil { return e } - if e := saveFileString(artifactsDir, "apiserver.crt", properties.CertificateProfile.APIServerCertificate); e != nil { + if e := f.SaveFileString(artifactsDir, "apiserver.crt", properties.CertificateProfile.APIServerCertificate); e != nil { return e } - if e := saveFileString(artifactsDir, "client.key", properties.CertificateProfile.ClientPrivateKey); e != nil { + if e := f.SaveFileString(artifactsDir, "client.key", properties.CertificateProfile.ClientPrivateKey); e != nil { return e } - if e := saveFileString(artifactsDir, "client.crt", properties.CertificateProfile.ClientCertificate); e != nil { + if e := f.SaveFileString(artifactsDir, "client.crt", properties.CertificateProfile.ClientCertificate); e != nil { return e } - if e := saveFileString(artifactsDir, "kubectlClient.key", properties.CertificateProfile.KubeConfigPrivateKey); e != nil { + if e := f.SaveFileString(artifactsDir, "kubectlClient.key", properties.CertificateProfile.KubeConfigPrivateKey); e != nil { return e } - if e := saveFileString(artifactsDir, "kubectlClient.crt", properties.CertificateProfile.KubeConfigCertificate); e != nil { + if e := f.SaveFileString(artifactsDir, "kubectlClient.crt", properties.CertificateProfile.KubeConfigCertificate); e != nil { return e } } return nil } - -func saveFileString(dir string, file string, data string) error { - return saveFile(dir, file, []byte(data)) -} - -func saveFile(dir string, file string, data []byte) error { - if _, err := os.Stat(dir); os.IsNotExist(err) { - if e := os.MkdirAll(dir, 0700); e != nil { - return fmt.Errorf("error creating directory '%s': %s", dir, e.Error()) - } - } - - path := path.Join(dir, file) - if err := ioutil.WriteFile(path, []byte(data), 0600); err != nil { - return err - } - - log.Debugf("output: wrote %s", path) - - return nil -} diff --git a/pkg/acsengine/ssh.go b/pkg/acsengine/ssh.go index f5a6f9ee88..1e000be206 100644 --- a/pkg/acsengine/ssh.go +++ b/pkg/acsengine/ssh.go @@ -6,25 +6,35 @@ import ( "fmt" "io" + "github.com/Azure/acs-engine/pkg/i18n" log "github.com/Sirupsen/logrus" "golang.org/x/crypto/ssh" ) +// SSHCreator represents the object that creates SSH key pair +type SSHCreator struct { + Translator *i18n.Translator +} + const ( // SSHKeySize is the size (in bytes) of SSH key to create SSHKeySize = 4096 ) // CreateSaveSSH generates and stashes an SSH key pair. -func CreateSaveSSH(username, outputDirectory string) (privateKey *rsa.PrivateKey, publicKeyString string, err error) { - privateKey, publicKeyString, err = CreateSSH(rand.Reader) +func (s *SSHCreator) CreateSaveSSH(username, outputDirectory string) (privateKey *rsa.PrivateKey, publicKeyString string, err error) { + privateKey, publicKeyString, err = s.CreateSSH(rand.Reader) if err != nil { return nil, "", err } privateKeyPem := privateKeyToPem(privateKey) - err = saveFile(outputDirectory, fmt.Sprintf("%s_rsa", username), privateKeyPem) + f := &FileSaver{ + Translator: s.Translator, + } + + err = f.SaveFile(outputDirectory, fmt.Sprintf("%s_rsa", username), privateKeyPem) if err != nil { return nil, "", err } @@ -33,17 +43,17 @@ func CreateSaveSSH(username, outputDirectory string) (privateKey *rsa.PrivateKey } // CreateSSH creates an SSH key pair. -func CreateSSH(rg io.Reader) (privateKey *rsa.PrivateKey, publicKeyString string, err error) { +func (s *SSHCreator) CreateSSH(rg io.Reader) (privateKey *rsa.PrivateKey, publicKeyString string, err error) { log.Debugf("ssh: generating %dbit rsa key", SSHKeySize) privateKey, err = rsa.GenerateKey(rg, SSHKeySize) if err != nil { - return nil, "", fmt.Errorf("failed to generate private key for ssh: %q", err) + return nil, "", s.Translator.Errorf("failed to generate private key for ssh: %q", err) } publicKey := privateKey.PublicKey sshPublicKey, err := ssh.NewPublicKey(&publicKey) if err != nil { - return nil, "", fmt.Errorf("failed to create openssh public key string: %q", err) + return nil, "", s.Translator.Errorf("failed to create openssh public key string: %q", err) } authorizedKeyBytes := ssh.MarshalAuthorizedKey(sshPublicKey) authorizedKey := string(authorizedKeyBytes) diff --git a/pkg/acsengine/ssh_test.go b/pkg/acsengine/ssh_test.go index 2ce7a4b36e..4c6a1c740a 100644 --- a/pkg/acsengine/ssh_test.go +++ b/pkg/acsengine/ssh_test.go @@ -63,7 +63,11 @@ EPDesL0rH+3s1CKpgkhYdbJ675GFoGoq+X21QaqsdvoXmmuJF9qq9Tq+JaWloUNq -----END RSA PRIVATE KEY----- ` - privateKey, publicKey, err := CreateSSH(rg) + creator := &SSHCreator{ + Translator: nil, + } + + privateKey, publicKey, err := creator.CreateSSH(rg) if err != nil { t.Fatalf("failed to generate SSH: %s", err) } diff --git a/pkg/acsengine/transform.go b/pkg/acsengine/transform.go index 0b780543c2..e18e103608 100644 --- a/pkg/acsengine/transform.go +++ b/pkg/acsengine/transform.go @@ -5,6 +5,7 @@ import ( "log" "strings" + "github.com/Azure/acs-engine/pkg/i18n" "github.com/Azure/azure-sdk-for-go/arm/compute" "github.com/Sirupsen/logrus" ) @@ -35,9 +36,14 @@ const ( vmExtensionType = "Microsoft.Compute/virtualMachines/extensions" ) +// Transformer represents the object that transforms template +type Transformer struct { + Translator *i18n.Translator +} + // NormalizeForVMSSScaling takes a template and removes elements that are unwanted in a VMSS scale up/down case -func NormalizeForVMSSScaling(logger *logrus.Entry, templateMap map[string]interface{}) error { - if err := NormalizeMasterResourcesForScaling(logger, templateMap); err != nil { +func (t *Transformer) NormalizeForVMSSScaling(logger *logrus.Entry, templateMap map[string]interface{}) error { + if err := t.NormalizeMasterResourcesForScaling(logger, templateMap); err != nil { return err } @@ -66,7 +72,7 @@ func NormalizeForVMSSScaling(logger *logrus.Entry, templateMap map[string]interf continue } - if !removeCustomData(logger, virtualMachineProfile) || !removeImageReference(logger, virtualMachineProfile) { + if !t.removeCustomData(logger, virtualMachineProfile) || !t.removeImageReference(logger, virtualMachineProfile) { continue } } @@ -74,8 +80,8 @@ func NormalizeForVMSSScaling(logger *logrus.Entry, templateMap map[string]interf } // NormalizeForK8sVMASScalingUp takes a template and removes elements that are unwanted in a K8s VMAS scale up/down case -func NormalizeForK8sVMASScalingUp(logger *logrus.Entry, templateMap map[string]interface{}) error { - if err := NormalizeMasterResourcesForScaling(logger, templateMap); err != nil { +func (t *Transformer) NormalizeForK8sVMASScalingUp(logger *logrus.Entry, templateMap map[string]interface{}) error { + if err := t.NormalizeMasterResourcesForScaling(logger, templateMap); err != nil { return err } nsgIndex := -1 @@ -90,7 +96,7 @@ func NormalizeForK8sVMASScalingUp(logger *logrus.Entry, templateMap map[string]i resourceType, ok := resourceMap[typeFieldName].(string) if ok && resourceType == nsgResourceType { if nsgIndex != -1 { - err := fmt.Errorf("Found 2 resources with type %s in the template. There should only be 1", nsgResourceType) + err := t.Translator.Errorf("Found 2 resources with type %s in the template. There should only be 1", nsgResourceType) logger.Errorf(err.Error()) return err } @@ -113,7 +119,7 @@ func NormalizeForK8sVMASScalingUp(logger *logrus.Entry, templateMap map[string]i resourceMap[dependsOnFieldName] = dependencies } if nsgIndex == -1 { - err := fmt.Errorf("Found no resources with type %s in the template. There should have been 1", nsgResourceType) + err := t.Translator.Errorf("Found no resources with type %s in the template. There should have been 1", nsgResourceType) logger.Errorf(err.Error()) return err } @@ -124,7 +130,7 @@ func NormalizeForK8sVMASScalingUp(logger *logrus.Entry, templateMap map[string]i } // NormalizeMasterResourcesForScaling takes a template and removes elements that are unwanted in any scale up/down case -func NormalizeMasterResourcesForScaling(logger *logrus.Entry, templateMap map[string]interface{}) error { +func (t *Transformer) NormalizeMasterResourcesForScaling(logger *logrus.Entry, templateMap map[string]interface{}) error { resources := templateMap[resourcesFieldName].([]interface{}) //update master nodes resources for _, resource := range resources { @@ -166,7 +172,7 @@ func NormalizeMasterResourcesForScaling(logger *logrus.Entry, templateMap map[st delete(hardwareProfile, vmSizeFieldName) } - if !removeCustomData(logger, resourceProperties) || !removeImageReference(logger, resourceProperties) { + if !t.removeCustomData(logger, resourceProperties) || !t.removeImageReference(logger, resourceProperties) { continue } } @@ -174,7 +180,7 @@ func NormalizeMasterResourcesForScaling(logger *logrus.Entry, templateMap map[st return nil } -func removeCustomData(logger *logrus.Entry, resourceProperties map[string]interface{}) bool { +func (t *Transformer) removeCustomData(logger *logrus.Entry, resourceProperties map[string]interface{}) bool { osProfile, ok := resourceProperties[osProfileFieldName].(map[string]interface{}) if !ok { logger.Warnf("Template improperly formatted") @@ -187,7 +193,7 @@ func removeCustomData(logger *logrus.Entry, resourceProperties map[string]interf return ok } -func removeImageReference(logger *logrus.Entry, resourceProperties map[string]interface{}) bool { +func (t *Transformer) removeImageReference(logger *logrus.Entry, resourceProperties map[string]interface{}) bool { storageProfile, ok := resourceProperties[storageProfileFieldName].(map[string]interface{}) if !ok { logger.Warnf("Template improperly formatted. Could not find: %s", storageProfileFieldName) @@ -201,7 +207,7 @@ func removeImageReference(logger *logrus.Entry, resourceProperties map[string]in } // NormalizeResourcesForK8sMasterUpgrade takes a template and removes elements that are unwanted in any scale up/down case -func NormalizeResourcesForK8sMasterUpgrade(logger *logrus.Entry, templateMap map[string]interface{}, isMasterManagedDisk bool, agentPoolsToPreserve map[string]bool) error { +func (t *Transformer) NormalizeResourcesForK8sMasterUpgrade(logger *logrus.Entry, templateMap map[string]interface{}, isMasterManagedDisk bool, agentPoolsToPreserve map[string]bool) error { resources := templateMap[resourcesFieldName].([]interface{}) logger.Infoln(fmt.Sprintf("Resource count before running NormalizeResourcesForK8sMasterUpgrade: %d", len(resources))) @@ -309,15 +315,15 @@ func NormalizeResourcesForK8sMasterUpgrade(logger *logrus.Entry, templateMap map } // NormalizeResourcesForK8sAgentUpgrade takes a template and removes elements that are unwanted in any scale up/down case -func NormalizeResourcesForK8sAgentUpgrade(logger *logrus.Entry, templateMap map[string]interface{}, isMasterManagedDisk bool, agentPoolsToPreserve map[string]bool) error { +func (t *Transformer) NormalizeResourcesForK8sAgentUpgrade(logger *logrus.Entry, templateMap map[string]interface{}, isMasterManagedDisk bool, agentPoolsToPreserve map[string]bool) error { logger.Infoln(fmt.Sprintf("Running NormalizeResourcesForK8sMasterUpgrade....")) - if err := NormalizeResourcesForK8sMasterUpgrade(logger, templateMap, isMasterManagedDisk, agentPoolsToPreserve); err != nil { + if err := t.NormalizeResourcesForK8sMasterUpgrade(logger, templateMap, isMasterManagedDisk, agentPoolsToPreserve); err != nil { log.Fatalln(err) return err } logger.Infoln(fmt.Sprintf("Running NormalizeForK8sVMASScalingUp....")) - if err := NormalizeForK8sVMASScalingUp(logger, templateMap); err != nil { + if err := t.NormalizeForK8sVMASScalingUp(logger, templateMap); err != nil { log.Fatalln(err) return err } diff --git a/pkg/acsengine/transform_test.go b/pkg/acsengine/transform_test.go index 53d0397e29..d158f068c5 100644 --- a/pkg/acsengine/transform_test.go +++ b/pkg/acsengine/transform_test.go @@ -6,8 +6,10 @@ import ( "encoding/json" "fmt" "io/ioutil" + "os" "testing" + "github.com/Azure/acs-engine/pkg/i18n" "github.com/Sirupsen/logrus" . "github.com/onsi/gomega" ) @@ -55,9 +57,17 @@ func TestNormalizeResourcesForK8sMasterUpgrade(t *testing.T) { var template interface{} json.Unmarshal([]byte(templateJSON), &template) templateMap := template.(map[string]interface{}) - e = NormalizeResourcesForK8sMasterUpgrade(logger, templateMap) + locale, _ := i18n.LoadTranslations() + transformer := &Transformer{ + Translator: i18n.Translator{ + Locale: locale, + }, + } + e = transformer.NormalizeResourcesForK8sMasterUpgrade(logger, templateMap) Expect(e).To(BeNil()) ValidateTemplate(templateMap, expectedFileContents, "k8sVMASTemplate") + // Clean up + os.RemoveAll("./translations") } func TestNormalizeResourcesForK8sAgentUpgrade(t *testing.T) { @@ -71,9 +81,17 @@ func TestNormalizeResourcesForK8sAgentUpgrade(t *testing.T) { var template interface{} json.Unmarshal([]byte(templateJSON), &template) templateMap := template.(map[string]interface{}) - e = NormalizeResourcesForK8sAgentUpgrade(logger, templateMap) + locale, _ := i18n.LoadTranslations() + transformer := &Transformer{ + Translator: i18n.Translator{ + Locale: locale, + }, + } + e = transformer.NormalizeResourcesForK8sAgentUpgrade(logger, templateMap) Expect(e).To(BeNil()) ValidateTemplate(templateMap, expectedFileContents, "k8sVMASTemplate") + // Clean up + os.RemoveAll("./translations") } func ValidateTemplate(templateMap map[string]interface{}, expectedFileContents []byte, testFileName string) { diff --git a/pkg/acsengine/types.go b/pkg/acsengine/types.go index b572014fe8..9267fd3d3c 100644 --- a/pkg/acsengine/types.go +++ b/pkg/acsengine/types.go @@ -4,6 +4,7 @@ import ( "github.com/Azure/acs-engine/pkg/api" "github.com/Azure/acs-engine/pkg/api/v20160330" "github.com/Azure/acs-engine/pkg/api/vlabs" + "github.com/Azure/acs-engine/pkg/i18n" ) // DCOSNodeType represents the type of DCOS Node @@ -52,3 +53,8 @@ type AzureEnvironmentSpecConfig struct { KubernetesSpecConfig KubernetesSpecConfig DCOSSpecConfig DCOSSpecConfig } + +// Context represents the object that is passed to the package +type Context struct { + Translator *i18n.Translator +} diff --git a/pkg/api/apiloader.go b/pkg/api/apiloader.go index c0d7833077..ff3f611a8d 100644 --- a/pkg/api/apiloader.go +++ b/pkg/api/apiloader.go @@ -2,7 +2,6 @@ package api import ( "encoding/json" - "fmt" "io/ioutil" "github.com/Azure/acs-engine/pkg/api/v20160330" @@ -10,31 +9,37 @@ import ( "github.com/Azure/acs-engine/pkg/api/v20170131" "github.com/Azure/acs-engine/pkg/api/v20170701" "github.com/Azure/acs-engine/pkg/api/vlabs" + "github.com/Azure/acs-engine/pkg/i18n" ) +// Apiloader represents the object that loads api model +type Apiloader struct { + Translator *i18n.Translator +} + // LoadContainerServiceFromFile loads an ACS Cluster API Model from a JSON file -func LoadContainerServiceFromFile(jsonFile string, validate bool) (*ContainerService, string, error) { +func (a *Apiloader) LoadContainerServiceFromFile(jsonFile string, validate bool) (*ContainerService, string, error) { contents, e := ioutil.ReadFile(jsonFile) if e != nil { - return nil, "", fmt.Errorf("error reading file %s: %s", jsonFile, e.Error()) + return nil, "", a.Translator.Errorf("error reading file %s: %s", jsonFile, e.Error()) } - return DeserializeContainerService(contents, validate) + return a.DeserializeContainerService(contents, validate) } // DeserializeContainerService loads an ACS Cluster API Model, validates it, and returns the unversioned representation -func DeserializeContainerService(contents []byte, validate bool) (*ContainerService, string, error) { +func (a *Apiloader) DeserializeContainerService(contents []byte, validate bool) (*ContainerService, string, error) { m := &TypeMeta{} if err := json.Unmarshal(contents, &m); err != nil { return nil, "", err } version := m.APIVersion - service, err := LoadContainerService(contents, version, validate) + service, err := a.LoadContainerService(contents, version, validate) return service, version, err } // LoadContainerService loads an ACS Cluster API Model, validates it, and returns the unversioned representation -func LoadContainerService(contents []byte, version string, validate bool) (*ContainerService, error) { +func (a *Apiloader) LoadContainerService(contents []byte, version string, validate bool) (*ContainerService, error) { switch version { case v20160930.APIVersion: containerService := &v20160930.ContainerService{} @@ -90,12 +95,12 @@ func LoadContainerService(contents []byte, version string, validate bool) (*Cont return ConvertVLabsContainerService(containerService), nil default: - return nil, fmt.Errorf("unrecognized APIVersion '%s'", version) + return nil, a.Translator.Errorf("unrecognized APIVersion '%s'", version) } } // SerializeContainerService takes an unversioned container service and returns the bytes -func SerializeContainerService(containerService *ContainerService, version string) ([]byte, error) { +func (a *Apiloader) SerializeContainerService(containerService *ContainerService, version string) ([]byte, error) { switch version { case v20160930.APIVersion: v20160930ContainerService := ConvertContainerServiceToV20160930(containerService) @@ -153,7 +158,7 @@ func SerializeContainerService(containerService *ContainerService, version strin return b, nil default: - return nil, fmt.Errorf("invalid version %s for conversion back from unversioned object", version) + return nil, a.Translator.Errorf("invalid version %s for conversion back from unversioned object", version) } } diff --git a/pkg/api/types_test.go b/pkg/api/types_test.go index 52f0742372..6c99662194 100644 --- a/pkg/api/types_test.go +++ b/pkg/api/types_test.go @@ -45,7 +45,10 @@ func TestIsDCOS(t *testing.T) { func TestCustomHyperkubeImageField(t *testing.T) { log.Println(exampleAPIModel) - apimodel, _, err := DeserializeContainerService([]byte(exampleAPIModel), false) + apiloader := &Apiloader{ + Translator: nil, + } + apimodel, _, err := apiloader.DeserializeContainerService([]byte(exampleAPIModel), false) if err != nil { t.Fatalf("unexpectedly error deserializing the example apimodel: %s", err) } diff --git a/pkg/api/upgradeapiloader.go b/pkg/api/upgradeapiloader.go index 46dc645546..4c857cef51 100644 --- a/pkg/api/upgradeapiloader.go +++ b/pkg/api/upgradeapiloader.go @@ -2,35 +2,40 @@ package api import ( "encoding/json" - "fmt" "io/ioutil" "github.com/Azure/acs-engine/pkg/api/vlabs" + "github.com/Azure/acs-engine/pkg/i18n" ) +// UpgradeApiloader represents the object that loads api model +type UpgradeApiloader struct { + Translator *i18n.Translator +} + // LoadUpgradeContainerServiceFromFile loads an ACS Cluster API Model from a JSON file -func LoadUpgradeContainerServiceFromFile(jsonFile string) (*UpgradeContainerService, string, error) { +func (ua *UpgradeApiloader) LoadUpgradeContainerServiceFromFile(jsonFile string) (*UpgradeContainerService, string, error) { contents, e := ioutil.ReadFile(jsonFile) if e != nil { - return nil, "", fmt.Errorf("error reading file %s: %s", jsonFile, e.Error()) + return nil, "", ua.Translator.Errorf("error reading file %s: %s", jsonFile, e.Error()) } - return DeserializeUpgradeContainerService(contents) + return ua.DeserializeUpgradeContainerService(contents) } // DeserializeUpgradeContainerService loads an ACS Cluster API Model, validates it, and returns the unversioned representation -func DeserializeUpgradeContainerService(contents []byte) (*UpgradeContainerService, string, error) { +func (ua *UpgradeApiloader) DeserializeUpgradeContainerService(contents []byte) (*UpgradeContainerService, string, error) { m := &TypeMeta{} if err := json.Unmarshal(contents, &m); err != nil { return nil, "", err } version := m.APIVersion - upgradecontainerservice, err := LoadUpgradeContainerService(contents, version) + upgradecontainerservice, err := ua.LoadUpgradeContainerService(contents, version) return upgradecontainerservice, version, err } // LoadUpgradeContainerService loads an ACS Cluster API Model, validates it, and returns the unversioned representation -func LoadUpgradeContainerService(contents []byte, version string) (*UpgradeContainerService, error) { +func (ua *UpgradeApiloader) LoadUpgradeContainerService(contents []byte, version string) (*UpgradeContainerService, error) { switch version { case vlabs.APIVersion: upgradecontainerService := &vlabs.UpgradeContainerService{} @@ -43,12 +48,12 @@ func LoadUpgradeContainerService(contents []byte, version string) (*UpgradeConta return ConvertVLabsUpgradeContainerService(upgradecontainerService), nil default: - return nil, fmt.Errorf("unrecognized APIVersion '%s'", version) + return nil, ua.Translator.Errorf("unrecognized APIVersion '%s'", version) } } // SerializeUpgradeContainerService takes an unversioned container service and returns the bytes -func SerializeUpgradeContainerService(upgradeContainerService *UpgradeContainerService, version string) ([]byte, error) { +func (ua *UpgradeApiloader) SerializeUpgradeContainerService(upgradeContainerService *UpgradeContainerService, version string) ([]byte, error) { switch version { case vlabs.APIVersion: vlabsUpgradeContainerService := ConvertUpgradeContainerServiceToVLabs(upgradeContainerService) @@ -62,6 +67,6 @@ func SerializeUpgradeContainerService(upgradeContainerService *UpgradeContainerS return b, nil default: - return nil, fmt.Errorf("invalid version %s for conversion back from unversioned object", version) + return nil, ua.Translator.Errorf("invalid version %s for conversion back from unversioned object", version) } } diff --git a/pkg/i18n/README.md b/pkg/i18n/README.md new file mode 100644 index 0000000000..5ff5dd1592 --- /dev/null +++ b/pkg/i18n/README.md @@ -0,0 +1,25 @@ +# Translation and Internationalization in acs-engine +The translation process in acs-engine borrows some approach from [Kubernetes translation](https://github.com/kubernetes/kubernetes/tree/master/translations). +The strings to be localized are mainly the error message strings under `pkg` directory. Those error message strings are also consumed by other components such as ACS RP. + +The localization in acs-engine depends on github.com/leonelquinteros/gotext, a GNU gettext utility for Go. The package supports concurrency in translating strings in multiple goroutines, e.g., the same acs-engine API called from multiple requests at the same time. + +The translation files containing resource strings are packaged into acs-engine binary using go-bindata. At runtime, the translation files are recreated on disk in the same directory as acs-engine binary, for gotext to load. + +## How to add new string to be localized +When a new error string needs to be localized, it needs to use translation function Errorf in `pkg/i18n/i18n.go`. The locale is passed to acs-engine API from acs-engine command or any other component calls it. If the locale is nil, then it falls back to en-us as in the Go source file. + +Once the Go source file is modified, `scripts/update-translation.sh` needs to be run to extract the resource strings. The script generates PO file according to the locale specified. An example of running the script is: +``` +scripts/update-translation.sh -l en_US -p +``` + +`poedit` is a common tool for translation. After the PO files are translated, MO files can be generated by either `poedit` or tool such as `msgfmt`. Both PO file and MO file need to be placed under `translations//LC_MESSAGES/`. + +## How to add a new language +When the resource strings need to be translated into a new language, the following steps are needed: +``` +1. Use scripts/update-translation.sh with the language to genreate PO file +2. Translate the PO file and generate MO file. +3. Place PO file and MO file under `translations//LC_MESSAGES/` and commit +``` diff --git a/pkg/i18n/i18n.go b/pkg/i18n/i18n.go new file mode 100644 index 0000000000..2295567ac5 --- /dev/null +++ b/pkg/i18n/i18n.go @@ -0,0 +1,136 @@ +package i18n + +import ( + "errors" + "fmt" + "io/ioutil" + "os" + "strings" + + "path" + + "github.com/leonelquinteros/gotext" +) + +const ( + defaultLanguage = "default" + defaultDomain = "acsengine" + defaultLocalDir = "translations" + defaultMessageDir = "LC_MESSAGES" +) + +var supportedTranslations = map[string]bool{ + defaultLanguage: true, + "en_US": true, + "zh_CN": true, +} + +func loadSystemLanguage() string { + language := os.Getenv("LANG") + if language == "" { + return defaultLanguage + } + + // Posix locale name usually has the ll_CC.encoding syntax. + parts := strings.Split(language, ".") + if len(parts) == 0 { + return defaultLanguage + } + if _, ok := supportedTranslations[parts[0]]; ok { + return parts[0] + } + return defaultLanguage +} + +// LoadTranslations loads translation files and sets the locale to +// the system locale. It should be called by the main program. +func LoadTranslations() (*gotext.Locale, error) { + lang := loadSystemLanguage() + SetLanguage(lang) + + dir := path.Join(defaultLocalDir, lang, defaultMessageDir) + translationFiles := []string{ + path.Join(dir, fmt.Sprintf("%s.mo", defaultDomain)), + path.Join(dir, fmt.Sprintf("%s.po", defaultDomain)), + } + + if _, err := os.Stat(dir); os.IsNotExist(err) { + if err := os.MkdirAll(dir, 0700); err != nil { + return nil, err + } + } + + for _, file := range translationFiles { + if _, err := os.Stat(file); os.IsNotExist(err) { + data, err := Asset(file) + if err != nil { + return nil, err + } + err = ioutil.WriteFile(file, data, 0600) + if err != nil { + return nil, err + } + } + } + + locale := gotext.NewLocale(defaultLocalDir, lang) + Initialize(locale) + + return locale, nil +} + +// Initialize is the translation initialization function shared by the main program and package. +func Initialize(locale *gotext.Locale) error { + if locale == nil { + return fmt.Errorf("Initialize expected locale but got nil") + } + locale.AddDomain(defaultDomain) + return nil +} + +// SetLanguage sets the program's current locale. If the language is not +// supported, then the default locale is used. +func SetLanguage(language string) { + if _, ok := supportedTranslations[language]; ok { + gotext.SetLanguage(language) + return + } + gotext.SetLanguage(defaultLanguage) +} + +// GetLanguage queries the program's current locale. +func GetLanguage() string { + return gotext.GetLanguage() +} + +// Translator is a wrapper over gotext's Locale and provides interface to +// translate text string and produce translated error +type Translator struct { + Locale *gotext.Locale +} + +// T translates a text string, based on GNU's gettext library. +func (t *Translator) T(msgid string, vars ...interface{}) string { + if t.Locale == nil { + return fmt.Sprintf(msgid, vars...) + } + return t.Locale.GetD(defaultDomain, msgid, vars...) +} + +// NT translates a text string into the appropriate plural form, based on GNU's gettext library. +func (t *Translator) NT(msgid, msgidPlural string, n int, vars ...interface{}) string { + if t.Locale == nil { + return fmt.Sprintf(msgidPlural, vars...) + } + return t.Locale.GetND(defaultDomain, msgid, msgidPlural, n, vars...) +} + +// Errorf produces an error with a translated error string. +func (t *Translator) Errorf(msgid string, vars ...interface{}) error { + return errors.New(t.T(msgid, vars...)) +} + +// NErrorf produces an error with a translated error string in the appropriate plural form. +func (t *Translator) NErrorf(msgid, msgidPlural string, n int, vars ...interface{}) error { + return errors.New(t.NT(msgid, msgidPlural, n, vars...)) +} diff --git a/pkg/i18n/i18n_test.go b/pkg/i18n/i18n_test.go new file mode 100644 index 0000000000..7926a68aa6 --- /dev/null +++ b/pkg/i18n/i18n_test.go @@ -0,0 +1,119 @@ +package i18n + +import ( + "os" + "strings" + "testing" + + . "github.com/onsi/gomega" +) + +func TestLoadTranslations(t *testing.T) { + RegisterTestingT(t) + + origLang := os.Getenv("LANG") + if origLang != "" && !strings.HasPrefix(origLang, "en_US") { + // The unit test has only en_US translation files + return + } + + _, err := LoadTranslations() + Expect(err).Should(BeNil()) +} + +func TestTranslationLanguage(t *testing.T) { + RegisterTestingT(t) + + origLang := os.Getenv("LANG") + os.Setenv("LANG", "en_US.UTF-8") + _, err := LoadTranslations() + Expect(err).Should(BeNil()) + + lang := GetLanguage() + Expect(lang).Should(Equal("en_US")) + + os.Setenv("LANG", origLang) +} + +func TestTranslationLanguageDefault(t *testing.T) { + RegisterTestingT(t) + + origLang := os.Getenv("LANG") + os.Setenv("LANG", "ll_CC.UTF-8") + _, err := LoadTranslations() + Expect(err).Should(BeNil()) + + lang := GetLanguage() + Expect(lang).Should(Equal("default")) + + os.Setenv("LANG", origLang) +} + +func TestTranslations(t *testing.T) { + RegisterTestingT(t) + + origLang := os.Getenv("LANG") + if origLang != "" && !strings.HasPrefix(origLang, "en_US") { + // The unit test has only en_US translation files + return + } + + l, err := LoadTranslations() + Expect(err).Should(BeNil()) + + translator := &Translator{ + Locale: l, + } + + msg := translator.T("Aloha") + Expect(msg).Should(Equal("Aloha")) + + msg = translator.T("Hello %s", "World") + Expect(msg).Should(Equal("Hello World")) +} + +func TestTranslationsPlural(t *testing.T) { + RegisterTestingT(t) + + origLang := os.Getenv("LANG") + if origLang != "" && !strings.HasPrefix(origLang, "en_US") { + // The unit test has only en_US translation files + return + } + + l, err := LoadTranslations() + Expect(err).Should(BeNil()) + + translator := &Translator{ + Locale: l, + } + + msg := translator.NT("There is %d parameter in resource %s", "There are %d parameters in resource %s", 1, 1, "Foo") + Expect(msg).Should(Equal("There is 1 parameter in resource Foo")) + + msg = translator.NT("There is %d parameter in resource %s", "There are %d parameters in resource %s", 9, 9, "Foo") + Expect(msg).Should(Equal("There are 9 parameters in resource Foo")) +} + +func TestTranslationsError(t *testing.T) { + RegisterTestingT(t) + + origLang := os.Getenv("LANG") + if origLang != "" && !strings.HasPrefix(origLang, "en_US") { + // The unit test has only en_US translation files + return + } + + l, err := LoadTranslations() + Expect(err).Should(BeNil()) + + translator := &Translator{ + Locale: l, + } + + e := translator.Errorf("File not exists") + Expect(e.Error()).Should(Equal("File not exists")) + + e = translator.NErrorf("There is %d error in the api model", "There are %d errors in the api model", 3, 3) + Expect(e.Error()).Should(Equal("There are 3 errors in the api model")) +} diff --git a/pkg/i18n/resourceloader.go b/pkg/i18n/resourceloader.go new file mode 100644 index 0000000000..e4ac64ba8a --- /dev/null +++ b/pkg/i18n/resourceloader.go @@ -0,0 +1,6 @@ +package i18n + +//go:generate go-bindata -nometadata -pkg $GOPACKAGE -prefix ../../ -o translations.go ../../translations/... +//go:generate gofmt -s -l -w translations.go +// resourceloader use go-bindata (https://github.com/jteeuwen/go-bindata) +// go-bindata is the way we handle embedded files, like binary, template, etc. diff --git a/pkg/i18n/translations/default/LC_MESSAGES/acsengine.mo b/pkg/i18n/translations/default/LC_MESSAGES/acsengine.mo new file mode 100644 index 0000000000..c57a041dc9 Binary files /dev/null and b/pkg/i18n/translations/default/LC_MESSAGES/acsengine.mo differ diff --git a/pkg/i18n/translations/default/LC_MESSAGES/acsengine.po b/pkg/i18n/translations/default/LC_MESSAGES/acsengine.po new file mode 100644 index 0000000000..e8283edc67 --- /dev/null +++ b/pkg/i18n/translations/default/LC_MESSAGES/acsengine.po @@ -0,0 +1,45 @@ +# Test translations for acsengine package. +# Copyright (C) 2017 +# Jiangtian Li , 2017. +# +msgid "" +msgstr "" +"Project-Id-Version: acsengine\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-18 00:31+0000\n" +"PO-Revision-Date: 2017-05-17 17:35-0700\n" +"Last-Translator: Jiangtian Li \n" +"Language-Team: English\n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.2\n" + +#: test/i18n/i18ntestinput.go:28 +msgid "Aloha" +msgstr "Aloha" + +#: test/i18n/i18ntestinput.go:32 +#, c-format +msgid "Hello %s" +msgstr "Hello %s" + +#: test/i18n/i18ntestinput.go:36 +#, c-format +msgid "There is %d parameter in resource %s" +msgid_plural "There are %d parameters in resource %s" +msgstr[0] "There is %d parameter in resource %s" +msgstr[1] "There are %d parameters in resource %s" + +#: test/i18n/i18ntestinput.go:40 +msgid "File not exists" +msgstr "File not exists" + +#: test/i18n/i18ntestinput.go:44 +#, c-format +msgid "There is %d error in the api model" +msgid_plural "There are %d errors in the api model" +msgstr[0] "There is %d error in the api model" +msgstr[1] "There are %d errors in the api model" diff --git a/pkg/i18n/translations/en_US/LC_MESSAGES/acsengine.mo b/pkg/i18n/translations/en_US/LC_MESSAGES/acsengine.mo new file mode 100644 index 0000000000..c57a041dc9 Binary files /dev/null and b/pkg/i18n/translations/en_US/LC_MESSAGES/acsengine.mo differ diff --git a/pkg/i18n/translations/en_US/LC_MESSAGES/acsengine.po b/pkg/i18n/translations/en_US/LC_MESSAGES/acsengine.po new file mode 100644 index 0000000000..e8283edc67 --- /dev/null +++ b/pkg/i18n/translations/en_US/LC_MESSAGES/acsengine.po @@ -0,0 +1,45 @@ +# Test translations for acsengine package. +# Copyright (C) 2017 +# Jiangtian Li , 2017. +# +msgid "" +msgstr "" +"Project-Id-Version: acsengine\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-18 00:31+0000\n" +"PO-Revision-Date: 2017-05-17 17:35-0700\n" +"Last-Translator: Jiangtian Li \n" +"Language-Team: English\n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.2\n" + +#: test/i18n/i18ntestinput.go:28 +msgid "Aloha" +msgstr "Aloha" + +#: test/i18n/i18ntestinput.go:32 +#, c-format +msgid "Hello %s" +msgstr "Hello %s" + +#: test/i18n/i18ntestinput.go:36 +#, c-format +msgid "There is %d parameter in resource %s" +msgid_plural "There are %d parameters in resource %s" +msgstr[0] "There is %d parameter in resource %s" +msgstr[1] "There are %d parameters in resource %s" + +#: test/i18n/i18ntestinput.go:40 +msgid "File not exists" +msgstr "File not exists" + +#: test/i18n/i18ntestinput.go:44 +#, c-format +msgid "There is %d error in the api model" +msgid_plural "There are %d errors in the api model" +msgstr[0] "There is %d error in the api model" +msgstr[1] "There are %d errors in the api model" diff --git a/pkg/operations/kubernetesupgrade/upgradecluster.go b/pkg/operations/kubernetesupgrade/upgradecluster.go index fdd5be54bb..c81f211d07 100644 --- a/pkg/operations/kubernetesupgrade/upgradecluster.go +++ b/pkg/operations/kubernetesupgrade/upgradecluster.go @@ -11,6 +11,7 @@ import ( "github.com/Azure/acs-engine/pkg/acsengine" "github.com/Azure/acs-engine/pkg/api" "github.com/Azure/acs-engine/pkg/armhelpers" + "github.com/Azure/acs-engine/pkg/i18n" "github.com/Azure/azure-sdk-for-go/arm/compute" log "github.com/Sirupsen/logrus" "github.com/satori/go.uuid" @@ -41,6 +42,7 @@ type AgentPoolTopology struct { // (or X.X or X.X.X) to version y (or Y.Y or X.X.X). RIght now // upgrades are supported for Kubernetes cluster only. type UpgradeCluster struct { + Translator *i18n.Translator ClusterTopology Client armhelpers.ACSEngineClient @@ -66,20 +68,22 @@ func (uc *UpgradeCluster) UpgradeCluster(subscriptionID uuid.UUID, resourceGroup uc.UpgradeModel = ucs if err := uc.getClusterNodeStatus(subscriptionID, resourceGroup); err != nil { - return fmt.Errorf("Error while querying ARM for resources: %+v", err) + return uc.Translator.Errorf("Error while querying ARM for resources: %+v", err) } switch ucs.OrchestratorProfile.OrchestratorVersion { case api.Kubernetes162: log.Infoln(fmt.Sprintf("Upgrading to Kubernetes 1.6.2")) - upgrader := Kubernetes162upgrader{} + upgrader := Kubernetes162upgrader{ + Translator: uc.Translator, + } upgrader.ClusterTopology = uc.ClusterTopology upgrader.Client = uc.Client if err := upgrader.RunUpgrade(); err != nil { return err } default: - return fmt.Errorf("Upgrade to Kubernetes version: %s is not supported from version: %s", + return uc.Translator.Errorf("Upgrade to Kubernetes version: %s is not supported from version: %s", ucs.OrchestratorProfile.OrchestratorVersion, uc.DataModel.Properties.OrchestratorProfile.OrchestratorVersion) } @@ -182,7 +186,9 @@ func (uc *UpgradeCluster) addVMToAgentPool(vm compute.VirtualMachine, isUpgradab } // WriteTemplate writes upgrade template to a folder -func WriteTemplate(upgradeContainerService *api.ContainerService, +func WriteTemplate( + translator *i18n.Translator, + upgradeContainerService *api.ContainerService, templateMap map[string]interface{}, parametersMap map[string]interface{}) { updatedTemplateJSON, _ := json.Marshal(templateMap) parametersJSON, _ := json.Marshal(parametersMap) @@ -196,7 +202,10 @@ func WriteTemplate(upgradeContainerService *api.ContainerService, log.Fatalf("error pretty printing template parameters: %s \n", e.Error()) } outputDirectory := path.Join("_output", upgradeContainerService.Properties.MasterProfile.DNSPrefix, "Upgrade") - if err := acsengine.WriteTLSArtifacts(upgradeContainerService, "vlabs", templateapp, parametersapp, outputDirectory, false, false); err != nil { + writer := &acsengine.ArtifactWriter{ + Translator: translator, + } + if err := writer.WriteTLSArtifacts(upgradeContainerService, "vlabs", templateapp, parametersapp, outputDirectory, false, false); err != nil { log.Fatalf("error writing artifacts: %s \n", err.Error()) } } diff --git a/pkg/operations/kubernetesupgrade/upgradecluster_test.go b/pkg/operations/kubernetesupgrade/upgradecluster_test.go index 68f51fb11d..820a77218e 100644 --- a/pkg/operations/kubernetesupgrade/upgradecluster_test.go +++ b/pkg/operations/kubernetesupgrade/upgradecluster_test.go @@ -6,6 +6,7 @@ import ( "github.com/Azure/acs-engine/pkg/api" "github.com/Azure/acs-engine/pkg/armhelpers" + "github.com/Azure/acs-engine/pkg/i18n" "github.com/onsi/ginkgo/reporters" . "github.com/onsi/gomega" "github.com/satori/go.uuid" @@ -29,7 +30,12 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() { cs := api.ContainerService{} ucs := api.UpgradeContainerService{} - uc := UpgradeCluster{} + locale, _ := i18n.LoadTranslations() + uc := UpgradeCluster{ + Translator: &i18n.Translator{ + Locale: locale, + }, + } mockClient := armhelpers.MockACSEngineClient{} mockClient.FailListVirtualMachines = true @@ -40,6 +46,9 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() { err := uc.UpgradeCluster(subID, "TestRg", &cs, &ucs, "12345678") Expect(err.Error()).To(Equal("Error while querying ARM for resources: ListVirtualMachines failed")) + + // Clean up + os.RemoveAll("./translations") }) It("Should return error message when failing to detete VMs during upgrade operation", func() { diff --git a/pkg/operations/kubernetesupgrade/v162upgradeagentnode.go b/pkg/operations/kubernetesupgrade/v162upgradeagentnode.go index 049e599486..d8f3051e77 100644 --- a/pkg/operations/kubernetesupgrade/v162upgradeagentnode.go +++ b/pkg/operations/kubernetesupgrade/v162upgradeagentnode.go @@ -7,6 +7,7 @@ import ( "github.com/Azure/acs-engine/pkg/api" "github.com/Azure/acs-engine/pkg/armhelpers" + "github.com/Azure/acs-engine/pkg/i18n" "github.com/Azure/acs-engine/pkg/operations" log "github.com/Sirupsen/logrus" @@ -17,6 +18,7 @@ var _ UpgradeNode = &UpgradeAgentNode{} // UpgradeAgentNode upgrades a Kubernetes 1.5.3 agent node to 1.6.2 type UpgradeAgentNode struct { + Translator *i18n.Translator TemplateMap map[string]interface{} ParametersMap map[string]interface{} UpgradeContainerService *api.ContainerService @@ -47,7 +49,7 @@ func (kan *UpgradeAgentNode) CreateNode(poolName string, agentNo int) error { templateVariables := kan.TemplateMap["variables"].(map[string]interface{}) templateVariables[poolOffsetVarName] = agentNo - WriteTemplate(kan.UpgradeContainerService, kan.TemplateMap, kan.ParametersMap) + WriteTemplate(kan.Translator, kan.UpgradeContainerService, kan.TemplateMap, kan.ParametersMap) random := rand.New(rand.NewSource(time.Now().UnixNano())) deploymentSuffix := random.Int31() diff --git a/pkg/operations/kubernetesupgrade/v162upgrademasternode.go b/pkg/operations/kubernetesupgrade/v162upgrademasternode.go index 5baf709b31..cc6b68ba5f 100644 --- a/pkg/operations/kubernetesupgrade/v162upgrademasternode.go +++ b/pkg/operations/kubernetesupgrade/v162upgrademasternode.go @@ -7,6 +7,7 @@ import ( "github.com/Azure/acs-engine/pkg/api" "github.com/Azure/acs-engine/pkg/armhelpers" + "github.com/Azure/acs-engine/pkg/i18n" "github.com/Azure/acs-engine/pkg/operations" log "github.com/Sirupsen/logrus" ) @@ -16,6 +17,7 @@ var _ UpgradeNode = &UpgradeMasterNode{} // UpgradeMasterNode upgrades a Kubernetes 1.5.3 master node to 1.6.2 type UpgradeMasterNode struct { + Translator *i18n.Translator TemplateMap map[string]interface{} ParametersMap map[string]interface{} UpgradeContainerService *api.ContainerService @@ -46,7 +48,7 @@ func (kmn *UpgradeMasterNode) CreateNode(poolName string, masterNo int) error { masterOffset, _ := templateVariables["masterCount"] log.Infoln(fmt.Sprintf("Master pool set count to: %v temporarily during upgrade...", masterOffset)) - WriteTemplate(kmn.UpgradeContainerService, kmn.TemplateMap, kmn.ParametersMap) + WriteTemplate(kmn.Translator, kmn.UpgradeContainerService, kmn.TemplateMap, kmn.ParametersMap) random := rand.New(rand.NewSource(time.Now().UnixNano())) deploymentSuffix := random.Int31() diff --git a/pkg/operations/kubernetesupgrade/v162upgrader.go b/pkg/operations/kubernetesupgrade/v162upgrader.go index 48eedee8a9..989ff38a9f 100644 --- a/pkg/operations/kubernetesupgrade/v162upgrader.go +++ b/pkg/operations/kubernetesupgrade/v162upgrader.go @@ -7,6 +7,7 @@ import ( "github.com/Azure/acs-engine/pkg/acsengine" "github.com/Azure/acs-engine/pkg/api" "github.com/Azure/acs-engine/pkg/armhelpers" + "github.com/Azure/acs-engine/pkg/i18n" log "github.com/Sirupsen/logrus" ) @@ -15,6 +16,7 @@ var _ UpgradeWorkFlow = &Kubernetes162upgrader{} // Kubernetes162upgrader upgrades a Kubernetes 1.5.3 cluster to 1.6.2 type Kubernetes162upgrader struct { + Translator *i18n.Translator ClusterTopology GoalStateDataModel *api.ContainerService @@ -25,7 +27,7 @@ type Kubernetes162upgrader struct { func (ku *Kubernetes162upgrader) ClusterPreflightCheck() error { // Check that current cluster is 1.5.3 if ku.DataModel.Properties.OrchestratorProfile.OrchestratorVersion != api.Kubernetes153 { - return fmt.Errorf("Upgrade to Kubernetes 1.6.2 is not supported from version: %s", + return ku.Translator.Errorf("Upgrade to Kubernetes 1.6.2 is not supported from version: %s", ku.DataModel.Properties.OrchestratorProfile.OrchestratorVersion) } @@ -62,17 +64,22 @@ func (ku *Kubernetes162upgrader) upgradeMasterNodes() error { // Upgrade Master VMs templateMap, parametersMap, err := ku.generateUpgradeTemplate(ku.GoalStateDataModel) if err != nil { - return fmt.Errorf("error generating upgrade template: %s", err.Error()) + return ku.Translator.Errorf("error generating upgrade template: %s", err.Error()) } log.Infoln(fmt.Sprintf("Prepping master nodes for upgrade...")) - if err := acsengine.NormalizeResourcesForK8sMasterUpgrade(log.NewEntry(log.New()), templateMap, ku.DataModel.Properties.MasterProfile.IsManagedDisks(), nil); err != nil { + transformer := &acsengine.Transformer{ + Translator: ku.Translator, + } + if err := transformer.NormalizeResourcesForK8sMasterUpgrade(log.NewEntry(log.New()), templateMap, ku.DataModel.Properties.MasterProfile.IsManagedDisks(), nil); err != nil { log.Fatalln(err) return err } - upgradeMasterNode := UpgradeMasterNode{} + upgradeMasterNode := UpgradeMasterNode{ + Translator: ku.Translator, + } upgradeMasterNode.TemplateMap = templateMap upgradeMasterNode.ParametersMap = parametersMap upgradeMasterNode.UpgradeContainerService = ku.GoalStateDataModel @@ -92,7 +99,7 @@ func (ku *Kubernetes162upgrader) upgradeMasterNodes() error { masterNodesInCluster := len(*ku.ClusterTopology.MasterVMs) + mastersUpgradedCount log.Infoln(fmt.Sprintf("masterNodesInCluster: %d", masterNodesInCluster)) if masterNodesInCluster > expectedMasterCount { - return fmt.Errorf("Total count of master VMs: %d exceeded expected count: %d", masterNodesInCluster, expectedMasterCount) + return ku.Translator.Errorf("Total count of master VMs: %d exceeded expected count: %d", masterNodesInCluster, expectedMasterCount) } upgradedMastersIndex := make(map[int]bool) @@ -172,13 +179,16 @@ func (ku *Kubernetes162upgrader) upgradeAgentPools() error { // Upgrade Agent VMs templateMap, parametersMap, err := ku.generateUpgradeTemplate(ku.GoalStateDataModel) if err != nil { - return fmt.Errorf("error generating upgrade template: %s", err.Error()) + return ku.Translator.Errorf("error generating upgrade template: %s", err.Error()) } log.Infoln(fmt.Sprintf("Prepping agent pool: %s for upgrade...", *agentPool.Name)) preservePools := map[string]bool{*agentPool.Name: true} - if err := acsengine.NormalizeResourcesForK8sAgentUpgrade(log.NewEntry(log.New()), templateMap, ku.DataModel.Properties.MasterProfile.IsManagedDisks(), preservePools); err != nil { + transformer := &acsengine.Transformer{ + Translator: ku.Translator, + } + if err := transformer.NormalizeResourcesForK8sAgentUpgrade(log.NewEntry(log.New()), templateMap, ku.DataModel.Properties.MasterProfile.IsManagedDisks(), preservePools); err != nil { log.Fatalln(err) return err } @@ -191,7 +201,9 @@ func (ku *Kubernetes162upgrader) upgradeAgentPools() error { } } - upgradeAgentNode := UpgradeAgentNode{} + upgradeAgentNode := UpgradeAgentNode{ + Translator: ku.Translator, + } upgradeAgentNode.TemplateMap = templateMap upgradeAgentNode.ParametersMap = parametersMap upgradeAgentNode.UpgradeContainerService = ku.GoalStateDataModel @@ -269,15 +281,18 @@ func (ku *Kubernetes162upgrader) upgradeAgentPools() error { func (ku *Kubernetes162upgrader) generateUpgradeTemplate(upgradeContainerService *api.ContainerService) (map[string]interface{}, map[string]interface{}, error) { var err error - templateGenerator, err := acsengine.InitializeTemplateGenerator(false) + ctx := acsengine.Context{ + Translator: ku.Translator, + } + templateGenerator, err := acsengine.InitializeTemplateGenerator(ctx, false) if err != nil { - return nil, nil, fmt.Errorf("failed to initialize template generator: %s", err.Error()) + return nil, nil, ku.Translator.Errorf("failed to initialize template generator: %s", err.Error()) } var templateJSON string var parametersJSON string if templateJSON, parametersJSON, _, err = templateGenerator.GenerateTemplate(upgradeContainerService); err != nil { - return nil, nil, fmt.Errorf("error generating upgrade template: %s", err.Error()) + return nil, nil, ku.Translator.Errorf("error generating upgrade template: %s", err.Error()) } var template interface{} diff --git a/scripts/update-translation.sh b/scripts/update-translation.sh new file mode 100644 index 0000000000..a3d4a49200 --- /dev/null +++ b/scripts/update-translation.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +GO_SOURCE="pkg/acsengine/*.go pkg/api/*.go pkg/operations/*.go pkg/operations/kubernetesupgrade/*.go" +LANGUAGE="en_US" +DOMAIN="acsengine" +generate_po="false" +generate_mo="false" + +while getopts "hl:pm" opt; do + case $opt in + h) + echo "$0 [-l language] [-p] [-m]" + echo " -l : Language to translate" + echo " -p extract strings and generate PO file" + echo " -m generate MO file" + exit 0 + ;; + l) + LANGUAGE="${OPTARG}" + ;; + p) + generate_po="true" + ;; + m) + generate_mo="true" + ;; + \?) + echo "$0 [-l language] [-p] [-m]" + exit 1 + ;; + esac +done + +if ! which go-xgettext > /dev/null; then + echo 'Can not find go-xgettext, install with:' + echo 'go get github.com/gosexy/gettext/go-xgettext' + exit 1 +fi + +if ! which msginit > /dev/null; then + echo 'Can not find msginit, install with:' + echo 'apt-get install gettext' + exit 1 +fi + +if [[ "${generate_po}" == "true" ]]; then + echo "Extract strings and generate PO files..." + go-xgettext -o ${DOMAIN}.pot --keyword=Translator.Errorf --keyword-plural=Translator.NErrorf --msgid-bugs-address="" --sort-output ${GO_SOURCE} + msginit -l ${LANGUAGE} -o ${DOMAIN}.po -i ${DOMAIN}.pot +fi + +if [[ "${generate_mo}" == "true" ]]; then + echo "Generate MO file..." + if [ ! -f ${DOMAIN}.po ]; then + echo "${DOMAIN}.po not found!" + exit 1 + fi + msgfmt -c -v -o ${DOMAIN}.mo ${DOMAIN}.po +fi diff --git a/scripts/validate-go.sh b/scripts/validate-go.sh index a051ea8f34..2b00dbab0d 100755 --- a/scripts/validate-go.sh +++ b/scripts/validate-go.sh @@ -36,6 +36,7 @@ gometalinter \ --tests \ --vendor \ --deadline 60s \ + --skip test/i18n \ ./... || exit_code=1 echo diff --git a/test/i18n/i18ntestinput.go b/test/i18n/i18ntestinput.go new file mode 100644 index 0000000000..df6a0b601b --- /dev/null +++ b/test/i18n/i18ntestinput.go @@ -0,0 +1,45 @@ +package fake + +import ( + "github.com/Azure/acs-engine/pkg/i18n" + "github.com/leonelquinteros/gotext" +) + +// This file is used to generate the test translation file +// 1. go-xgettext -o i18ntestinput.pot --keyword=translator.T --keyword-plural=translator.NT --msgid-bugs-address="" --sort-output test/i18n/i18ntestinput.go +// 2. go-xgettext -o i18ntestinput.err.pot --keyword=translator.Errorf --keyword-plural=translator.NErrorf --msgid-bugs-address="" --sort-output test/i18n/i18ntestinput.go +// 3. sed '1,18d' i18ntestinput.err.pot >> i18ntestinput.pot +// 4. msginit -l en_US -o i18ntestinput.po -i i18ntestinput.pot +// 5. Modify i18ntestinput.po using poedit as necessary +// Or msgfmt -c -v -o i18ntestinput.mo i18ntestinput.po +// 6. for d in "default" "en_US"; do cp i18ntestinput.mo translations/test/$d/LC_MESSAGES/acsengine.mo; cp i18ntestinput.po translations/test/$d/LC_MESSAGES/acsengine.po; done +// 7. rm i18ntestinput.* + +var ( + locale = gotext.NewLocale("d", "l") + translator = &i18n.Translator{ + Locale: locale, + } + world = "World" + resource = "Foo" +) + +func aloha() { + translator.T("Aloha") +} + +func foo() { + translator.T("Hello %s", world) +} + +func bar() { + translator.NT("There is %d parameter in resource %s", "There are %d parameters in resource %s", 9, 9, resource) +} + +func file() error { + return translator.Errorf("File not exists") +} + +func api() error { + return translator.NErrorf("There is %d error in the api model", "There are %d errors in the api model", 3, 3) +} diff --git a/translations/default/LC_MESSAGES/acsengine.mo b/translations/default/LC_MESSAGES/acsengine.mo new file mode 100644 index 0000000000..959e81d01c Binary files /dev/null and b/translations/default/LC_MESSAGES/acsengine.mo differ diff --git a/translations/default/LC_MESSAGES/acsengine.po b/translations/default/LC_MESSAGES/acsengine.po new file mode 100644 index 0000000000..d6b886a6d3 --- /dev/null +++ b/translations/default/LC_MESSAGES/acsengine.po @@ -0,0 +1,121 @@ +# English translations for acs-engine package. +# Copyright (C) 2017 +# This file is distributed under the same license as the acs-engine package. +# Jiangtian Li , 2017. +# +msgid "" +msgstr "" +"Project-Id-Version: acsengine\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-25 00:04+0000\n" +"PO-Revision-Date: 2017-07-24 17:23-0700\n" +"Last-Translator: Jiangtian Li \n" +"Language-Team: English\n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.3\n" + +#: pkg/acsengine/engine.go:239 +#, c-format +msgid "Error reading file %s, Error: %s" +msgstr "Error reading file %s, Error: %s" + +#: pkg/operations/kubernetesupgrade/upgradecluster.go:71 +#, c-format +msgid "Error while querying ARM for resources: %+v" +msgstr "Error while querying ARM for resources: %+v" + +#: pkg/acsengine/transform.go:99 +#, c-format +msgid "Found 2 resources with type %s in the template. There should only be 1" +msgstr "Found 2 resources with type %s in the template. There should only be 1" + +#: pkg/acsengine/transform.go:122 +#, c-format +msgid "Found no resources with type %s in the template. There should have been 1" +msgstr "Found no resources with type %s in the template. There should have been 1" + +#: pkg/operations/kubernetesupgrade/v162upgrader.go:102 +#, c-format +msgid "Total count of master VMs: %d exceeded expected count: %d" +msgstr "Total count of master VMs: %d exceeded expected count: %d" + +#: pkg/operations/kubernetesupgrade/v162upgrader.go:30 +#, c-format +msgid "Upgrade to Kubernetes 1.6.2 is not supported from version: %s" +msgstr "Upgrade to Kubernetes 1.6.2 is not supported from version: %s" + +#: pkg/operations/kubernetesupgrade/upgradecluster.go:86 +#, c-format +msgid "Upgrade to Kubernetes version: %s is not supported from version: %s" +msgstr "Upgrade to Kubernetes version: %s is not supported from version: %s" + +#: pkg/acsengine/filesaver.go:24 +#, c-format +msgid "error creating directory '%s': %s" +msgstr "error creating directory '%s': %s" + +#: pkg/acsengine/engine.go:1194 +#, c-format +msgid "error executing template for file %s: %v" +msgstr "error executing template for file %s: %v" + +#: pkg/operations/kubernetesupgrade/v162upgrader.go:67 +#: pkg/operations/kubernetesupgrade/v162upgrader.go:182 +#: pkg/operations/kubernetesupgrade/v162upgrader.go:295 +#, c-format +msgid "error generating upgrade template: %s" +msgstr "error generating upgrade template: %s" + +#: pkg/acsengine/engine.go:1189 +#, c-format +msgid "error parsing file %s: %v" +msgstr "error parsing file %s: %v" + +#: pkg/api/apiloader.go:24 pkg/api/upgradeapiloader.go:20 +#, c-format +msgid "error reading file %s: %s" +msgstr "error reading file %s: %s" + +#: pkg/acsengine/ssh.go:55 +#, c-format +msgid "failed to create openssh public key string: %q" +msgstr "failed to create openssh public key string: %q" + +#: pkg/acsengine/ssh.go:49 +#, c-format +msgid "failed to generate private key for ssh: %q" +msgstr "failed to generate private key for ssh: %q" + +#: pkg/operations/kubernetesupgrade/v162upgrader.go:289 +#, c-format +msgid "failed to initialize template generator: %s" +msgstr "failed to initialize template generator: %s" + +#: pkg/api/apiloader.go:161 pkg/api/upgradeapiloader.go:70 +#, c-format +msgid "invalid version %s for conversion back from unversioned object" +msgstr "invalid version %s for conversion back from unversioned object" + +#: pkg/acsengine/engine.go:322 +#, c-format +msgid "orchestrator '%s' is unsupported" +msgstr "orchestrator '%s' is unsupported" + +#: pkg/acsengine/engine.go:187 +#, c-format +msgid "template file %s does not exist" +msgstr "template file %s does not exist" + +#: pkg/api/apiloader.go:98 pkg/api/upgradeapiloader.go:51 +#, c-format +msgid "unrecognized APIVersion '%s'" +msgstr "unrecognized APIVersion '%s'" + +#: pkg/acsengine/engine.go:1183 +#, c-format +msgid "yaml file %s does not exist" +msgstr "yaml file %s does not exist" diff --git a/translations/default/LC_MESSAGES/acsengine.po.lcg b/translations/default/LC_MESSAGES/acsengine.po.lcg new file mode 100644 index 0000000000..5f3303db62 --- /dev/null +++ b/translations/default/LC_MESSAGES/acsengine.po.lcg @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/translations/default/LC_MESSAGES/en-US/lcl/acsengine.po.lcl b/translations/default/LC_MESSAGES/en-US/lcl/acsengine.po.lcl new file mode 100644 index 0000000000..f391730398 --- /dev/null +++ b/translations/default/LC_MESSAGES/en-US/lcl/acsengine.po.lcl @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/translations/default/LC_MESSAGES/en-US/metadata/acsengine.po.xml b/translations/default/LC_MESSAGES/en-US/metadata/acsengine.po.xml new file mode 100644 index 0000000000..885406fa0c --- /dev/null +++ b/translations/default/LC_MESSAGES/en-US/metadata/acsengine.po.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/translations/en_US/LC_MESSAGES/acsengine.mo b/translations/en_US/LC_MESSAGES/acsengine.mo new file mode 100644 index 0000000000..959e81d01c Binary files /dev/null and b/translations/en_US/LC_MESSAGES/acsengine.mo differ diff --git a/translations/en_US/LC_MESSAGES/acsengine.po b/translations/en_US/LC_MESSAGES/acsengine.po new file mode 100644 index 0000000000..d6b886a6d3 --- /dev/null +++ b/translations/en_US/LC_MESSAGES/acsengine.po @@ -0,0 +1,121 @@ +# English translations for acs-engine package. +# Copyright (C) 2017 +# This file is distributed under the same license as the acs-engine package. +# Jiangtian Li , 2017. +# +msgid "" +msgstr "" +"Project-Id-Version: acsengine\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-25 00:04+0000\n" +"PO-Revision-Date: 2017-07-24 17:23-0700\n" +"Last-Translator: Jiangtian Li \n" +"Language-Team: English\n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.3\n" + +#: pkg/acsengine/engine.go:239 +#, c-format +msgid "Error reading file %s, Error: %s" +msgstr "Error reading file %s, Error: %s" + +#: pkg/operations/kubernetesupgrade/upgradecluster.go:71 +#, c-format +msgid "Error while querying ARM for resources: %+v" +msgstr "Error while querying ARM for resources: %+v" + +#: pkg/acsengine/transform.go:99 +#, c-format +msgid "Found 2 resources with type %s in the template. There should only be 1" +msgstr "Found 2 resources with type %s in the template. There should only be 1" + +#: pkg/acsengine/transform.go:122 +#, c-format +msgid "Found no resources with type %s in the template. There should have been 1" +msgstr "Found no resources with type %s in the template. There should have been 1" + +#: pkg/operations/kubernetesupgrade/v162upgrader.go:102 +#, c-format +msgid "Total count of master VMs: %d exceeded expected count: %d" +msgstr "Total count of master VMs: %d exceeded expected count: %d" + +#: pkg/operations/kubernetesupgrade/v162upgrader.go:30 +#, c-format +msgid "Upgrade to Kubernetes 1.6.2 is not supported from version: %s" +msgstr "Upgrade to Kubernetes 1.6.2 is not supported from version: %s" + +#: pkg/operations/kubernetesupgrade/upgradecluster.go:86 +#, c-format +msgid "Upgrade to Kubernetes version: %s is not supported from version: %s" +msgstr "Upgrade to Kubernetes version: %s is not supported from version: %s" + +#: pkg/acsengine/filesaver.go:24 +#, c-format +msgid "error creating directory '%s': %s" +msgstr "error creating directory '%s': %s" + +#: pkg/acsengine/engine.go:1194 +#, c-format +msgid "error executing template for file %s: %v" +msgstr "error executing template for file %s: %v" + +#: pkg/operations/kubernetesupgrade/v162upgrader.go:67 +#: pkg/operations/kubernetesupgrade/v162upgrader.go:182 +#: pkg/operations/kubernetesupgrade/v162upgrader.go:295 +#, c-format +msgid "error generating upgrade template: %s" +msgstr "error generating upgrade template: %s" + +#: pkg/acsengine/engine.go:1189 +#, c-format +msgid "error parsing file %s: %v" +msgstr "error parsing file %s: %v" + +#: pkg/api/apiloader.go:24 pkg/api/upgradeapiloader.go:20 +#, c-format +msgid "error reading file %s: %s" +msgstr "error reading file %s: %s" + +#: pkg/acsengine/ssh.go:55 +#, c-format +msgid "failed to create openssh public key string: %q" +msgstr "failed to create openssh public key string: %q" + +#: pkg/acsengine/ssh.go:49 +#, c-format +msgid "failed to generate private key for ssh: %q" +msgstr "failed to generate private key for ssh: %q" + +#: pkg/operations/kubernetesupgrade/v162upgrader.go:289 +#, c-format +msgid "failed to initialize template generator: %s" +msgstr "failed to initialize template generator: %s" + +#: pkg/api/apiloader.go:161 pkg/api/upgradeapiloader.go:70 +#, c-format +msgid "invalid version %s for conversion back from unversioned object" +msgstr "invalid version %s for conversion back from unversioned object" + +#: pkg/acsengine/engine.go:322 +#, c-format +msgid "orchestrator '%s' is unsupported" +msgstr "orchestrator '%s' is unsupported" + +#: pkg/acsengine/engine.go:187 +#, c-format +msgid "template file %s does not exist" +msgstr "template file %s does not exist" + +#: pkg/api/apiloader.go:98 pkg/api/upgradeapiloader.go:51 +#, c-format +msgid "unrecognized APIVersion '%s'" +msgstr "unrecognized APIVersion '%s'" + +#: pkg/acsengine/engine.go:1183 +#, c-format +msgid "yaml file %s does not exist" +msgstr "yaml file %s does not exist" diff --git a/translations/en_US/LC_MESSAGES/acsengine.po.lcg b/translations/en_US/LC_MESSAGES/acsengine.po.lcg new file mode 100644 index 0000000000..5f3303db62 --- /dev/null +++ b/translations/en_US/LC_MESSAGES/acsengine.po.lcg @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/translations/en_US/LC_MESSAGES/en-US/lcl/acsengine.po.lcl b/translations/en_US/LC_MESSAGES/en-US/lcl/acsengine.po.lcl new file mode 100644 index 0000000000..f391730398 --- /dev/null +++ b/translations/en_US/LC_MESSAGES/en-US/lcl/acsengine.po.lcl @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/translations/en_US/LC_MESSAGES/en-US/metadata/acsengine.po.xml b/translations/en_US/LC_MESSAGES/en-US/metadata/acsengine.po.xml new file mode 100644 index 0000000000..976dabd856 --- /dev/null +++ b/translations/en_US/LC_MESSAGES/en-US/metadata/acsengine.po.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/translations/zh_CN/LC_MESSAGES/acsengine.mo b/translations/zh_CN/LC_MESSAGES/acsengine.mo new file mode 100644 index 0000000000..a6f0c52819 Binary files /dev/null and b/translations/zh_CN/LC_MESSAGES/acsengine.mo differ diff --git a/translations/zh_CN/LC_MESSAGES/acsengine.po b/translations/zh_CN/LC_MESSAGES/acsengine.po new file mode 100644 index 0000000000..9555544928 --- /dev/null +++ b/translations/zh_CN/LC_MESSAGES/acsengine.po @@ -0,0 +1,120 @@ +# Chinese translations for acs-engine package. +# Copyright (C) 2017 +# This file is distributed under the same license as the acs-engine package. +# Jiangtian Li , 2017. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-25 00:11+0000\n" +"PO-Revision-Date: 2017-07-24 17:21-0700\n" +"Last-Translator: Jiangtian Li \n" +"Language-Team: Chinese (simplified)\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.0.3\n" + +#: pkg/acsengine/engine.go:239 +#, c-format +msgid "Error reading file %s, Error: %s" +msgstr "文件 %s,错误读取时出错: %s" + +#: pkg/operations/kubernetesupgrade/upgradecluster.go:71 +#, c-format +msgid "Error while querying ARM for resources: %+v" +msgstr "查询ARM资源时出错: %+v" + +#: pkg/acsengine/transform.go:99 +#, c-format +msgid "Found 2 resources with type %s in the template. There should only be 1" +msgstr "模板发现两个类型%s 的资源。应该只有一个" + +#: pkg/acsengine/transform.go:122 +#, c-format +msgid "Found no resources with type %s in the template. There should have been 1" +msgstr "模板没有发现类型%s 的资源。应该有一个" + +#: pkg/operations/kubernetesupgrade/v162upgrader.go:102 +#, c-format +msgid "Total count of master VMs: %d exceeded expected count: %d" +msgstr "主虚拟机总数: %d 超过期望的数目: %d" + +#: pkg/operations/kubernetesupgrade/v162upgrader.go:30 +#, c-format +msgid "Upgrade to Kubernetes 1.6.2 is not supported from version: %s" +msgstr "版本%s 不支持升级到Kubernetes 1.6.2" + +#: pkg/operations/kubernetesupgrade/upgradecluster.go:86 +#, c-format +msgid "Upgrade to Kubernetes version: %s is not supported from version: %s" +msgstr "版本%s 不支持升级到Kubernetes版本%s" + +#: pkg/acsengine/filesaver.go:24 +#, c-format +msgid "error creating directory '%s': %s" +msgstr "创建目录 %s 时出错: %s" + +#: pkg/acsengine/engine.go:1194 +#, c-format +msgid "error executing template for file %s: %v" +msgstr "执行文件 %s %v 模板时出错" + +#: pkg/operations/kubernetesupgrade/v162upgrader.go:67 +#: pkg/operations/kubernetesupgrade/v162upgrader.go:182 +#: pkg/operations/kubernetesupgrade/v162upgrader.go:295 +#, c-format +msgid "error generating upgrade template: %s" +msgstr "执行文件 %s 模板时出错" + +#: pkg/acsengine/engine.go:1189 +#, c-format +msgid "error parsing file %s: %v" +msgstr "解析文件 %s: %v 时出错" + +#: pkg/api/apiloader.go:24 pkg/api/upgradeapiloader.go:20 +#, c-format +msgid "error reading file %s: %s" +msgstr "读取文件 %s: %s 时出错" + +#: pkg/acsengine/ssh.go:55 +#, c-format +msgid "failed to create openssh public key string: %q" +msgstr "生成 openssh 公开密钥字符串出错: %q" + +#: pkg/acsengine/ssh.go:49 +#, c-format +msgid "failed to generate private key for ssh: %q" +msgstr "生成 ssh 私有密钥出错: %q" + +#: pkg/operations/kubernetesupgrade/v162upgrader.go:289 +#, c-format +msgid "failed to initialize template generator: %s" +msgstr "初始化模板生成器时出错: %s" + +#: pkg/api/apiloader.go:161 pkg/api/upgradeapiloader.go:70 +#, c-format +msgid "invalid version %s for conversion back from unversioned object" +msgstr "与回是非版本化的对象的转换的版本无效 %s" + +#: pkg/acsengine/engine.go:322 +#, c-format +msgid "orchestrator '%s' is unsupported" +msgstr "%s 配器是不受支持" + +#: pkg/acsengine/engine.go:187 +#, c-format +msgid "template file %s does not exist" +msgstr "模板文件 %s 不存在" + +#: pkg/api/apiloader.go:98 pkg/api/upgradeapiloader.go:51 +#, c-format +msgid "unrecognized APIVersion '%s'" +msgstr "无法识别的 APIVersion '%s'" + +#: pkg/acsengine/engine.go:1183 +#, c-format +msgid "yaml file %s does not exist" +msgstr "yaml 文件 %s 不存在" diff --git a/translations/zh_CN/LC_MESSAGES/acsengine.po.lcg b/translations/zh_CN/LC_MESSAGES/acsengine.po.lcg new file mode 100644 index 0000000000..5f3303db62 --- /dev/null +++ b/translations/zh_CN/LC_MESSAGES/acsengine.po.lcg @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/translations/zh_CN/LC_MESSAGES/en-US/lcl/acsengine.po.lcl b/translations/zh_CN/LC_MESSAGES/en-US/lcl/acsengine.po.lcl new file mode 100644 index 0000000000..f391730398 --- /dev/null +++ b/translations/zh_CN/LC_MESSAGES/en-US/lcl/acsengine.po.lcl @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/translations/zh_CN/LC_MESSAGES/en-US/metadata/acsengine.po.xml b/translations/zh_CN/LC_MESSAGES/en-US/metadata/acsengine.po.xml new file mode 100644 index 0000000000..4ddd84864b --- /dev/null +++ b/translations/zh_CN/LC_MESSAGES/en-US/metadata/acsengine.po.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/recommendations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/recommendations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/suppressions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/suppressions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/analysisservices/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/analysisservices/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/analysisservices/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/analysisservices/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/analysisservices/servers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/analysisservices/servers.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/analysisservices/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/analysisservices/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/apiexport.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/apiexport.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/apioperations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/apioperations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/apioperationspolicy.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/apioperationspolicy.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/apipolicy.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/apipolicy.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/apiproducts.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/apiproducts.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/apis.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/apis.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/authorizationservers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/authorizationservers.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/backends.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/backends.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/certificates.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/certificates.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/groups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/groups.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/groupusers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/groupusers.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/identityproviders.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/identityproviders.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/loggers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/loggers.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/networkstatus.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/networkstatus.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/openidconnectproviders.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/openidconnectproviders.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/policysnippets.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/policysnippets.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/productapis.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/productapis.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/productgroups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/productgroups.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/productpolicy.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/productpolicy.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/products.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/products.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/productsubscriptions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/productsubscriptions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/properties.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/properties.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/property.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/property.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/quotabycounterkeys.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/quotabycounterkeys.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/quotabyperiodkeys.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/quotabyperiodkeys.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/regions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/regions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/reports.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/reports.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/services.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/services.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/subscriptions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/subscriptions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/tenantaccess.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/tenantaccess.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/tenantaccessgit.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/tenantaccessgit.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/tenantconfiguration.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/tenantconfiguration.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/tenantconfigurationsyncstate.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/tenantconfigurationsyncstate.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/tenantpolicy.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/tenantpolicy.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/usergroups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/usergroups.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/useridentities.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/useridentities.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/users.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/users.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/usersubscriptions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/usersubscriptions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/components.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/components.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/webtests.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/webtests.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/classicadministrators.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/classicadministrators.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/permissions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/permissions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/provideroperationsmetadata.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/provideroperationsmetadata.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/roleassignments.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/roleassignments.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/roledefinitions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/roledefinitions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/account.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/account.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/activity.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/activity.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/agentregistrationinformation.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/agentregistrationinformation.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/certificate.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/certificate.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/connection.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/connection.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/connectiontype.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/connectiontype.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/credential.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/credential.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dsccompilationjob.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dsccompilationjob.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscconfiguration.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscconfiguration.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscnode.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscnode.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscnodeconfiguration.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscnodeconfiguration.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/fields.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/fields.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/hybridrunbookworkergroup.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/hybridrunbookworkergroup.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/job.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/job.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/jobschedule.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/jobschedule.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/jobstream.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/jobstream.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/module.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/module.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/nodereports.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/nodereports.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/objectdatatypes.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/objectdatatypes.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/runbook.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/runbook.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/runbookdraft.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/runbookdraft.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/schedule.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/schedule.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/statistics.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/statistics.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/testjobs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/testjobs.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/testjobstreams.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/testjobstreams.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/usages.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/usages.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/variable.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/variable.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/webhook.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/webhook.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/account.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/account.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/application.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/application.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/applicationpackage.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/applicationpackage.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/location.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/location.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/invoices.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/invoices.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/periods.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/periods.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/customdomains.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/customdomains.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/edgenodes.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/edgenodes.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/endpoints.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/endpoints.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/origins.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/origins.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/profiles.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/profiles.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cognitiveservices/accounts.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cognitiveservices/accounts.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cognitiveservices/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cognitiveservices/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cognitiveservices/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cognitiveservices/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cognitiveservices/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cognitiveservices/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/ratecard.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/ratecard.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/usageaggregates.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/usageaggregates.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/availabilitysets.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/availabilitysets.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/images.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/images.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/usage.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/usage.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensionimages.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensionimages.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineimages.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineimages.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachines.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachines.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesets.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesets.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesetvms.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesetvms.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinesizes.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinesizes.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/usagedetails.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/usagedetails.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/registries.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/registries.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/containerservices.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/containerservices.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/authorizationpolicies.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/authorizationpolicies.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/connectormappings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/connectormappings.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/connectors.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/connectors.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/hubs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/hubs.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/images.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/images.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/interactions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/interactions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/kpi.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/kpi.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/links.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/links.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/profiles.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/profiles.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/relationshiplinks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/relationshiplinks.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/relationships.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/relationships.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/roleassignments.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/roleassignments.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/roles.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/roles.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/views.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/views.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/widgettypes.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/widgettypes.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/accountgroup.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/accountgroup.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/datalakestoreaccounts.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/datalakestoreaccounts.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/firewallrules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/firewallrules.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/storageaccounts.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/storageaccounts.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/accountgroup.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/accountgroup.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/firewallrules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/firewallrules.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/trustedidproviders.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/trustedidproviders.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/armtemplates.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/armtemplates.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/artifacts.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/artifacts.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/artifactsources.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/artifactsources.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/costs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/costs.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/customimages.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/customimages.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/disks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/disks.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/environments.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/environments.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/formulas.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/formulas.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/galleryimages.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/galleryimages.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/globalschedules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/globalschedules.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/labs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/labs.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/notificationchannels.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/notificationchannels.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/policies.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/policies.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/policysets.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/policysets.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/schedules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/schedules.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/secrets.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/secrets.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/servicerunners.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/servicerunners.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/users.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/users.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/virtualmachines.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/virtualmachines.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/virtualmachineschedules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/virtualmachineschedules.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/virtualnetworks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/virtualnetworks.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/disks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/disks.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/snapshots.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/snapshots.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/recordsets.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/recordsets.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/zones.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/zones.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/documentdb/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/documentdb/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/documentdb/databaseaccounts.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/documentdb/databaseaccounts.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/documentdb/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/documentdb/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/documentdb/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/documentdb/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/consumergroups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/consumergroups.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/eventhubs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/eventhubs.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/namespaces.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/namespaces.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/applications.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/applications.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/groups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/groups.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/objects.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/objects.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/serviceprincipals.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/serviceprincipals.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/users.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/users.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/applications.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/applications.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/clusters.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/clusters.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/configurations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/configurations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/extension.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/extension.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/location.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/location.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/scriptactions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/scriptactions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/scriptexecutionhistory.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/scriptexecutionhistory.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/alertruleincidents.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/alertruleincidents.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/alertrules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/alertrules.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/autoscalesettings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/autoscalesettings.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/logprofiles.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/logprofiles.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/servicediagnosticsettings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/servicediagnosticsettings.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/android.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/android.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/ios.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/ios.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/iothub/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/iothub/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/iothub/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/iothub/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/iothub/resource.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/iothub/resource.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/iothub/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/iothub/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/vaults.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/vaults.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/agreements.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/agreements.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/certificates.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/certificates.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/integrationaccounts.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/integrationaccounts.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/maps.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/maps.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/partners.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/partners.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/schemas.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/schemas.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/sessions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/sessions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/workflowrunactions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/workflowrunactions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/workflowruns.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/workflowruns.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/workflows.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/workflows.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/workflowtriggerhistories.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/workflowtriggerhistories.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/workflowtriggers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/workflowtriggers.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/workflowversions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/workflowversions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/commitmentassociations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/commitmentassociations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/commitmentplansgroup.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/commitmentplansgroup.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/usagehistory.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/usagehistory.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/webservices/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/webservices/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/webservices/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/webservices/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/webservices/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/webservices/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/webservices/webservicesgroup.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/webservices/webservicesgroup.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mediaservices/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mediaservices/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mediaservices/mediaservice.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mediaservices/mediaservice.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mediaservices/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mediaservices/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mediaservices/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mediaservices/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/appcollections.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/appcollections.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/apps.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/apps.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/campaigns.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/campaigns.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/devices.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/devices.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/exporttasks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/exporttasks.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/importtasks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/importtasks.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/supportedplatforms.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/supportedplatforms.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/activitylogalerts.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/activitylogalerts.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/alertruleincidents.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/alertruleincidents.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/alertrules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/alertrules.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/autoscalesettings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/autoscalesettings.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/logprofiles.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/logprofiles.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/servicediagnosticsettings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/servicediagnosticsettings.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/applicationgateways.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/applicationgateways.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/bgpservicecommunities.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/bgpservicecommunities.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitauthorizations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitauthorizations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitpeerings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitpeerings.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuits.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuits.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressrouteserviceproviders.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressrouteserviceproviders.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/interfaces.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/interfaces.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/loadbalancers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/loadbalancers.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/localnetworkgateways.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/localnetworkgateways.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/packetcaptures.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/packetcaptures.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/publicipaddresses.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/publicipaddresses.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routefilterrules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routefilterrules.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routefilters.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routefilters.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routes.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routes.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routetables.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routetables.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securitygroups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securitygroups.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securityrules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securityrules.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/subnets.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/subnets.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/usages.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/usages.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgatewayconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgatewayconnections.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgateways.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgateways.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkpeerings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkpeerings.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworks.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/watchers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/watchers.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/namespaces.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/namespaces.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/notificationhubsgroup.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/notificationhubsgroup.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/datasources.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/datasources.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/linkedservices.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/linkedservices.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/workspaces.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/workspaces.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/workspacecollections.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/workspacecollections.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/workspaces.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/workspaces.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/vaultextendedinfo.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/vaultextendedinfo.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/vaults.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/vaults.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupengines.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupengines.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupjobs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupjobs.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupoperationresults.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupoperationresults.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupoperationstatuses.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupoperationstatuses.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backuppolicies.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backuppolicies.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupprotectableitems.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupprotectableitems.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupprotecteditems.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupprotecteditems.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupprotectioncontainers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupprotectioncontainers.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupresourcestorageconfigs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupresourcestorageconfigs.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupresourcevaultconfigs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupresourcevaultconfigs.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backups.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupusagesummaries.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/backupusagesummaries.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/exportjobsoperationresults.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/exportjobsoperationresults.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/itemlevelrecoveryconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/itemlevelrecoveryconnections.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/jobcancellations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/jobcancellations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/jobdetails.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/jobdetails.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/joboperationresults.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/joboperationresults.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/jobs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/jobs.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protecteditemoperationresults.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protecteditemoperationresults.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protecteditemoperationstatuses.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protecteditemoperationstatuses.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protecteditems.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protecteditems.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protectioncontaineroperationresults.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protectioncontaineroperationresults.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protectioncontainerrefreshoperationresults.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protectioncontainerrefreshoperationresults.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protectioncontainers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protectioncontainers.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protectionpolicies.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protectionpolicies.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protectionpolicyoperationresults.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protectionpolicyoperationresults.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protectionpolicyoperationstatuses.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/protectionpolicyoperationstatuses.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/recoverypoints.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/recoverypoints.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/restores.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/restores.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/securitypins.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/securitypins.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/firewallrule.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/firewallrule.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/firewallrules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/firewallrules.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/patchschedules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/patchschedules.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/redisgroup.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/redisgroup.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/hybridconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/hybridconnections.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/namespaces.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/namespaces.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/wcfrelays.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/wcfrelays.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/availabilitystatuses.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/availabilitystatuses.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/features/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/features/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/features/featuresgroup.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/features/featuresgroup.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/features/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/features/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/features/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/features/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/links/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/links/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/links/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/links/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/links/resourcelinks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/links/resourcelinks.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/links/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/links/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/locks/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/locks/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/locks/managementlocks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/locks/managementlocks.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/locks/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/locks/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/locks/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/locks/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/assignments.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/assignments.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/definitions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/definitions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deploymentoperations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deploymentoperations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deployments.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deployments.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/groups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/groups.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/providers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/providers.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/resourcesgroup.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/resourcesgroup.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/tags.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/tags.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/subscriptionsgroup.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/subscriptionsgroup.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/tenants.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/tenants.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/jobcollections.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/jobcollections.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/jobs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/jobs.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/search/adminkeys.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/search/adminkeys.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/search/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/search/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/search/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/search/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/search/querykeys.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/search/querykeys.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/search/services.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/search/services.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/search/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/search/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/gateway.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/gateway.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/node.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/node.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/powershell.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/powershell.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/session.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/session.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/clientgroups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/clientgroups.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/machinegroups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/machinegroups.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/machines.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/machines.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/maps.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/maps.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/ports.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/ports.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/processes.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/processes.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/summaries.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/summaries.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/namespaces.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/namespaces.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/queues.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/queues.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/subscriptions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/subscriptions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/topics.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/topics.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/clusters.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/clusters.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/clusterversions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/clusterversions.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/capabilities.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/capabilities.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/databases.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/databases.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/elasticpools.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/elasticpools.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/firewallrules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/firewallrules.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/operations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/recommendedelasticpools.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/recommendedelasticpools.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/servers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/servers.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/accounts.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/accounts.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/usage.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/usage.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storageimportexport/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storageimportexport/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storageimportexport/jobs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storageimportexport/jobs.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storageimportexport/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storageimportexport/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storageimportexport/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storageimportexport/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/endpoints.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/endpoints.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/profiles.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/profiles.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/apps.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/apps.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/appservicecertificateorders.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/appservicecertificateorders.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/appserviceenvironments.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/appserviceenvironments.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/appserviceplans.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/appserviceplans.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/certificates.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/certificates.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/deletedwebapps.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/deletedwebapps.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/domains.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/domains.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/provider.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/provider.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/recommendations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/recommendations.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/topleveldomains.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/topleveldomains.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/datalake-store/filesystem/client.go b/vendor/github.com/Azure/azure-sdk-for-go/datalake-store/filesystem/client.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/datalake-store/filesystem/filesystemgroup.go b/vendor/github.com/Azure/azure-sdk-for-go/datalake-store/filesystem/filesystemgroup.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/datalake-store/filesystem/models.go b/vendor/github.com/Azure/azure-sdk-for-go/datalake-store/filesystem/models.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/datalake-store/filesystem/version.go b/vendor/github.com/Azure/azure-sdk-for-go/datalake-store/filesystem/version.go old mode 100755 new mode 100644 diff --git a/vendor/github.com/leonelquinteros/gotext/.gitignore b/vendor/github.com/leonelquinteros/gotext/.gitignore new file mode 100644 index 0000000000..d537248563 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/.gitignore @@ -0,0 +1,29 @@ +# Eclipse shit +.project +.settings +.buildpath + +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/vendor/github.com/leonelquinteros/gotext/.travis.yml b/vendor/github.com/leonelquinteros/gotext/.travis.yml new file mode 100644 index 0000000000..74aadf366e --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/.travis.yml @@ -0,0 +1,7 @@ +language: go +script: go test -v -race ./... + +go: + - 1.5 + - 1.6 + - tip diff --git a/vendor/github.com/leonelquinteros/gotext/Godeps/Godeps.json b/vendor/github.com/leonelquinteros/gotext/Godeps/Godeps.json new file mode 100644 index 0000000000..968e5f9543 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/Godeps/Godeps.json @@ -0,0 +1,22 @@ +{ + "ImportPath": "github.com/leonelquinteros/gotext", + "GoVersion": "go1.6", + "GodepVersion": "v74", + "Packages": [ + "./..." + ], + "Deps": [ + { + "ImportPath": "github.com/mattn/anko/ast", + "Rev": "a8c68fa2983e7dd5d3472992b1fbe2f7c44261f0" + }, + { + "ImportPath": "github.com/mattn/anko/parser", + "Rev": "a8c68fa2983e7dd5d3472992b1fbe2f7c44261f0" + }, + { + "ImportPath": "github.com/mattn/anko/vm", + "Rev": "a8c68fa2983e7dd5d3472992b1fbe2f7c44261f0" + } + ] +} diff --git a/vendor/github.com/leonelquinteros/gotext/Godeps/Readme b/vendor/github.com/leonelquinteros/gotext/Godeps/Readme new file mode 100644 index 0000000000..4cdaa53d56 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/Godeps/Readme @@ -0,0 +1,5 @@ +This directory tree is generated automatically by godep. + +Please do not edit. + +See https://github.com/tools/godep for more information. diff --git a/vendor/github.com/leonelquinteros/gotext/LICENSE b/vendor/github.com/leonelquinteros/gotext/LICENSE new file mode 100644 index 0000000000..a753ef28a5 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Leonel Quinteros + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/leonelquinteros/gotext/README.md b/vendor/github.com/leonelquinteros/gotext/README.md new file mode 100644 index 0000000000..3dd621afe7 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/README.md @@ -0,0 +1,307 @@ +[![GoDoc](https://godoc.org/github.com/leonelquinteros/gotext?status.svg)](https://godoc.org/github.com/leonelquinteros/gotext) +[![Build Status](https://travis-ci.org/leonelquinteros/gotext.svg?branch=master)](https://travis-ci.org/leonelquinteros/gotext) +[![Go Report Card](https://goreportcard.com/badge/github.com/leonelquinteros/gotext)](https://goreportcard.com/report/github.com/leonelquinteros/gotext) + +# Gotext + +[GNU gettext utilities](https://www.gnu.org/software/gettext) for Go. + +Version: [v1.1.1](https://github.com/leonelquinteros/gotext/releases/tag/v1.1.1) + + +# Features + +- Implements GNU gettext support in native Go. +- Complete support for [PO files](https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html) including: + - Support for multiline strings and headers. + - Support for variables inside translation strings using Go's [fmt syntax](https://golang.org/pkg/fmt/). + - Support for [pluralization rules](https://www.gnu.org/software/gettext/manual/html_node/Translating-plural-forms.html). + - Support for [message contexts](https://www.gnu.org/software/gettext/manual/html_node/Contexts.html). +- Thread-safe: This package is safe for concurrent use across multiple goroutines. +- It works with UTF-8 encoding as it's the default for Go language. +- Unit tests available. See coverage: https://gocover.io/github.com/leonelquinteros/gotext +- Language codes are automatically simplified from the form `en_UK` to `en` if the first isn't available. +- Ready to use inside Go templates. + + +# License + +[MIT license](LICENSE) + + +# Documentation + +Refer to the Godoc package documentation at (https://godoc.org/github.com/leonelquinteros/gotext) + + +# Installation + +``` +go get github.com/leonelquinteros/gotext +``` + +- There are no requirements or dependencies to use this package. +- No need to install GNU gettext utilities (unless specific needs of CLI tools). +- No need for environment variables. Some naming conventions are applied but not needed. + + +#### Version vendoring + +Stable releases use [semantic versioning](http://semver.org/spec/v2.0.0.html) tagging on this repository. + +You can rely on this to use your preferred vendoring tool or to manually retrieve the corresponding release tag from the GitHub repository. + + +##### Vendoring with [gopkg.in](http://labix.org/gopkg.in) + +[http://gopkg.in/leonelquinteros/gotext.v1](http://gopkg.in/leonelquinteros/gotext.v1) + +To get the latest v1 package stable release, execute: + +``` +go get gopkg.in/leonelquinteros/gotext.v1 +``` + +To import this package, add the following line to your code: + +```go +import "gopkg.in/leonelquinteros/gotext.v1" +``` + +Refer to it as gotext. + + +# Locales directories structure + +The package will assume a directories structure starting with a base path that will be provided to the package configuration +or to object constructors depending on the use, but either will use the same convention to lookup inside the base path. + +Inside the base directory where will be the language directories named using the language and country 2-letter codes (en_US, es_AR, ...). +All package functions can lookup after the simplified version for each language in case the full code isn't present but the more general language code exists. +So if the language set is `en_UK`, but there is no directory named after that code and there is a directory named `en`, +all package functions will be able to resolve this generalization and provide translations for the more general library. + +The language codes are assumed to be [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) codes (2-letter codes). +That said, most functions will work with any coding standard as long the directory name matches the language code set on the configuration. + +Then, there can be a `LC_MESSAGES` containing all PO files or the PO files themselves. +A library directory structure can look like: + +``` +/path/to/locales +/path/to/locales/en_US +/path/to/locales/en_US/LC_MESSAGES +/path/to/locales/en_US/LC_MESSAGES/default.po +/path/to/locales/en_US/LC_MESSAGES/extras.po +/path/to/locales/en_UK +/path/to/locales/en_UK/LC_MESSAGES +/path/to/locales/en_UK/LC_MESSAGES/default.po +/path/to/locales/en_UK/LC_MESSAGES/extras.po +/path/to/locales/en_AU +/path/to/locales/en_AU/LC_MESSAGES +/path/to/locales/en_AU/LC_MESSAGES/default.po +/path/to/locales/en_AU/LC_MESSAGES/extras.po +/path/to/locales/es +/path/to/locales/es/default.po +/path/to/locales/es/extras.po +/path/to/locales/es_ES +/path/to/locales/es_ES/default.po +/path/to/locales/es_ES/extras.po +/path/to/locales/fr +/path/to/locales/fr/default.po +/path/to/locales/fr/extras.po +``` + +And so on... + + + +# About translation function names + +The standard GNU gettext defines helper functions that maps to the `gettext()` function and it's widely adopted by most implementations. + +The basic translation function is usually `_()` in the form: + +``` +_("Translate this") +``` + +In Go, this can't be implemented by a reusable package as the function name has to start with a capital letter in order to be exported. + +Each implementation of this package can declare this helper functions inside their own packages if this function naming are desired/needed: + +```go +package main + +import "github.com/leonelquinteros/gotext" + +func _(str string, vars ...interface{}) string { + return gotext.Get(str, vars...) +} + +``` + +This is valid and can be used within a package. + +In normal conditions the Go compiler will optimize the calls to `_()` by replacing its content in place of the function call to reduce the function calling overhead. +This is a normal Go compiler behavior. + + + +# Usage examples + +## Using package for single language/domain settings + +For quick/simple translations you can use the package level functions directly. + +```go +import "github.com/leonelquinteros/gotext" + +func main() { + // Configure package + gotext.Configure("/path/to/locales/root/dir", "en_UK", "domain-name") + + // Translate text from default domain + println(gotext.Get("My text on 'domain-name' domain")) + + // Translate text from a different domain without reconfigure + println(gotext.GetD("domain2", "Another text on a different domain")) +} + +``` + +## Using dynamic variables on translations + +All translation strings support dynamic variables to be inserted without translate. +Use the fmt.Printf syntax (from Go's "fmt" package) to specify how to print the non-translated variable inside the translation string. + +```go +import "github.com/leonelquinteros/gotext" + +func main() { + // Configure package + gotext.Configure("/path/to/locales/root/dir", "en_UK", "domain-name") + + // Set variables + name := "John" + + // Translate text with variables + println(gotext.Get("Hi, my name is %s", name)) +} + +``` + + +## Using Locale object + +When having multiple languages/domains/libraries at the same time, you can create Locale objects for each variation +so you can handle each settings on their own. + +```go +import "github.com/leonelquinteros/gotext" + +func main() { + // Create Locale with library path and language code + l := gotext.NewLocale("/path/to/locales/root/dir", "es_UY") + + // Load domain '/path/to/locales/root/dir/es_UY/default.po' + l.AddDomain("default") + + // Translate text from default domain + println(l.Get("Translate this")) + + // Load different domain + l.AddDomain("translations") + + // Translate text from domain + println(l.GetD("translations", "Translate this")) +} +``` + +This is also helpful for using inside templates (from the "text/template" package), where you can pass the Locale object to the template. +If you set the Locale object as "Loc" in the template, then the template code would look like: + +``` +{{ .Loc.Get "Translate this" }} +``` + + +## Using the Po object to handle .po files and PO-formatted strings + +For when you need to work with PO files and strings, +you can directly use the Po object to parse it and access the translations in there in the same way. + +```go +import "github.com/leonelquinteros/gotext" + +func main() { + // Set PO content + str := ` +msgid "Translate this" +msgstr "Translated text" + +msgid "Another string" +msgstr "" + +msgid "One with var: %s" +msgstr "This one sets the var: %s" +` + + // Create Po object + po := new(Po) + po.Parse(str) + + println(po.Get("Translate this")) +} +``` + + +## Use plural forms of translations + +PO format supports defining one or more plural forms for the same translation. +Relying on the PO file headers, a Plural-Forms formula can be set on the translation file +as defined in (https://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/Plural-forms.html) + +Plural formulas are parsed and evaluated using [Anko](https://github.com/mattn/anko) + +```go +import "github.com/leonelquinteros/gotext" + +func main() { + // Set PO content + str := ` +msgid "" +msgstr "" + +# Header below +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgid "Translate this" +msgstr "Translated text" + +msgid "Another string" +msgstr "" + +msgid "One with var: %s" +msgid_plural "Several with vars: %s" +msgstr[0] "This one is the singular: %s" +msgstr[1] "This one is the plural: %s" +` + + // Create Po object + po := new(Po) + po.Parse(str) + + println(po.GetN("One with var: %s", "Several with vars: %s", 54, v)) + // "This one is the plural: Variable" +} +``` + + +# Contribute + +- Please, contribute. +- Use the package on your projects. +- Report issues on Github. +- Send pull requests for bugfixes and improvements. +- Send proposals on Github issues. diff --git a/vendor/github.com/leonelquinteros/gotext/gotext.go b/vendor/github.com/leonelquinteros/gotext/gotext.go new file mode 100644 index 0000000000..4f4d94362c --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/gotext.go @@ -0,0 +1,151 @@ +/* +Package gotext implements GNU gettext utilities. + +For quick/simple translations you can use the package level functions directly. + + import "github.com/leonelquinteros/gotext" + + func main() { + // Configure package + gotext.Configure("/path/to/locales/root/dir", "en_UK", "domain-name") + + // Translate text from default domain + println(gotext.Get("My text on 'domain-name' domain")) + + // Translate text from a different domain without reconfigure + println(gotext.GetD("domain2", "Another text on a different domain")) + } + +*/ +package gotext + +// Global environment variables +var ( + // Default domain to look at when no domain is specified. Used by package level functions. + domain = "default" + + // Language set. + language = "en_US" + + // Path to library directory where all locale directories and translation files are. + library = "/usr/local/share/locale" + + // Storage for package level methods + storage *Locale +) + +// loadStorage creates a new Locale object at package level based on the Global variables settings. +// It's called automatically when trying to use Get or GetD methods. +func loadStorage(force bool) { + if storage == nil || force { + storage = NewLocale(library, language) + } + + if _, ok := storage.domains[domain]; !ok || force { + storage.AddDomain(domain) + } +} + +// GetDomain is the domain getter for the package configuration +func GetDomain() string { + return domain +} + +// SetDomain sets the name for the domain to be used at package level. +// It reloads the corresponding translation file. +func SetDomain(dom string) { + domain = dom + loadStorage(true) +} + +// GetLanguage is the language getter for the package configuration +func GetLanguage() string { + return language +} + +// SetLanguage sets the language code to be used at package level. +// It reloads the corresponding translation file. +func SetLanguage(lang string) { + language = lang + loadStorage(true) +} + +// GetLibrary is the library getter for the package configuration +func GetLibrary() string { + return library +} + +// SetLibrary sets the root path for the loale directories and files to be used at package level. +// It reloads the corresponding translation file. +func SetLibrary(lib string) { + library = lib + loadStorage(true) +} + +// Configure sets all configuration variables to be used at package level and reloads the corresponding translation file. +// It receives the library path, language code and domain name. +// This function is recommended to be used when changing more than one setting, +// as using each setter will introduce a I/O overhead because the translation file will be loaded after each set. +func Configure(lib, lang, dom string) { + library = lib + language = lang + domain = dom + + loadStorage(true) +} + +// Get uses the default domain globally set to return the corresponding translation of a given string. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func Get(str string, vars ...interface{}) string { + return GetD(domain, str, vars...) +} + +// GetN retrieves the (N)th plural form of translation for the given string in the "default" domain. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func GetN(str, plural string, n int, vars ...interface{}) string { + return GetND("default", str, plural, n, vars...) +} + +// GetD returns the corresponding translation in the given domain for a given string. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func GetD(dom, str string, vars ...interface{}) string { + return GetND(dom, str, str, 1, vars...) +} + +// GetND retrieves the (N)th plural form of translation in the given domain for a given string. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func GetND(dom, str, plural string, n int, vars ...interface{}) string { + // Try to load default package Locale storage + loadStorage(false) + + // Return translation + return storage.GetND(dom, str, plural, n, vars...) +} + +// GetC uses the default domain globally set to return the corresponding translation of the given string in the given context. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func GetC(str, ctx string, vars ...interface{}) string { + return GetDC(domain, str, ctx, vars...) +} + +// GetNC retrieves the (N)th plural form of translation for the given string in the given context in the "default" domain. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func GetNC(str, plural string, n int, ctx string, vars ...interface{}) string { + return GetNDC("default", str, plural, n, ctx, vars...) +} + +// GetDC returns the corresponding translation in the given domain for the given string in the given context. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func GetDC(dom, str, ctx string, vars ...interface{}) string { + return GetNDC(dom, str, str, 1, ctx, vars...) +} + +// GetNDC retrieves the (N)th plural form of translation in the given domain for a given string. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func GetNDC(dom, str, plural string, n int, ctx string, vars ...interface{}) string { + // Try to load default package Locale storage + loadStorage(false) + + // Return translation + return storage.GetNDC(dom, str, plural, n, ctx, vars...) +} diff --git a/vendor/github.com/leonelquinteros/gotext/gotext_test.go b/vendor/github.com/leonelquinteros/gotext/gotext_test.go new file mode 100644 index 0000000000..d9b786ded5 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/gotext_test.go @@ -0,0 +1,199 @@ +package gotext + +import ( + "os" + "path" + "testing" +) + +func TestGettersSetters(t *testing.T) { + SetDomain("test") + dom := GetDomain() + + if dom != "test" { + t.Errorf("Expected GetDomain to return 'test', but got '%s'", dom) + } + + SetLibrary("/tmp/test") + lib := GetLibrary() + + if lib != "/tmp/test" { + t.Errorf("Expected GetLibrary to return '/tmp/test', but got '%s'", lib) + } + + SetLanguage("es") + lang := GetLanguage() + + if lang != "es" { + t.Errorf("Expected GetLanguage to return 'es', but got '%s'", lang) + } +} + +func TestPackageFunctions(t *testing.T) { + // Set PO content + str := ` +msgid "" +msgstr "" +# Initial comment +# Headers below +"Language: en\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +# Some comment +msgid "My text" +msgstr "Translated text" + +# More comments +msgid "Another string" +msgstr "" + +msgid "One with var: %s" +msgid_plural "Several with vars: %s" +msgstr[0] "This one is the singular: %s" +msgstr[1] "This one is the plural: %s" +msgstr[2] "And this is the second plural form: %s" + +msgid "This one has invalid syntax translations" +msgid_plural "Plural index" +msgstr[abc] "Wrong index" +msgstr[1 "Forgot to close brackets" +msgstr[0] "Badly formatted string' + +msgid "Invalid formatted id[] with no translations + +msgctxt "Ctx" +msgid "One with var: %s" +msgid_plural "Several with vars: %s" +msgstr[0] "This one is the singular in a Ctx context: %s" +msgstr[1] "This one is the plural in a Ctx context: %s" + +msgid "Some random" +msgstr "Some random translation" + +msgctxt "Ctx" +msgid "Some random in a context" +msgstr "Some random translation in a context" + +msgid "More" +msgstr "More translation" + + ` + + // Create Locales directory on default location + dirname := path.Clean("/tmp" + string(os.PathSeparator) + "en_US") + err := os.MkdirAll(dirname, os.ModePerm) + if err != nil { + t.Fatalf("Can't create test directory: %s", err.Error()) + } + + // Write PO content to default domain file + filename := path.Clean(dirname + string(os.PathSeparator) + "default.po") + + f, err := os.Create(filename) + if err != nil { + t.Fatalf("Can't create test file: %s", err.Error()) + } + defer f.Close() + + _, err = f.WriteString(str) + if err != nil { + t.Fatalf("Can't write to test file: %s", err.Error()) + } + + // Set package configuration + Configure("/tmp", "en_US", "default") + + // Test translations + tr := Get("My text") + if tr != "Translated text" { + t.Errorf("Expected 'Translated text' but got '%s'", tr) + } + + v := "Variable" + tr = Get("One with var: %s", v) + if tr != "This one is the singular: Variable" { + t.Errorf("Expected 'This one is the singular: Variable' but got '%s'", tr) + } + + // Test plural + tr = GetN("One with var: %s", "Several with vars: %s", 2, v) + if tr != "This one is the plural: Variable" { + t.Errorf("Expected 'This one is the plural: Variable' but got '%s'", tr) + } + + // Test context translations + tr = GetC("Some random in a context", "Ctx") + if tr != "Some random translation in a context" { + t.Errorf("Expected 'Some random translation in a context' but got '%s'", tr) + } + + v = "Variable" + tr = GetC("One with var: %s", "Ctx", v) + if tr != "This one is the singular in a Ctx context: Variable" { + t.Errorf("Expected 'This one is the singular in a Ctx context: Variable' but got '%s'", tr) + } + + tr = GetNC("One with var: %s", "Several with vars: %s", 19, "Ctx", v) + if tr != "This one is the plural in a Ctx context: Variable" { + t.Errorf("Expected 'This one is the plural in a Ctx context: Variable' but got '%s'", tr) + } +} + +func TestPackageRace(t *testing.T) { + // Set PO content + str := `# Some comment +msgid "My text" +msgstr "Translated text" + +# More comments +msgid "Another string" +msgstr "" + +msgid "One with var: %s" +msgid_plural "Several with vars: %s" +msgstr[0] "This one is the singular: %s" +msgstr[1] "This one is the plural: %s" +msgstr[2] "And this is the second plural form: %s" + + ` + + // Create Locales directory on default location + dirname := path.Clean(library + string(os.PathSeparator) + "en_US") + err := os.MkdirAll(dirname, os.ModePerm) + if err != nil { + t.Fatalf("Can't create test directory: %s", err.Error()) + } + + // Write PO content to default domain file + filename := path.Clean(dirname + string(os.PathSeparator) + domain + ".po") + + f, err := os.Create(filename) + if err != nil { + t.Fatalf("Can't create test file: %s", err.Error()) + } + defer f.Close() + + _, err = f.WriteString(str) + if err != nil { + t.Fatalf("Can't write to test file: %s", err.Error()) + } + + // Init sync channels + c1 := make(chan bool) + c2 := make(chan bool) + + // Test translations + go func(done chan bool) { + Get("My text") + done <- true + }(c1) + + go func(done chan bool) { + Get("My text") + done <- true + }(c2) + + Get("My text") +} diff --git a/vendor/github.com/leonelquinteros/gotext/locale.go b/vendor/github.com/leonelquinteros/gotext/locale.go new file mode 100644 index 0000000000..1cb59b7a80 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/locale.go @@ -0,0 +1,176 @@ +package gotext + +import ( + "fmt" + "os" + "path" + "sync" +) + +/* +Locale wraps the entire i18n collection for a single language (locale) +It's used by the package functions, but it can also be used independently to handle +multiple languages at the same time by working with this object. + +Example: + + import "github.com/leonelquinteros/gotext" + + func main() { + // Create Locale with library path and language code + l := gotext.NewLocale("/path/to/i18n/dir", "en_US") + + // Load domain '/path/to/i18n/dir/en_US/LC_MESSAGES/default.po' + l.AddDomain("default") + + // Translate text from default domain + println(l.Get("Translate this")) + + // Load different domain ('/path/to/i18n/dir/en_US/LC_MESSAGES/extras.po') + l.AddDomain("extras") + + // Translate text from domain + println(l.GetD("extras", "Translate this")) + } + +*/ +type Locale struct { + // Path to locale files. + path string + + // Language for this Locale + lang string + + // List of available domains for this locale. + domains map[string]*Po + + // Sync Mutex + sync.RWMutex +} + +// NewLocale creates and initializes a new Locale object for a given language. +// It receives a path for the i18n files directory (p) and a language code to use (l). +func NewLocale(p, l string) *Locale { + return &Locale{ + path: p, + lang: l, + domains: make(map[string]*Po), + } +} + +func (l *Locale) findPO(dom string) string { + filename := path.Join(l.path, l.lang, "LC_MESSAGES", dom+".po") + if _, err := os.Stat(filename); err == nil { + return filename + } + + if len(l.lang) > 2 { + filename = path.Join(l.path, l.lang[:2], "LC_MESSAGES", dom+".po") + if _, err := os.Stat(filename); err == nil { + return filename + } + } + + filename = path.Join(l.path, l.lang, dom+".po") + if _, err := os.Stat(filename); err == nil { + return filename + } + + if len(l.lang) > 2 { + filename = path.Join(l.path, l.lang[:2], dom+".po") + } + + return filename +} + +// AddDomain creates a new domain for a given locale object and initializes the Po object. +// If the domain exists, it gets reloaded. +func (l *Locale) AddDomain(dom string) { + po := new(Po) + + // Parse file. + po.ParseFile(l.findPO(dom)) + + // Save new domain + l.Lock() + defer l.Unlock() + + if l.domains == nil { + l.domains = make(map[string]*Po) + } + l.domains[dom] = po +} + +// Get uses a domain "default" to return the corresponding translation of a given string. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func (l *Locale) Get(str string, vars ...interface{}) string { + return l.GetD("default", str, vars...) +} + +// GetN retrieves the (N)th plural form of translation for the given string in the "default" domain. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func (l *Locale) GetN(str, plural string, n int, vars ...interface{}) string { + return l.GetND("default", str, plural, n, vars...) +} + +// GetD returns the corresponding translation in the given domain for the given string. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func (l *Locale) GetD(dom, str string, vars ...interface{}) string { + return l.GetND(dom, str, str, 1, vars...) +} + +// GetND retrieves the (N)th plural form of translation in the given domain for the given string. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func (l *Locale) GetND(dom, str, plural string, n int, vars ...interface{}) string { + // Sync read + l.RLock() + defer l.RUnlock() + + if l.domains != nil { + if _, ok := l.domains[dom]; ok { + if l.domains[dom] != nil { + return l.domains[dom].GetN(str, plural, n, vars...) + } + } + } + + // Return the same we received by default + return fmt.Sprintf(plural, vars...) +} + +// GetC uses a domain "default" to return the corresponding translation of the given string in the given context. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func (l *Locale) GetC(str, ctx string, vars ...interface{}) string { + return l.GetDC("default", str, ctx, vars...) +} + +// GetNC retrieves the (N)th plural form of translation for the given string in the given context in the "default" domain. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func (l *Locale) GetNC(str, plural string, n int, ctx string, vars ...interface{}) string { + return l.GetNDC("default", str, plural, n, ctx, vars...) +} + +// GetDC returns the corresponding translation in the given domain for the given string in the given context. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func (l *Locale) GetDC(dom, str, ctx string, vars ...interface{}) string { + return l.GetNDC(dom, str, str, 1, ctx, vars...) +} + +// GetNDC retrieves the (N)th plural form of translation in the given domain for the given string in the given context. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func (l *Locale) GetNDC(dom, str, plural string, n int, ctx string, vars ...interface{}) string { + // Sync read + l.RLock() + defer l.RUnlock() + + if l.domains != nil { + if _, ok := l.domains[dom]; ok { + if l.domains[dom] != nil { + return l.domains[dom].GetNC(str, plural, n, ctx, vars...) + } + } + } + + // Return the same we received by default + return fmt.Sprintf(plural, vars...) +} diff --git a/vendor/github.com/leonelquinteros/gotext/locale_test.go b/vendor/github.com/leonelquinteros/gotext/locale_test.go new file mode 100644 index 0000000000..062b0bfc36 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/locale_test.go @@ -0,0 +1,310 @@ +package gotext + +import ( + "os" + "path" + "testing" +) + +func TestLocale(t *testing.T) { + // Set PO content + str := ` +msgid "" +msgstr "" +# Initial comment +# Headers below +"Language: en\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +# Some comment +msgid "My text" +msgstr "Translated text" + +# More comments +msgid "Another string" +msgstr "" + +msgid "One with var: %s" +msgid_plural "Several with vars: %s" +msgstr[0] "This one is the singular: %s" +msgstr[1] "This one is the plural: %s" +msgstr[2] "And this is the second plural form: %s" + +msgid "This one has invalid syntax translations" +msgid_plural "Plural index" +msgstr[abc] "Wrong index" +msgstr[1 "Forgot to close brackets" +msgstr[0] "Badly formatted string' + +msgid "Invalid formatted id[] with no translations + +msgctxt "Ctx" +msgid "One with var: %s" +msgid_plural "Several with vars: %s" +msgstr[0] "This one is the singular in a Ctx context: %s" +msgstr[1] "This one is the plural in a Ctx context: %s" + +msgid "Some random" +msgstr "Some random translation" + +msgctxt "Ctx" +msgid "Some random in a context" +msgstr "Some random translation in a context" + +msgid "More" +msgstr "More translation" + + ` + + // Create Locales directory with simplified language code + dirname := path.Join("/tmp", "en", "LC_MESSAGES") + err := os.MkdirAll(dirname, os.ModePerm) + if err != nil { + t.Fatalf("Can't create test directory: %s", err.Error()) + } + + // Write PO content to file + filename := path.Join(dirname, "my_domain.po") + + f, err := os.Create(filename) + if err != nil { + t.Fatalf("Can't create test file: %s", err.Error()) + } + defer f.Close() + + _, err = f.WriteString(str) + if err != nil { + t.Fatalf("Can't write to test file: %s", err.Error()) + } + + // Create Locale with full language code + l := NewLocale("/tmp", "en_US") + + // Force nil domain storage + l.domains = nil + + // Add domain + l.AddDomain("my_domain") + + // Test translations + tr := l.GetD("my_domain", "My text") + if tr != "Translated text" { + t.Errorf("Expected 'Translated text' but got '%s'", tr) + } + + v := "Variable" + tr = l.GetD("my_domain", "One with var: %s", v) + if tr != "This one is the singular: Variable" { + t.Errorf("Expected 'This one is the singular: Variable' but got '%s'", tr) + } + + // Test plural + tr = l.GetND("my_domain", "One with var: %s", "Several with vars: %s", 7, v) + if tr != "This one is the plural: Variable" { + t.Errorf("Expected 'This one is the plural: Variable' but got '%s'", tr) + } + + // Test context translations + v = "Test" + tr = l.GetDC("my_domain", "One with var: %s", "Ctx", v) + if tr != "This one is the singular in a Ctx context: Test" { + t.Errorf("Expected 'This one is the singular in a Ctx context: Test' but got '%s'", tr) + } + + // Test plural + tr = l.GetNDC("my_domain", "One with var: %s", "Several with vars: %s", 3, "Ctx", v) + if tr != "This one is the plural in a Ctx context: Test" { + t.Errorf("Expected 'This one is the plural in a Ctx context: Test' but got '%s'", tr) + } + + // Test last translation + tr = l.GetD("my_domain", "More") + if tr != "More translation" { + t.Errorf("Expected 'More translation' but got '%s'", tr) + } +} + +func TestLocaleFails(t *testing.T) { + // Set PO content + str := ` +msgid "" +msgstr "" +# Initial comment +# Headers below +"Language: en\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +# Some comment +msgid "My text" +msgstr "Translated text" + +# More comments +msgid "Another string" +msgstr "" + +msgid "One with var: %s" +msgid_plural "Several with vars: %s" +msgstr[0] "This one is the singular: %s" +msgstr[1] "This one is the plural: %s" +msgstr[2] "And this is the second plural form: %s" + +msgid "This one has invalid syntax translations" +msgid_plural "Plural index" +msgstr[abc] "Wrong index" +msgstr[1 "Forgot to close brackets" +msgstr[0] "Badly formatted string' + +msgid "Invalid formatted id[] with no translations + +msgctxt "Ctx" +msgid "One with var: %s" +msgid_plural "Several with vars: %s" +msgstr[0] "This one is the singular in a Ctx context: %s" +msgstr[1] "This one is the plural in a Ctx context: %s" + +msgid "Some random" +msgstr "Some random translation" + +msgctxt "Ctx" +msgid "Some random in a context" +msgstr "Some random translation in a context" + +msgid "More" +msgstr "More translation" + + ` + + // Create Locales directory with simplified language code + dirname := path.Join("/tmp", "en", "LC_MESSAGES") + err := os.MkdirAll(dirname, os.ModePerm) + if err != nil { + t.Fatalf("Can't create test directory: %s", err.Error()) + } + + // Write PO content to file + filename := path.Join(dirname, "my_domain.po") + + f, err := os.Create(filename) + if err != nil { + t.Fatalf("Can't create test file: %s", err.Error()) + } + defer f.Close() + + _, err = f.WriteString(str) + if err != nil { + t.Fatalf("Can't write to test file: %s", err.Error()) + } + + // Create Locale with full language code + l := NewLocale("/tmp", "en_US") + + // Force nil domain storage + l.domains = nil + + // Add domain + l.AddDomain("my_domain") + + // Test non-existent "deafult" domain responses + tr := l.Get("My text") + if tr != "My text" { + t.Errorf("Expected 'My text' but got '%s'", tr) + } + + v := "Variable" + tr = l.GetN("One with var: %s", "Several with vars: %s", 2, v) + if tr != "Several with vars: Variable" { + t.Errorf("Expected 'Several with vars: Variable' but got '%s'", tr) + } + + // Test inexistent translations + tr = l.Get("This is a test") + if tr != "This is a test" { + t.Errorf("Expected 'This is a test' but got '%s'", tr) + } + + tr = l.GetN("This is a test", "This are tests", 1) + if tr != "This are tests" { + t.Errorf("Expected 'This are tests' but got '%s'", tr) + } + + // Test syntax error parsed translations + tr = l.Get("This one has invalid syntax translations") + if tr != "This one has invalid syntax translations" { + t.Errorf("Expected 'This one has invalid syntax translations' but got '%s'", tr) + } + + tr = l.GetN("This one has invalid syntax translations", "This are tests", 1) + if tr != "This are tests" { + t.Errorf("Expected 'Plural index' but got '%s'", tr) + } +} + +func TestLocaleRace(t *testing.T) { + // Set PO content + str := `# Some comment +msgid "My text" +msgstr "Translated text" + +# More comments +msgid "Another string" +msgstr "" + +msgid "One with var: %s" +msgid_plural "Several with vars: %s" +msgstr[0] "This one is the singular: %s" +msgstr[1] "This one is the plural: %s" +msgstr[2] "And this is the second plural form: %s" + + ` + + // Create Locales directory with simplified language code + dirname := path.Join("/tmp", "es") + err := os.MkdirAll(dirname, os.ModePerm) + if err != nil { + t.Fatalf("Can't create test directory: %s", err.Error()) + } + + // Write PO content to file + filename := path.Join(dirname, "race.po") + + f, err := os.Create(filename) + if err != nil { + t.Fatalf("Can't create test file: %s", err.Error()) + } + defer f.Close() + + _, err = f.WriteString(str) + if err != nil { + t.Fatalf("Can't write to test file: %s", err.Error()) + } + + // Create Locale with full language code + l := NewLocale("/tmp", "es") + + // Init sync channels + ac := make(chan bool) + rc := make(chan bool) + + // Add domain in goroutine + go func(l *Locale, done chan bool) { + l.AddDomain("race") + done <- true + }(l, ac) + + // Get translations in goroutine + go func(l *Locale, done chan bool) { + l.GetD("race", "My text") + done <- true + }(l, rc) + + // Get translations at top level + l.GetD("race", "My text") + + // Wait for goroutines to finish + <-ac + <-rc +} diff --git a/vendor/github.com/leonelquinteros/gotext/po.go b/vendor/github.com/leonelquinteros/gotext/po.go new file mode 100644 index 0000000000..57a818484a --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/po.go @@ -0,0 +1,450 @@ +package gotext + +import ( + "bufio" + "fmt" + "github.com/mattn/anko/vm" + "io/ioutil" + "net/textproto" + "os" + "strconv" + "strings" + "sync" +) + +type translation struct { + id string + pluralID string + trs map[int]string +} + +func newTranslation() *translation { + tr := new(translation) + tr.trs = make(map[int]string) + + return tr +} + +func (t *translation) get() string { + // Look for translation index 0 + if _, ok := t.trs[0]; ok { + return t.trs[0] + } + + // Return unstranlated id by default + return t.id +} + +func (t *translation) getN(n int) string { + // Look for translation index + if _, ok := t.trs[n]; ok { + return t.trs[n] + } + + // Return unstranlated plural by default + return t.pluralID +} + +/* +Po parses the content of any PO file and provides all the translation functions needed. +It's the base object used by all package methods. +And it's safe for concurrent use by multiple goroutines by using the sync package for locking. + +Example: + + import "github.com/leonelquinteros/gotext" + + func main() { + // Create po object + po := new(gotext.Po) + + // Parse .po file + po.ParseFile("/path/to/po/file/translations.po") + + // Get translation + println(po.Get("Translate this")) + } + +*/ +type Po struct { + // Headers + RawHeaders string + + // Language header + Language string + + // Plural-Forms header + PluralForms string + + // Parsed Plural-Forms header values + nplurals int + plural string + + // Storage + translations map[string]*translation + contexts map[string]map[string]*translation + + // Sync Mutex + sync.RWMutex + + // Parsing buffers + trBuffer *translation + ctxBuffer string +} + +// ParseFile tries to read the file by its provided path (f) and parse its content as a .po file. +func (po *Po) ParseFile(f string) { + // Check if file exists + info, err := os.Stat(f) + if err != nil { + return + } + + // Check that isn't a directory + if info.IsDir() { + return + } + + // Parse file content + data, err := ioutil.ReadFile(f) + if err != nil { + return + } + + po.Parse(string(data)) +} + +// Parse loads the translations specified in the provided string (str) +func (po *Po) Parse(str string) { + // Lock while parsing + po.Lock() + defer po.Unlock() + + // Init storage + if po.translations == nil { + po.translations = make(map[string]*translation) + po.contexts = make(map[string]map[string]*translation) + } + + // Get lines + lines := strings.Split(str, "\n") + + // Init buffer + po.trBuffer = newTranslation() + po.ctxBuffer = "" + + for _, l := range lines { + // Trim spaces + l = strings.TrimSpace(l) + + // Skip invalid lines + if !po.isValidLine(l) { + continue + } + + // Buffer context and continue + if strings.HasPrefix(l, "msgctxt") { + po.parseContext(l) + continue + } + + // Buffer msgid and continue + if strings.HasPrefix(l, "msgid") && !strings.HasPrefix(l, "msgid_plural") { + po.parseID(l) + continue + } + + // Check for plural form + if strings.HasPrefix(l, "msgid_plural") { + po.parsePluralID(l) + continue + } + + // Save translation + if strings.HasPrefix(l, "msgstr") { + po.parseMessage(l) + continue + } + + // Multi line strings and headers + if strings.HasPrefix(l, "\"") && strings.HasSuffix(l, "\"") { + po.parseString(l) + continue + } + } + + // Save last translation buffer. + po.saveBuffer() + + // Parse headers + po.parseHeaders() +} + +// saveBuffer takes the context and translation buffers +// and saves it on the translations collection +func (po *Po) saveBuffer() { + // If we have something to save... + if po.trBuffer.id != "" { + // With no context... + if po.ctxBuffer == "" { + po.translations[po.trBuffer.id] = po.trBuffer + } else { + // With context... + if _, ok := po.contexts[po.ctxBuffer]; !ok { + po.contexts[po.ctxBuffer] = make(map[string]*translation) + } + po.contexts[po.ctxBuffer][po.trBuffer.id] = po.trBuffer + } + + // Flush buffer + po.trBuffer = newTranslation() + po.ctxBuffer = "" + } +} + +// parseContext takes a line starting with "msgctxt", +// saves the current translation buffer and creates a new context. +func (po *Po) parseContext(l string) { + // Save current translation buffer. + po.saveBuffer() + + // Buffer context + po.ctxBuffer, _ = strconv.Unquote(strings.TrimSpace(strings.TrimPrefix(l, "msgctxt"))) +} + +// parseID takes a line starting with "msgid", +// saves the current translation and creates a new msgid buffer. +func (po *Po) parseID(l string) { + // Save current translation buffer. + po.saveBuffer() + + // Set id + po.trBuffer.id, _ = strconv.Unquote(strings.TrimSpace(strings.TrimPrefix(l, "msgid"))) +} + +// parsePluralID saves the plural id buffer from a line starting with "msgid_plural" +func (po *Po) parsePluralID(l string) { + po.trBuffer.pluralID, _ = strconv.Unquote(strings.TrimSpace(strings.TrimPrefix(l, "msgid_plural"))) +} + +// parseMessage takes a line starting with "msgstr" and saves it into the current buffer. +func (po *Po) parseMessage(l string) { + l = strings.TrimSpace(strings.TrimPrefix(l, "msgstr")) + + // Check for indexed translation forms + if strings.HasPrefix(l, "[") { + idx := strings.Index(l, "]") + if idx == -1 { + // Skip wrong index formatting + return + } + + // Parse index + i, err := strconv.Atoi(l[1:idx]) + if err != nil { + // Skip wrong index formatting + return + } + + // Parse translation string + po.trBuffer.trs[i], _ = strconv.Unquote(strings.TrimSpace(l[idx+1:])) + + // Loop + return + } + + // Save single translation form under 0 index + po.trBuffer.trs[0], _ = strconv.Unquote(l) +} + +// parseString takes a well formatted string without prefix +// and creates headers or attach multi-line strings when corresponding +func (po *Po) parseString(l string) { + // Check for multiline from previously set msgid + if po.trBuffer.id != "" { + // Append to last translation found + uq, _ := strconv.Unquote(l) + po.trBuffer.trs[len(po.trBuffer.trs)-1] += uq + + return + } + + // Otherwise is a header + h, err := strconv.Unquote(strings.TrimSpace(l)) + if err != nil { + return + } + + po.RawHeaders += h +} + +// isValidLine checks for line prefixes to detect valid syntax. +func (po *Po) isValidLine(l string) bool { + // Skip empty lines + if l == "" { + return false + } + + // Check prefix + if !strings.HasPrefix(l, "\"") && !strings.HasPrefix(l, "msgctxt") && !strings.HasPrefix(l, "msgid") && !strings.HasPrefix(l, "msgid_plural") && !strings.HasPrefix(l, "msgstr") { + return false + } + + return true +} + +// parseHeaders retrieves data from previously parsed headers +func (po *Po) parseHeaders() { + // Make sure we end with 2 carriage returns. + po.RawHeaders += "\n\n" + + // Read + reader := bufio.NewReader(strings.NewReader(po.RawHeaders)) + tp := textproto.NewReader(reader) + + mimeHeader, err := tp.ReadMIMEHeader() + if err != nil { + return + } + + // Get/save needed headers + po.Language = mimeHeader.Get("Language") + po.PluralForms = mimeHeader.Get("Plural-Forms") + + // Parse Plural-Forms formula + if po.PluralForms == "" { + return + } + + // Split plural form header value + pfs := strings.Split(po.PluralForms, ";") + + // Parse values + for _, i := range pfs { + vs := strings.SplitN(i, "=", 2) + if len(vs) != 2 { + continue + } + + switch strings.TrimSpace(vs[0]) { + case "nplurals": + po.nplurals, _ = strconv.Atoi(vs[1]) + + case "plural": + po.plural = vs[1] + } + } +} + +// pluralForm calculates the plural form index corresponding to n. +// Returns 0 on error +func (po *Po) pluralForm(n int) int { + po.RLock() + defer po.RUnlock() + + // Failsafe + if po.nplurals < 1 { + return 0 + } + if po.plural == "" { + return 0 + } + + // Init compiler + env := vm.NewEnv() + env.Define("n", n) + + plural, err := env.Execute(po.plural) + if err != nil { + return 0 + } + if plural.Type().Name() == "bool" { + if plural.Bool() { + return 1 + } + // Else + return 0 + } + + if int(plural.Int()) > po.nplurals { + return 0 + } + + return int(plural.Int()) +} + +// Get retrieves the corresponding translation for the given string. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func (po *Po) Get(str string, vars ...interface{}) string { + // Sync read + po.RLock() + defer po.RUnlock() + + if po.translations != nil { + if _, ok := po.translations[str]; ok { + return fmt.Sprintf(po.translations[str].get(), vars...) + } + } + + // Return the same we received by default + return fmt.Sprintf(str, vars...) +} + +// GetN retrieves the (N)th plural form of translation for the given string. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func (po *Po) GetN(str, plural string, n int, vars ...interface{}) string { + // Sync read + po.RLock() + defer po.RUnlock() + + if po.translations != nil { + if _, ok := po.translations[str]; ok { + return fmt.Sprintf(po.translations[str].getN(po.pluralForm(n)), vars...) + } + } + + // Return the plural string we received by default + return fmt.Sprintf(plural, vars...) +} + +// GetC retrieves the corresponding translation for a given string in the given context. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func (po *Po) GetC(str, ctx string, vars ...interface{}) string { + // Sync read + po.RLock() + defer po.RUnlock() + + if po.contexts != nil { + if _, ok := po.contexts[ctx]; ok { + if po.contexts[ctx] != nil { + if _, ok := po.contexts[ctx][str]; ok { + return fmt.Sprintf(po.contexts[ctx][str].get(), vars...) + } + } + } + } + + // Return the string we received by default + return fmt.Sprintf(str, vars...) +} + +// GetNC retrieves the (N)th plural form of translation for the given string in the given context. +// Supports optional parameters (vars... interface{}) to be inserted on the formatted string using the fmt.Printf syntax. +func (po *Po) GetNC(str, plural string, n int, ctx string, vars ...interface{}) string { + // Sync read + po.RLock() + defer po.RUnlock() + + if po.contexts != nil { + if _, ok := po.contexts[ctx]; ok { + if po.contexts[ctx] != nil { + if _, ok := po.contexts[ctx][str]; ok { + return fmt.Sprintf(po.contexts[ctx][str].getN(po.pluralForm(n)), vars...) + } + } + } + } + + // Return the plural string we received by default + return fmt.Sprintf(plural, vars...) +} diff --git a/vendor/github.com/leonelquinteros/gotext/po_test.go b/vendor/github.com/leonelquinteros/gotext/po_test.go new file mode 100644 index 0000000000..9f59a33d22 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/po_test.go @@ -0,0 +1,424 @@ +package gotext + +import ( + "os" + "path" + "testing" +) + +func TestPo(t *testing.T) { + // Set PO content + str := ` +msgid "" +msgstr "" +# Initial comment +# Headers below +"Language: en\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +# Some comment +msgid "My text" +msgstr "Translated text" + +# More comments +msgid "Another string" +msgstr "" + +#Multi-line string +msgid "Multi-line" +msgstr "Multi " +"line" + +msgid "One with var: %s" +msgid_plural "Several with vars: %s" +msgstr[0] "This one is the singular: %s" +msgstr[1] "This one is the plural: %s" +msgstr[2] "And this is the second plural form: %s" + +msgid "This one has invalid syntax translations" +msgid_plural "Plural index" +msgstr[abc] "Wrong index" +msgstr[1 "Forgot to close brackets" +msgstr[0] "Badly formatted string' + +msgid "Invalid formatted id[] with no translations + +msgctxt "Ctx" +msgid "One with var: %s" +msgid_plural "Several with vars: %s" +msgstr[0] "This one is the singular in a Ctx context: %s" +msgstr[1] "This one is the plural in a Ctx context: %s" + +msgid "Some random" +msgstr "Some random translation" + +msgctxt "Ctx" +msgid "Some random in a context" +msgstr "Some random translation in a context" + +msgid "More" +msgstr "More translation" + ` + + // Write PO content to file + filename := path.Clean(os.TempDir() + string(os.PathSeparator) + "default.po") + + f, err := os.Create(filename) + if err != nil { + t.Fatalf("Can't create test file: %s", err.Error()) + } + defer f.Close() + + _, err = f.WriteString(str) + if err != nil { + t.Fatalf("Can't write to test file: %s", err.Error()) + } + + // Create po object + po := new(Po) + + // Try to parse a directory + po.ParseFile(path.Clean(os.TempDir())) + + // Parse file + po.ParseFile(filename) + + // Test translations + tr := po.Get("My text") + if tr != "Translated text" { + t.Errorf("Expected 'Translated text' but got '%s'", tr) + } + + v := "Variable" + tr = po.Get("One with var: %s", v) + if tr != "This one is the singular: Variable" { + t.Errorf("Expected 'This one is the singular: Variable' but got '%s'", tr) + } + + // Test multi-line + tr = po.Get("Multi-line") + if tr != "Multi line" { + t.Errorf("Expected 'Multi line' but got '%s'", tr) + } + + // Test plural + tr = po.GetN("One with var: %s", "Several with vars: %s", 2, v) + if tr != "This one is the plural: Variable" { + t.Errorf("Expected 'This one is the plural: Variable' but got '%s'", tr) + } + + // Test inexistent translations + tr = po.Get("This is a test") + if tr != "This is a test" { + t.Errorf("Expected 'This is a test' but got '%s'", tr) + } + + tr = po.GetN("This is a test", "This are tests", 100) + if tr != "This are tests" { + t.Errorf("Expected 'This are tests' but got '%s'", tr) + } + + // Test syntax error parsed translations + tr = po.Get("This one has invalid syntax translations") + if tr != "" { + t.Errorf("Expected '' but got '%s'", tr) + } + + tr = po.GetN("This one has invalid syntax translations", "This are tests", 4) + if tr != "Plural index" { + t.Errorf("Expected 'Plural index' but got '%s'", tr) + } + + // Test context translations + v = "Test" + tr = po.GetC("One with var: %s", "Ctx", v) + if tr != "This one is the singular in a Ctx context: Test" { + t.Errorf("Expected 'This one is the singular in a Ctx context: Test' but got '%s'", tr) + } + + // Test plural + tr = po.GetNC("One with var: %s", "Several with vars: %s", 17, "Ctx", v) + if tr != "This one is the plural in a Ctx context: Test" { + t.Errorf("Expected 'This one is the plural in a Ctx context: Test' but got '%s'", tr) + } + + // Test last translation + tr = po.Get("More") + if tr != "More translation" { + t.Errorf("Expected 'More translation' but got '%s'", tr) + } + +} + +func TestPoHeaders(t *testing.T) { + // Set PO content + str := ` +msgid "" +msgstr "" +# Initial comment +# Headers below +"Language: en\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +# Some comment +msgid "Example" +msgstr "Translated example" + ` + + // Create po object + po := new(Po) + + // Parse + po.Parse(str) + + // Check headers expected + if po.Language != "en" { + t.Errorf("Expected 'Language: en' but got '%s'", po.Language) + } + + // Check headers expected + if po.PluralForms != "nplurals=2; plural=(n != 1);" { + t.Errorf("Expected 'Plural-Forms: nplurals=2; plural=(n != 1);' but got '%s'", po.PluralForms) + } +} + +func TestPluralFormsSingle(t *testing.T) { + // Single form + str := ` +"Plural-Forms: nplurals=1; plural=0;" + +# Some comment +msgid "Singular" +msgid_plural "Plural" +msgstr[0] "Singular form" +msgstr[1] "Plural form 1" +msgstr[2] "Plural form 2" +msgstr[3] "Plural form 3" + ` + + // Create po object + po := new(Po) + + // Parse + po.Parse(str) + + // Check plural form + n := po.pluralForm(0) + if n != 0 { + t.Errorf("Expected 0 for pluralForm(0), got %d", n) + } + n = po.pluralForm(1) + if n != 0 { + t.Errorf("Expected 0 for pluralForm(1), got %d", n) + } + n = po.pluralForm(2) + if n != 0 { + t.Errorf("Expected 0 for pluralForm(2), got %d", n) + } + n = po.pluralForm(3) + if n != 0 { + t.Errorf("Expected 0 for pluralForm(3), got %d", n) + } + n = po.pluralForm(50) + if n != 0 { + t.Errorf("Expected 0 for pluralForm(50), got %d", n) + } +} + +func TestPluralForms2(t *testing.T) { + // 2 forms + str := ` +"Plural-Forms: nplurals=2; plural=n != 1;" + +# Some comment +msgid "Singular" +msgid_plural "Plural" +msgstr[0] "Singular form" +msgstr[1] "Plural form 1" +msgstr[2] "Plural form 2" +msgstr[3] "Plural form 3" + ` + + // Create po object + po := new(Po) + + // Parse + po.Parse(str) + + // Check plural form + n := po.pluralForm(0) + if n != 1 { + t.Errorf("Expected 1 for pluralForm(0), got %d", n) + } + n = po.pluralForm(1) + if n != 0 { + t.Errorf("Expected 0 for pluralForm(1), got %d", n) + } + n = po.pluralForm(2) + if n != 1 { + t.Errorf("Expected 1 for pluralForm(2), got %d", n) + } + n = po.pluralForm(3) + if n != 1 { + t.Errorf("Expected 1 for pluralForm(3), got %d", n) + } +} + +func TestPluralForms3(t *testing.T) { + // 3 forms + str := ` +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2;" + +# Some comment +msgid "Singular" +msgid_plural "Plural" +msgstr[0] "Singular form" +msgstr[1] "Plural form 1" +msgstr[2] "Plural form 2" +msgstr[3] "Plural form 3" + ` + + // Create po object + po := new(Po) + + // Parse + po.Parse(str) + + // Check plural form + n := po.pluralForm(0) + if n != 2 { + t.Errorf("Expected 2 for pluralForm(0), got %d", n) + } + n = po.pluralForm(1) + if n != 0 { + t.Errorf("Expected 0 for pluralForm(1), got %d", n) + } + n = po.pluralForm(2) + if n != 1 { + t.Errorf("Expected 1 for pluralForm(2), got %d", n) + } + n = po.pluralForm(3) + if n != 1 { + t.Errorf("Expected 1 for pluralForm(3), got %d", n) + } + n = po.pluralForm(100) + if n != 1 { + t.Errorf("Expected 1 for pluralForm(100), got %d", n) + } + n = po.pluralForm(49) + if n != 1 { + t.Errorf("Expected 1 for pluralForm(3), got %d", n) + } +} + +func TestPluralFormsSpecial(t *testing.T) { + // 3 forms special + str := ` +"Plural-Forms: nplurals=3;" +"plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;" + +# Some comment +msgid "Singular" +msgid_plural "Plural" +msgstr[0] "Singular form" +msgstr[1] "Plural form 1" +msgstr[2] "Plural form 2" +msgstr[3] "Plural form 3" + ` + + // Create po object + po := new(Po) + + // Parse + po.Parse(str) + + // Check plural form + n := po.pluralForm(1) + if n != 0 { + t.Errorf("Expected 0 for pluralForm(1), got %d", n) + } + n = po.pluralForm(2) + if n != 1 { + t.Errorf("Expected 1 for pluralForm(2), got %d", n) + } + n = po.pluralForm(4) + if n != 1 { + t.Errorf("Expected 4 for pluralForm(4), got %d", n) + } + n = po.pluralForm(0) + if n != 2 { + t.Errorf("Expected 2 for pluralForm(2), got %d", n) + } + n = po.pluralForm(1000) + if n != 2 { + t.Errorf("Expected 2 for pluralForm(1000), got %d", n) + } +} + +func TestTranslationObject(t *testing.T) { + tr := newTranslation() + str := tr.get() + + if str != "" { + t.Errorf("Expected '' but got '%s'", str) + } + + // Set id + tr.id = "Text" + + // Get again + str = tr.get() + + if str != "Text" { + t.Errorf("Expected 'Text' but got '%s'", str) + } +} + +func TestPoRace(t *testing.T) { + // Set PO content + str := `# Some comment +msgid "My text" +msgstr "Translated text" + +# More comments +msgid "Another string" +msgstr "" + +msgid "One with var: %s" +msgid_plural "Several with vars: %s" +msgstr[0] "This one is the singular: %s" +msgstr[1] "This one is the plural: %s" +msgstr[2] "And this is the second plural form: %s" + + ` + + // Create Po object + po := new(Po) + + // Create sync channels + pc := make(chan bool) + rc := make(chan bool) + + // Parse po content in a goroutine + go func(po *Po, done chan bool) { + po.Parse(str) + done <- true + }(po, pc) + + // Read some translation on a goroutine + go func(po *Po, done chan bool) { + po.Get("My text") + done <- true + }(po, rc) + + // Read something at top level + po.Get("My text") + + // Wait for goroutines to finish + <-pc + <-rc +} diff --git a/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/doc.go b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/doc.go new file mode 100644 index 0000000000..8781cfc7d9 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/doc.go @@ -0,0 +1,2 @@ +// Package ast implements abstruct-syntax-tree for anko. +package ast diff --git a/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/expr.go b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/expr.go new file mode 100644 index 0000000000..c43aac6dd5 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/expr.go @@ -0,0 +1,201 @@ +package ast + +// Expr provides all of interfaces for expression. +type Expr interface { + Pos + expr() +} + +// ExprImpl provide commonly implementations for Expr. +type ExprImpl struct { + PosImpl // ExprImpl provide Pos() function. +} + +// expr provide restraint interface. +func (x *ExprImpl) expr() {} + +// NumberExpr provide Number expression. +type NumberExpr struct { + ExprImpl + Lit string +} + +// StringExpr provide String expression. +type StringExpr struct { + ExprImpl + Lit string +} + +// ArrayExpr provide Array expression. +type ArrayExpr struct { + ExprImpl + Exprs []Expr +} + +// PairExpr provide one of Map key/value pair. +type PairExpr struct { + ExprImpl + Key string + Value Expr +} + +// MapExpr provide Map expression. +type MapExpr struct { + ExprImpl + MapExpr map[string]Expr +} + +// IdentExpr provide identity expression. +type IdentExpr struct { + ExprImpl + Lit string +} + +// UnaryExpr provide unary minus expression. ex: -1, ^1, ~1. +type UnaryExpr struct { + ExprImpl + Operator string + Expr Expr +} + +// AddrExpr provide referencing address expression. +type AddrExpr struct { + ExprImpl + Expr Expr +} + +// DerefExpr provide dereferencing address expression. +type DerefExpr struct { + ExprImpl + Expr Expr +} + +// ParenExpr provide parent block expression. +type ParenExpr struct { + ExprImpl + SubExpr Expr +} + +// BinOpExpr provide binary operator expression. +type BinOpExpr struct { + ExprImpl + Lhs Expr + Operator string + Rhs Expr +} + +type TernaryOpExpr struct { + ExprImpl + Expr Expr + Lhs Expr + Rhs Expr +} + +// CallExpr provide calling expression. +type CallExpr struct { + ExprImpl + Func interface{} + Name string + SubExprs []Expr + VarArg bool + Go bool +} + +// AnonCallExpr provide anonymous calling expression. ex: func(){}(). +type AnonCallExpr struct { + ExprImpl + Expr Expr + SubExprs []Expr + VarArg bool + Go bool +} + +// MemberExpr provide expression to refer menber. +type MemberExpr struct { + ExprImpl + Expr Expr + Name string +} + +// ItemExpr provide expression to refer Map/Array item. +type ItemExpr struct { + ExprImpl + Value Expr + Index Expr +} + +// SliceExpr provide expression to refer slice of Array. +type SliceExpr struct { + ExprImpl + Value Expr + Begin Expr + End Expr +} + +// FuncExpr provide function expression. +type FuncExpr struct { + ExprImpl + Name string + Stmts []Stmt + Args []string + VarArg bool +} + +// LetExpr provide expression to let variable. +type LetExpr struct { + ExprImpl + Lhs Expr + Rhs Expr +} + +// LetsExpr provide multiple expression of let. +type LetsExpr struct { + ExprImpl + Lhss []Expr + Operator string + Rhss []Expr +} + +// AssocExpr provide expression to assoc operation. +type AssocExpr struct { + ExprImpl + Lhs Expr + Operator string + Rhs Expr +} + +// NewExpr provide expression to make new instance. +type NewExpr struct { + ExprImpl + Name string + SubExprs []Expr +} + +// ConstExpr provide expression for constant variable. +type ConstExpr struct { + ExprImpl + Value string +} + +type ChanExpr struct { + ExprImpl + Lhs Expr + Rhs Expr +} + +type Type struct { + Name string +} + +type MakeChanExpr struct { + ExprImpl + Type string + SizeExpr Expr +} + +type MakeArrayExpr struct { + ExprImpl + Type string + LenExpr Expr + CapExpr Expr +} diff --git a/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/pos.go b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/pos.go new file mode 100644 index 0000000000..5a0e470d92 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/pos.go @@ -0,0 +1,28 @@ +package ast + +// Position provides interface to store code locations. +type Position struct { + Line int + Column int +} + +// Pos interface provies two functions to get/set the position for expression or statement. +type Pos interface { + Position() Position + SetPosition(Position) +} + +// PosImpl provies commonly implementations for Pos. +type PosImpl struct { + pos Position +} + +// Position return the position of the expression or statement. +func (x *PosImpl) Position() Position { + return x.pos +} + +// SetPosition is a function to specify position of the expression or statement. +func (x *PosImpl) SetPosition(pos Position) { + x.pos = pos +} diff --git a/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/stmt.go b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/stmt.go new file mode 100644 index 0000000000..14bbdf7174 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/stmt.go @@ -0,0 +1,127 @@ +package ast + +// Stmt provides all of interfaces for statement. +type Stmt interface { + Pos + stmt() +} + +// StmtImpl provide commonly implementations for Stmt.. +type StmtImpl struct { + PosImpl // StmtImpl provide Pos() function. +} + +// stmt provide restraint interface. +func (x *StmtImpl) stmt() {} + +// ExprStmt provide expression statement. +type ExprStmt struct { + StmtImpl + Expr Expr +} + +// IfStmt provide "if/else" statement. +type IfStmt struct { + StmtImpl + If Expr + Then []Stmt + ElseIf []Stmt // This is array of IfStmt + Else []Stmt +} + +// TryStmt provide "try/catch/finally" statement. +type TryStmt struct { + StmtImpl + Try []Stmt + Var string + Catch []Stmt + Finally []Stmt +} + +// ForStmt provide "for in" expression statement. +type ForStmt struct { + StmtImpl + Var string + Value Expr + Stmts []Stmt +} + +// CForStmt provide C-style "for (;;)" expression statement. +type CForStmt struct { + StmtImpl + Expr1 Expr + Expr2 Expr + Expr3 Expr + Stmts []Stmt +} + +// LoopStmt provide "for expr" expression statement. +type LoopStmt struct { + StmtImpl + Expr Expr + Stmts []Stmt +} + +// BreakStmt provide "break" expression statement. +type BreakStmt struct { + StmtImpl +} + +// ContinueStmt provide "continue" expression statement. +type ContinueStmt struct { + StmtImpl +} + +// ForStmt provide "return" expression statement. +type ReturnStmt struct { + StmtImpl + Exprs []Expr +} + +// ThrowStmt provide "throw" expression statement. +type ThrowStmt struct { + StmtImpl + Expr Expr +} + +// ModuleStmt provide "module" expression statement. +type ModuleStmt struct { + StmtImpl + Name string + Stmts []Stmt +} + +// VarStmt provide statement to let variables in current scope. +type VarStmt struct { + StmtImpl + Names []string + Exprs []Expr +} + +// SwitchStmt provide switch statement. +type SwitchStmt struct { + StmtImpl + Expr Expr + Cases []Stmt +} + +// CaseStmt provide switch/case statement. +type CaseStmt struct { + StmtImpl + Expr Expr + Stmts []Stmt +} + +// DefaultStmt provide switch/default statement. +type DefaultStmt struct { + StmtImpl + Stmts []Stmt +} + +// LetsStmt provide multiple statement of let. +type LetsStmt struct { + StmtImpl + Lhss []Expr + Operator string + Rhss []Expr +} diff --git a/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/token.go b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/token.go new file mode 100644 index 0000000000..6b47cd0544 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/ast/token.go @@ -0,0 +1,7 @@ +package ast + +type Token struct { + PosImpl // StmtImpl provide Pos() function. + Tok int + Lit string +} diff --git a/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/parser/Makefile b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/parser/Makefile new file mode 100644 index 0000000000..8b33e31724 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/parser/Makefile @@ -0,0 +1,4 @@ +all : parser.go + +parser.go : parser.go.y + go tool yacc -o $@ parser.go.y diff --git a/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/parser/lexer.go b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/parser/lexer.go new file mode 100644 index 0000000000..ea0fc49300 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/parser/lexer.go @@ -0,0 +1,530 @@ +// Package parser implements parser for anko. +package parser + +import ( + "errors" + "fmt" + + "github.com/mattn/anko/ast" +) + +const ( + EOF = -1 // End of file. + EOL = '\n' // End of line. +) + +// Error provides a convenient interface for handling runtime error. +// It can be Error inteface with type cast which can call Pos(). +type Error struct { + Message string + Pos ast.Position + Filename string + Fatal bool +} + +// Error returns the error message. +func (e *Error) Error() string { + return e.Message +} + +// Scanner stores informations for lexer. +type Scanner struct { + src []rune + offset int + lineHead int + line int +} + +// opName is correction of operation names. +var opName = map[string]int{ + "func": FUNC, + "return": RETURN, + "var": VAR, + "throw": THROW, + "if": IF, + "for": FOR, + "break": BREAK, + "continue": CONTINUE, + "in": IN, + "else": ELSE, + "new": NEW, + "true": TRUE, + "false": FALSE, + "nil": NIL, + "module": MODULE, + "try": TRY, + "catch": CATCH, + "finally": FINALLY, + "switch": SWITCH, + "case": CASE, + "default": DEFAULT, + "go": GO, + "chan": CHAN, + "make": MAKE, +} + +// Init resets code to scan. +func (s *Scanner) Init(src string) { + s.src = []rune(src) +} + +// Scan analyses token, and decide identify or literals. +func (s *Scanner) Scan() (tok int, lit string, pos ast.Position, err error) { +retry: + s.skipBlank() + pos = s.pos() + switch ch := s.peek(); { + case isLetter(ch): + lit, err = s.scanIdentifier() + if err != nil { + return + } + if name, ok := opName[lit]; ok { + tok = name + } else { + tok = IDENT + } + case isDigit(ch): + tok = NUMBER + lit, err = s.scanNumber() + if err != nil { + return + } + case ch == '"': + tok = STRING + lit, err = s.scanString('"') + if err != nil { + return + } + case ch == '\'': + tok = STRING + lit, err = s.scanString('\'') + if err != nil { + return + } + case ch == '`': + tok = STRING + lit, err = s.scanRawString() + if err != nil { + return + } + default: + switch ch { + case EOF: + tok = EOF + case '#': + for !isEOL(s.peek()) { + s.next() + } + goto retry + case '!': + s.next() + switch s.peek() { + case '=': + tok = NEQ + lit = "!=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '=': + s.next() + switch s.peek() { + case '=': + tok = EQEQ + lit = "==" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '+': + s.next() + switch s.peek() { + case '+': + tok = PLUSPLUS + lit = "++" + case '=': + tok = PLUSEQ + lit = "+=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '-': + s.next() + switch s.peek() { + case '-': + tok = MINUSMINUS + lit = "--" + case '=': + tok = MINUSEQ + lit = "-=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '*': + s.next() + switch s.peek() { + case '*': + tok = POW + lit = "**" + case '=': + tok = MULEQ + lit = "*=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '/': + s.next() + switch s.peek() { + case '=': + tok = DIVEQ + lit = "/=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '>': + s.next() + switch s.peek() { + case '=': + tok = GE + lit = ">=" + case '>': + tok = SHIFTRIGHT + lit = ">>" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '<': + s.next() + switch s.peek() { + case '-': + tok = OPCHAN + lit = "<-" + case '=': + tok = LE + lit = "<=" + case '<': + tok = SHIFTLEFT + lit = "<<" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '|': + s.next() + switch s.peek() { + case '|': + tok = OROR + lit = "||" + case '=': + tok = OREQ + lit = "|=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '&': + s.next() + switch s.peek() { + case '&': + tok = ANDAND + lit = "&&" + case '=': + tok = ANDEQ + lit = "&=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '.': + s.next() + if s.peek() == '.' { + s.next() + if s.peek() == '.' { + tok = VARARG + } else { + err = fmt.Errorf(`syntax error "%s"`, "..") + return + } + } else { + s.back() + tok = int(ch) + lit = string(ch) + } + case '(', ')', ':', ';', '%', '?', '{', '}', ',', '[', ']', '^', '\n': + s.next() + if ch == '[' && s.peek() == ']' { + s.next() + if isLetter(s.peek()) { + s.back() + tok = ARRAYLIT + lit = "[]" + } else { + s.back() + s.back() + tok = int(ch) + lit = string(ch) + } + } else { + s.back() + tok = int(ch) + lit = string(ch) + } + default: + err = fmt.Errorf(`syntax error "%s"`, string(ch)) + return + } + s.next() + } + return +} + +// isLetter returns true if the rune is a letter for identity. +func isLetter(ch rune) bool { + return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' +} + +// isDigit returns true if the rune is a number. +func isDigit(ch rune) bool { + return '0' <= ch && ch <= '9' +} + +// isHex returns true if the rune is a hex digits. +func isHex(ch rune) bool { + return ('0' <= ch && ch <= '9') || ('a' <= ch && ch <= 'f') || ('A' <= ch && ch <= 'F') +} + +// isEOL returns true if the rune is at end-of-line or end-of-file. +func isEOL(ch rune) bool { + return ch == '\n' || ch == -1 +} + +// isBlank returns true if the rune is empty character.. +func isBlank(ch rune) bool { + return ch == ' ' || ch == '\t' || ch == '\r' +} + +// peek returns current rune in the code. +func (s *Scanner) peek() rune { + if s.reachEOF() { + return EOF + } + return s.src[s.offset] +} + +// next moves offset to next. +func (s *Scanner) next() { + if !s.reachEOF() { + if s.peek() == '\n' { + s.lineHead = s.offset + 1 + s.line++ + } + s.offset++ + } +} + +// current returns the current offset. +func (s *Scanner) current() int { + return s.offset +} + +// offset sets the offset value. +func (s *Scanner) set(o int) { + s.offset = o +} + +// back moves back offset once to top. +func (s *Scanner) back() { + s.offset-- +} + +// reachEOF returns true if offset is at end-of-file. +func (s *Scanner) reachEOF() bool { + return len(s.src) <= s.offset +} + +// pos returns the position of current. +func (s *Scanner) pos() ast.Position { + return ast.Position{Line: s.line + 1, Column: s.offset - s.lineHead + 1} +} + +// skipBlank moves position into non-black character. +func (s *Scanner) skipBlank() { + for isBlank(s.peek()) { + s.next() + } +} + +// scanIdentifier returns identifier begining at current position. +func (s *Scanner) scanIdentifier() (string, error) { + var ret []rune + for { + if !isLetter(s.peek()) && !isDigit(s.peek()) { + break + } + ret = append(ret, s.peek()) + s.next() + } + return string(ret), nil +} + +// scanNumber returns number begining at current position. +func (s *Scanner) scanNumber() (string, error) { + var ret []rune + ch := s.peek() + ret = append(ret, ch) + s.next() + if ch == '0' && s.peek() == 'x' { + ret = append(ret, s.peek()) + s.next() + for isHex(s.peek()) { + ret = append(ret, s.peek()) + s.next() + } + } else { + for isDigit(s.peek()) || s.peek() == '.' { + ret = append(ret, s.peek()) + s.next() + } + if s.peek() == 'e' { + ret = append(ret, s.peek()) + s.next() + if isDigit(s.peek()) || s.peek() == '+' || s.peek() == '-' { + ret = append(ret, s.peek()) + s.next() + for isDigit(s.peek()) || s.peek() == '.' { + ret = append(ret, s.peek()) + s.next() + } + } + for isDigit(s.peek()) || s.peek() == '.' { + ret = append(ret, s.peek()) + s.next() + } + } + if isLetter(s.peek()) { + return "", errors.New("identifier starts immediately after numeric literal") + } + } + return string(ret), nil +} + +// scanRawString returns raw-string starting at current position. +func (s *Scanner) scanRawString() (string, error) { + var ret []rune + for { + s.next() + if s.peek() == EOF { + return "", errors.New("unexpected EOF") + break + } + if s.peek() == '`' { + s.next() + break + } + ret = append(ret, s.peek()) + } + return string(ret), nil +} + +// scanString returns string starting at current position. +// This handles backslash escaping. +func (s *Scanner) scanString(l rune) (string, error) { + var ret []rune +eos: + for { + s.next() + switch s.peek() { + case EOL: + return "", errors.New("unexpected EOL") + case EOF: + return "", errors.New("unexpected EOF") + case l: + s.next() + break eos + case '\\': + s.next() + switch s.peek() { + case 'b': + ret = append(ret, '\b') + continue + case 'f': + ret = append(ret, '\f') + continue + case 'r': + ret = append(ret, '\r') + continue + case 'n': + ret = append(ret, '\n') + continue + case 't': + ret = append(ret, '\t') + continue + } + ret = append(ret, s.peek()) + continue + default: + ret = append(ret, s.peek()) + } + } + return string(ret), nil +} + +// Lexer provides inteface to parse codes. +type Lexer struct { + s *Scanner + lit string + pos ast.Position + e error + stmts []ast.Stmt +} + +// Lex scans the token and literals. +func (l *Lexer) Lex(lval *yySymType) int { + tok, lit, pos, err := l.s.Scan() + if err != nil { + l.e = &Error{Message: fmt.Sprintf("%s", err.Error()), Pos: pos, Fatal: true} + } + lval.tok = ast.Token{Tok: tok, Lit: lit} + lval.tok.SetPosition(pos) + l.lit = lit + l.pos = pos + return tok +} + +// Error sets parse error. +func (l *Lexer) Error(msg string) { + l.e = &Error{Message: msg, Pos: l.pos, Fatal: false} +} + +// Parser provides way to parse the code using Scanner. +func Parse(s *Scanner) ([]ast.Stmt, error) { + l := Lexer{s: s} + if yyParse(&l) != 0 { + return nil, l.e + } + return l.stmts, l.e +} + +// ParserSrc provides way to parse the code from source. +func ParseSrc(src string) ([]ast.Stmt, error) { + scanner := &Scanner{ + src: []rune(src), + } + return Parse(scanner) +} diff --git a/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/parser/parser.go b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/parser/parser.go new file mode 100644 index 0000000000..01f5adf689 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/parser/parser.go @@ -0,0 +1,1997 @@ +//line parser.go.y:2 +package parser + +import __yyfmt__ "fmt" + +//line parser.go.y:2 +import ( + "github.com/mattn/anko/ast" +) + +//line parser.go.y:26 +type yySymType struct { + yys int + compstmt []ast.Stmt + stmt_if ast.Stmt + stmt_default ast.Stmt + stmt_case ast.Stmt + stmt_cases []ast.Stmt + stmts []ast.Stmt + stmt ast.Stmt + typ ast.Type + expr ast.Expr + exprs []ast.Expr + expr_many []ast.Expr + expr_lets ast.Expr + expr_pair ast.Expr + expr_pairs []ast.Expr + expr_idents []string + tok ast.Token + term ast.Token + terms ast.Token + opt_terms ast.Token +} + +const IDENT = 57346 +const NUMBER = 57347 +const STRING = 57348 +const ARRAY = 57349 +const VARARG = 57350 +const FUNC = 57351 +const RETURN = 57352 +const VAR = 57353 +const THROW = 57354 +const IF = 57355 +const ELSE = 57356 +const FOR = 57357 +const IN = 57358 +const EQEQ = 57359 +const NEQ = 57360 +const GE = 57361 +const LE = 57362 +const OROR = 57363 +const ANDAND = 57364 +const NEW = 57365 +const TRUE = 57366 +const FALSE = 57367 +const NIL = 57368 +const MODULE = 57369 +const TRY = 57370 +const CATCH = 57371 +const FINALLY = 57372 +const PLUSEQ = 57373 +const MINUSEQ = 57374 +const MULEQ = 57375 +const DIVEQ = 57376 +const ANDEQ = 57377 +const OREQ = 57378 +const BREAK = 57379 +const CONTINUE = 57380 +const PLUSPLUS = 57381 +const MINUSMINUS = 57382 +const POW = 57383 +const SHIFTLEFT = 57384 +const SHIFTRIGHT = 57385 +const SWITCH = 57386 +const CASE = 57387 +const DEFAULT = 57388 +const GO = 57389 +const CHAN = 57390 +const MAKE = 57391 +const OPCHAN = 57392 +const ARRAYLIT = 57393 +const UNARY = 57394 + +var yyToknames = [...]string{ + "$end", + "error", + "$unk", + "IDENT", + "NUMBER", + "STRING", + "ARRAY", + "VARARG", + "FUNC", + "RETURN", + "VAR", + "THROW", + "IF", + "ELSE", + "FOR", + "IN", + "EQEQ", + "NEQ", + "GE", + "LE", + "OROR", + "ANDAND", + "NEW", + "TRUE", + "FALSE", + "NIL", + "MODULE", + "TRY", + "CATCH", + "FINALLY", + "PLUSEQ", + "MINUSEQ", + "MULEQ", + "DIVEQ", + "ANDEQ", + "OREQ", + "BREAK", + "CONTINUE", + "PLUSPLUS", + "MINUSMINUS", + "POW", + "SHIFTLEFT", + "SHIFTRIGHT", + "SWITCH", + "CASE", + "DEFAULT", + "GO", + "CHAN", + "MAKE", + "OPCHAN", + "ARRAYLIT", + "'='", + "'?'", + "':'", + "','", + "'>'", + "'<'", + "'+'", + "'-'", + "'*'", + "'/'", + "'%'", + "UNARY", + "'{'", + "'}'", + "';'", + "'.'", + "'!'", + "'^'", + "'&'", + "'('", + "')'", + "'['", + "']'", + "'|'", + "'\\n'", +} +var yyStatenames = [...]string{} + +const yyEofCode = 1 +const yyErrCode = 2 +const yyInitialStackSize = 16 + +//line parser.go.y:705 + +//line yacctab:1 +var yyExca = [...]int{ + -1, 0, + 1, 3, + -2, 121, + -1, 1, + 1, -1, + -2, 0, + -1, 2, + 55, 48, + -2, 1, + -1, 10, + 55, 49, + -2, 24, + -1, 43, + 55, 48, + -2, 122, + -1, 85, + 65, 3, + -2, 121, + -1, 88, + 55, 49, + -2, 43, + -1, 90, + 65, 3, + -2, 121, + -1, 97, + 1, 57, + 8, 57, + 45, 57, + 46, 57, + 52, 57, + 54, 57, + 55, 57, + 64, 57, + 65, 57, + 66, 57, + 72, 57, + 74, 57, + 76, 57, + -2, 52, + -1, 99, + 1, 59, + 8, 59, + 45, 59, + 46, 59, + 52, 59, + 54, 59, + 55, 59, + 64, 59, + 65, 59, + 66, 59, + 72, 59, + 74, 59, + 76, 59, + -2, 52, + -1, 127, + 17, 0, + 18, 0, + -2, 85, + -1, 128, + 17, 0, + 18, 0, + -2, 86, + -1, 147, + 55, 49, + -2, 43, + -1, 149, + 65, 3, + -2, 121, + -1, 151, + 65, 3, + -2, 121, + -1, 153, + 65, 1, + -2, 36, + -1, 156, + 65, 3, + -2, 121, + -1, 178, + 65, 3, + -2, 121, + -1, 220, + 55, 50, + -2, 44, + -1, 221, + 1, 45, + 45, 45, + 46, 45, + 52, 45, + 55, 51, + 65, 45, + 66, 45, + 76, 45, + -2, 52, + -1, 228, + 1, 51, + 8, 51, + 45, 51, + 46, 51, + 55, 51, + 65, 51, + 66, 51, + 72, 51, + 74, 51, + 76, 51, + -2, 52, + -1, 230, + 65, 3, + -2, 121, + -1, 232, + 65, 3, + -2, 121, + -1, 245, + 65, 3, + -2, 121, + -1, 256, + 1, 106, + 8, 106, + 45, 106, + 46, 106, + 52, 106, + 54, 106, + 55, 106, + 64, 106, + 65, 106, + 66, 106, + 72, 106, + 74, 106, + 76, 106, + -2, 104, + -1, 258, + 1, 110, + 8, 110, + 45, 110, + 46, 110, + 52, 110, + 54, 110, + 55, 110, + 64, 110, + 65, 110, + 66, 110, + 72, 110, + 74, 110, + 76, 110, + -2, 108, + -1, 269, + 65, 3, + -2, 121, + -1, 274, + 65, 3, + -2, 121, + -1, 275, + 65, 3, + -2, 121, + -1, 280, + 1, 105, + 8, 105, + 45, 105, + 46, 105, + 52, 105, + 54, 105, + 55, 105, + 64, 105, + 65, 105, + 66, 105, + 72, 105, + 74, 105, + 76, 105, + -2, 103, + -1, 281, + 1, 109, + 8, 109, + 45, 109, + 46, 109, + 52, 109, + 54, 109, + 55, 109, + 64, 109, + 65, 109, + 66, 109, + 72, 109, + 74, 109, + 76, 109, + -2, 107, + -1, 287, + 65, 3, + -2, 121, + -1, 288, + 65, 3, + -2, 121, + -1, 291, + 45, 3, + 46, 3, + 65, 3, + -2, 121, + -1, 295, + 65, 3, + -2, 121, + -1, 302, + 45, 3, + 46, 3, + 65, 3, + -2, 121, + -1, 315, + 65, 3, + -2, 121, + -1, 316, + 65, 3, + -2, 121, +} + +const yyNprod = 127 +const yyPrivate = 57344 + +var yyTokenNames []string +var yyStates []string + +const yyLast = 2223 + +var yyAct = [...]int{ + + 81, 169, 237, 10, 217, 238, 45, 6, 92, 211, + 93, 2, 1, 250, 281, 42, 82, 7, 209, 88, + 6, 91, 280, 276, 94, 95, 96, 98, 100, 6, + 7, 11, 40, 154, 246, 173, 105, 93, 108, 7, + 110, 243, 112, 225, 10, 103, 104, 80, 116, 117, + 89, 119, 120, 121, 122, 123, 124, 125, 126, 127, + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, + 138, 102, 172, 139, 140, 141, 142, 166, 144, 145, + 147, 257, 64, 65, 66, 67, 68, 69, 92, 109, + 93, 155, 55, 261, 161, 255, 148, 153, 152, 115, + 115, 78, 199, 158, 320, 259, 182, 262, 164, 143, + 260, 146, 319, 254, 312, 147, 247, 205, 49, 259, + 309, 74, 76, 177, 77, 160, 72, 180, 148, 170, + 239, 240, 268, 308, 305, 304, 167, 301, 101, 292, + 286, 285, 148, 263, 252, 258, 179, 234, 231, 148, + 236, 188, 316, 148, 10, 192, 193, 229, 147, 256, + 186, 196, 187, 315, 189, 190, 200, 150, 295, 194, + 183, 198, 288, 207, 275, 274, 245, 149, 220, 210, + 212, 219, 224, 90, 148, 111, 226, 227, 279, 195, + 114, 222, 269, 115, 271, 213, 175, 157, 79, 176, + 8, 241, 314, 244, 242, 214, 215, 216, 239, 240, + 5, 310, 235, 84, 253, 44, 248, 206, 151, 170, + 282, 249, 223, 251, 218, 208, 204, 203, 165, 118, + 106, 83, 46, 4, 267, 168, 87, 43, 197, 17, + 270, 3, 0, 265, 113, 266, 0, 0, 0, 0, + 227, 0, 0, 278, 44, 61, 63, 0, 273, 0, + 0, 0, 283, 284, 0, 0, 0, 64, 65, 66, + 67, 68, 69, 0, 0, 70, 71, 55, 56, 57, + 0, 0, 289, 291, 0, 0, 78, 293, 294, 0, + 0, 0, 60, 62, 50, 51, 52, 53, 54, 307, + 299, 300, 302, 49, 303, 0, 74, 76, 306, 77, + 0, 72, 0, 0, 0, 311, 58, 59, 61, 63, + 73, 75, 0, 0, 0, 0, 0, 0, 317, 318, + 64, 65, 66, 67, 68, 69, 0, 0, 70, 71, + 55, 56, 57, 0, 0, 0, 0, 0, 0, 78, + 0, 0, 48, 0, 298, 60, 62, 50, 51, 52, + 53, 54, 0, 0, 0, 0, 49, 0, 0, 74, + 76, 297, 77, 0, 72, 58, 59, 61, 63, 73, + 75, 0, 0, 0, 0, 0, 0, 0, 0, 64, + 65, 66, 67, 68, 69, 0, 0, 70, 71, 55, + 56, 57, 0, 0, 0, 0, 0, 0, 78, 0, + 0, 48, 202, 0, 60, 62, 50, 51, 52, 53, + 54, 0, 0, 0, 0, 49, 0, 0, 74, 76, + 0, 77, 201, 72, 58, 59, 61, 63, 73, 75, + 0, 0, 0, 0, 0, 0, 0, 0, 64, 65, + 66, 67, 68, 69, 0, 0, 70, 71, 55, 56, + 57, 0, 0, 0, 0, 0, 0, 78, 0, 0, + 48, 185, 0, 60, 62, 50, 51, 52, 53, 54, + 0, 0, 0, 0, 49, 0, 0, 74, 76, 0, + 77, 184, 72, 58, 59, 61, 63, 73, 75, 0, + 0, 0, 0, 0, 0, 0, 0, 64, 65, 66, + 67, 68, 69, 0, 0, 70, 71, 55, 56, 57, + 0, 0, 0, 0, 0, 0, 78, 0, 0, 48, + 0, 0, 60, 62, 50, 51, 52, 53, 54, 0, + 0, 0, 0, 49, 0, 0, 74, 76, 313, 77, + 0, 72, 58, 59, 61, 63, 73, 75, 0, 0, + 0, 0, 0, 0, 0, 0, 64, 65, 66, 67, + 68, 69, 0, 0, 70, 71, 55, 56, 57, 0, + 0, 0, 0, 0, 0, 78, 0, 0, 48, 0, + 0, 60, 62, 50, 51, 52, 53, 54, 0, 0, + 0, 0, 49, 0, 0, 74, 76, 296, 77, 0, + 72, 58, 59, 61, 63, 73, 75, 0, 0, 0, + 0, 0, 0, 0, 0, 64, 65, 66, 67, 68, + 69, 0, 0, 70, 71, 55, 56, 57, 0, 0, + 0, 0, 0, 0, 78, 0, 0, 48, 290, 0, + 60, 62, 50, 51, 52, 53, 54, 0, 0, 0, + 0, 49, 0, 0, 74, 76, 0, 77, 0, 72, + 58, 59, 61, 63, 73, 75, 0, 0, 0, 0, + 0, 0, 0, 0, 64, 65, 66, 67, 68, 69, + 0, 0, 70, 71, 55, 56, 57, 0, 0, 0, + 0, 0, 0, 78, 0, 0, 48, 0, 0, 60, + 62, 50, 51, 52, 53, 54, 0, 287, 0, 0, + 49, 0, 0, 74, 76, 0, 77, 0, 72, 58, + 59, 61, 63, 73, 75, 0, 0, 0, 0, 0, + 0, 0, 0, 64, 65, 66, 67, 68, 69, 0, + 0, 70, 71, 55, 56, 57, 0, 0, 0, 0, + 0, 0, 78, 0, 0, 48, 0, 0, 60, 62, + 50, 51, 52, 53, 54, 0, 0, 0, 0, 49, + 0, 0, 74, 76, 0, 77, 272, 72, 58, 59, + 61, 63, 73, 75, 0, 0, 0, 0, 0, 0, + 0, 0, 64, 65, 66, 67, 68, 69, 0, 0, + 70, 71, 55, 56, 57, 0, 0, 0, 0, 0, + 0, 78, 0, 0, 48, 0, 0, 60, 62, 50, + 51, 52, 53, 54, 0, 0, 0, 0, 49, 0, + 0, 74, 76, 0, 77, 264, 72, 58, 59, 61, + 63, 73, 75, 0, 0, 0, 0, 0, 0, 0, + 0, 64, 65, 66, 67, 68, 69, 0, 0, 70, + 71, 55, 56, 57, 0, 0, 0, 0, 0, 0, + 78, 0, 0, 48, 0, 0, 60, 62, 50, 51, + 52, 53, 54, 0, 0, 0, 233, 49, 0, 0, + 74, 76, 0, 77, 0, 72, 58, 59, 61, 63, + 73, 75, 0, 0, 0, 0, 0, 0, 0, 0, + 64, 65, 66, 67, 68, 69, 0, 0, 70, 71, + 55, 56, 57, 0, 0, 0, 0, 0, 0, 78, + 0, 0, 48, 0, 0, 60, 62, 50, 51, 52, + 53, 54, 0, 232, 0, 0, 49, 0, 0, 74, + 76, 0, 77, 0, 72, 58, 59, 61, 63, 73, + 75, 0, 0, 0, 0, 0, 0, 0, 0, 64, + 65, 66, 67, 68, 69, 0, 0, 70, 71, 55, + 56, 57, 0, 0, 0, 0, 0, 0, 78, 0, + 0, 48, 0, 0, 60, 62, 50, 51, 52, 53, + 54, 0, 230, 0, 0, 49, 0, 0, 74, 76, + 0, 77, 0, 72, 58, 59, 61, 63, 73, 75, + 0, 0, 0, 0, 0, 0, 0, 0, 64, 65, + 66, 67, 68, 69, 0, 0, 70, 71, 55, 56, + 57, 0, 0, 0, 0, 0, 0, 78, 0, 0, + 48, 181, 0, 60, 62, 50, 51, 52, 53, 54, + 0, 0, 0, 0, 49, 0, 0, 74, 76, 0, + 77, 0, 72, 58, 59, 61, 63, 73, 75, 0, + 0, 0, 0, 0, 0, 0, 0, 64, 65, 66, + 67, 68, 69, 0, 0, 70, 71, 55, 56, 57, + 0, 0, 0, 0, 0, 0, 78, 0, 0, 48, + 0, 0, 60, 62, 50, 51, 52, 53, 54, 0, + 178, 0, 0, 49, 0, 0, 74, 76, 0, 77, + 0, 72, 58, 59, 61, 63, 73, 75, 0, 0, + 0, 0, 0, 0, 0, 0, 64, 65, 66, 67, + 68, 69, 0, 0, 70, 71, 55, 56, 57, 0, + 0, 0, 0, 0, 0, 78, 0, 0, 48, 0, + 0, 60, 62, 50, 51, 52, 53, 54, 0, 0, + 0, 0, 49, 0, 0, 74, 76, 171, 77, 0, + 72, 58, 59, 61, 63, 73, 75, 0, 0, 0, + 0, 0, 0, 0, 0, 64, 65, 66, 67, 68, + 69, 0, 0, 70, 71, 55, 56, 57, 0, 0, + 0, 0, 0, 0, 78, 0, 0, 48, 0, 0, + 60, 62, 50, 51, 52, 53, 54, 0, 159, 0, + 0, 49, 0, 0, 74, 76, 0, 77, 0, 72, + 58, 59, 61, 63, 73, 75, 0, 0, 0, 0, + 0, 0, 0, 0, 64, 65, 66, 67, 68, 69, + 0, 0, 70, 71, 55, 56, 57, 0, 0, 0, + 0, 0, 0, 78, 0, 0, 48, 0, 0, 60, + 62, 50, 51, 52, 53, 54, 0, 156, 0, 0, + 49, 0, 0, 74, 76, 0, 77, 0, 72, 21, + 22, 28, 0, 0, 32, 14, 9, 15, 41, 0, + 18, 0, 0, 0, 0, 0, 0, 0, 36, 29, + 30, 31, 16, 19, 0, 0, 0, 0, 0, 0, + 0, 0, 12, 13, 0, 0, 0, 0, 0, 20, + 0, 0, 37, 0, 38, 39, 0, 0, 0, 0, + 0, 0, 0, 0, 23, 27, 0, 0, 0, 34, + 0, 6, 0, 24, 25, 26, 35, 0, 33, 0, + 0, 7, 58, 59, 61, 63, 73, 75, 0, 0, + 0, 0, 0, 0, 0, 0, 64, 65, 66, 67, + 68, 69, 0, 0, 70, 71, 55, 56, 57, 0, + 0, 0, 0, 0, 0, 78, 0, 47, 48, 0, + 0, 60, 62, 50, 51, 52, 53, 54, 0, 0, + 0, 0, 49, 0, 0, 74, 76, 0, 77, 0, + 72, 58, 59, 61, 63, 73, 75, 0, 0, 0, + 0, 0, 0, 0, 0, 64, 65, 66, 67, 68, + 69, 0, 0, 70, 71, 55, 56, 57, 0, 0, + 0, 0, 0, 0, 78, 0, 0, 48, 0, 0, + 60, 62, 50, 51, 52, 53, 54, 0, 0, 0, + 0, 49, 0, 0, 74, 76, 0, 77, 0, 72, + 58, 59, 61, 63, 73, 75, 0, 0, 0, 0, + 0, 0, 0, 0, 64, 65, 66, 67, 68, 69, + 0, 0, 70, 71, 55, 56, 57, 0, 0, 0, + 0, 0, 0, 78, 0, 0, 48, 0, 0, 60, + 62, 50, 51, 52, 53, 54, 0, 0, 0, 0, + 49, 0, 0, 74, 174, 0, 77, 0, 72, 58, + 59, 61, 63, 73, 75, 0, 0, 0, 0, 0, + 0, 0, 0, 64, 65, 66, 67, 68, 69, 0, + 0, 70, 71, 55, 56, 57, 0, 0, 0, 0, + 0, 0, 78, 0, 0, 48, 0, 0, 60, 62, + 50, 51, 52, 53, 54, 0, 0, 0, 0, 163, + 0, 0, 74, 76, 0, 77, 0, 72, 58, 59, + 61, 63, 73, 75, 0, 0, 0, 0, 0, 0, + 0, 0, 64, 65, 66, 67, 68, 69, 0, 0, + 70, 71, 55, 56, 57, 0, 0, 0, 0, 0, + 0, 78, 0, 0, 48, 0, 0, 60, 62, 50, + 51, 52, 53, 54, 58, 59, 61, 63, 162, 75, + 0, 74, 76, 0, 77, 0, 72, 0, 64, 65, + 66, 67, 68, 69, 0, 0, 70, 71, 55, 56, + 57, 0, 0, 0, 0, 0, 0, 78, 0, 0, + 0, 0, 0, 60, 62, 50, 51, 52, 53, 54, + 58, 59, 61, 63, 49, 0, 0, 74, 76, 0, + 77, 0, 72, 0, 64, 65, 66, 67, 68, 69, + 0, 0, 70, 71, 55, 56, 57, 0, 0, 0, + 0, 0, 0, 78, 0, 0, 0, 0, 0, 60, + 62, 50, 51, 52, 53, 54, 0, 0, 0, 0, + 49, 0, 0, 74, 76, 0, 77, 0, 72, 21, + 22, 191, 0, 0, 32, 14, 9, 15, 41, 0, + 18, 0, 0, 0, 0, 0, 0, 0, 36, 29, + 30, 31, 16, 19, 0, 0, 0, 0, 0, 0, + 0, 0, 12, 13, 0, 0, 0, 0, 0, 20, + 0, 0, 37, 0, 38, 39, 0, 0, 0, 0, + 0, 0, 0, 0, 23, 27, 0, 0, 0, 34, + 0, 0, 0, 24, 25, 26, 35, 0, 33, 21, + 22, 28, 0, 0, 32, 14, 9, 15, 41, 0, + 18, 0, 0, 0, 0, 0, 0, 0, 36, 29, + 30, 31, 16, 19, 0, 0, 0, 0, 0, 0, + 0, 0, 12, 13, 0, 0, 0, 0, 0, 20, + 0, 0, 37, 0, 38, 39, 0, 0, 64, 65, + 66, 67, 68, 69, 23, 27, 70, 71, 55, 34, + 0, 0, 0, 24, 25, 26, 35, 78, 33, 0, + 0, 0, 0, 0, 0, 50, 51, 52, 53, 54, + 228, 22, 28, 0, 49, 32, 0, 74, 76, 0, + 77, 0, 72, 0, 0, 0, 0, 0, 0, 36, + 29, 30, 31, 0, 0, 0, 0, 0, 21, 22, + 28, 0, 0, 32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 37, 0, 38, 39, 36, 29, 30, + 31, 0, 0, 0, 0, 23, 27, 228, 22, 28, + 34, 0, 32, 0, 24, 25, 26, 35, 0, 33, + 277, 37, 0, 38, 39, 0, 36, 29, 30, 31, + 0, 0, 0, 23, 27, 221, 22, 28, 34, 0, + 32, 0, 24, 25, 26, 35, 0, 33, 0, 0, + 37, 0, 38, 39, 36, 29, 30, 31, 0, 0, + 0, 0, 23, 27, 107, 22, 28, 34, 0, 32, + 0, 24, 25, 26, 35, 0, 33, 0, 37, 0, + 38, 39, 0, 36, 29, 30, 31, 0, 0, 0, + 23, 27, 99, 22, 28, 34, 0, 32, 0, 24, + 25, 26, 35, 0, 33, 0, 0, 37, 0, 38, + 39, 36, 29, 30, 31, 0, 0, 0, 0, 23, + 27, 97, 22, 28, 34, 0, 32, 0, 24, 25, + 26, 35, 0, 33, 0, 37, 0, 38, 39, 0, + 36, 29, 30, 31, 0, 0, 0, 23, 27, 86, + 22, 28, 34, 0, 32, 0, 24, 25, 26, 35, + 0, 33, 0, 0, 37, 0, 38, 39, 36, 29, + 30, 31, 0, 0, 0, 0, 23, 27, 0, 0, + 0, 34, 0, 0, 0, 24, 25, 26, 35, 0, + 33, 0, 37, 0, 38, 39, 0, 0, 64, 65, + 66, 67, 68, 69, 23, 27, 0, 0, 55, 85, + 0, 0, 0, 24, 25, 26, 35, 78, 33, 0, + 0, 0, 0, 0, 0, 0, 0, 52, 53, 54, + 0, 0, 0, 0, 49, 0, 0, 74, 76, 0, + 77, 0, 72, +} +var yyPact = [...]int{ + + -59, -1000, 1845, -59, -59, -1000, -1000, -1000, -1000, 228, + 1375, 146, -1000, -1000, 1954, 1954, 227, 199, 2125, 119, + 1954, -63, -1000, 1954, 1954, 1954, 2097, 2068, -1000, -1000, + -1000, -1000, 67, -59, -59, 1954, 226, 2040, 18, 1954, + 130, 1954, -1000, 1315, -1000, 138, -1000, 1954, 1954, 225, + 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, + 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, + -1000, -1000, 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, + 129, 1434, 1434, 113, 154, -59, 17, 25, 1243, 145, + -59, 1184, 1954, 1954, 51, 51, 51, -63, 1611, -63, + 1552, 224, 6, 1954, 213, 1125, 1, -36, 1493, 148, + 1434, -59, 1066, -1000, 1954, -59, 1434, 1007, -1000, 2147, + 2147, 51, 51, 51, 1434, 1867, 1867, 236, 236, 1867, + 1867, 1867, 1867, 1434, 1434, 1434, 1434, 1434, 1434, 1434, + 1657, 1434, 1703, 98, 417, 1434, -1000, 1434, -59, -59, + 1954, -59, 100, 1775, 1954, 1954, -59, 1954, 96, -59, + 94, 358, 223, 222, 45, 209, 221, -37, -46, -1000, + 141, -1000, 1954, 1954, 1954, 220, 220, 2011, -59, -1000, + 218, 1954, -29, -1000, -1000, 1954, 1983, 92, 948, 83, + -1000, 141, 889, 830, 82, -1000, 183, 85, 163, -31, + -1000, -1000, 1954, -1000, -1000, 112, -38, 44, 208, -59, + -61, -59, 79, 1954, 41, 87, 73, 38, -1000, 52, + 1434, -63, 78, -1000, 1434, -1000, 771, 1434, -63, -1000, + -59, -1000, -59, 1954, -1000, 128, -1000, -1000, -1000, 1954, + 140, -1000, -1000, -1000, 712, -59, 111, 110, -49, 1926, + -1000, 123, -1000, 1434, -1000, -50, -1000, -58, -1000, 216, + -1000, 1954, 1954, -1000, -1000, 76, 75, 653, 108, -59, + 594, -59, -1000, 74, -59, -59, 104, -1000, -1000, -1000, + -1000, -1000, -1000, 535, 299, -1000, -1000, -59, -59, 72, + -59, -59, -1000, 70, 69, -59, -1000, -1000, 1954, 68, + 55, 181, -59, -1000, -1000, -1000, 49, 476, -1000, 172, + 99, -1000, -1000, -1000, 88, -59, -59, 47, 39, -1000, + -1000, +} +var yyPgo = [...]int{ + + 0, 12, 241, 200, 239, 5, 2, 238, 4, 0, + 32, 31, 236, 1, 235, 6, 11, 233, 210, +} +var yyR1 = [...]int{ + + 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 4, 4, 4, 7, 7, + 7, 7, 7, 6, 5, 13, 14, 14, 14, 15, + 15, 15, 12, 11, 11, 11, 8, 8, 10, 10, + 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 16, 16, 17, 17, 18, 18, +} +var yyR2 = [...]int{ + + 0, 1, 2, 0, 2, 3, 4, 3, 3, 1, + 1, 2, 2, 5, 1, 4, 7, 9, 5, 13, + 12, 9, 8, 5, 1, 7, 5, 5, 0, 2, + 2, 2, 2, 5, 4, 3, 0, 1, 4, 0, + 1, 4, 3, 1, 4, 4, 1, 3, 0, 1, + 4, 4, 1, 1, 2, 2, 2, 2, 4, 2, + 4, 1, 1, 1, 1, 5, 3, 7, 8, 8, + 9, 5, 6, 5, 6, 3, 5, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, + 3, 3, 3, 5, 4, 6, 5, 5, 4, 6, + 5, 4, 4, 6, 6, 5, 7, 7, 9, 3, + 2, 0, 1, 1, 2, 1, 1, +} +var yyChk = [...]int{ + + -1000, -1, -16, -2, -17, -18, 66, 76, -3, 11, + -9, -11, 37, 38, 10, 12, 27, -4, 15, 28, + 44, 4, 5, 59, 68, 69, 70, 60, 6, 24, + 25, 26, 9, 73, 64, 71, 23, 47, 49, 50, + -10, 13, -16, -17, -18, -15, 4, 52, 53, 67, + 58, 59, 60, 61, 62, 41, 42, 43, 17, 18, + 56, 19, 57, 20, 31, 32, 33, 34, 35, 36, + 39, 40, 75, 21, 70, 22, 71, 73, 50, 52, + -10, -9, -9, 4, 14, 64, 4, -12, -9, -11, + 64, -9, 71, 73, -9, -9, -9, 4, -9, 4, + -9, 71, 4, -16, -16, -9, 4, 4, -9, 71, + -9, 55, -9, -3, 52, 55, -9, -9, 4, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -10, -9, -9, -11, -9, 55, 64, + 13, 64, -1, -16, 16, 66, 64, 52, -1, 64, + -10, -9, 67, 67, -15, 4, 71, -10, -14, -13, + 6, 72, 71, 71, 71, 48, 51, -16, 64, -11, + -16, 54, 8, 72, 74, 54, -16, -1, -9, -1, + 65, 6, -9, -9, -1, -11, 65, -7, -16, 8, + 72, 74, 54, 4, 4, 72, 8, -15, 4, 55, + -16, 55, -16, 54, -10, -10, -10, -8, 4, -8, + -9, 4, -1, 4, -9, 72, -9, -9, 4, 65, + 64, 65, 64, 66, 65, 29, 65, -6, -5, 45, + 46, -6, -5, 72, -9, 64, 72, 72, 8, -16, + 74, -16, 65, -9, 72, 8, 72, 8, 72, 67, + 72, 55, 55, 65, 74, -1, -1, -9, 4, 64, + -9, 54, 74, -1, 64, 64, 72, 74, -13, 65, + 72, 72, 4, -9, -9, 65, 65, 64, 64, -1, + 54, -16, 65, -1, -1, 64, 72, 72, 55, -1, + -1, 65, -16, -1, 65, 65, -1, -9, 65, 65, + 30, -1, 65, 72, 30, 64, 64, -1, -1, 65, + 65, +} +var yyDef = [...]int{ + + -2, -2, -2, 121, 122, 123, 125, 126, 4, 39, + -2, 0, 9, 10, 48, 0, 0, 14, 48, 0, + 0, 52, 53, 0, 0, 0, 0, 0, 61, 62, + 63, 64, 0, 121, 121, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 124, 0, 40, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 97, 98, 0, 0, 0, 0, 48, 0, 0, 48, + 11, 49, 12, 0, 0, -2, 52, 0, -2, 0, + -2, 0, 48, 0, 54, 55, 56, -2, 0, -2, + 0, 39, 0, 48, 36, 0, 0, 52, 0, 0, + 120, 121, 0, 5, 48, 121, 7, 0, 66, 77, + 78, 79, 80, 81, 82, 83, 84, -2, -2, 87, + 88, 89, 90, 91, 92, 93, 94, 95, 96, 99, + 100, 101, 102, 0, 0, 119, 8, -2, 121, -2, + 0, -2, 0, -2, 0, 0, -2, 48, 0, 28, + 0, 0, 0, 0, 0, 40, 39, 121, 121, 37, + 0, 75, 48, 48, 48, 0, 0, 0, -2, 6, + 0, 0, 0, 108, 112, 0, 0, 0, 0, 0, + 15, 61, 0, 0, 0, 42, 0, 0, 0, 0, + 104, 111, 0, 58, 60, 0, 0, 0, 40, 121, + 0, 121, 0, 0, 0, 0, 0, 0, 46, 0, + -2, -2, 0, 41, 65, 107, 0, 50, -2, 13, + -2, 26, -2, 0, 18, 0, 23, 31, 32, 0, + 0, 29, 30, 103, 0, -2, 0, 0, 0, 0, + 71, 0, 73, 35, 76, 0, -2, 0, -2, 0, + 115, 0, 0, 27, 114, 0, 0, 0, 0, -2, + 0, 121, 113, 0, -2, -2, 0, 72, 38, 74, + -2, -2, 47, 0, 0, 25, 16, -2, -2, 0, + 121, -2, 67, 0, 0, -2, 116, 117, 0, 0, + 0, 22, -2, 34, 68, 69, 0, 0, 17, 21, + 0, 33, 70, 118, 0, -2, -2, 0, 0, 20, + 19, +} +var yyTok1 = [...]int{ + + 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 76, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 68, 3, 3, 3, 62, 70, 3, + 71, 72, 60, 58, 55, 59, 67, 61, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 54, 66, + 57, 52, 56, 53, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 73, 3, 74, 69, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 64, 75, 65, +} +var yyTok2 = [...]int{ + + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 63, +} +var yyTok3 = [...]int{ + 0, +} + +var yyErrorMessages = [...]struct { + state int + token int + msg string +}{} + +//line yaccpar:1 + +/* parser for yacc output */ + +var ( + yyDebug = 0 + yyErrorVerbose = false +) + +type yyLexer interface { + Lex(lval *yySymType) int + Error(s string) +} + +type yyParser interface { + Parse(yyLexer) int + Lookahead() int +} + +type yyParserImpl struct { + lval yySymType + stack [yyInitialStackSize]yySymType + char int +} + +func (p *yyParserImpl) Lookahead() int { + return p.char +} + +func yyNewParser() yyParser { + return &yyParserImpl{} +} + +const yyFlag = -1000 + +func yyTokname(c int) string { + if c >= 1 && c-1 < len(yyToknames) { + if yyToknames[c-1] != "" { + return yyToknames[c-1] + } + } + return __yyfmt__.Sprintf("tok-%v", c) +} + +func yyStatname(s int) string { + if s >= 0 && s < len(yyStatenames) { + if yyStatenames[s] != "" { + return yyStatenames[s] + } + } + return __yyfmt__.Sprintf("state-%v", s) +} + +func yyErrorMessage(state, lookAhead int) string { + const TOKSTART = 4 + + if !yyErrorVerbose { + return "syntax error" + } + + for _, e := range yyErrorMessages { + if e.state == state && e.token == lookAhead { + return "syntax error: " + e.msg + } + } + + res := "syntax error: unexpected " + yyTokname(lookAhead) + + // To match Bison, suggest at most four expected tokens. + expected := make([]int, 0, 4) + + // Look for shiftable tokens. + base := yyPact[state] + for tok := TOKSTART; tok-1 < len(yyToknames); tok++ { + if n := base + tok; n >= 0 && n < yyLast && yyChk[yyAct[n]] == tok { + if len(expected) == cap(expected) { + return res + } + expected = append(expected, tok) + } + } + + if yyDef[state] == -2 { + i := 0 + for yyExca[i] != -1 || yyExca[i+1] != state { + i += 2 + } + + // Look for tokens that we accept or reduce. + for i += 2; yyExca[i] >= 0; i += 2 { + tok := yyExca[i] + if tok < TOKSTART || yyExca[i+1] == 0 { + continue + } + if len(expected) == cap(expected) { + return res + } + expected = append(expected, tok) + } + + // If the default action is to accept or reduce, give up. + if yyExca[i+1] != 0 { + return res + } + } + + for i, tok := range expected { + if i == 0 { + res += ", expecting " + } else { + res += " or " + } + res += yyTokname(tok) + } + return res +} + +func yylex1(lex yyLexer, lval *yySymType) (char, token int) { + token = 0 + char = lex.Lex(lval) + if char <= 0 { + token = yyTok1[0] + goto out + } + if char < len(yyTok1) { + token = yyTok1[char] + goto out + } + if char >= yyPrivate { + if char < yyPrivate+len(yyTok2) { + token = yyTok2[char-yyPrivate] + goto out + } + } + for i := 0; i < len(yyTok3); i += 2 { + token = yyTok3[i+0] + if token == char { + token = yyTok3[i+1] + goto out + } + } + +out: + if token == 0 { + token = yyTok2[1] /* unknown char */ + } + if yyDebug >= 3 { + __yyfmt__.Printf("lex %s(%d)\n", yyTokname(token), uint(char)) + } + return char, token +} + +func yyParse(yylex yyLexer) int { + return yyNewParser().Parse(yylex) +} + +func (yyrcvr *yyParserImpl) Parse(yylex yyLexer) int { + var yyn int + var yyVAL yySymType + var yyDollar []yySymType + _ = yyDollar // silence set and not used + yyS := yyrcvr.stack[:] + + Nerrs := 0 /* number of errors */ + Errflag := 0 /* error recovery flag */ + yystate := 0 + yyrcvr.char = -1 + yytoken := -1 // yyrcvr.char translated into internal numbering + defer func() { + // Make sure we report no lookahead when not parsing. + yystate = -1 + yyrcvr.char = -1 + yytoken = -1 + }() + yyp := -1 + goto yystack + +ret0: + return 0 + +ret1: + return 1 + +yystack: + /* put a state and value onto the stack */ + if yyDebug >= 4 { + __yyfmt__.Printf("char %v in %v\n", yyTokname(yytoken), yyStatname(yystate)) + } + + yyp++ + if yyp >= len(yyS) { + nyys := make([]yySymType, len(yyS)*2) + copy(nyys, yyS) + yyS = nyys + } + yyS[yyp] = yyVAL + yyS[yyp].yys = yystate + +yynewstate: + yyn = yyPact[yystate] + if yyn <= yyFlag { + goto yydefault /* simple state */ + } + if yyrcvr.char < 0 { + yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval) + } + yyn += yytoken + if yyn < 0 || yyn >= yyLast { + goto yydefault + } + yyn = yyAct[yyn] + if yyChk[yyn] == yytoken { /* valid shift */ + yyrcvr.char = -1 + yytoken = -1 + yyVAL = yyrcvr.lval + yystate = yyn + if Errflag > 0 { + Errflag-- + } + goto yystack + } + +yydefault: + /* default state action */ + yyn = yyDef[yystate] + if yyn == -2 { + if yyrcvr.char < 0 { + yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval) + } + + /* look through exception table */ + xi := 0 + for { + if yyExca[xi+0] == -1 && yyExca[xi+1] == yystate { + break + } + xi += 2 + } + for xi += 2; ; xi += 2 { + yyn = yyExca[xi+0] + if yyn < 0 || yyn == yytoken { + break + } + } + yyn = yyExca[xi+1] + if yyn < 0 { + goto ret0 + } + } + if yyn == 0 { + /* error ... attempt to resume parsing */ + switch Errflag { + case 0: /* brand new error */ + yylex.Error(yyErrorMessage(yystate, yytoken)) + Nerrs++ + if yyDebug >= 1 { + __yyfmt__.Printf("%s", yyStatname(yystate)) + __yyfmt__.Printf(" saw %s\n", yyTokname(yytoken)) + } + fallthrough + + case 1, 2: /* incompletely recovered error ... try again */ + Errflag = 3 + + /* find a state where "error" is a legal shift action */ + for yyp >= 0 { + yyn = yyPact[yyS[yyp].yys] + yyErrCode + if yyn >= 0 && yyn < yyLast { + yystate = yyAct[yyn] /* simulate a shift of "error" */ + if yyChk[yystate] == yyErrCode { + goto yystack + } + } + + /* the current p has no shift on "error", pop stack */ + if yyDebug >= 2 { + __yyfmt__.Printf("error recovery pops state %d\n", yyS[yyp].yys) + } + yyp-- + } + /* there is no state on the stack with an error shift ... abort */ + goto ret1 + + case 3: /* no shift yet; clobber input char */ + if yyDebug >= 2 { + __yyfmt__.Printf("error recovery discards %s\n", yyTokname(yytoken)) + } + if yytoken == yyEofCode { + goto ret1 + } + yyrcvr.char = -1 + yytoken = -1 + goto yynewstate /* try again in the same state */ + } + } + + /* reduction by production yyn */ + if yyDebug >= 2 { + __yyfmt__.Printf("reduce %v in:\n\t%v\n", yyn, yyStatname(yystate)) + } + + yynt := yyn + yypt := yyp + _ = yypt // guard against "declared and not used" + + yyp -= yyR2[yyn] + // yyp is now the index of $0. Perform the default action. Iff the + // reduced production is ε, $1 is possibly out of range. + if yyp+1 >= len(yyS) { + nyys := make([]yySymType, len(yyS)*2) + copy(nyys, yyS) + yyS = nyys + } + yyVAL = yyS[yyp+1] + + /* consult goto table to find next state */ + yyn = yyR1[yyn] + yyg := yyPgo[yyn] + yyj := yyg + yyS[yyp].yys + 1 + + if yyj >= yyLast { + yystate = yyAct[yyg] + } else { + yystate = yyAct[yyj] + if yyChk[yystate] != -yyn { + yystate = yyAct[yyg] + } + } + // dummy call; replaced with literal code + switch yynt { + + case 1: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:65 + { + yyVAL.compstmt = nil + } + case 2: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:69 + { + yyVAL.compstmt = yyDollar[1].stmts + } + case 3: + yyDollar = yyS[yypt-0 : yypt+1] + //line parser.go.y:74 + { + yyVAL.stmts = nil + if l, ok := yylex.(*Lexer); ok { + l.stmts = yyVAL.stmts + } + } + case 4: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:81 + { + yyVAL.stmts = []ast.Stmt{yyDollar[2].stmt} + if l, ok := yylex.(*Lexer); ok { + l.stmts = yyVAL.stmts + } + } + case 5: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:88 + { + if yyDollar[3].stmt != nil { + yyVAL.stmts = append(yyDollar[1].stmts, yyDollar[3].stmt) + if l, ok := yylex.(*Lexer); ok { + l.stmts = yyVAL.stmts + } + } + } + case 6: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:99 + { + yyVAL.stmt = &ast.VarStmt{Names: yyDollar[2].expr_idents, Exprs: yyDollar[4].expr_many} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 7: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:104 + { + yyVAL.stmt = &ast.LetsStmt{Lhss: []ast.Expr{yyDollar[1].expr}, Operator: "=", Rhss: []ast.Expr{yyDollar[3].expr}} + } + case 8: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:108 + { + yyVAL.stmt = &ast.LetsStmt{Lhss: yyDollar[1].expr_many, Operator: "=", Rhss: yyDollar[3].expr_many} + } + case 9: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:112 + { + yyVAL.stmt = &ast.BreakStmt{} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 10: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:117 + { + yyVAL.stmt = &ast.ContinueStmt{} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 11: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:122 + { + yyVAL.stmt = &ast.ReturnStmt{Exprs: yyDollar[2].exprs} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 12: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:127 + { + yyVAL.stmt = &ast.ThrowStmt{Expr: yyDollar[2].expr} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 13: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:132 + { + yyVAL.stmt = &ast.ModuleStmt{Name: yyDollar[2].tok.Lit, Stmts: yyDollar[4].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 14: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:137 + { + yyVAL.stmt = yyDollar[1].stmt_if + yyVAL.stmt.SetPosition(yyDollar[1].stmt_if.Position()) + } + case 15: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:142 + { + yyVAL.stmt = &ast.LoopStmt{Stmts: yyDollar[3].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 16: + yyDollar = yyS[yypt-7 : yypt+1] + //line parser.go.y:147 + { + yyVAL.stmt = &ast.ForStmt{Var: yyDollar[2].tok.Lit, Value: yyDollar[4].expr, Stmts: yyDollar[6].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 17: + yyDollar = yyS[yypt-9 : yypt+1] + //line parser.go.y:152 + { + yyVAL.stmt = &ast.CForStmt{Expr1: yyDollar[2].expr_lets, Expr2: yyDollar[4].expr, Expr3: yyDollar[6].expr, Stmts: yyDollar[8].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 18: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:157 + { + yyVAL.stmt = &ast.LoopStmt{Expr: yyDollar[2].expr, Stmts: yyDollar[4].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 19: + yyDollar = yyS[yypt-13 : yypt+1] + //line parser.go.y:162 + { + yyVAL.stmt = &ast.TryStmt{Try: yyDollar[3].compstmt, Var: yyDollar[6].tok.Lit, Catch: yyDollar[8].compstmt, Finally: yyDollar[12].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 20: + yyDollar = yyS[yypt-12 : yypt+1] + //line parser.go.y:167 + { + yyVAL.stmt = &ast.TryStmt{Try: yyDollar[3].compstmt, Catch: yyDollar[7].compstmt, Finally: yyDollar[11].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 21: + yyDollar = yyS[yypt-9 : yypt+1] + //line parser.go.y:172 + { + yyVAL.stmt = &ast.TryStmt{Try: yyDollar[3].compstmt, Var: yyDollar[6].tok.Lit, Catch: yyDollar[8].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 22: + yyDollar = yyS[yypt-8 : yypt+1] + //line parser.go.y:177 + { + yyVAL.stmt = &ast.TryStmt{Try: yyDollar[3].compstmt, Catch: yyDollar[7].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 23: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:182 + { + yyVAL.stmt = &ast.SwitchStmt{Expr: yyDollar[2].expr, Cases: yyDollar[4].stmt_cases} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 24: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:187 + { + yyVAL.stmt = &ast.ExprStmt{Expr: yyDollar[1].expr} + yyVAL.stmt.SetPosition(yyDollar[1].expr.Position()) + } + case 25: + yyDollar = yyS[yypt-7 : yypt+1] + //line parser.go.y:195 + { + yyDollar[1].stmt_if.(*ast.IfStmt).ElseIf = append(yyDollar[1].stmt_if.(*ast.IfStmt).ElseIf, &ast.IfStmt{If: yyDollar[4].expr, Then: yyDollar[6].compstmt}) + yyVAL.stmt_if.SetPosition(yyDollar[1].stmt_if.Position()) + } + case 26: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:200 + { + if yyVAL.stmt_if.(*ast.IfStmt).Else != nil { + yylex.Error("multiple else statement") + } else { + yyVAL.stmt_if.(*ast.IfStmt).Else = append(yyVAL.stmt_if.(*ast.IfStmt).Else, yyDollar[4].compstmt...) + } + yyVAL.stmt_if.SetPosition(yyDollar[1].stmt_if.Position()) + } + case 27: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:209 + { + yyVAL.stmt_if = &ast.IfStmt{If: yyDollar[2].expr, Then: yyDollar[4].compstmt, Else: nil} + yyVAL.stmt_if.SetPosition(yyDollar[1].tok.Position()) + } + case 28: + yyDollar = yyS[yypt-0 : yypt+1] + //line parser.go.y:215 + { + yyVAL.stmt_cases = []ast.Stmt{} + } + case 29: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:219 + { + yyVAL.stmt_cases = []ast.Stmt{yyDollar[2].stmt_case} + } + case 30: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:223 + { + yyVAL.stmt_cases = []ast.Stmt{yyDollar[2].stmt_default} + } + case 31: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:227 + { + yyVAL.stmt_cases = append(yyDollar[1].stmt_cases, yyDollar[2].stmt_case) + } + case 32: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:231 + { + for _, stmt := range yyDollar[1].stmt_cases { + if _, ok := stmt.(*ast.DefaultStmt); ok { + yylex.Error("multiple default statement") + } + } + yyVAL.stmt_cases = append(yyDollar[1].stmt_cases, yyDollar[2].stmt_default) + } + case 33: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:242 + { + yyVAL.stmt_case = &ast.CaseStmt{Expr: yyDollar[2].expr, Stmts: yyDollar[5].compstmt} + } + case 34: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:248 + { + yyVAL.stmt_default = &ast.DefaultStmt{Stmts: yyDollar[4].compstmt} + } + case 35: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:254 + { + yyVAL.expr_pair = &ast.PairExpr{Key: yyDollar[1].tok.Lit, Value: yyDollar[3].expr} + } + case 36: + yyDollar = yyS[yypt-0 : yypt+1] + //line parser.go.y:259 + { + yyVAL.expr_pairs = []ast.Expr{} + } + case 37: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:263 + { + yyVAL.expr_pairs = []ast.Expr{yyDollar[1].expr_pair} + } + case 38: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:267 + { + yyVAL.expr_pairs = append(yyDollar[1].expr_pairs, yyDollar[4].expr_pair) + } + case 39: + yyDollar = yyS[yypt-0 : yypt+1] + //line parser.go.y:272 + { + yyVAL.expr_idents = []string{} + } + case 40: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:276 + { + yyVAL.expr_idents = []string{yyDollar[1].tok.Lit} + } + case 41: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:280 + { + yyVAL.expr_idents = append(yyDollar[1].expr_idents, yyDollar[4].tok.Lit) + } + case 42: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:285 + { + yyVAL.expr_lets = &ast.LetsExpr{Lhss: yyDollar[1].expr_many, Operator: "=", Rhss: yyDollar[3].expr_many} + } + case 43: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:291 + { + yyVAL.expr_many = []ast.Expr{yyDollar[1].expr} + } + case 44: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:295 + { + yyVAL.expr_many = append(yyDollar[1].exprs, yyDollar[4].expr) + } + case 45: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:299 + { + yyVAL.expr_many = append(yyDollar[1].exprs, &ast.IdentExpr{Lit: yyDollar[4].tok.Lit}) + } + case 46: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:304 + { + yyVAL.typ = ast.Type{Name: yyDollar[1].tok.Lit} + } + case 47: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:308 + { + yyVAL.typ = ast.Type{Name: yyDollar[1].typ.Name + "." + yyDollar[3].tok.Lit} + } + case 48: + yyDollar = yyS[yypt-0 : yypt+1] + //line parser.go.y:313 + { + yyVAL.exprs = nil + } + case 49: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:317 + { + yyVAL.exprs = []ast.Expr{yyDollar[1].expr} + } + case 50: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:321 + { + yyVAL.exprs = append(yyDollar[1].exprs, yyDollar[4].expr) + } + case 51: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:325 + { + yyVAL.exprs = append(yyDollar[1].exprs, &ast.IdentExpr{Lit: yyDollar[4].tok.Lit}) + } + case 52: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:331 + { + yyVAL.expr = &ast.IdentExpr{Lit: yyDollar[1].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 53: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:336 + { + yyVAL.expr = &ast.NumberExpr{Lit: yyDollar[1].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 54: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:341 + { + yyVAL.expr = &ast.UnaryExpr{Operator: "-", Expr: yyDollar[2].expr} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 55: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:346 + { + yyVAL.expr = &ast.UnaryExpr{Operator: "!", Expr: yyDollar[2].expr} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 56: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:351 + { + yyVAL.expr = &ast.UnaryExpr{Operator: "^", Expr: yyDollar[2].expr} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 57: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:356 + { + yyVAL.expr = &ast.AddrExpr{Expr: &ast.IdentExpr{Lit: yyDollar[2].tok.Lit}} + yyVAL.expr.SetPosition(yyDollar[2].tok.Position()) + } + case 58: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:361 + { + yyVAL.expr = &ast.AddrExpr{Expr: &ast.MemberExpr{Expr: yyDollar[2].expr, Name: yyDollar[4].tok.Lit}} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 59: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:366 + { + yyVAL.expr = &ast.DerefExpr{Expr: &ast.IdentExpr{Lit: yyDollar[2].tok.Lit}} + yyVAL.expr.SetPosition(yyDollar[2].tok.Position()) + } + case 60: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:371 + { + yyVAL.expr = &ast.DerefExpr{Expr: &ast.MemberExpr{Expr: yyDollar[2].expr, Name: yyDollar[4].tok.Lit}} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 61: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:376 + { + yyVAL.expr = &ast.StringExpr{Lit: yyDollar[1].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 62: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:381 + { + yyVAL.expr = &ast.ConstExpr{Value: yyDollar[1].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 63: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:386 + { + yyVAL.expr = &ast.ConstExpr{Value: yyDollar[1].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 64: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:391 + { + yyVAL.expr = &ast.ConstExpr{Value: yyDollar[1].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 65: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:396 + { + yyVAL.expr = &ast.TernaryOpExpr{Expr: yyDollar[1].expr, Lhs: yyDollar[3].expr, Rhs: yyDollar[5].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 66: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:401 + { + yyVAL.expr = &ast.MemberExpr{Expr: yyDollar[1].expr, Name: yyDollar[3].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 67: + yyDollar = yyS[yypt-7 : yypt+1] + //line parser.go.y:406 + { + yyVAL.expr = &ast.FuncExpr{Args: yyDollar[3].expr_idents, Stmts: yyDollar[6].compstmt} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 68: + yyDollar = yyS[yypt-8 : yypt+1] + //line parser.go.y:411 + { + yyVAL.expr = &ast.FuncExpr{Args: []string{yyDollar[3].tok.Lit}, Stmts: yyDollar[7].compstmt, VarArg: true} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 69: + yyDollar = yyS[yypt-8 : yypt+1] + //line parser.go.y:416 + { + yyVAL.expr = &ast.FuncExpr{Name: yyDollar[2].tok.Lit, Args: yyDollar[4].expr_idents, Stmts: yyDollar[7].compstmt} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 70: + yyDollar = yyS[yypt-9 : yypt+1] + //line parser.go.y:421 + { + yyVAL.expr = &ast.FuncExpr{Name: yyDollar[2].tok.Lit, Args: []string{yyDollar[4].tok.Lit}, Stmts: yyDollar[8].compstmt, VarArg: true} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 71: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:426 + { + yyVAL.expr = &ast.ArrayExpr{Exprs: yyDollar[3].exprs} + if l, ok := yylex.(*Lexer); ok { + yyVAL.expr.SetPosition(l.pos) + } + } + case 72: + yyDollar = yyS[yypt-6 : yypt+1] + //line parser.go.y:431 + { + yyVAL.expr = &ast.ArrayExpr{Exprs: yyDollar[3].exprs} + if l, ok := yylex.(*Lexer); ok { + yyVAL.expr.SetPosition(l.pos) + } + } + case 73: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:436 + { + mapExpr := make(map[string]ast.Expr) + for _, v := range yyDollar[3].expr_pairs { + mapExpr[v.(*ast.PairExpr).Key] = v.(*ast.PairExpr).Value + } + yyVAL.expr = &ast.MapExpr{MapExpr: mapExpr} + if l, ok := yylex.(*Lexer); ok { + yyVAL.expr.SetPosition(l.pos) + } + } + case 74: + yyDollar = yyS[yypt-6 : yypt+1] + //line parser.go.y:445 + { + mapExpr := make(map[string]ast.Expr) + for _, v := range yyDollar[3].expr_pairs { + mapExpr[v.(*ast.PairExpr).Key] = v.(*ast.PairExpr).Value + } + yyVAL.expr = &ast.MapExpr{MapExpr: mapExpr} + if l, ok := yylex.(*Lexer); ok { + yyVAL.expr.SetPosition(l.pos) + } + } + case 75: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:454 + { + yyVAL.expr = &ast.ParenExpr{SubExpr: yyDollar[2].expr} + if l, ok := yylex.(*Lexer); ok { + yyVAL.expr.SetPosition(l.pos) + } + } + case 76: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:459 + { + yyVAL.expr = &ast.NewExpr{Name: yyDollar[2].tok.Lit, SubExprs: yyDollar[4].exprs} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 77: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:464 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "+", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 78: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:469 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "-", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 79: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:474 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "*", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 80: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:479 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "/", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 81: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:484 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "%", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 82: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:489 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "**", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 83: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:494 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "<<", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 84: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:499 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: ">>", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 85: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:504 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "==", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 86: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:509 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "!=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 87: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:514 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: ">", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 88: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:519 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: ">=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 89: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:524 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "<", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 90: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:529 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "<=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 91: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:534 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "+=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 92: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:539 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "-=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 93: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:544 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "*=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 94: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:549 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "/=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 95: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:554 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "&=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 96: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:559 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "|=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 97: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:564 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "++"} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 98: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:569 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "--"} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 99: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:574 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "|", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 100: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:579 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "||", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 101: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:584 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "&", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 102: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:589 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "&&", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 103: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:594 + { + yyVAL.expr = &ast.CallExpr{Name: yyDollar[1].tok.Lit, SubExprs: yyDollar[3].exprs, VarArg: true} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 104: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:599 + { + yyVAL.expr = &ast.CallExpr{Name: yyDollar[1].tok.Lit, SubExprs: yyDollar[3].exprs} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 105: + yyDollar = yyS[yypt-6 : yypt+1] + //line parser.go.y:604 + { + yyVAL.expr = &ast.CallExpr{Name: yyDollar[2].tok.Lit, SubExprs: yyDollar[4].exprs, VarArg: true, Go: true} + yyVAL.expr.SetPosition(yyDollar[2].tok.Position()) + } + case 106: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:609 + { + yyVAL.expr = &ast.CallExpr{Name: yyDollar[2].tok.Lit, SubExprs: yyDollar[4].exprs, Go: true} + yyVAL.expr.SetPosition(yyDollar[2].tok.Position()) + } + case 107: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:614 + { + yyVAL.expr = &ast.AnonCallExpr{Expr: yyDollar[1].expr, SubExprs: yyDollar[3].exprs, VarArg: true} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 108: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:619 + { + yyVAL.expr = &ast.AnonCallExpr{Expr: yyDollar[1].expr, SubExprs: yyDollar[3].exprs} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 109: + yyDollar = yyS[yypt-6 : yypt+1] + //line parser.go.y:624 + { + yyVAL.expr = &ast.AnonCallExpr{Expr: yyDollar[2].expr, SubExprs: yyDollar[4].exprs, VarArg: true, Go: true} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 110: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:629 + { + yyVAL.expr = &ast.AnonCallExpr{Expr: yyDollar[2].expr, SubExprs: yyDollar[4].exprs, Go: true} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 111: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:634 + { + yyVAL.expr = &ast.ItemExpr{Value: &ast.IdentExpr{Lit: yyDollar[1].tok.Lit}, Index: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 112: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:639 + { + yyVAL.expr = &ast.ItemExpr{Value: yyDollar[1].expr, Index: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 113: + yyDollar = yyS[yypt-6 : yypt+1] + //line parser.go.y:644 + { + yyVAL.expr = &ast.SliceExpr{Value: &ast.IdentExpr{Lit: yyDollar[1].tok.Lit}, Begin: yyDollar[3].expr, End: yyDollar[5].expr} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 114: + yyDollar = yyS[yypt-6 : yypt+1] + //line parser.go.y:649 + { + yyVAL.expr = &ast.SliceExpr{Value: yyDollar[1].expr, Begin: yyDollar[3].expr, End: yyDollar[5].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 115: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:654 + { + yyVAL.expr = &ast.MakeChanExpr{Type: yyDollar[4].typ.Name, SizeExpr: nil} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 116: + yyDollar = yyS[yypt-7 : yypt+1] + //line parser.go.y:659 + { + yyVAL.expr = &ast.MakeChanExpr{Type: yyDollar[4].typ.Name, SizeExpr: yyDollar[6].expr} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 117: + yyDollar = yyS[yypt-7 : yypt+1] + //line parser.go.y:664 + { + yyVAL.expr = &ast.MakeArrayExpr{Type: yyDollar[4].typ.Name, LenExpr: yyDollar[6].expr} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 118: + yyDollar = yyS[yypt-9 : yypt+1] + //line parser.go.y:669 + { + yyVAL.expr = &ast.MakeArrayExpr{Type: yyDollar[4].typ.Name, LenExpr: yyDollar[6].expr, CapExpr: yyDollar[8].expr} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 119: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:674 + { + yyVAL.expr = &ast.ChanExpr{Lhs: yyDollar[1].expr, Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 120: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:679 + { + yyVAL.expr = &ast.ChanExpr{Rhs: yyDollar[2].expr} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 123: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:690 + { + } + case 124: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:693 + { + } + case 125: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:698 + { + } + case 126: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:701 + { + } + } + goto yystack /* stack new state and value */ +} diff --git a/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/parser/parser.go.y b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/parser/parser.go.y new file mode 100644 index 0000000000..9ebe8ae068 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/parser/parser.go.y @@ -0,0 +1,705 @@ +%{ +package parser + +import ( + "github.com/mattn/anko/ast" +) + +%} + +%type compstmt +%type stmts +%type stmt +%type stmt_if +%type stmt_default +%type stmt_case +%type stmt_cases +%type typ +%type expr +%type exprs +%type expr_many +%type expr_lets +%type expr_pair +%type expr_pairs +%type expr_idents + +%union{ + compstmt []ast.Stmt + stmt_if ast.Stmt + stmt_default ast.Stmt + stmt_case ast.Stmt + stmt_cases []ast.Stmt + stmts []ast.Stmt + stmt ast.Stmt + typ ast.Type + expr ast.Expr + exprs []ast.Expr + expr_many []ast.Expr + expr_lets ast.Expr + expr_pair ast.Expr + expr_pairs []ast.Expr + expr_idents []string + tok ast.Token + term ast.Token + terms ast.Token + opt_terms ast.Token +} + +%token IDENT NUMBER STRING ARRAY VARARG FUNC RETURN VAR THROW IF ELSE FOR IN EQEQ NEQ GE LE OROR ANDAND NEW TRUE FALSE NIL MODULE TRY CATCH FINALLY PLUSEQ MINUSEQ MULEQ DIVEQ ANDEQ OREQ BREAK CONTINUE PLUSPLUS MINUSMINUS POW SHIFTLEFT SHIFTRIGHT SWITCH CASE DEFAULT GO CHAN MAKE OPCHAN ARRAYLIT + +%right '=' +%right '?' ':' +%left OROR +%left ANDAND +%left IDENT +%nonassoc EQEQ NEQ ',' +%left '>' GE '<' LE SHIFTLEFT SHIFTRIGHT + +%left '+' '-' PLUSPLUS MINUSMINUS +%left '*' '/' '%' +%right UNARY + +%% + +compstmt : opt_terms + { + $$ = nil + } + | stmts opt_terms + { + $$ = $1 + } + +stmts : + { + $$ = nil + if l, ok := yylex.(*Lexer); ok { + l.stmts = $$ + } + } + | opt_terms stmt + { + $$ = []ast.Stmt{$2} + if l, ok := yylex.(*Lexer); ok { + l.stmts = $$ + } + } + | stmts terms stmt + { + if $3 != nil { + $$ = append($1, $3) + if l, ok := yylex.(*Lexer); ok { + l.stmts = $$ + } + } + } + +stmt : + VAR expr_idents '=' expr_many + { + $$ = &ast.VarStmt{Names: $2, Exprs: $4} + $$.SetPosition($1.Position()) + } + | expr '=' expr + { + $$ = &ast.LetsStmt{Lhss: []ast.Expr{$1}, Operator: "=", Rhss: []ast.Expr{$3}} + } + | expr_many '=' expr_many + { + $$ = &ast.LetsStmt{Lhss: $1, Operator: "=", Rhss: $3} + } + | BREAK + { + $$ = &ast.BreakStmt{} + $$.SetPosition($1.Position()) + } + | CONTINUE + { + $$ = &ast.ContinueStmt{} + $$.SetPosition($1.Position()) + } + | RETURN exprs + { + $$ = &ast.ReturnStmt{Exprs: $2} + $$.SetPosition($1.Position()) + } + | THROW expr + { + $$ = &ast.ThrowStmt{Expr: $2} + $$.SetPosition($1.Position()) + } + | MODULE IDENT '{' compstmt '}' + { + $$ = &ast.ModuleStmt{Name: $2.Lit, Stmts: $4} + $$.SetPosition($1.Position()) + } + | stmt_if + { + $$ = $1 + $$.SetPosition($1.Position()) + } + | FOR '{' compstmt '}' + { + $$ = &ast.LoopStmt{Stmts: $3} + $$.SetPosition($1.Position()) + } + | FOR IDENT IN expr '{' compstmt '}' + { + $$ = &ast.ForStmt{Var: $2.Lit, Value: $4, Stmts: $6} + $$.SetPosition($1.Position()) + } + | FOR expr_lets ';' expr ';' expr '{' compstmt '}' + { + $$ = &ast.CForStmt{Expr1: $2, Expr2: $4, Expr3: $6, Stmts: $8} + $$.SetPosition($1.Position()) + } + | FOR expr '{' compstmt '}' + { + $$ = &ast.LoopStmt{Expr: $2, Stmts: $4} + $$.SetPosition($1.Position()) + } + | TRY '{' compstmt '}' CATCH IDENT '{' compstmt '}' FINALLY '{' compstmt '}' + { + $$ = &ast.TryStmt{Try: $3, Var: $6.Lit, Catch: $8, Finally: $12} + $$.SetPosition($1.Position()) + } + | TRY '{' compstmt '}' CATCH '{' compstmt '}' FINALLY '{' compstmt '}' + { + $$ = &ast.TryStmt{Try: $3, Catch: $7, Finally: $11} + $$.SetPosition($1.Position()) + } + | TRY '{' compstmt '}' CATCH IDENT '{' compstmt '}' + { + $$ = &ast.TryStmt{Try: $3, Var: $6.Lit, Catch: $8} + $$.SetPosition($1.Position()) + } + | TRY '{' compstmt '}' CATCH '{' compstmt '}' + { + $$ = &ast.TryStmt{Try: $3, Catch: $7} + $$.SetPosition($1.Position()) + } + | SWITCH expr '{' stmt_cases '}' + { + $$ = &ast.SwitchStmt{Expr: $2, Cases: $4} + $$.SetPosition($1.Position()) + } + | expr + { + $$ = &ast.ExprStmt{Expr: $1} + $$.SetPosition($1.Position()) + } + + +stmt_if : + stmt_if ELSE IF expr '{' compstmt '}' + { + $1.(*ast.IfStmt).ElseIf = append($1.(*ast.IfStmt).ElseIf, &ast.IfStmt{If: $4, Then: $6}) + $$.SetPosition($1.Position()) + } + | stmt_if ELSE '{' compstmt '}' + { + if $$.(*ast.IfStmt).Else != nil { + yylex.Error("multiple else statement") + } else { + $$.(*ast.IfStmt).Else = append($$.(*ast.IfStmt).Else, $4...) + } + $$.SetPosition($1.Position()) + } + | IF expr '{' compstmt '}' + { + $$ = &ast.IfStmt{If: $2, Then: $4, Else: nil} + $$.SetPosition($1.Position()) + } + +stmt_cases : + { + $$ = []ast.Stmt{} + } + | opt_terms stmt_case + { + $$ = []ast.Stmt{$2} + } + | opt_terms stmt_default + { + $$ = []ast.Stmt{$2} + } + | stmt_cases stmt_case + { + $$ = append($1, $2) + } + | stmt_cases stmt_default + { + for _, stmt := range $1 { + if _, ok := stmt.(*ast.DefaultStmt); ok { + yylex.Error("multiple default statement") + } + } + $$ = append($1, $2) + } + +stmt_case : + CASE expr ':' opt_terms compstmt + { + $$ = &ast.CaseStmt{Expr: $2, Stmts: $5} + } + +stmt_default : + DEFAULT ':' opt_terms compstmt + { + $$ = &ast.DefaultStmt{Stmts: $4} + } + +expr_pair : + STRING ':' expr + { + $$ = &ast.PairExpr{Key: $1.Lit, Value: $3} + } + +expr_pairs : + { + $$ = []ast.Expr{} + } + | expr_pair + { + $$ = []ast.Expr{$1} + } + | expr_pairs ',' opt_terms expr_pair + { + $$ = append($1, $4) + } + +expr_idents : + { + $$ = []string{} + } + | IDENT + { + $$ = []string{$1.Lit} + } + | expr_idents ',' opt_terms IDENT + { + $$ = append($1, $4.Lit) + } + +expr_lets : expr_many '=' expr_many + { + $$ = &ast.LetsExpr{Lhss: $1, Operator: "=", Rhss: $3} + } + +expr_many : + expr + { + $$ = []ast.Expr{$1} + } + | exprs ',' opt_terms expr + { + $$ = append($1, $4) + } + | exprs ',' opt_terms IDENT + { + $$ = append($1, &ast.IdentExpr{Lit: $4.Lit}) + } + +typ : IDENT + { + $$ = ast.Type{Name: $1.Lit} + } + | typ '.' IDENT + { + $$ = ast.Type{Name: $1.Name + "." + $3.Lit} + } + +exprs : + { + $$ = nil + } + | expr + { + $$ = []ast.Expr{$1} + } + | exprs ',' opt_terms expr + { + $$ = append($1, $4) + } + | exprs ',' opt_terms IDENT + { + $$ = append($1, &ast.IdentExpr{Lit: $4.Lit}) + } + +expr : + IDENT + { + $$ = &ast.IdentExpr{Lit: $1.Lit} + $$.SetPosition($1.Position()) + } + | NUMBER + { + $$ = &ast.NumberExpr{Lit: $1.Lit} + $$.SetPosition($1.Position()) + } + | '-' expr %prec UNARY + { + $$ = &ast.UnaryExpr{Operator: "-", Expr: $2} + $$.SetPosition($2.Position()) + } + | '!' expr %prec UNARY + { + $$ = &ast.UnaryExpr{Operator: "!", Expr: $2} + $$.SetPosition($2.Position()) + } + | '^' expr %prec UNARY + { + $$ = &ast.UnaryExpr{Operator: "^", Expr: $2} + $$.SetPosition($2.Position()) + } + | '&' IDENT %prec UNARY + { + $$ = &ast.AddrExpr{Expr: &ast.IdentExpr{Lit: $2.Lit}} + $$.SetPosition($2.Position()) + } + | '&' expr '.' IDENT %prec UNARY + { + $$ = &ast.AddrExpr{Expr: &ast.MemberExpr{Expr: $2, Name: $4.Lit}} + $$.SetPosition($2.Position()) + } + | '*' IDENT %prec UNARY + { + $$ = &ast.DerefExpr{Expr: &ast.IdentExpr{Lit: $2.Lit}} + $$.SetPosition($2.Position()) + } + | '*' expr '.' IDENT %prec UNARY + { + $$ = &ast.DerefExpr{Expr: &ast.MemberExpr{Expr: $2, Name: $4.Lit}} + $$.SetPosition($2.Position()) + } + | STRING + { + $$ = &ast.StringExpr{Lit: $1.Lit} + $$.SetPosition($1.Position()) + } + | TRUE + { + $$ = &ast.ConstExpr{Value: $1.Lit} + $$.SetPosition($1.Position()) + } + | FALSE + { + $$ = &ast.ConstExpr{Value: $1.Lit} + $$.SetPosition($1.Position()) + } + | NIL + { + $$ = &ast.ConstExpr{Value: $1.Lit} + $$.SetPosition($1.Position()) + } + | expr '?' expr ':' expr + { + $$ = &ast.TernaryOpExpr{Expr: $1, Lhs: $3, Rhs: $5} + $$.SetPosition($1.Position()) + } + | expr '.' IDENT + { + $$ = &ast.MemberExpr{Expr: $1, Name: $3.Lit} + $$.SetPosition($1.Position()) + } + | FUNC '(' expr_idents ')' '{' compstmt '}' + { + $$ = &ast.FuncExpr{Args: $3, Stmts: $6} + $$.SetPosition($1.Position()) + } + | FUNC '(' IDENT VARARG ')' '{' compstmt '}' + { + $$ = &ast.FuncExpr{Args: []string{$3.Lit}, Stmts: $7, VarArg: true} + $$.SetPosition($1.Position()) + } + | FUNC IDENT '(' expr_idents ')' '{' compstmt '}' + { + $$ = &ast.FuncExpr{Name: $2.Lit, Args: $4, Stmts: $7} + $$.SetPosition($1.Position()) + } + | FUNC IDENT '(' IDENT VARARG ')' '{' compstmt '}' + { + $$ = &ast.FuncExpr{Name: $2.Lit, Args: []string{$4.Lit}, Stmts: $8, VarArg: true} + $$.SetPosition($1.Position()) + } + | '[' opt_terms exprs opt_terms ']' + { + $$ = &ast.ArrayExpr{Exprs: $3} + if l, ok := yylex.(*Lexer); ok { $$.SetPosition(l.pos) } + } + | '[' opt_terms exprs ',' opt_terms ']' + { + $$ = &ast.ArrayExpr{Exprs: $3} + if l, ok := yylex.(*Lexer); ok { $$.SetPosition(l.pos) } + } + | '{' opt_terms expr_pairs opt_terms '}' + { + mapExpr := make(map[string]ast.Expr) + for _, v := range $3 { + mapExpr[v.(*ast.PairExpr).Key] = v.(*ast.PairExpr).Value + } + $$ = &ast.MapExpr{MapExpr: mapExpr} + if l, ok := yylex.(*Lexer); ok { $$.SetPosition(l.pos) } + } + | '{' opt_terms expr_pairs ',' opt_terms '}' + { + mapExpr := make(map[string]ast.Expr) + for _, v := range $3 { + mapExpr[v.(*ast.PairExpr).Key] = v.(*ast.PairExpr).Value + } + $$ = &ast.MapExpr{MapExpr: mapExpr} + if l, ok := yylex.(*Lexer); ok { $$.SetPosition(l.pos) } + } + | '(' expr ')' + { + $$ = &ast.ParenExpr{SubExpr: $2} + if l, ok := yylex.(*Lexer); ok { $$.SetPosition(l.pos) } + } + | NEW IDENT '(' exprs ')' + { + $$ = &ast.NewExpr{Name: $2.Lit, SubExprs: $4} + $$.SetPosition($1.Position()) + } + | expr '+' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "+", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '-' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "-", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '*' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "*", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '/' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "/", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '%' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "%", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr POW expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "**", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr SHIFTLEFT expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "<<", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr SHIFTRIGHT expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: ">>", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr EQEQ expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "==", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr NEQ expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "!=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '>' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: ">", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr GE expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: ">=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '<' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "<", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr LE expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "<=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr PLUSEQ expr + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "+=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr MINUSEQ expr + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "-=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr MULEQ expr + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "*=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr DIVEQ expr + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "/=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr ANDEQ expr + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "&=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr OREQ expr + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "|=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr PLUSPLUS + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "++"} + $$.SetPosition($1.Position()) + } + | expr MINUSMINUS + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "--"} + $$.SetPosition($1.Position()) + } + | expr '|' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "|", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr OROR expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "||", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '&' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "&", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr ANDAND expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "&&", Rhs: $3} + $$.SetPosition($1.Position()) + } + | IDENT '(' exprs VARARG ')' + { + $$ = &ast.CallExpr{Name: $1.Lit, SubExprs: $3, VarArg: true} + $$.SetPosition($1.Position()) + } + | IDENT '(' exprs ')' + { + $$ = &ast.CallExpr{Name: $1.Lit, SubExprs: $3} + $$.SetPosition($1.Position()) + } + | GO IDENT '(' exprs VARARG ')' + { + $$ = &ast.CallExpr{Name: $2.Lit, SubExprs: $4, VarArg: true, Go: true} + $$.SetPosition($2.Position()) + } + | GO IDENT '(' exprs ')' + { + $$ = &ast.CallExpr{Name: $2.Lit, SubExprs: $4, Go: true} + $$.SetPosition($2.Position()) + } + | expr '(' exprs VARARG ')' + { + $$ = &ast.AnonCallExpr{Expr: $1, SubExprs: $3, VarArg: true} + $$.SetPosition($1.Position()) + } + | expr '(' exprs ')' + { + $$ = &ast.AnonCallExpr{Expr: $1, SubExprs: $3} + $$.SetPosition($1.Position()) + } + | GO expr '(' exprs VARARG ')' + { + $$ = &ast.AnonCallExpr{Expr: $2, SubExprs: $4, VarArg: true, Go: true} + $$.SetPosition($2.Position()) + } + | GO expr '(' exprs ')' + { + $$ = &ast.AnonCallExpr{Expr: $2, SubExprs: $4, Go: true} + $$.SetPosition($1.Position()) + } + | IDENT '[' expr ']' + { + $$ = &ast.ItemExpr{Value: &ast.IdentExpr{Lit: $1.Lit}, Index: $3} + $$.SetPosition($1.Position()) + } + | expr '[' expr ']' + { + $$ = &ast.ItemExpr{Value: $1, Index: $3} + $$.SetPosition($1.Position()) + } + | IDENT '[' expr ':' expr ']' + { + $$ = &ast.SliceExpr{Value: &ast.IdentExpr{Lit: $1.Lit}, Begin: $3, End: $5} + $$.SetPosition($1.Position()) + } + | expr '[' expr ':' expr ']' + { + $$ = &ast.SliceExpr{Value: $1, Begin: $3, End: $5} + $$.SetPosition($1.Position()) + } + | MAKE '(' CHAN typ ')' + { + $$ = &ast.MakeChanExpr{Type: $4.Name, SizeExpr: nil} + $$.SetPosition($1.Position()) + } + | MAKE '(' CHAN typ ',' expr ')' + { + $$ = &ast.MakeChanExpr{Type: $4.Name, SizeExpr: $6} + $$.SetPosition($1.Position()) + } + | MAKE '(' ARRAYLIT typ ',' expr ')' + { + $$ = &ast.MakeArrayExpr{Type: $4.Name, LenExpr: $6} + $$.SetPosition($1.Position()) + } + | MAKE '(' ARRAYLIT typ ',' expr ',' expr ')' + { + $$ = &ast.MakeArrayExpr{Type: $4.Name, LenExpr: $6, CapExpr: $8} + $$.SetPosition($1.Position()) + } + | expr OPCHAN expr + { + $$ = &ast.ChanExpr{Lhs: $1, Rhs: $3} + $$.SetPosition($1.Position()) + } + | OPCHAN expr + { + $$ = &ast.ChanExpr{Rhs: $2} + $$.SetPosition($2.Position()) + } + +opt_terms : /* none */ + | terms + ; + + +terms : term + { + } + | terms term + { + } + ; + +term : ';' + { + } + | '\n' + { + } + ; + +%% diff --git a/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/vm/doc.go b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/vm/doc.go new file mode 100644 index 0000000000..6bbb194516 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/vm/doc.go @@ -0,0 +1,2 @@ +// Package vm implements virtual-machine for anko. +package vm diff --git a/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/vm/env.go b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/vm/env.go new file mode 100644 index 0000000000..0e431e2b33 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/vm/env.go @@ -0,0 +1,258 @@ +package vm + +import ( + "fmt" + "reflect" + "strings" + "sync" + + "github.com/mattn/anko/parser" +) + +// Env provides interface to run VM. This mean function scope and blocked-scope. +// If stack goes to blocked-scope, it will make new Env. +type Env struct { + name string + env map[string]reflect.Value + typ map[string]reflect.Type + parent *Env + interrupt *bool + sync.RWMutex +} + +// NewEnv creates new global scope. +func NewEnv() *Env { + b := false + + return &Env{ + env: make(map[string]reflect.Value), + typ: make(map[string]reflect.Type), + parent: nil, + interrupt: &b, + } +} + +// NewEnv creates new child scope. +func (e *Env) NewEnv() *Env { + return &Env{ + env: make(map[string]reflect.Value), + typ: make(map[string]reflect.Type), + parent: e, + name: e.name, + interrupt: e.interrupt, + } +} + +func NewPackage(n string) *Env { + b := false + + return &Env{ + env: make(map[string]reflect.Value), + typ: make(map[string]reflect.Type), + parent: nil, + name: n, + interrupt: &b, + } +} + +func (e *Env) NewPackage(n string) *Env { + return &Env{ + env: make(map[string]reflect.Value), + typ: make(map[string]reflect.Type), + parent: e, + name: n, + interrupt: e.interrupt, + } +} + +// Destroy deletes current scope. +func (e *Env) Destroy() { + e.Lock() + defer e.Unlock() + + if e.parent == nil { + return + } + for k, v := range e.parent.env { + if v.IsValid() && v.Interface() == e { + delete(e.parent.env, k) + } + } + e.parent = nil + e.env = nil +} + +// NewModule creates new module scope as global. +func (e *Env) NewModule(n string) *Env { + m := &Env{ + env: make(map[string]reflect.Value), + parent: e, + name: n, + } + e.Define(n, m) + return m +} + +// SetName sets a name of the scope. This means that the scope is module. +func (e *Env) SetName(n string) { + e.Lock() + e.name = n + e.Unlock() +} + +// GetName returns module name. +func (e *Env) GetName() string { + e.RLock() + defer e.RUnlock() + + return e.name +} + +// Addr returns pointer value which specified symbol. It goes to upper scope until +// found or returns error. +func (e *Env) Addr(k string) (reflect.Value, error) { + e.RLock() + defer e.RUnlock() + + if v, ok := e.env[k]; ok { + return v.Addr(), nil + } + if e.parent == nil { + return NilValue, fmt.Errorf("Undefined symbol '%s'", k) + } + return e.parent.Addr(k) +} + +// Type returns type which specified symbol. It goes to upper scope until +// found or returns error. +func (e *Env) Type(k string) (reflect.Type, error) { + e.RLock() + defer e.RUnlock() + + if v, ok := e.typ[k]; ok { + return v, nil + } + if e.parent == nil { + return NilType, fmt.Errorf("Undefined type '%s'", k) + } + return e.parent.Type(k) +} + +// Get returns value which specified symbol. It goes to upper scope until +// found or returns error. +func (e *Env) Get(k string) (reflect.Value, error) { + e.RLock() + defer e.RUnlock() + + if v, ok := e.env[k]; ok { + return v, nil + } + if e.parent == nil { + return NilValue, fmt.Errorf("Undefined symbol '%s'", k) + } + return e.parent.Get(k) +} + +// Set modifies value which specified as symbol. It goes to upper scope until +// found or returns error. +func (e *Env) Set(k string, v interface{}) error { + e.Lock() + defer e.Unlock() + + if _, ok := e.env[k]; ok { + val, ok := v.(reflect.Value) + if !ok { + val = reflect.ValueOf(v) + } + e.env[k] = val + return nil + } + if e.parent == nil { + return fmt.Errorf("Unknown symbol '%s'", k) + } + return e.parent.Set(k, v) +} + +// DefineGlobal defines symbol in global scope. +func (e *Env) DefineGlobal(k string, v interface{}) error { + if e.parent == nil { + return e.Define(k, v) + } + return e.parent.DefineGlobal(k, v) +} + +// DefineType defines type which specifis symbol in global scope. +func (e *Env) DefineType(k string, t interface{}) error { + if strings.Contains(k, ".") { + return fmt.Errorf("Unknown symbol '%s'", k) + } + global := e + keys := []string{k} + + e.RLock() + for global.parent != nil { + if global.name != "" { + keys = append(keys, global.name) + } + global = global.parent + } + e.RUnlock() + + for i, j := 0, len(keys)-1; i < j; i, j = i+1, j-1 { + keys[i], keys[j] = keys[j], keys[i] + } + + typ, ok := t.(reflect.Type) + if !ok { + typ = reflect.TypeOf(t) + } + + global.Lock() + global.typ[strings.Join(keys, ".")] = typ + global.Unlock() + + return nil +} + +// Define defines symbol in current scope. +func (e *Env) Define(k string, v interface{}) error { + if strings.Contains(k, ".") { + return fmt.Errorf("Unknown symbol '%s'", k) + } + val, ok := v.(reflect.Value) + if !ok { + val = reflect.ValueOf(v) + } + + e.Lock() + e.env[k] = val + e.Unlock() + + return nil +} + +// String return the name of current scope. +func (e *Env) String() string { + e.RLock() + defer e.RUnlock() + + return e.name +} + +// Dump show symbol values in the scope. +func (e *Env) Dump() { + e.RLock() + for k, v := range e.env { + fmt.Printf("%v = %#v\n", k, v) + } + e.RUnlock() +} + +// Execute parses and runs source in current scope. +func (e *Env) Execute(src string) (reflect.Value, error) { + stmts, err := parser.ParseSrc(src) + if err != nil { + return NilValue, err + } + return Run(stmts, e) +} diff --git a/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/vm/vm.go b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/vm/vm.go new file mode 100644 index 0000000000..7e85d5b438 --- /dev/null +++ b/vendor/github.com/leonelquinteros/gotext/vendor/github.com/mattn/anko/vm/vm.go @@ -0,0 +1,1504 @@ +package vm + +import ( + "errors" + "fmt" + "math" + "os" + "reflect" + "strconv" + "strings" + + "github.com/mattn/anko/ast" + "github.com/mattn/anko/parser" +) + +var ( + NilValue = reflect.ValueOf((*interface{})(nil)) + NilType = reflect.TypeOf((*interface{})(nil)) + TrueValue = reflect.ValueOf(true) + FalseValue = reflect.ValueOf(false) +) + +// Error provides a convenient interface for handling runtime error. +// It can be Error interface with type cast which can call Pos(). +type Error struct { + Message string + Pos ast.Position +} + +var ( + BreakError = errors.New("Unexpected break statement") + ContinueError = errors.New("Unexpected continue statement") + ReturnError = errors.New("Unexpected return statement") + InterruptError = errors.New("Execution interrupted") +) + +// NewStringError makes error interface with message. +func NewStringError(pos ast.Pos, err string) error { + if pos == nil { + return &Error{Message: err, Pos: ast.Position{1, 1}} + } + return &Error{Message: err, Pos: pos.Position()} +} + +// NewErrorf makes error interface with message. +func NewErrorf(pos ast.Pos, format string, args ...interface{}) error { + return &Error{Message: fmt.Sprintf(format, args...), Pos: pos.Position()} +} + +// NewError makes error interface with message. +// This doesn't overwrite last error. +func NewError(pos ast.Pos, err error) error { + if err == nil { + return nil + } + if err == BreakError || err == ContinueError || err == ReturnError { + return err + } + if pe, ok := err.(*parser.Error); ok { + return pe + } + if ee, ok := err.(*Error); ok { + return ee + } + return &Error{Message: err.Error(), Pos: pos.Position()} +} + +// Error returns the error message. +func (e *Error) Error() string { + return e.Message +} + +// Func is function interface to reflect functions internaly. +type Func func(args ...reflect.Value) (reflect.Value, error) + +func (f Func) String() string { + return fmt.Sprintf("[Func: %p]", f) +} + +func ToFunc(f Func) reflect.Value { + return reflect.ValueOf(f) +} + +// Run executes statements in the specified environment. +func Run(stmts []ast.Stmt, env *Env) (reflect.Value, error) { + rv := NilValue + var err error + for _, stmt := range stmts { + if _, ok := stmt.(*ast.BreakStmt); ok { + return NilValue, BreakError + } + if _, ok := stmt.(*ast.ContinueStmt); ok { + return NilValue, ContinueError + } + rv, err = RunSingleStmt(stmt, env) + if err != nil { + return rv, err + } + if _, ok := stmt.(*ast.ReturnStmt); ok { + return reflect.ValueOf(rv), ReturnError + } + } + return rv, nil +} + +// Interrupts the execution of any running statements in the specified environment. +// +// Note that the execution is not instantly aborted: after a call to Interrupt, +// the current running statement will finish, but the next statement will not run, +// and instead will return a NilValue and an InterruptError. +func Interrupt(env *Env) { + env.Lock() + *(env.interrupt) = true + env.Unlock() +} + +// RunSingleStmt executes one statement in the specified environment. +func RunSingleStmt(stmt ast.Stmt, env *Env) (reflect.Value, error) { + env.Lock() + if *(env.interrupt) { + *(env.interrupt) = false + env.Unlock() + + return NilValue, InterruptError + } + env.Unlock() + + switch stmt := stmt.(type) { + case *ast.ExprStmt: + rv, err := invokeExpr(stmt.Expr, env) + if err != nil { + return rv, NewError(stmt, err) + } + return rv, nil + case *ast.VarStmt: + rv := NilValue + var err error + rvs := []reflect.Value{} + for _, expr := range stmt.Exprs { + rv, err = invokeExpr(expr, env) + if err != nil { + return rv, NewError(expr, err) + } + rvs = append(rvs, rv) + } + result := []interface{}{} + for i, name := range stmt.Names { + if i < len(rvs) { + env.Define(name, rvs[i]) + result = append(result, rvs[i].Interface()) + } + } + return reflect.ValueOf(result), nil + case *ast.LetsStmt: + rv := NilValue + var err error + vs := []interface{}{} + for _, rhs := range stmt.Rhss { + rv, err = invokeExpr(rhs, env) + if err != nil { + return rv, NewError(rhs, err) + } + if rv == NilValue { + vs = append(vs, nil) + } else if rv.IsValid() && rv.CanInterface() { + vs = append(vs, rv.Interface()) + } else { + vs = append(vs, nil) + } + } + rvs := reflect.ValueOf(vs) + if len(stmt.Lhss) > 1 && rvs.Len() == 1 { + item := rvs.Index(0) + if item.Kind() == reflect.Interface { + item = item.Elem() + } + if item.Kind() == reflect.Slice { + rvs = item + } + } + for i, lhs := range stmt.Lhss { + if i >= rvs.Len() { + break + } + v := rvs.Index(i) + if v.Kind() == reflect.Interface { + v = v.Elem() + } + _, err = invokeLetExpr(lhs, v, env) + if err != nil { + return rvs, NewError(lhs, err) + } + } + if rvs.Len() == 1 { + return rvs.Index(0), nil + } + return rvs, nil + case *ast.IfStmt: + // If + rv, err := invokeExpr(stmt.If, env) + if err != nil { + return rv, NewError(stmt, err) + } + if toBool(rv) { + // Then + newenv := env.NewEnv() + defer newenv.Destroy() + rv, err = Run(stmt.Then, newenv) + if err != nil { + return rv, NewError(stmt, err) + } + return rv, nil + } + done := false + if len(stmt.ElseIf) > 0 { + for _, stmt := range stmt.ElseIf { + stmt_if := stmt.(*ast.IfStmt) + // ElseIf + rv, err = invokeExpr(stmt_if.If, env) + if err != nil { + return rv, NewError(stmt, err) + } + if !toBool(rv) { + continue + } + // ElseIf Then + done = true + rv, err = Run(stmt_if.Then, env) + if err != nil { + return rv, NewError(stmt, err) + } + break + } + } + if !done && len(stmt.Else) > 0 { + // Else + newenv := env.NewEnv() + defer newenv.Destroy() + rv, err = Run(stmt.Else, newenv) + if err != nil { + return rv, NewError(stmt, err) + } + } + return rv, nil + case *ast.TryStmt: + newenv := env.NewEnv() + defer newenv.Destroy() + _, err := Run(stmt.Try, newenv) + if err != nil { + // Catch + cenv := env.NewEnv() + defer cenv.Destroy() + if stmt.Var != "" { + cenv.Define(stmt.Var, reflect.ValueOf(err)) + } + _, e1 := Run(stmt.Catch, cenv) + if e1 != nil { + err = NewError(stmt.Catch[0], e1) + } else { + err = nil + } + } + if len(stmt.Finally) > 0 { + // Finally + fenv := env.NewEnv() + defer fenv.Destroy() + _, e2 := Run(stmt.Finally, newenv) + if e2 != nil { + err = NewError(stmt.Finally[0], e2) + } + } + return NilValue, NewError(stmt, err) + case *ast.LoopStmt: + newenv := env.NewEnv() + defer newenv.Destroy() + for { + if stmt.Expr != nil { + ev, ee := invokeExpr(stmt.Expr, newenv) + if ee != nil { + return ev, ee + } + if !toBool(ev) { + break + } + } + + rv, err := Run(stmt.Stmts, newenv) + if err != nil { + if err == BreakError { + err = nil + break + } + if err == ContinueError { + err = nil + continue + } + if err == ReturnError { + return rv, err + } + return rv, NewError(stmt, err) + } + } + return NilValue, nil + case *ast.ForStmt: + val, ee := invokeExpr(stmt.Value, env) + if ee != nil { + return val, ee + } + if val.Kind() == reflect.Interface { + val = val.Elem() + } + if val.Kind() != reflect.Array && val.Kind() != reflect.Slice { + return NilValue, NewStringError(stmt, "Invalid operation for non-array value") + } + newenv := env.NewEnv() + defer newenv.Destroy() + + for i := 0; i < val.Len(); i++ { + iv := val.Index(i) + if val.Index(i).Kind() == reflect.Interface || val.Index(i).Kind() == reflect.Ptr { + iv = iv.Elem() + } + newenv.Define(stmt.Var, iv) + rv, err := Run(stmt.Stmts, newenv) + if err != nil { + if err == BreakError { + err = nil + break + } + if err == ContinueError { + err = nil + continue + } + if err == ReturnError { + return rv, err + } + return rv, NewError(stmt, err) + } + } + return NilValue, nil + case *ast.CForStmt: + newenv := env.NewEnv() + defer newenv.Destroy() + _, err := invokeExpr(stmt.Expr1, newenv) + if err != nil { + return NilValue, err + } + for { + fb, err := invokeExpr(stmt.Expr2, newenv) + if err != nil { + return NilValue, err + } + if !toBool(fb) { + break + } + + rv, err := Run(stmt.Stmts, newenv) + if err != nil { + if err == BreakError { + err = nil + break + } + if err == ContinueError { + err = nil + continue + } + if err == ReturnError { + return rv, err + } + return rv, NewError(stmt, err) + } + _, err = invokeExpr(stmt.Expr3, newenv) + if err != nil { + return NilValue, err + } + } + return NilValue, nil + case *ast.ReturnStmt: + rvs := []interface{}{} + switch len(stmt.Exprs) { + case 0: + return NilValue, nil + case 1: + rv, err := invokeExpr(stmt.Exprs[0], env) + if err != nil { + return rv, NewError(stmt, err) + } + return rv, nil + } + for _, expr := range stmt.Exprs { + rv, err := invokeExpr(expr, env) + if err != nil { + return rv, NewError(stmt, err) + } + if isNil(rv) { + rvs = append(rvs, nil) + } else if rv.IsValid() { + rvs = append(rvs, rv.Interface()) + } else { + rvs = append(rvs, nil) + } + } + return reflect.ValueOf(rvs), nil + case *ast.ThrowStmt: + rv, err := invokeExpr(stmt.Expr, env) + if err != nil { + return rv, NewError(stmt, err) + } + if !rv.IsValid() { + return NilValue, NewError(stmt, err) + } + return rv, NewStringError(stmt, fmt.Sprint(rv.Interface())) + case *ast.ModuleStmt: + newenv := env.NewEnv() + newenv.SetName(stmt.Name) + rv, err := Run(stmt.Stmts, newenv) + if err != nil { + return rv, NewError(stmt, err) + } + env.DefineGlobal(stmt.Name, reflect.ValueOf(newenv)) + return rv, nil + case *ast.SwitchStmt: + rv, err := invokeExpr(stmt.Expr, env) + if err != nil { + return rv, NewError(stmt, err) + } + done := false + var default_stmt *ast.DefaultStmt + for _, ss := range stmt.Cases { + if ssd, ok := ss.(*ast.DefaultStmt); ok { + default_stmt = ssd + continue + } + case_stmt := ss.(*ast.CaseStmt) + cv, err := invokeExpr(case_stmt.Expr, env) + if err != nil { + return rv, NewError(stmt, err) + } + if !equal(rv, cv) { + continue + } + rv, err = Run(case_stmt.Stmts, env) + if err != nil { + return rv, NewError(stmt, err) + } + done = true + break + } + if !done && default_stmt != nil { + rv, err = Run(default_stmt.Stmts, env) + if err != nil { + return rv, NewError(stmt, err) + } + } + return rv, nil + default: + return NilValue, NewStringError(stmt, "unknown statement") + } +} + +// toString converts all reflect.Value-s into string. +func toString(v reflect.Value) string { + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.String { + return v.String() + } + if !v.IsValid() { + return "nil" + } + return fmt.Sprint(v.Interface()) +} + +// toBool converts all reflect.Value-s into bool. +func toBool(v reflect.Value) bool { + if v.Kind() == reflect.Interface { + v = v.Elem() + } + + switch v.Kind() { + case reflect.Float32, reflect.Float64: + return v.Float() != 0.0 + case reflect.Int, reflect.Int32, reflect.Int64: + return v.Int() != 0 + case reflect.Bool: + return v.Bool() + case reflect.String: + if v.String() == "true" { + return true + } + if toInt64(v) != 0 { + return true + } + } + return false +} + +// toFloat64 converts all reflect.Value-s into float64. +func toFloat64(v reflect.Value) float64 { + if v.Kind() == reflect.Interface { + v = v.Elem() + } + switch v.Kind() { + case reflect.Float32, reflect.Float64: + return v.Float() + case reflect.Int, reflect.Int32, reflect.Int64: + return float64(v.Int()) + } + return 0.0 +} + +func isNil(v reflect.Value) bool { + if !v.IsValid() || v.Kind().String() == "unsafe.Pointer" { + return true + } + if (v.Kind() == reflect.Interface || v.Kind() == reflect.Ptr) && v.IsNil() { + return true + } + return false +} + +func isNum(v reflect.Value) bool { + switch v.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64: + return true + } + return false +} + +// equal returns true when lhsV and rhsV is same value. +func equal(lhsV, rhsV reflect.Value) bool { + lhsIsNil, rhsIsNil := isNil(lhsV), isNil(rhsV) + if lhsIsNil && rhsIsNil { + return true + } + if (!lhsIsNil && rhsIsNil) || (lhsIsNil && !rhsIsNil) { + return false + } + if lhsV.Kind() == reflect.Interface || lhsV.Kind() == reflect.Ptr { + lhsV = lhsV.Elem() + } + if rhsV.Kind() == reflect.Interface || rhsV.Kind() == reflect.Ptr { + rhsV = rhsV.Elem() + } + if !lhsV.IsValid() || !rhsV.IsValid() { + return true + } + if isNum(lhsV) && isNum(rhsV) { + if rhsV.Type().ConvertibleTo(lhsV.Type()) { + rhsV = rhsV.Convert(lhsV.Type()) + } + } + if lhsV.CanInterface() && rhsV.CanInterface() { + return reflect.DeepEqual(lhsV.Interface(), rhsV.Interface()) + } + return reflect.DeepEqual(lhsV, rhsV) +} + +// toInt64 converts all reflect.Value-s into int64. +func toInt64(v reflect.Value) int64 { + if v.Kind() == reflect.Interface { + v = v.Elem() + } + switch v.Kind() { + case reflect.Float32, reflect.Float64: + return int64(v.Float()) + case reflect.Int, reflect.Int32, reflect.Int64: + return v.Int() + case reflect.String: + s := v.String() + var i int64 + var err error + if strings.HasPrefix(s, "0x") { + i, err = strconv.ParseInt(s, 16, 64) + } else { + i, err = strconv.ParseInt(s, 10, 64) + } + if err == nil { + return int64(i) + } + } + return 0 +} + +func invokeLetExpr(expr ast.Expr, rv reflect.Value, env *Env) (reflect.Value, error) { + switch lhs := expr.(type) { + case *ast.IdentExpr: + if env.Set(lhs.Lit, rv) != nil { + if strings.Contains(lhs.Lit, ".") { + return NilValue, NewErrorf(expr, "Undefined symbol '%s'", lhs.Lit) + } + env.Define(lhs.Lit, rv) + } + return rv, nil + case *ast.MemberExpr: + v, err := invokeExpr(lhs.Expr, env) + if err != nil { + return v, NewError(expr, err) + } + + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Slice { + v = v.Index(0) + } + + if !v.IsValid() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + if v.Kind() == reflect.Struct { + v = v.FieldByName(lhs.Name) + if !v.CanSet() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + v.Set(rv) + } else if v.Kind() == reflect.Map { + v.SetMapIndex(reflect.ValueOf(lhs.Name), rv) + } else { + if !v.CanSet() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + v.Set(rv) + } + return v, nil + case *ast.ItemExpr: + v, err := invokeExpr(lhs.Value, env) + if err != nil { + return v, NewError(expr, err) + } + i, err := invokeExpr(lhs.Index, env) + if err != nil { + return i, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Array || v.Kind() == reflect.Slice { + if i.Kind() != reflect.Int && i.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + ii := int(i.Int()) + if ii < 0 || ii >= v.Len() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + vv := v.Index(ii) + if !vv.CanSet() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + vv.Set(rv) + return rv, nil + } + if v.Kind() == reflect.Map { + if i.Kind() != reflect.String { + return NilValue, NewStringError(expr, "Map key should be string") + } + v.SetMapIndex(i, rv) + return rv, nil + } + return v, NewStringError(expr, "Invalid operation") + case *ast.SliceExpr: + v, err := invokeExpr(lhs.Value, env) + if err != nil { + return v, NewError(expr, err) + } + rb, err := invokeExpr(lhs.Begin, env) + if err != nil { + return rb, NewError(expr, err) + } + re, err := invokeExpr(lhs.End, env) + if err != nil { + return re, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Array || v.Kind() == reflect.Slice { + if rb.Kind() != reflect.Int && rb.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + if re.Kind() != reflect.Int && re.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + ii := int(rb.Int()) + if ii < 0 || ii >= v.Len() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + ij := int(re.Int()) + if ij < 0 || ij >= v.Len() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + vv := v.Slice(ii, ij) + if !vv.CanSet() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + vv.Set(rv) + return rv, nil + } + return v, NewStringError(expr, "Invalid operation") + } + return NilValue, NewStringError(expr, "Invalid operation") +} + +// invokeExpr evaluates one expression. +func invokeExpr(expr ast.Expr, env *Env) (reflect.Value, error) { + switch e := expr.(type) { + case *ast.NumberExpr: + if strings.Contains(e.Lit, ".") || strings.Contains(e.Lit, "e") { + v, err := strconv.ParseFloat(e.Lit, 64) + if err != nil { + return NilValue, NewError(expr, err) + } + return reflect.ValueOf(float64(v)), nil + } + var i int64 + var err error + if strings.HasPrefix(e.Lit, "0x") { + i, err = strconv.ParseInt(e.Lit[2:], 16, 64) + } else { + i, err = strconv.ParseInt(e.Lit, 10, 64) + } + if err != nil { + return NilValue, NewError(expr, err) + } + return reflect.ValueOf(i), nil + case *ast.IdentExpr: + return env.Get(e.Lit) + case *ast.StringExpr: + return reflect.ValueOf(e.Lit), nil + case *ast.ArrayExpr: + a := make([]interface{}, len(e.Exprs)) + for i, expr := range e.Exprs { + arg, err := invokeExpr(expr, env) + if err != nil { + return arg, NewError(expr, err) + } + a[i] = arg.Interface() + } + return reflect.ValueOf(a), nil + case *ast.MapExpr: + m := make(map[string]interface{}) + for k, expr := range e.MapExpr { + v, err := invokeExpr(expr, env) + if err != nil { + return v, NewError(expr, err) + } + m[k] = v.Interface() + } + return reflect.ValueOf(m), nil + case *ast.DerefExpr: + v := NilValue + var err error + switch ee := e.Expr.(type) { + case *ast.IdentExpr: + v, err = env.Get(ee.Lit) + if err != nil { + return v, err + } + case *ast.MemberExpr: + v, err := invokeExpr(ee.Expr, env) + if err != nil { + return v, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Slice { + v = v.Index(0) + } + if v.IsValid() && v.CanInterface() { + if vme, ok := v.Interface().(*Env); ok { + m, err := vme.Get(ee.Name) + if !m.IsValid() || err != nil { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + return m, nil + } + } + + m := v.MethodByName(ee.Name) + if !m.IsValid() { + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + if v.Kind() == reflect.Struct { + m = v.FieldByName(ee.Name) + if !m.IsValid() { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + } else if v.Kind() == reflect.Map { + m = v.MapIndex(reflect.ValueOf(ee.Name)) + if !m.IsValid() { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + } else { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + v = m + } else { + v = m + } + default: + return NilValue, NewStringError(expr, "Invalid operation for the value") + } + if v.Kind() != reflect.Ptr { + return NilValue, NewStringError(expr, "Cannot deference for the value") + } + return v.Addr(), nil + case *ast.AddrExpr: + v := NilValue + var err error + switch ee := e.Expr.(type) { + case *ast.IdentExpr: + v, err = env.Get(ee.Lit) + if err != nil { + return v, err + } + case *ast.MemberExpr: + v, err := invokeExpr(ee.Expr, env) + if err != nil { + return v, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Slice { + v = v.Index(0) + } + if v.IsValid() && v.CanInterface() { + if vme, ok := v.Interface().(*Env); ok { + m, err := vme.Get(ee.Name) + if !m.IsValid() || err != nil { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + return m, nil + } + } + + m := v.MethodByName(ee.Name) + if !m.IsValid() { + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + if v.Kind() == reflect.Struct { + m = v.FieldByName(ee.Name) + if !m.IsValid() { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + } else if v.Kind() == reflect.Map { + m = v.MapIndex(reflect.ValueOf(ee.Name)) + if !m.IsValid() { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + } else { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + v = m + } else { + v = m + } + default: + return NilValue, NewStringError(expr, "Invalid operation for the value") + } + if !v.CanAddr() { + i := v.Interface() + return reflect.ValueOf(&i), nil + } + return v.Addr(), nil + case *ast.UnaryExpr: + v, err := invokeExpr(e.Expr, env) + if err != nil { + return v, NewError(expr, err) + } + switch e.Operator { + case "-": + if v.Kind() == reflect.Float64 { + return reflect.ValueOf(-v.Float()), nil + } + return reflect.ValueOf(-v.Int()), nil + case "^": + return reflect.ValueOf(^toInt64(v)), nil + case "!": + return reflect.ValueOf(!toBool(v)), nil + default: + return NilValue, NewStringError(e, "Unknown operator ''") + } + case *ast.ParenExpr: + v, err := invokeExpr(e.SubExpr, env) + if err != nil { + return v, NewError(expr, err) + } + return v, nil + case *ast.FuncExpr: + f := reflect.ValueOf(func(expr *ast.FuncExpr, env *Env) Func { + return func(args ...reflect.Value) (reflect.Value, error) { + if !expr.VarArg { + if len(args) != len(expr.Args) { + return NilValue, NewStringError(expr, "Arguments Number of mismatch") + } + } + newenv := env.NewEnv() + if expr.VarArg { + newenv.Define(expr.Args[0], reflect.ValueOf(args)) + } else { + for i, arg := range expr.Args { + newenv.Define(arg, args[i]) + } + } + rr, err := Run(expr.Stmts, newenv) + if err == ReturnError { + err = nil + rr = rr.Interface().(reflect.Value) + } + return rr, err + } + }(e, env)) + env.Define(e.Name, f) + return f, nil + case *ast.MemberExpr: + v, err := invokeExpr(e.Expr, env) + if err != nil { + return v, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Slice { + v = v.Index(0) + } + if v.IsValid() && v.CanInterface() { + if vme, ok := v.Interface().(*Env); ok { + m, err := vme.Get(e.Name) + if !m.IsValid() || err != nil { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", e.Name)) + } + return m, nil + } + } + + m := v.MethodByName(e.Name) + if !m.IsValid() { + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + if v.Kind() == reflect.Struct { + m = v.FieldByName(e.Name) + if !m.IsValid() { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", e.Name)) + } + } else if v.Kind() == reflect.Map { + m = v.MapIndex(reflect.ValueOf(e.Name)) + if !m.IsValid() { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", e.Name)) + } + } else { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", e.Name)) + } + } + return m, nil + case *ast.ItemExpr: + v, err := invokeExpr(e.Value, env) + if err != nil { + return v, NewError(expr, err) + } + i, err := invokeExpr(e.Index, env) + if err != nil { + return i, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Array || v.Kind() == reflect.Slice { + if i.Kind() != reflect.Int && i.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + ii := int(i.Int()) + if ii < 0 || ii >= v.Len() { + return NilValue, nil + } + return v.Index(ii), nil + } + if v.Kind() == reflect.Map { + if i.Kind() != reflect.String { + return NilValue, NewStringError(expr, "Map key should be string") + } + return v.MapIndex(i), nil + } + if v.Kind() == reflect.String { + rs := []rune(v.Interface().(string)) + ii := int(i.Int()) + if ii < 0 || ii >= len(rs) { + return NilValue, nil + } + return reflect.ValueOf(rs[ii]), nil + } + return v, NewStringError(expr, "Invalid operation") + case *ast.SliceExpr: + v, err := invokeExpr(e.Value, env) + if err != nil { + return v, NewError(expr, err) + } + rb, err := invokeExpr(e.Begin, env) + if err != nil { + return rb, NewError(expr, err) + } + re, err := invokeExpr(e.End, env) + if err != nil { + return re, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Array || v.Kind() == reflect.Slice { + if rb.Kind() != reflect.Int && rb.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + if re.Kind() != reflect.Int && re.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + ii := int(rb.Int()) + if ii < 0 || ii > v.Len() { + return NilValue, nil + } + ij := int(re.Int()) + if ij < 0 || ij > v.Len() { + return v, nil + } + return v.Slice(ii, ij), nil + } + if v.Kind() == reflect.String { + if rb.Kind() != reflect.Int && rb.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + if re.Kind() != reflect.Int && re.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + r := []rune(v.String()) + ii := int(rb.Int()) + if ii < 0 || ii >= len(r) { + return NilValue, nil + } + ij := int(re.Int()) + if ij < 0 || ij >= len(r) { + return NilValue, nil + } + return reflect.ValueOf(string(r[ii:ij])), nil + } + return v, NewStringError(expr, "Invalid operation") + case *ast.AssocExpr: + switch e.Operator { + case "++": + if alhs, ok := e.Lhs.(*ast.IdentExpr); ok { + v, err := env.Get(alhs.Lit) + if err != nil { + return v, err + } + if v.Kind() == reflect.Float64 { + v = reflect.ValueOf(toFloat64(v) + 1.0) + } else { + v = reflect.ValueOf(toInt64(v) + 1) + } + if env.Set(alhs.Lit, v) != nil { + env.Define(alhs.Lit, v) + } + return v, nil + } + case "--": + if alhs, ok := e.Lhs.(*ast.IdentExpr); ok { + v, err := env.Get(alhs.Lit) + if err != nil { + return v, err + } + if v.Kind() == reflect.Float64 { + v = reflect.ValueOf(toFloat64(v) - 1.0) + } else { + v = reflect.ValueOf(toInt64(v) - 1) + } + if env.Set(alhs.Lit, v) != nil { + env.Define(alhs.Lit, v) + } + return v, nil + } + } + + v, err := invokeExpr(&ast.BinOpExpr{Lhs: e.Lhs, Operator: e.Operator[0:1], Rhs: e.Rhs}, env) + if err != nil { + return v, err + } + + if v.Kind() == reflect.Interface { + v = v.Elem() + } + return invokeLetExpr(e.Lhs, v, env) + case *ast.LetExpr: + rv, err := invokeExpr(e.Rhs, env) + if err != nil { + return rv, NewError(e, err) + } + if rv.Kind() == reflect.Interface { + rv = rv.Elem() + } + return invokeLetExpr(e.Lhs, rv, env) + case *ast.LetsExpr: + rv := NilValue + var err error + vs := []interface{}{} + for _, rhs := range e.Rhss { + rv, err = invokeExpr(rhs, env) + if err != nil { + return rv, NewError(rhs, err) + } + if rv == NilValue { + vs = append(vs, nil) + } else if rv.IsValid() && rv.CanInterface() { + vs = append(vs, rv.Interface()) + } else { + vs = append(vs, nil) + } + } + rvs := reflect.ValueOf(vs) + if len(e.Lhss) > 1 && rvs.Len() == 1 { + item := rvs.Index(0) + if item.Kind() == reflect.Interface { + item = item.Elem() + } + if item.Kind() == reflect.Slice { + rvs = item + } + } + for i, lhs := range e.Lhss { + if i >= rvs.Len() { + break + } + v := rvs.Index(i) + if v.Kind() == reflect.Interface { + v = v.Elem() + } + _, err = invokeLetExpr(lhs, v, env) + if err != nil { + return rvs, NewError(lhs, err) + } + } + if rvs.Len() == 1 { + return rvs.Index(0), nil + } + return rvs, nil + //case *ast.NewExpr: + // println("NEW") + // return NilValue, nil + case *ast.BinOpExpr: + lhsV := NilValue + rhsV := NilValue + var err error + + lhsV, err = invokeExpr(e.Lhs, env) + if err != nil { + return lhsV, NewError(expr, err) + } + if lhsV.Kind() == reflect.Interface { + lhsV = lhsV.Elem() + } + if e.Rhs != nil { + rhsV, err = invokeExpr(e.Rhs, env) + if err != nil { + return rhsV, NewError(expr, err) + } + if rhsV.Kind() == reflect.Interface { + rhsV = rhsV.Elem() + } + } + switch e.Operator { + case "+": + if lhsV.Kind() == reflect.String || rhsV.Kind() == reflect.String { + return reflect.ValueOf(toString(lhsV) + toString(rhsV)), nil + } + if (lhsV.Kind() == reflect.Array || lhsV.Kind() == reflect.Slice) && (rhsV.Kind() != reflect.Array && rhsV.Kind() != reflect.Slice) { + return reflect.Append(lhsV, rhsV), nil + } + if (lhsV.Kind() == reflect.Array || lhsV.Kind() == reflect.Slice) && (rhsV.Kind() == reflect.Array || rhsV.Kind() == reflect.Slice) { + return reflect.AppendSlice(lhsV, rhsV), nil + } + if lhsV.Kind() == reflect.Float64 || rhsV.Kind() == reflect.Float64 { + return reflect.ValueOf(toFloat64(lhsV) + toFloat64(rhsV)), nil + } + return reflect.ValueOf(toInt64(lhsV) + toInt64(rhsV)), nil + case "-": + if lhsV.Kind() == reflect.Float64 || rhsV.Kind() == reflect.Float64 { + return reflect.ValueOf(toFloat64(lhsV) - toFloat64(rhsV)), nil + } + return reflect.ValueOf(toInt64(lhsV) - toInt64(rhsV)), nil + case "*": + if lhsV.Kind() == reflect.String && (rhsV.Kind() == reflect.Int || rhsV.Kind() == reflect.Int32 || rhsV.Kind() == reflect.Int64) { + return reflect.ValueOf(strings.Repeat(toString(lhsV), int(toInt64(rhsV)))), nil + } + if lhsV.Kind() == reflect.Float64 || rhsV.Kind() == reflect.Float64 { + return reflect.ValueOf(toFloat64(lhsV) * toFloat64(rhsV)), nil + } + return reflect.ValueOf(toInt64(lhsV) * toInt64(rhsV)), nil + case "/": + return reflect.ValueOf(toFloat64(lhsV) / toFloat64(rhsV)), nil + case "%": + return reflect.ValueOf(toInt64(lhsV) % toInt64(rhsV)), nil + case "==": + return reflect.ValueOf(equal(lhsV, rhsV)), nil + case "!=": + return reflect.ValueOf(equal(lhsV, rhsV) == false), nil + case ">": + return reflect.ValueOf(toFloat64(lhsV) > toFloat64(rhsV)), nil + case ">=": + return reflect.ValueOf(toFloat64(lhsV) >= toFloat64(rhsV)), nil + case "<": + return reflect.ValueOf(toFloat64(lhsV) < toFloat64(rhsV)), nil + case "<=": + return reflect.ValueOf(toFloat64(lhsV) <= toFloat64(rhsV)), nil + case "|": + return reflect.ValueOf(toInt64(lhsV) | toInt64(rhsV)), nil + case "||": + if toBool(lhsV) { + return lhsV, nil + } + return rhsV, nil + case "&": + return reflect.ValueOf(toInt64(lhsV) & toInt64(rhsV)), nil + case "&&": + if toBool(lhsV) { + return rhsV, nil + } + return lhsV, nil + case "**": + if lhsV.Kind() == reflect.Float64 { + return reflect.ValueOf(math.Pow(toFloat64(lhsV), toFloat64(rhsV))), nil + } + return reflect.ValueOf(int64(math.Pow(toFloat64(lhsV), toFloat64(rhsV)))), nil + case ">>": + return reflect.ValueOf(toInt64(lhsV) >> uint64(toInt64(rhsV))), nil + case "<<": + return reflect.ValueOf(toInt64(lhsV) << uint64(toInt64(rhsV))), nil + default: + return NilValue, NewStringError(expr, "Unknown operator") + } + case *ast.ConstExpr: + switch e.Value { + case "true": + return reflect.ValueOf(true), nil + case "false": + return reflect.ValueOf(false), nil + } + return reflect.ValueOf(nil), nil + case *ast.AnonCallExpr: + f, err := invokeExpr(e.Expr, env) + if err != nil { + return f, NewError(expr, err) + } + if f.Kind() == reflect.Interface { + f = f.Elem() + } + if f.Kind() != reflect.Func { + return f, NewStringError(expr, "Unknown function") + } + return invokeExpr(&ast.CallExpr{Func: f, SubExprs: e.SubExprs, VarArg: e.VarArg, Go: e.Go}, env) + case *ast.CallExpr: + f := NilValue + + if e.Func != nil { + f = e.Func.(reflect.Value) + } else { + var err error + ff, err := env.Get(e.Name) + if err != nil { + return f, err + } + f = ff + } + _, isReflect := f.Interface().(Func) + + args := []reflect.Value{} + l := len(e.SubExprs) + for i, expr := range e.SubExprs { + arg, err := invokeExpr(expr, env) + if err != nil { + return arg, NewError(expr, err) + } + + if i < f.Type().NumIn() { + if !f.Type().IsVariadic() { + it := f.Type().In(i) + if arg.Kind().String() == "unsafe.Pointer" { + arg = reflect.New(it).Elem() + } + if arg.Kind() != it.Kind() && arg.IsValid() && arg.Type().ConvertibleTo(it) { + arg = arg.Convert(it) + } else if arg.Kind() == reflect.Func { + if _, isFunc := arg.Interface().(Func); isFunc { + rfunc := arg + arg = reflect.MakeFunc(it, func(args []reflect.Value) []reflect.Value { + for i := range args { + args[i] = reflect.ValueOf(args[i]) + } + if e.Go { + go func() { + rfunc.Call(args) + }() + return []reflect.Value{} + } + return rfunc.Call(args)[:it.NumOut()] + }) + } + } else if !arg.IsValid() { + arg = reflect.Zero(it) + } + } + } + if !arg.IsValid() { + arg = NilValue + } + + if !isReflect { + if e.VarArg && i == l-1 { + for j := 0; j < arg.Len(); j++ { + args = append(args, arg.Index(j).Elem()) + } + } else { + args = append(args, arg) + } + } else { + if arg.Kind() == reflect.Interface { + arg = arg.Elem() + } + if e.VarArg && i == l-1 { + for j := 0; j < arg.Len(); j++ { + args = append(args, reflect.ValueOf(arg.Index(j).Elem())) + } + } else { + args = append(args, reflect.ValueOf(arg)) + } + } + } + ret := NilValue + var err error + fnc := func() { + defer func() { + if os.Getenv("ANKO_DEBUG") == "" { + if ex := recover(); ex != nil { + if e, ok := ex.(error); ok { + err = e + } else { + err = errors.New(fmt.Sprint(ex)) + } + } + } + }() + if f.Kind() == reflect.Interface { + f = f.Elem() + } + rets := f.Call(args) + if isReflect { + ev := rets[1].Interface() + if ev != nil { + err = ev.(error) + } + ret = rets[0].Interface().(reflect.Value) + } else { + for i, expr := range e.SubExprs { + if ae, ok := expr.(*ast.AddrExpr); ok { + if id, ok := ae.Expr.(*ast.IdentExpr); ok { + invokeLetExpr(id, args[i].Elem().Elem(), env) + } + } + } + if f.Type().NumOut() == 1 { + ret = rets[0] + } else { + var result []interface{} + for _, r := range rets { + result = append(result, r.Interface()) + } + ret = reflect.ValueOf(result) + } + } + } + if e.Go { + go fnc() + return NilValue, nil + } + fnc() + if err != nil { + return ret, NewError(expr, err) + } + return ret, nil + case *ast.TernaryOpExpr: + rv, err := invokeExpr(e.Expr, env) + if err != nil { + return rv, NewError(expr, err) + } + if toBool(rv) { + lhsV, err := invokeExpr(e.Lhs, env) + if err != nil { + return lhsV, NewError(expr, err) + } + return lhsV, nil + } + rhsV, err := invokeExpr(e.Rhs, env) + if err != nil { + return rhsV, NewError(expr, err) + } + return rhsV, nil + case *ast.MakeChanExpr: + typ, err := env.Type(e.Type) + if err != nil { + return NilValue, err + } + var size int + if e.SizeExpr != nil { + rv, err := invokeExpr(e.SizeExpr, env) + if err != nil { + return NilValue, err + } + size = int(toInt64(rv)) + } + return func() (reflect.Value, error) { + defer func() { + if os.Getenv("ANKO_DEBUG") == "" { + if ex := recover(); ex != nil { + if e, ok := ex.(error); ok { + err = e + } else { + err = errors.New(fmt.Sprint(ex)) + } + } + } + }() + return reflect.MakeChan(reflect.ChanOf(reflect.BothDir, typ), size), nil + }() + case *ast.MakeArrayExpr: + typ, err := env.Type(e.Type) + if err != nil { + return NilValue, err + } + var alen int + if e.LenExpr != nil { + rv, err := invokeExpr(e.LenExpr, env) + if err != nil { + return NilValue, err + } + alen = int(toInt64(rv)) + } + var acap int + if e.CapExpr != nil { + rv, err := invokeExpr(e.CapExpr, env) + if err != nil { + return NilValue, err + } + acap = int(toInt64(rv)) + } else { + acap = alen + } + return func() (reflect.Value, error) { + defer func() { + if os.Getenv("ANKO_DEBUG") == "" { + if ex := recover(); ex != nil { + if e, ok := ex.(error); ok { + err = e + } else { + err = errors.New(fmt.Sprint(ex)) + } + } + } + }() + return reflect.MakeSlice(reflect.SliceOf(typ), alen, acap), nil + }() + case *ast.ChanExpr: + rhs, err := invokeExpr(e.Rhs, env) + if err != nil { + return NilValue, NewError(expr, err) + } + + if e.Lhs == nil { + if rhs.Kind() == reflect.Chan { + rv, _ := rhs.Recv() + return rv, nil + } + } else { + lhs, err := invokeExpr(e.Lhs, env) + if err != nil { + return NilValue, NewError(expr, err) + } + if lhs.Kind() == reflect.Chan { + lhs.Send(rhs) + return NilValue, nil + } else if rhs.Kind() == reflect.Chan { + rv, _ := rhs.Recv() + return invokeLetExpr(e.Lhs, rv, env) + } + } + return NilValue, NewStringError(expr, "Invalid operation for chan") + default: + return NilValue, NewStringError(expr, "Unknown expression") + } +} diff --git a/vendor/github.com/mattn/anko/.travis.yml b/vendor/github.com/mattn/anko/.travis.yml new file mode 100644 index 0000000000..a6ccc91c8b --- /dev/null +++ b/vendor/github.com/mattn/anko/.travis.yml @@ -0,0 +1,10 @@ +language: go +go: + - tip +before_install: + - go get github.com/daviddengcn/go-colortext +script: + - go build + - ./t/test.sh + - ./anko ./_example/scripts/term.ank + diff --git a/vendor/github.com/mattn/anko/README.md b/vendor/github.com/mattn/anko/README.md new file mode 100644 index 0000000000..2bb218d10a --- /dev/null +++ b/vendor/github.com/mattn/anko/README.md @@ -0,0 +1,92 @@ +# anko + +[![Build Status](https://travis-ci.org/mattn/anko.png?branch=master)](https://travis-ci.org/mattn/anko) +[![GoDoc](https://godoc.org/github.com/mattn/anko/vm?status.svg)](https://godoc.org/github.com/mattn/anko/vm) + +Anko is a scriptable interpreter written in Go. + +![](https://raw.githubusercontent.com/mattn/anko/master/anko.png) + +(Picture licensed under CC BY-SA 3.0 by wikipedia) + +## Installation +Requires Go. +``` +$ go get -u github.com/mattn/anko +``` + +## Examples + +```bash +# declare function +func plus(n){ + return n + 1 +} + +# declare variables +x = 1 +y = x + 1 + +# print values +println(x * (y + 2 * x + plus(x) / 2)) + +# if/else condition +if plus(y) > 1 { + println("こんにちわ世界") +} else { + println("Hello, World") +} + +# array type +a = [1,2,3] +println(a[2]) +println(len(a)) + +# map type +m = {"foo": "bar", "far": "boo"} +m.foo = "baz" +for k in keys(m) { + println(m[k]) +} +``` + +See `_examples/scripts` for more examples. + + + +## Usage + +Embedding the interpreter into your own program: + +```Go +var env = vm.NewEnv() + +env.Define("foo", 1) +env.Define("bar", func() int { + return 2 +}) + +val, err := env.Execute(`foo + bar()`) +if err != nil { + panic(err) +} + +fmt.Println(val) +// output: +// 3 +``` + +Running scripts using anko command-line tool: + +``` +$ anko script.ank +``` + +# License + +MIT + +# Author + +Yasuhiro Matsumoto (a.k.a mattn) + diff --git a/vendor/github.com/mattn/anko/TODO b/vendor/github.com/mattn/anko/TODO new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vendor/github.com/mattn/anko/_example/embed/main.go b/vendor/github.com/mattn/anko/_example/embed/main.go new file mode 100644 index 0000000000..d82397c26b --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/embed/main.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + "log" + + "github.com/mattn/anko/vm" +) + +func main() { + env := vm.NewEnv() + + env.Define("foo", 1) + env.Define("bar", func() int { + return 2 + }) + + v, err := env.Execute(`foo + bar()`) + if err != nil { + log.Fatal(err) + } + + fmt.Println(v) +} diff --git a/vendor/github.com/mattn/anko/_example/scripts/anonymous-call.ank b/vendor/github.com/mattn/anko/_example/scripts/anonymous-call.ank new file mode 100644 index 0000000000..df73133c2b --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/anonymous-call.ank @@ -0,0 +1,9 @@ +#!anko + +func(x) { + return func(y) { + x(y) + } +}(func(z) { + println("Yay!", z) +})("hello world") diff --git a/vendor/github.com/mattn/anko/_example/scripts/chan.ank b/vendor/github.com/mattn/anko/_example/scripts/chan.ank new file mode 100644 index 0000000000..18d6e78269 --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/chan.ank @@ -0,0 +1,13 @@ +#!anko + +c = make(chan int64) + +go func() { + c <- 1 + c <- 2 + c <- 3 +}() + +println(<-c) +println(<-c) +println(<-c) diff --git a/vendor/github.com/mattn/anko/_example/scripts/env.ank b/vendor/github.com/mattn/anko/_example/scripts/env.ank new file mode 100644 index 0000000000..b98b7cc0bb --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/env.ank @@ -0,0 +1,9 @@ +#!anko + +var os, runtime = import("os"), import("runtime") + +if runtime.GOOS == "windows" { + println(os.Getenv("USERPROFILE")) +} else { + println(os.Getenv("HOME")) +} diff --git a/vendor/github.com/mattn/anko/_example/scripts/example.ank b/vendor/github.com/mattn/anko/_example/scripts/example.ank new file mode 100644 index 0000000000..77faad9074 --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/example.ank @@ -0,0 +1,70 @@ +#!anko + +# declare function +func foo(x){ + return x + 1 +} + +func bar(x ...){ + return len(x) +} + +# declare variables +x = 1 +y = x + 1 + +# print values +println(x * (y + 2 * x + foo(x) / 2)) + +# if/else condition +if foo(y) >= 1 { + println("こんにちわ世界") +} else { + println("Hello, World") +} + +# array type +a = [1,2,3] +println(a) +println(a[2]) +println(len(a)) + +# map type +m = {"foo": "bar", "bar": "baz"} +for k in keys(m) { + println(m[k]) +} + +f = func(a) { + println(a) +} + +f("あんこ") + +f = func(a ...) { + println(a) +} + +f("あんこ", "だいすき") + +println(1 && 2) + +println(bar(1,2,3)) +println("foo") +println(toByteSlice("あいう")) +println(toRuneSlice("あいう")) + +a = 1 +func foo() { + a = 2 +} +foo() +println(a) + +module Foo { + func bar1() { + println("Foo.bar1") + } +} + +println(Foo.bar1()) diff --git a/vendor/github.com/mattn/anko/_example/scripts/exec.ank b/vendor/github.com/mattn/anko/_example/scripts/exec.ank new file mode 100644 index 0000000000..45b3988960 --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/exec.ank @@ -0,0 +1,7 @@ +#!anko + +var os, exec = import("os"), import("os/exec") + +cmd = exec.Command("ls", "-la") +cmd.Stdout = os.Stdout +cmd.Run() diff --git a/vendor/github.com/mattn/anko/_example/scripts/fib-for.ank b/vendor/github.com/mattn/anko/_example/scripts/fib-for.ank new file mode 100644 index 0000000000..e4d8b1931b --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/fib-for.ank @@ -0,0 +1,15 @@ +#!anko + +func fib(n) { + a, b = 1, 1 + f = [] + for i in range(n) { + f += a + b += a + a = b - a + } + return f +} + + +println(fib(20)) diff --git a/vendor/github.com/mattn/anko/_example/scripts/fib-recursion.ank b/vendor/github.com/mattn/anko/_example/scripts/fib-recursion.ank new file mode 100644 index 0000000000..01cbab0329 --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/fib-recursion.ank @@ -0,0 +1,14 @@ +#!anko + +func fib(n) { + if n == 1 { + return [1] + } else if n == 2 { + return [1,1] + } else { + t = fib(n-1) + return t + (t[len(t)-1] + t[len(t)-2]) + } +} + +println(fib(20)) diff --git a/vendor/github.com/mattn/anko/_example/scripts/for-break-continue.ank b/vendor/github.com/mattn/anko/_example/scripts/for-break-continue.ank new file mode 100644 index 0000000000..2f5185a154 --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/for-break-continue.ank @@ -0,0 +1,12 @@ +#!anko + +for i in [1,2,3,4,5] { + if i == 2 { + continue + } + println(i) + if i > 3 { + break + } + println("foo") +} diff --git a/vendor/github.com/mattn/anko/_example/scripts/http.ank b/vendor/github.com/mattn/anko/_example/scripts/http.ank new file mode 100644 index 0000000000..eaa62adf6e --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/http.ank @@ -0,0 +1,8 @@ +#!anko + +var http, ioutil = import("net/http"), import("io/ioutil") + +r = http.DefaultClient.Get("http://golang.org/") +b, _ = ioutil.ReadAll(r[0].Body) +printf("%s", toString(b)) +r[0].Body.Close() diff --git a/vendor/github.com/mattn/anko/_example/scripts/module.ank b/vendor/github.com/mattn/anko/_example/scripts/module.ank new file mode 100644 index 0000000000..2a17d9079a --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/module.ank @@ -0,0 +1,10 @@ +#!anko + +module Foo { + func bar1() { + println("Foo.bar1") + return 1 + } +} + +println(Foo.bar1()) diff --git a/vendor/github.com/mattn/anko/_example/scripts/regexp.ank b/vendor/github.com/mattn/anko/_example/scripts/regexp.ank new file mode 100644 index 0000000000..27e2e65efb --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/regexp.ank @@ -0,0 +1,8 @@ +#!anko + +var regexp = import("regexp") + +for s in regexp.MustCompile(`[\s_]`).Split("foo_bar_baz", -1) { + println(s) +} + diff --git a/vendor/github.com/mattn/anko/_example/scripts/server.ank b/vendor/github.com/mattn/anko/_example/scripts/server.ank new file mode 100644 index 0000000000..1a7cfc779c --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/server.ank @@ -0,0 +1,8 @@ +#!anko + +var http = import("net/http") + +http.HandleFunc("/", func(w, r) { + w.Write(toByteSlice("hello world")) +}) +http.ListenAndServe(":8080", nil) diff --git a/vendor/github.com/mattn/anko/_example/scripts/signal.ank b/vendor/github.com/mattn/anko/_example/scripts/signal.ank new file mode 100644 index 0000000000..ccd64c519a --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/signal.ank @@ -0,0 +1,14 @@ +#!anko + +var os, signal, time = import("os"), import("os/signal"), import("time") + +c = make(chan os.Signal, 1) +signal.Notify(c, os.Interrupt) +go func() { + <-c + println("CTRL-C") + os.Exit(0) +}() + +d, _ = time.ParseDuration("10s") +time.Sleep(d) diff --git a/vendor/github.com/mattn/anko/_example/scripts/slice.ank b/vendor/github.com/mattn/anko/_example/scripts/slice.ank new file mode 100644 index 0000000000..3216ffb202 --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/slice.ank @@ -0,0 +1,10 @@ +#!anko + +a = make([]int64, 5) + +for i = 0; i < len(a); i++ { + a[i] = i +} +for i in a { + println(i) +} diff --git a/vendor/github.com/mattn/anko/_example/scripts/socket.ank b/vendor/github.com/mattn/anko/_example/scripts/socket.ank new file mode 100644 index 0000000000..5e4c3f6f1a --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/socket.ank @@ -0,0 +1,26 @@ +#!anko + +var os, net, url, ioutil = import("os"), import("net"), import("net/url"), import("io/ioutil"); + +func connect(uri) { + proxy = os.Getenv("http_proxy") + if proxy != "" { + u, e = url.Parse(proxy) + if e != nil { + return nil, e + } + return net.Dial("tcp", u.Host) + } + return net.Dial("tcp", uri) +} + +c, e = connect("www.google.com:80") +if e != nil { + throw e +} +c.Write(toByteSlice("GET http://www.google.com/ HTTP/1.0\r\n\r\n")) +b, e = ioutil.ReadAll(c) +if e != nil { + throw e +} +printf("%s", b) diff --git a/vendor/github.com/mattn/anko/_example/scripts/term.ank b/vendor/github.com/mattn/anko/_example/scripts/term.ank new file mode 100644 index 0000000000..73e6851953 --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/term.ank @@ -0,0 +1,60 @@ +#!anko + +var colortext = import("github.com/daviddengcn/go-colortext") + +data = [ +"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOOOOOOO OOO", +"OOOOOOOOOOOOOOOOOOOOO O . OOO", +"OOOOOOOOOOOOOOOOOOOO XXXX . OOOO", +"OOOOOOOOOOOOOOOOOOO XOXXXX OOOOO", +"OOOOOOOOOOOOOOOOOO XOXXXXXX OOOO", +"OOOOOOOOOOOOOOOOOO XXXXXXXX OOOO", +"OOOOOOOOOOOOOOOOOO XXXXXXXX OOOO", +"OOOOOOOOOOOOOOO XXXXXXX OOOO", +"OOOOOOOOOOOOOO OOOO XXXXX OOOOO", +"OOOOOOOOOOOOO OOOOOOO XXX OOOOOO", +"OOOOOOOOOOOO OOOOOOOO OOOOOOO", +"OOOOOOOOOOOO OOOOOOOOO OOOOOOOOO", +"OOOOOOOOOOOO OOOOOOOOO OOOOOOOOO", +"OOOOOOOOOO OOOOOOO OOOOOOOOO", +"OOOOOOOOO ooooo OOOOO OOOOOOOOOO", +"OOOOOOOO oOooooo OOO OOOOOOOOOOO", +"OOOOOOO oOoooooo OOOOOOOOOOOO", +"OOOOOOO ooooooooo OOOOOOOOOOOOOO", +"OOOOOOO ooooooooo OOOOOOOOOOOOOO", +"OOOOOOO ooooooooo OOOOOOOOOOOOOO", +"OOOOOOO o ooooo OOOOOOOOOOOOOO", +"OOOOOOOO . ooooo OOOOOOOOOOOOOOO", +"OOOOOOO . oooo OOOOOOOOOOOOOOOO", +"OOOOOO . O OOOOOOOOOOOOOOOOO", +"OOOOO . OOOOOOOOOOOOOOOOOOOOOOOO", +"OOOO . OOOOOOOOOOOOOOOOOOOOOOOOO", +"OOO . OOOOOOOOOOOOOOOOOOOOOOOOOO", +"OOOO OOOOOOOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO", +] + +for d in data { + for b in toRuneSlice(d) { + switch toChar(b) { + case "O": + colortext.ChangeColor("none", false, "white", true) + case ".": + colortext.ChangeColor("none", false, "red", false) + case "X": + colortext.ChangeColor("none", false, "green", true) + case "o": + colortext.ChangeColor("none", false, "mazenta", true) + case " ": + colortext.ChangeColor("none", false, "black", false) + case "+": + colortext.ChangeColor("none", false, "white", true) + case "X": + colortext.ChangeColor("none", false, "red", false) + } + print(" ") + } + colortext.ResetColor() + println() +} diff --git a/vendor/github.com/mattn/anko/_example/scripts/try-catch.ank b/vendor/github.com/mattn/anko/_example/scripts/try-catch.ank new file mode 100644 index 0000000000..80029b38ee --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/try-catch.ank @@ -0,0 +1,19 @@ +#!anko + +var http = import("net/http") + +try { + http.Do() +} catch { + println("catch!") +} finally { + println("finally!") +} + +try { + http.Do() +} catch e { + println("catch!", e) +} finally { + println("finally!") +} diff --git a/vendor/github.com/mattn/anko/_example/scripts/url.ank b/vendor/github.com/mattn/anko/_example/scripts/url.ank new file mode 100644 index 0000000000..4454fc8b03 --- /dev/null +++ b/vendor/github.com/mattn/anko/_example/scripts/url.ank @@ -0,0 +1,7 @@ +#!anko + +var url = import("net/url") + +u, _ = url.Parse("http://www.google.com/search?q=こんにちわ世界") +println(u.Path) +println(u.Host) diff --git a/vendor/github.com/mattn/anko/anko.go b/vendor/github.com/mattn/anko/anko.go new file mode 100644 index 0000000000..181507260f --- /dev/null +++ b/vendor/github.com/mattn/anko/anko.go @@ -0,0 +1,238 @@ +// +build !appengine + +package main + +import ( + "bufio" + "flag" + "fmt" + "io/ioutil" + "os" + "path/filepath" + "reflect" + "strings" + + "github.com/daviddengcn/go-colortext" + "github.com/mattn/anko/parser" + "github.com/mattn/anko/vm" + "github.com/mattn/go-isatty" + + anko_core "github.com/mattn/anko/builtins" + anko_encoding_json "github.com/mattn/anko/builtins/encoding/json" + anko_errors "github.com/mattn/anko/builtins/errors" + anko_flag "github.com/mattn/anko/builtins/flag" + anko_fmt "github.com/mattn/anko/builtins/fmt" + anko_io "github.com/mattn/anko/builtins/io" + anko_io_ioutil "github.com/mattn/anko/builtins/io/ioutil" + anko_math "github.com/mattn/anko/builtins/math" + anko_math_rand "github.com/mattn/anko/builtins/math/rand" + anko_net "github.com/mattn/anko/builtins/net" + anko_net_http "github.com/mattn/anko/builtins/net/http" + anko_net_url "github.com/mattn/anko/builtins/net/url" + anko_os "github.com/mattn/anko/builtins/os" + anko_os_exec "github.com/mattn/anko/builtins/os/exec" + anko_os_signal "github.com/mattn/anko/builtins/os/signal" + anko_path "github.com/mattn/anko/builtins/path" + anko_path_filepath "github.com/mattn/anko/builtins/path/filepath" + anko_regexp "github.com/mattn/anko/builtins/regexp" + anko_runtime "github.com/mattn/anko/builtins/runtime" + anko_sort "github.com/mattn/anko/builtins/sort" + anko_strings "github.com/mattn/anko/builtins/strings" + anko_time "github.com/mattn/anko/builtins/time" + + anko_colortext "github.com/mattn/anko/builtins/github.com/daviddengcn/go-colortext" +) + +const version = "0.0.1" + +var ( + fs = flag.NewFlagSet(os.Args[0], 1) + line = fs.String("e", "", "One line of program") + v = fs.Bool("v", false, "Display version") + + istty = isatty.IsTerminal(os.Stdout.Fd()) +) + +func colortext(color ct.Color, bright bool, f func()) { + if istty { + ct.ChangeColor(color, bright, ct.None, false) + f() + ct.ResetColor() + } else { + f() + } +} + +func main() { + fs.Parse(os.Args[1:]) + if *v { + fmt.Println(version) + os.Exit(0) + } + + var ( + code string + b []byte + reader *bufio.Reader + following bool + source string + ) + + env := vm.NewEnv() + interactive := fs.NArg() == 0 && *line == "" + + env.Define("args", fs.Args()) + + if interactive { + reader = bufio.NewReader(os.Stdin) + source = "typein" + os.Args = append([]string{os.Args[0]}, fs.Args()...) + } else { + if *line != "" { + b = []byte(*line) + source = "argument" + } else { + var err error + b, err = ioutil.ReadFile(fs.Arg(0)) + if err != nil { + colortext(ct.Red, false, func() { + fmt.Fprintln(os.Stderr, err) + }) + os.Exit(1) + } + env.Define("args", fs.Args()[1:]) + source = filepath.Clean(fs.Arg(0)) + } + os.Args = fs.Args() + } + + anko_core.Import(env) + + pkgs := map[string]func(env *vm.Env) *vm.Env{ + "encoding/json": anko_encoding_json.Import, + "errors": anko_errors.Import, + "flag": anko_flag.Import, + "fmt": anko_fmt.Import, + "io": anko_io.Import, + "io/ioutil": anko_io_ioutil.Import, + "math": anko_math.Import, + "math/rand": anko_math_rand.Import, + "net": anko_net.Import, + "net/http": anko_net_http.Import, + "net/url": anko_net_url.Import, + "os": anko_os.Import, + "os/exec": anko_os_exec.Import, + "os/signal": anko_os_signal.Import, + "path": anko_path.Import, + "path/filepath": anko_path_filepath.Import, + "regexp": anko_regexp.Import, + "runtime": anko_runtime.Import, + "sort": anko_sort.Import, + "strings": anko_strings.Import, + "time": anko_time.Import, + "github.com/daviddengcn/go-colortext": anko_colortext.Import, + } + + env.Define("import", func(s string) interface{} { + if loader, ok := pkgs[s]; ok { + m := loader(env) + return m + } + panic(fmt.Sprintf("package '%s' not found", s)) + }) + + for { + if interactive { + colortext(ct.Green, true, func() { + if following { + fmt.Print(" ") + } else { + fmt.Print("> ") + } + }) + var err error + b, _, err = reader.ReadLine() + if err != nil { + break + } + if len(b) == 0 { + continue + } + if code != "" { + code += "\n" + } + code += string(b) + } else { + code = string(b) + } + + stmts, err := parser.ParseSrc(code) + + if interactive { + if e, ok := err.(*parser.Error); ok { + es := e.Error() + if strings.HasPrefix(es, "syntax error: unexpected") { + if strings.HasPrefix(es, "syntax error: unexpected $end,") { + following = true + continue + } + } else { + if e.Pos.Column == len(b) && !e.Fatal { + println(e.Error()) + following = true + continue + } + if e.Error() == "unexpected EOF" { + following = true + continue + } + } + } + } + + following = false + code = "" + v := vm.NilValue + + if err == nil { + v, err = vm.Run(stmts, env) + } + if err != nil { + colortext(ct.Red, false, func() { + if e, ok := err.(*vm.Error); ok { + fmt.Fprintf(os.Stderr, "%s:%d: %s\n", source, e.Pos.Line, err) + } else if e, ok := err.(*parser.Error); ok { + if e.Filename != "" { + source = e.Filename + } + fmt.Fprintf(os.Stderr, "%s:%d: %s\n", source, e.Pos.Line, err) + } else { + fmt.Fprintln(os.Stderr, err) + } + }) + + if interactive { + continue + } else { + os.Exit(1) + } + } else { + if interactive { + colortext(ct.Black, true, func() { + if v == vm.NilValue || !v.IsValid() { + fmt.Println("nil") + } else { + s, ok := v.Interface().(fmt.Stringer) + if v.Kind() != reflect.String && ok { + fmt.Println(s) + } else { + fmt.Printf("%#v\n", v.Interface()) + } + } + }) + } else { + break + } + } + } +} diff --git a/vendor/github.com/mattn/anko/anko.png b/vendor/github.com/mattn/anko/anko.png new file mode 100644 index 0000000000..f1b98f2379 Binary files /dev/null and b/vendor/github.com/mattn/anko/anko.png differ diff --git a/vendor/github.com/mattn/anko/ast/doc.go b/vendor/github.com/mattn/anko/ast/doc.go new file mode 100644 index 0000000000..8781cfc7d9 --- /dev/null +++ b/vendor/github.com/mattn/anko/ast/doc.go @@ -0,0 +1,2 @@ +// Package ast implements abstruct-syntax-tree for anko. +package ast diff --git a/vendor/github.com/mattn/anko/ast/expr.go b/vendor/github.com/mattn/anko/ast/expr.go new file mode 100644 index 0000000000..c43aac6dd5 --- /dev/null +++ b/vendor/github.com/mattn/anko/ast/expr.go @@ -0,0 +1,201 @@ +package ast + +// Expr provides all of interfaces for expression. +type Expr interface { + Pos + expr() +} + +// ExprImpl provide commonly implementations for Expr. +type ExprImpl struct { + PosImpl // ExprImpl provide Pos() function. +} + +// expr provide restraint interface. +func (x *ExprImpl) expr() {} + +// NumberExpr provide Number expression. +type NumberExpr struct { + ExprImpl + Lit string +} + +// StringExpr provide String expression. +type StringExpr struct { + ExprImpl + Lit string +} + +// ArrayExpr provide Array expression. +type ArrayExpr struct { + ExprImpl + Exprs []Expr +} + +// PairExpr provide one of Map key/value pair. +type PairExpr struct { + ExprImpl + Key string + Value Expr +} + +// MapExpr provide Map expression. +type MapExpr struct { + ExprImpl + MapExpr map[string]Expr +} + +// IdentExpr provide identity expression. +type IdentExpr struct { + ExprImpl + Lit string +} + +// UnaryExpr provide unary minus expression. ex: -1, ^1, ~1. +type UnaryExpr struct { + ExprImpl + Operator string + Expr Expr +} + +// AddrExpr provide referencing address expression. +type AddrExpr struct { + ExprImpl + Expr Expr +} + +// DerefExpr provide dereferencing address expression. +type DerefExpr struct { + ExprImpl + Expr Expr +} + +// ParenExpr provide parent block expression. +type ParenExpr struct { + ExprImpl + SubExpr Expr +} + +// BinOpExpr provide binary operator expression. +type BinOpExpr struct { + ExprImpl + Lhs Expr + Operator string + Rhs Expr +} + +type TernaryOpExpr struct { + ExprImpl + Expr Expr + Lhs Expr + Rhs Expr +} + +// CallExpr provide calling expression. +type CallExpr struct { + ExprImpl + Func interface{} + Name string + SubExprs []Expr + VarArg bool + Go bool +} + +// AnonCallExpr provide anonymous calling expression. ex: func(){}(). +type AnonCallExpr struct { + ExprImpl + Expr Expr + SubExprs []Expr + VarArg bool + Go bool +} + +// MemberExpr provide expression to refer menber. +type MemberExpr struct { + ExprImpl + Expr Expr + Name string +} + +// ItemExpr provide expression to refer Map/Array item. +type ItemExpr struct { + ExprImpl + Value Expr + Index Expr +} + +// SliceExpr provide expression to refer slice of Array. +type SliceExpr struct { + ExprImpl + Value Expr + Begin Expr + End Expr +} + +// FuncExpr provide function expression. +type FuncExpr struct { + ExprImpl + Name string + Stmts []Stmt + Args []string + VarArg bool +} + +// LetExpr provide expression to let variable. +type LetExpr struct { + ExprImpl + Lhs Expr + Rhs Expr +} + +// LetsExpr provide multiple expression of let. +type LetsExpr struct { + ExprImpl + Lhss []Expr + Operator string + Rhss []Expr +} + +// AssocExpr provide expression to assoc operation. +type AssocExpr struct { + ExprImpl + Lhs Expr + Operator string + Rhs Expr +} + +// NewExpr provide expression to make new instance. +type NewExpr struct { + ExprImpl + Name string + SubExprs []Expr +} + +// ConstExpr provide expression for constant variable. +type ConstExpr struct { + ExprImpl + Value string +} + +type ChanExpr struct { + ExprImpl + Lhs Expr + Rhs Expr +} + +type Type struct { + Name string +} + +type MakeChanExpr struct { + ExprImpl + Type string + SizeExpr Expr +} + +type MakeArrayExpr struct { + ExprImpl + Type string + LenExpr Expr + CapExpr Expr +} diff --git a/vendor/github.com/mattn/anko/ast/pos.go b/vendor/github.com/mattn/anko/ast/pos.go new file mode 100644 index 0000000000..5a0e470d92 --- /dev/null +++ b/vendor/github.com/mattn/anko/ast/pos.go @@ -0,0 +1,28 @@ +package ast + +// Position provides interface to store code locations. +type Position struct { + Line int + Column int +} + +// Pos interface provies two functions to get/set the position for expression or statement. +type Pos interface { + Position() Position + SetPosition(Position) +} + +// PosImpl provies commonly implementations for Pos. +type PosImpl struct { + pos Position +} + +// Position return the position of the expression or statement. +func (x *PosImpl) Position() Position { + return x.pos +} + +// SetPosition is a function to specify position of the expression or statement. +func (x *PosImpl) SetPosition(pos Position) { + x.pos = pos +} diff --git a/vendor/github.com/mattn/anko/ast/stmt.go b/vendor/github.com/mattn/anko/ast/stmt.go new file mode 100644 index 0000000000..14bbdf7174 --- /dev/null +++ b/vendor/github.com/mattn/anko/ast/stmt.go @@ -0,0 +1,127 @@ +package ast + +// Stmt provides all of interfaces for statement. +type Stmt interface { + Pos + stmt() +} + +// StmtImpl provide commonly implementations for Stmt.. +type StmtImpl struct { + PosImpl // StmtImpl provide Pos() function. +} + +// stmt provide restraint interface. +func (x *StmtImpl) stmt() {} + +// ExprStmt provide expression statement. +type ExprStmt struct { + StmtImpl + Expr Expr +} + +// IfStmt provide "if/else" statement. +type IfStmt struct { + StmtImpl + If Expr + Then []Stmt + ElseIf []Stmt // This is array of IfStmt + Else []Stmt +} + +// TryStmt provide "try/catch/finally" statement. +type TryStmt struct { + StmtImpl + Try []Stmt + Var string + Catch []Stmt + Finally []Stmt +} + +// ForStmt provide "for in" expression statement. +type ForStmt struct { + StmtImpl + Var string + Value Expr + Stmts []Stmt +} + +// CForStmt provide C-style "for (;;)" expression statement. +type CForStmt struct { + StmtImpl + Expr1 Expr + Expr2 Expr + Expr3 Expr + Stmts []Stmt +} + +// LoopStmt provide "for expr" expression statement. +type LoopStmt struct { + StmtImpl + Expr Expr + Stmts []Stmt +} + +// BreakStmt provide "break" expression statement. +type BreakStmt struct { + StmtImpl +} + +// ContinueStmt provide "continue" expression statement. +type ContinueStmt struct { + StmtImpl +} + +// ForStmt provide "return" expression statement. +type ReturnStmt struct { + StmtImpl + Exprs []Expr +} + +// ThrowStmt provide "throw" expression statement. +type ThrowStmt struct { + StmtImpl + Expr Expr +} + +// ModuleStmt provide "module" expression statement. +type ModuleStmt struct { + StmtImpl + Name string + Stmts []Stmt +} + +// VarStmt provide statement to let variables in current scope. +type VarStmt struct { + StmtImpl + Names []string + Exprs []Expr +} + +// SwitchStmt provide switch statement. +type SwitchStmt struct { + StmtImpl + Expr Expr + Cases []Stmt +} + +// CaseStmt provide switch/case statement. +type CaseStmt struct { + StmtImpl + Expr Expr + Stmts []Stmt +} + +// DefaultStmt provide switch/default statement. +type DefaultStmt struct { + StmtImpl + Stmts []Stmt +} + +// LetsStmt provide multiple statement of let. +type LetsStmt struct { + StmtImpl + Lhss []Expr + Operator string + Rhss []Expr +} diff --git a/vendor/github.com/mattn/anko/ast/token.go b/vendor/github.com/mattn/anko/ast/token.go new file mode 100644 index 0000000000..6b47cd0544 --- /dev/null +++ b/vendor/github.com/mattn/anko/ast/token.go @@ -0,0 +1,7 @@ +package ast + +type Token struct { + PosImpl // StmtImpl provide Pos() function. + Tok int + Lit string +} diff --git a/vendor/github.com/mattn/anko/builtins/core.go b/vendor/github.com/mattn/anko/builtins/core.go new file mode 100644 index 0000000000..4a82c6f89b --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/core.go @@ -0,0 +1,217 @@ +// Package core implements core interface for anko script. +package core + +import ( + "fmt" + "io/ioutil" + "os" + "reflect" + + "github.com/mattn/anko/parser" + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + env.Define("len", func(v interface{}) int64 { + rv := reflect.ValueOf(v) + if rv.Kind() == reflect.Interface { + rv = rv.Elem() + } + if rv.Kind() == reflect.String { + return int64(len([]byte(rv.String()))) + } + if rv.Kind() != reflect.Array && rv.Kind() != reflect.Slice { + panic("Argument #1 should be array") + } + return int64(rv.Len()) + }) + + env.Define("keys", func(v interface{}) []string { + rv := reflect.ValueOf(v) + if rv.Kind() == reflect.Interface { + rv = rv.Elem() + } + if rv.Kind() != reflect.Map { + panic("Argument #1 should be map") + } + keys := []string{} + mk := rv.MapKeys() + for _, key := range mk { + keys = append(keys, key.String()) + } + return keys + }) + + env.Define("range", func(args ...int64) []int64 { + if len(args) < 1 { + panic("Missing arguments") + } + if len(args) > 2 { + panic("Too many arguments") + } + var min, max int64 + if len(args) == 1 { + min = 0 + max = args[0] - 1 + } else { + min = args[0] + max = args[1] + } + arr := []int64{} + for i := min; i <= max; i++ { + arr = append(arr, i) + } + return arr + }) + + env.Define("toString", func(v interface{}) string { + if b, ok := v.([]byte); ok { + return string(b) + } + return fmt.Sprint(v) + }) + + env.Define("toInt", func(v interface{}) int64 { + nt := reflect.TypeOf(1) + rv := reflect.ValueOf(v) + if !rv.Type().ConvertibleTo(nt) { + return 0 + } + return rv.Convert(nt).Int() + }) + + env.Define("toFloat", func(v interface{}) float64 { + nt := reflect.TypeOf(1.0) + rv := reflect.ValueOf(v) + if !rv.Type().ConvertibleTo(nt) { + return 0.0 + } + return rv.Convert(nt).Float() + }) + + env.Define("toBool", func(v interface{}) bool { + nt := reflect.TypeOf(true) + rv := reflect.ValueOf(v) + if !rv.Type().ConvertibleTo(nt) { + return false + } + return rv.Convert(nt).Bool() + }) + + env.Define("toChar", func(s rune) string { + return string(s) + }) + + env.Define("toRune", func(s string) rune { + if len(s) == 0 { + return 0 + } + return []rune(s)[0] + }) + + env.Define("toByteSlice", func(s string) []byte { + return []byte(s) + }) + + env.Define("toRuneSlice", func(s string) []rune { + return []rune(s) + }) + + env.Define("toBoolSlice", func(v []interface{}) []bool { + var result []bool + toSlice(v, &result) + return result + }) + + env.Define("toFloatSlice", func(v []interface{}) []float64 { + var result []float64 + toSlice(v, &result) + return result + }) + + env.Define("toIntSlice", func(v []interface{}) []int64 { + var result []int64 + toSlice(v, &result) + return result + }) + + env.Define("toStringSlice", func(v []interface{}) []string { + var result []string + toSlice(v, &result) + return result + }) + + env.Define("typeOf", func(v interface{}) string { + return reflect.TypeOf(v).String() + }) + + env.Define("chanOf", func(t reflect.Type) reflect.Value { + return reflect.MakeChan(t, 1) + }) + + env.Define("defined", func(s string) bool { + _, err := env.Get(s) + return err == nil + }) + + env.Define("load", func(s string) interface{} { + body, err := ioutil.ReadFile(s) + if err != nil { + panic(err) + } + scanner := new(parser.Scanner) + scanner.Init(string(body)) + stmts, err := parser.Parse(scanner) + if err != nil { + if pe, ok := err.(*parser.Error); ok { + pe.Filename = s + panic(pe) + } + panic(err) + } + rv, err := vm.Run(stmts, env) + if err != nil { + panic(err) + } + if rv.IsValid() && rv.CanInterface() { + return rv.Interface() + } + return nil + }) + + env.Define("panic", func(e interface{}) { + os.Setenv("ANKO_DEBUG", "1") + panic(e) + }) + + env.Define("print", fmt.Print) + env.Define("println", fmt.Println) + env.Define("printf", fmt.Printf) + + env.DefineType("int64", int64(0)) + env.DefineType("float64", float64(0.0)) + env.DefineType("bool", true) + env.DefineType("string", "") + return env +} + +// toSlice takes in a "generic" slice and converts and copies +// it's elements into the typed slice pointed at by ptr. +// Note that this is a costly operation. +func toSlice(from []interface{}, ptr interface{}) { + // Value of the pointer to the target + obj := reflect.Indirect(reflect.ValueOf(ptr)) + // We can't just convert from interface{} to whatever the target is (diff memory layout), + // so we need to create a New slice of the proper type and copy the values individually + t := reflect.TypeOf(ptr).Elem() + slice := reflect.MakeSlice(t, len(from), len(from)) + // Copying the data, val is an adressable Pointer of the actual target type + val := reflect.Indirect(reflect.New(t.Elem())) + for i := 0; i < len(from); i++ { + v := reflect.ValueOf(from[i]) + val.Set(v) + slice.Index(i).Set(v) + } + // Ok now assign our slice to the target pointer + obj.Set(slice) +} diff --git a/vendor/github.com/mattn/anko/builtins/encoding/json/json.go b/vendor/github.com/mattn/anko/builtins/encoding/json/json.go new file mode 100644 index 0000000000..5d9f16327e --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/encoding/json/json.go @@ -0,0 +1,15 @@ +// Package json implements json interface for anko script. +package json + +import ( + "encoding/json" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("json") + m.Define("Marshal", json.Marshal) + m.Define("Unmarshal", json.Unmarshal) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/errors/errors.go b/vendor/github.com/mattn/anko/builtins/errors/errors.go new file mode 100644 index 0000000000..09da555e17 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/errors/errors.go @@ -0,0 +1,13 @@ +// Package errors implements errors interface for anko script. +package errors + +import ( + pkg "errors" + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewModule("errors") + m.Define("New", pkg.New) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/flag/flag.go b/vendor/github.com/mattn/anko/builtins/flag/flag.go new file mode 100644 index 0000000000..76fb9fb6d6 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/flag/flag.go @@ -0,0 +1,48 @@ +// Package flag implements flag interface for anko script. +package flag + +import ( + pkg "flag" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("flag") + m.Define("Arg", pkg.Arg) + m.Define("Args", pkg.Args) + m.Define("Bool", pkg.Bool) + m.Define("BoolVar", pkg.BoolVar) + m.Define("CommandLine", pkg.CommandLine) + m.Define("ContinueOnError", pkg.ContinueOnError) + m.Define("Duration", pkg.Duration) + m.Define("DurationVar", pkg.DurationVar) + m.Define("ErrHelp", pkg.ErrHelp) + m.Define("ExitOnError", pkg.ExitOnError) + m.Define("Float64", pkg.Float64) + m.Define("Float64Var", pkg.Float64Var) + m.Define("Int", pkg.Int) + m.Define("Int64", pkg.Int64) + m.Define("Int64Var", pkg.Int64Var) + m.Define("IntVar", pkg.IntVar) + m.Define("Lookup", pkg.Lookup) + m.Define("NArg", pkg.NArg) + m.Define("NFlag", pkg.NFlag) + m.Define("NewFlagSet", pkg.NewFlagSet) + m.Define("PanicOnError", pkg.PanicOnError) + m.Define("Parse", pkg.Parse) + m.Define("Parsed", pkg.Parsed) + m.Define("PrintDefaults", pkg.PrintDefaults) + m.Define("Set", pkg.Set) + m.Define("String", pkg.String) + m.Define("StringVar", pkg.StringVar) + m.Define("Uint", pkg.Uint) + m.Define("Uint64", pkg.Uint64) + m.Define("Uint64Var", pkg.Uint64Var) + m.Define("UintVar", pkg.UintVar) + m.Define("Usage", pkg.Usage) + m.Define("Var", pkg.Var) + m.Define("Visit", pkg.Visit) + m.Define("VisitAll", pkg.VisitAll) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/fmt/fmt.go b/vendor/github.com/mattn/anko/builtins/fmt/fmt.go new file mode 100644 index 0000000000..9ee526f790 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/fmt/fmt.go @@ -0,0 +1,32 @@ +// Package fmt implements json interface for anko script. +package fmt + +import ( + pkg "fmt" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("fmt") + m.Define("Errorf", pkg.Errorf) + m.Define("Fprint", pkg.Fprint) + m.Define("Fprintf", pkg.Fprintf) + m.Define("Fprintln", pkg.Fprintln) + m.Define("Fscan", pkg.Fscan) + m.Define("Fscanf", pkg.Fscanf) + m.Define("Fscanln", pkg.Fscanln) + m.Define("Print", pkg.Print) + m.Define("Printf", pkg.Printf) + m.Define("Println", pkg.Println) + m.Define("Scan", pkg.Scan) + m.Define("Scanf", pkg.Scanf) + m.Define("Scanln", pkg.Scanln) + m.Define("Sprint", pkg.Sprint) + m.Define("Sprintf", pkg.Sprintf) + m.Define("Sprintln", pkg.Sprintln) + m.Define("Sscan", pkg.Sscan) + m.Define("Sscanf", pkg.Sscanf) + m.Define("Sscanln", pkg.Sscanln) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/github.com/daviddengcn/go-colortext/colortext.go b/vendor/github.com/mattn/anko/builtins/github.com/daviddengcn/go-colortext/colortext.go new file mode 100644 index 0000000000..e7c3911bf0 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/github.com/daviddengcn/go-colortext/colortext.go @@ -0,0 +1,53 @@ +// +build !appengine + +// Package colortext implements terminal interface for anko script. +package colortext + +import ( + "github.com/daviddengcn/go-colortext" + "github.com/mattn/anko/vm" +) + +var ntoc = map[string]ct.Color{ + "none": ct.None, + "black": ct.Black, + "red": ct.Red, + "green": ct.Green, + "yellow": ct.Yellow, + "blue": ct.Blue, + "mazenta": ct.Magenta, + "cyan": ct.Cyan, + "white": ct.White, +} + +func colorOf(name string) ct.Color { + if c, ok := ntoc[name]; ok { + return c + } + return ct.None +} + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("ct") + + m.Define("ChangeColor", func(fg string, fa bool, rest ...interface{}) { + if len(rest) == 2 { + bg, ok := rest[0].(string) + if !ok { + panic("Argument #3 should be string") + } + ba, ok := rest[1].(bool) + if !ok { + panic("Argument #4 should be string") + } + ct.ChangeColor(colorOf(fg), fa, colorOf(bg), ba) + } else { + ct.ChangeColor(colorOf(fg), fa, ct.None, false) + } + }) + + m.Define("ResetColor", func() { + ct.ResetColor() + }) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/github.com/daviddengcn/go-colortext/colortext_appengine.go b/vendor/github.com/mattn/anko/builtins/github.com/daviddengcn/go-colortext/colortext_appengine.go new file mode 100644 index 0000000000..62b86542ba --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/github.com/daviddengcn/go-colortext/colortext_appengine.go @@ -0,0 +1,13 @@ +// +build appengine + +// Package colortext implements terminal interface for anko script. +package colortext + +import ( + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + panic("can't import 'github.com/daviddengcn/go-colortext'") + return nil +} diff --git a/vendor/github.com/mattn/anko/builtins/io/io.go b/vendor/github.com/mattn/anko/builtins/io/io.go new file mode 100644 index 0000000000..46c5dc2c9d --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/io/io.go @@ -0,0 +1,30 @@ +// Package io implements io interface for anko script. +package io + +import ( + pkg "io" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("io") + m.Define("Copy", pkg.Copy) + m.Define("CopyN", pkg.CopyN) + m.Define("EOF", pkg.EOF) + m.Define("ErrClosedPipe", pkg.ErrClosedPipe) + m.Define("ErrNoProgress", pkg.ErrNoProgress) + m.Define("ErrShortBuffer", pkg.ErrShortBuffer) + m.Define("ErrShortWrite", pkg.ErrShortWrite) + m.Define("ErrUnexpectedEOF", pkg.ErrUnexpectedEOF) + m.Define("LimitReader", pkg.LimitReader) + m.Define("MultiReader", pkg.MultiReader) + m.Define("MultiWriter", pkg.MultiWriter) + m.Define("NewSectionReader", pkg.NewSectionReader) + m.Define("Pipe", pkg.Pipe) + m.Define("ReadAtLeast", pkg.ReadAtLeast) + m.Define("ReadFull", pkg.ReadFull) + m.Define("TeeReader", pkg.TeeReader) + m.Define("WriteString", pkg.WriteString) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/io/ioutil/ioutil.go b/vendor/github.com/mattn/anko/builtins/io/ioutil/ioutil.go new file mode 100644 index 0000000000..ca67785665 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/io/ioutil/ioutil.go @@ -0,0 +1,17 @@ +// Package ioutil implements I/O interface for anko script. +package ioutil + +import ( + u "io/ioutil" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("iotuil") + m.Define("ReadAll", u.ReadAll) + m.Define("ReadDir", u.ReadDir) + m.Define("ReadFile", u.ReadFile) + m.Define("WriteFile", u.WriteFile) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/math/math.go b/vendor/github.com/mattn/anko/builtins/math/math.go new file mode 100644 index 0000000000..84fd1594ee --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/math/math.go @@ -0,0 +1,74 @@ +// Package math implements math interface for anko script. +package math + +import ( + t "math" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("math") + m.Define("Abs", t.Abs) + m.Define("Acos", t.Acos) + m.Define("Acosh", t.Acosh) + m.Define("Asin", t.Asin) + m.Define("Asinh", t.Asinh) + m.Define("Atan", t.Atan) + m.Define("Atan2", t.Atan2) + m.Define("Atanh", t.Atanh) + m.Define("Cbrt", t.Cbrt) + m.Define("Ceil", t.Ceil) + m.Define("Copysign", t.Copysign) + m.Define("Cos", t.Cos) + m.Define("Cosh", t.Cosh) + m.Define("Dim", t.Dim) + m.Define("Erf", t.Erf) + m.Define("Erfc", t.Erfc) + m.Define("Exp", t.Exp) + m.Define("Exp2", t.Exp2) + m.Define("Expm1", t.Expm1) + m.Define("Float32bits", t.Float32bits) + m.Define("Float32frombits", t.Float32frombits) + m.Define("Float64bits", t.Float64bits) + m.Define("Float64frombits", t.Float64frombits) + m.Define("Floor", t.Floor) + m.Define("Frexp", t.Frexp) + m.Define("Gamma", t.Gamma) + m.Define("Hypot", t.Hypot) + m.Define("Ilogb", t.Ilogb) + m.Define("Inf", t.Inf) + m.Define("IsInf", t.IsInf) + m.Define("IsNaN", t.IsNaN) + m.Define("J0", t.J0) + m.Define("J1", t.J1) + m.Define("Jn", t.Jn) + m.Define("Ldexp", t.Ldexp) + m.Define("Lgamma", t.Lgamma) + m.Define("Log", t.Log) + m.Define("Log10", t.Log10) + m.Define("Log1p", t.Log1p) + m.Define("Log2", t.Log2) + m.Define("Logb", t.Logb) + m.Define("Max", t.Max) + m.Define("Min", t.Min) + m.Define("Mod", t.Mod) + m.Define("Modf", t.Modf) + m.Define("NaN", t.NaN) + m.Define("Nextafter", t.Nextafter) + m.Define("Pow", t.Pow) + m.Define("Pow10", t.Pow10) + m.Define("Remainder", t.Remainder) + m.Define("Signbit", t.Signbit) + m.Define("Sin", t.Sin) + m.Define("Sincos", t.Sincos) + m.Define("Sinh", t.Sinh) + m.Define("Sqrt", t.Sqrt) + m.Define("Tan", t.Tan) + m.Define("Tanh", t.Tanh) + m.Define("Trunc", t.Trunc) + m.Define("Y0", t.Y0) + m.Define("Y1", t.Y1) + m.Define("Yn", t.Yn) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/math/rand/rand.go b/vendor/github.com/mattn/anko/builtins/math/rand/rand.go new file mode 100644 index 0000000000..0318fe680f --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/math/rand/rand.go @@ -0,0 +1,26 @@ +// Package rand implements math/rand interface for anko script. +package rand + +import ( + t "math/rand" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("rand") + m.Define("ExpFloat64", t.ExpFloat64) + m.Define("Float32", t.Float32) + m.Define("Float64", t.Float64) + m.Define("Int", t.Int) + m.Define("Int31", t.Int31) + m.Define("Int31n", t.Int31n) + m.Define("Int63", t.Int63) + m.Define("Int63n", t.Int63n) + m.Define("Intn", t.Intn) + m.Define("NormFloat64", t.NormFloat64) + m.Define("Perm", t.Perm) + m.Define("Seed", t.Seed) + m.Define("Uint32", t.Uint32) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/net/http/http.go b/vendor/github.com/mattn/anko/builtins/net/http/http.go new file mode 100644 index 0000000000..cd1fe952ea --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/net/http/http.go @@ -0,0 +1,40 @@ +// +build !appengine + +// Package http implements http interface for anko script. +package http + +import ( + "errors" + h "net/http" + "reflect" + + "github.com/mattn/anko/vm" +) + +type Client struct { + c *h.Client +} + +func (c *Client) Get(args ...reflect.Value) (reflect.Value, error) { + if len(args) < 1 { + return vm.NilValue, errors.New("Missing arguments") + } + if len(args) > 1 { + return vm.NilValue, errors.New("Too many arguments") + } + if args[0].Kind() != reflect.String { + return vm.NilValue, errors.New("Argument should be string") + } + res, err := h.Get(args[0].String()) + return reflect.ValueOf(res), err +} + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("http") + m.Define("DefaultClient", h.DefaultClient) + m.Define("NewServeMux", h.NewServeMux) + m.Define("Handle", h.Handle) + m.Define("HandleFunc", h.HandleFunc) + m.Define("ListenAndServe", h.ListenAndServe) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/net/http/http_appengine.go b/vendor/github.com/mattn/anko/builtins/net/http/http_appengine.go new file mode 100644 index 0000000000..45c8837811 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/net/http/http_appengine.go @@ -0,0 +1,13 @@ +// +build appengine + +// Package net implements http interface for anko script. +package net + +import ( + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + panic("can't import 'net/http'") + return nil +} diff --git a/vendor/github.com/mattn/anko/builtins/net/net.go b/vendor/github.com/mattn/anko/builtins/net/net.go new file mode 100644 index 0000000000..22e49f5502 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/net/net.go @@ -0,0 +1,76 @@ +// +build !appengine + +// Package net implements net interface for anko script. +package net + +import ( + pkg "net" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("net") + m.Define("CIDRMask", pkg.CIDRMask) + m.Define("Dial", pkg.Dial) + m.Define("DialIP", pkg.DialIP) + m.Define("DialTCP", pkg.DialTCP) + m.Define("DialTimeout", pkg.DialTimeout) + m.Define("DialUDP", pkg.DialUDP) + m.Define("DialUnix", pkg.DialUnix) + m.Define("ErrWriteToConnected", pkg.ErrWriteToConnected) + m.Define("FileConn", pkg.FileConn) + m.Define("FileListener", pkg.FileListener) + m.Define("FilePacketConn", pkg.FilePacketConn) + m.Define("FlagBroadcast", pkg.FlagBroadcast) + m.Define("FlagLoopback", pkg.FlagLoopback) + m.Define("FlagMulticast", pkg.FlagMulticast) + m.Define("FlagPointToPoint", pkg.FlagPointToPoint) + m.Define("FlagUp", pkg.FlagUp) + m.Define("IPv4", pkg.IPv4) + m.Define("IPv4Mask", pkg.IPv4Mask) + m.Define("IPv4allrouter", pkg.IPv4allrouter) + m.Define("IPv4allsys", pkg.IPv4allsys) + m.Define("IPv4bcast", pkg.IPv4bcast) + m.Define("IPv4len", pkg.IPv4len) + m.Define("IPv4zero", pkg.IPv4zero) + m.Define("IPv6interfacelocalallnodes", pkg.IPv6interfacelocalallnodes) + m.Define("IPv6len", pkg.IPv6len) + m.Define("IPv6linklocalallnodes", pkg.IPv6linklocalallnodes) + m.Define("IPv6linklocalallrouters", pkg.IPv6linklocalallrouters) + m.Define("IPv6loopback", pkg.IPv6loopback) + m.Define("IPv6unspecified", pkg.IPv6unspecified) + m.Define("IPv6zero", pkg.IPv6zero) + m.Define("InterfaceAddrs", pkg.InterfaceAddrs) + m.Define("InterfaceByIndex", pkg.InterfaceByIndex) + m.Define("InterfaceByName", pkg.InterfaceByName) + m.Define("Interfaces", pkg.Interfaces) + m.Define("JoinHostPort", pkg.JoinHostPort) + m.Define("Listen", pkg.Listen) + m.Define("ListenIP", pkg.ListenIP) + m.Define("ListenMulticastUDP", pkg.ListenMulticastUDP) + m.Define("ListenPacket", pkg.ListenPacket) + m.Define("ListenTCP", pkg.ListenTCP) + m.Define("ListenUDP", pkg.ListenUDP) + m.Define("ListenUnix", pkg.ListenUnix) + m.Define("ListenUnixgram", pkg.ListenUnixgram) + m.Define("LookupAddr", pkg.LookupAddr) + m.Define("LookupCNAME", pkg.LookupCNAME) + m.Define("LookupHost", pkg.LookupHost) + m.Define("LookupIP", pkg.LookupIP) + m.Define("LookupMX", pkg.LookupMX) + m.Define("LookupNS", pkg.LookupNS) + m.Define("LookupPort", pkg.LookupPort) + m.Define("LookupSRV", pkg.LookupSRV) + m.Define("LookupTXT", pkg.LookupTXT) + m.Define("ParseCIDR", pkg.ParseCIDR) + m.Define("ParseIP", pkg.ParseIP) + m.Define("ParseMAC", pkg.ParseMAC) + m.Define("Pipe", pkg.Pipe) + m.Define("ResolveIPAddr", pkg.ResolveIPAddr) + m.Define("ResolveTCPAddr", pkg.ResolveTCPAddr) + m.Define("ResolveUDPAddr", pkg.ResolveUDPAddr) + m.Define("ResolveUnixAddr", pkg.ResolveUnixAddr) + m.Define("SplitHostPort", pkg.SplitHostPort) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/net/net_appengine.go b/vendor/github.com/mattn/anko/builtins/net/net_appengine.go new file mode 100644 index 0000000000..48fefa095e --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/net/net_appengine.go @@ -0,0 +1,13 @@ +// +build appengine + +// Package net implements net interface for anko script. +package net + +import ( + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + panic("can't import 'net'") + return nil +} diff --git a/vendor/github.com/mattn/anko/builtins/net/url/url.go b/vendor/github.com/mattn/anko/builtins/net/url/url.go new file mode 100644 index 0000000000..3109c8b258 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/net/url/url.go @@ -0,0 +1,16 @@ +// +build !appengine + +// Package url implements url interface for anko script. +package url + +import ( + u "net/url" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("url") + m.Define("Parse", u.Parse) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/net/url/url_appengine.go b/vendor/github.com/mattn/anko/builtins/net/url/url_appengine.go new file mode 100644 index 0000000000..ea639e485c --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/net/url/url_appengine.go @@ -0,0 +1,13 @@ +// +build appengine + +// Package url implements url interface for anko script. +package url + +import ( + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + panic("can't import 'url'") + return nil +} diff --git a/vendor/github.com/mattn/anko/builtins/os/exec/exec.go b/vendor/github.com/mattn/anko/builtins/os/exec/exec.go new file mode 100644 index 0000000000..b05809d4c8 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/os/exec/exec.go @@ -0,0 +1,16 @@ +// Package exec implements os/exec interface for anko script. +package exec + +import ( + e "os/exec" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("exec") + m.Define("ErrNotFound", e.ErrNotFound) + m.Define("LookPath", e.LookPath) + m.Define("Command", e.Command) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/os/os.go b/vendor/github.com/mattn/anko/builtins/os/os.go new file mode 100644 index 0000000000..3318e2ecc7 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/os/os.go @@ -0,0 +1,102 @@ +// Package os implements os interface for anko script. +package os + +import ( + pkg "os" + "reflect" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("os") + m.Define("Args", pkg.Args) + m.Define("Chdir", pkg.Chdir) + m.Define("Chmod", pkg.Chmod) + m.Define("Chown", pkg.Chown) + m.Define("Chtimes", pkg.Chtimes) + m.Define("Clearenv", pkg.Clearenv) + m.Define("Create", pkg.Create) + m.Define("DevNull", pkg.DevNull) + m.Define("Environ", pkg.Environ) + m.Define("ErrExist", pkg.ErrExist) + m.Define("ErrInvalid", pkg.ErrInvalid) + m.Define("ErrNotExist", pkg.ErrNotExist) + m.Define("ErrPermission", pkg.ErrPermission) + m.Define("Exit", pkg.Exit) + m.Define("Expand", pkg.Expand) + m.Define("ExpandEnv", pkg.ExpandEnv) + m.Define("FindProcess", pkg.FindProcess) + m.Define("Getegid", pkg.Getegid) + m.Define("Getenv", pkg.Getenv) + m.Define("Geteuid", pkg.Geteuid) + m.Define("Getgid", pkg.Getgid) + m.Define("Getgroups", pkg.Getgroups) + m.Define("Getpagesize", pkg.Getpagesize) + m.Define("Getpid", pkg.Getpid) + handleAppEngine(m) + m.Define("Getuid", pkg.Getuid) + m.Define("Getwd", pkg.Getwd) + m.Define("Hostname", pkg.Hostname) + m.Define("Interrupt", pkg.Interrupt) + m.Define("IsExist", pkg.IsExist) + m.Define("IsNotExist", pkg.IsNotExist) + m.Define("IsPathSeparator", pkg.IsPathSeparator) + m.Define("IsPermission", pkg.IsPermission) + m.Define("Kill", pkg.Kill) + m.Define("Lchown", pkg.Lchown) + m.Define("Link", pkg.Link) + m.Define("Lstat", pkg.Lstat) + m.Define("Mkdir", pkg.Mkdir) + m.Define("MkdirAll", pkg.MkdirAll) + m.Define("ModeAppend", pkg.ModeAppend) + m.Define("ModeCharDevice", pkg.ModeCharDevice) + m.Define("ModeDevice", pkg.ModeDevice) + m.Define("ModeDir", pkg.ModeDir) + m.Define("ModeExclusive", pkg.ModeExclusive) + m.Define("ModeNamedPipe", pkg.ModeNamedPipe) + m.Define("ModePerm", pkg.ModePerm) + m.Define("ModeSetgid", pkg.ModeSetgid) + m.Define("ModeSetuid", pkg.ModeSetuid) + m.Define("ModeSocket", pkg.ModeSocket) + m.Define("ModeSticky", pkg.ModeSticky) + m.Define("ModeSymlink", pkg.ModeSymlink) + m.Define("ModeTemporary", pkg.ModeTemporary) + m.Define("ModeType", pkg.ModeType) + m.Define("NewFile", pkg.NewFile) + m.Define("NewSyscallError", pkg.NewSyscallError) + m.Define("O_APPEND", pkg.O_APPEND) + m.Define("O_CREATE", pkg.O_CREATE) + m.Define("O_EXCL", pkg.O_EXCL) + m.Define("O_RDONLY", pkg.O_RDONLY) + m.Define("O_RDWR", pkg.O_RDWR) + m.Define("O_SYNC", pkg.O_SYNC) + m.Define("O_TRUNC", pkg.O_TRUNC) + m.Define("O_WRONLY", pkg.O_WRONLY) + m.Define("Open", pkg.Open) + m.Define("OpenFile", pkg.OpenFile) + m.Define("PathListSeparator", pkg.PathListSeparator) + m.Define("PathSeparator", pkg.PathSeparator) + m.Define("Pipe", pkg.Pipe) + m.Define("Readlink", pkg.Readlink) + m.Define("Remove", pkg.Remove) + m.Define("RemoveAll", pkg.RemoveAll) + m.Define("Rename", pkg.Rename) + m.Define("SEEK_CUR", pkg.SEEK_CUR) + m.Define("SEEK_END", pkg.SEEK_END) + m.Define("SEEK_SET", pkg.SEEK_SET) + m.Define("SameFile", pkg.SameFile) + m.Define("Setenv", pkg.Setenv) + m.Define("StartProcess", pkg.StartProcess) + m.Define("Stat", pkg.Stat) + m.Define("Stderr", pkg.Stderr) + m.Define("Stdin", pkg.Stdin) + m.Define("Stdout", pkg.Stdout) + m.Define("Symlink", pkg.Symlink) + m.Define("TempDir", pkg.TempDir) + m.Define("Truncate", pkg.Truncate) + + var v pkg.Signal + m.DefineType("Signal", reflect.TypeOf(&v).Elem()) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/os/os_appengine.go b/vendor/github.com/mattn/anko/builtins/os/os_appengine.go new file mode 100644 index 0000000000..41371ae8ab --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/os/os_appengine.go @@ -0,0 +1,10 @@ +// +build appengine + +package os + +import ( + "github.com/mattn/anko/vm" +) + +func handleAppEngine(m *vm.Env) { +} diff --git a/vendor/github.com/mattn/anko/builtins/os/os_nonappengine.go b/vendor/github.com/mattn/anko/builtins/os/os_nonappengine.go new file mode 100644 index 0000000000..ce65a61439 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/os/os_nonappengine.go @@ -0,0 +1,13 @@ +// +build !appengine + +package os + +import ( + "github.com/mattn/anko/vm" + pkg "os" + "reflect" +) + +func handleAppEngine(m *vm.Env) { + m.Define("Getppid", reflect.ValueOf(pkg.Getppid)) +} diff --git a/vendor/github.com/mattn/anko/builtins/os/signal/signal.go b/vendor/github.com/mattn/anko/builtins/os/signal/signal.go new file mode 100644 index 0000000000..7aa59e3494 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/os/signal/signal.go @@ -0,0 +1,18 @@ +// Package signal implements signal interface for anko script. +package signal + +import ( + pkg "os/signal" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("os/signal") + + //m.Define("Ignore", pkg.Ignore) + m.Define("Notify", pkg.Notify) + //m.Define("Reset", pkg.Reset) + m.Define("Stop", pkg.Stop) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/path/filepath/filepath.go b/vendor/github.com/mattn/anko/builtins/path/filepath/filepath.go new file mode 100644 index 0000000000..9cedb5ed1c --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/path/filepath/filepath.go @@ -0,0 +1,32 @@ +// Package path implements path manipulation interface for anko script. +package filepath + +import ( + f "path/filepath" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("filepath") + m.Define("Join", f.Join) + m.Define("Clean", f.Join) + m.Define("Abs", f.Abs) + m.Define("Base", f.Base) + m.Define("Clean", f.Clean) + m.Define("Dir", f.Dir) + m.Define("EvalSymlinks", f.EvalSymlinks) + m.Define("Ext", f.Ext) + m.Define("FromSlash", f.FromSlash) + m.Define("Glob", f.Glob) + m.Define("HasPrefix", f.HasPrefix) + m.Define("IsAbs", f.IsAbs) + m.Define("Join", f.Join) + m.Define("Match", f.Match) + m.Define("Rel", f.Rel) + m.Define("Split", f.Split) + m.Define("SplitList", f.SplitList) + m.Define("ToSlash", f.ToSlash) + m.Define("VolumeName", f.VolumeName) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/path/path.go b/vendor/github.com/mattn/anko/builtins/path/path.go new file mode 100644 index 0000000000..2e7cd41e77 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/path/path.go @@ -0,0 +1,22 @@ +// Package path implements path interface for anko script. +package path + +import ( + pkg "path" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("path") + m.Define("Base", pkg.Base) + m.Define("Clean", pkg.Clean) + m.Define("Dir", pkg.Dir) + m.Define("ErrBadPattern", pkg.ErrBadPattern) + m.Define("Ext", pkg.Ext) + m.Define("IsAbs", pkg.IsAbs) + m.Define("Join", pkg.Join) + m.Define("Match", pkg.Match) + m.Define("Split", pkg.Split) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/regexp/regexp.go b/vendor/github.com/mattn/anko/builtins/regexp/regexp.go new file mode 100644 index 0000000000..8848a3ce3f --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/regexp/regexp.go @@ -0,0 +1,21 @@ +// Package regexp implements regexp interface for anko script. +package sort + +import ( + r "regexp" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("sort") + m.Define("Match", r.Match) + m.Define("MatchReader", r.MatchReader) + m.Define("MatchString", r.MatchString) + m.Define("QuoteMeta", r.QuoteMeta) + m.Define("Compile", r.Compile) + m.Define("CompilePOSIX", r.CompilePOSIX) + m.Define("MustCompile", r.MustCompile) + m.Define("MustCompilePOSIX", r.MustCompilePOSIX) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/runtime/runtime.go b/vendor/github.com/mattn/anko/builtins/runtime/runtime.go new file mode 100644 index 0000000000..29d7087c1c --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/runtime/runtime.go @@ -0,0 +1,45 @@ +// Package runtime implements runtime interface for anko script. +package runtime + +import ( + "github.com/mattn/anko/vm" + pkg "runtime" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewModule("runtime") + //m.Define("BlockProfile", pkg.BlockProfile) + //m.Define("Breakpoint", pkg.Breakpoint) + //m.Define("CPUProfile", pkg.CPUProfile) + //m.Define("Caller", pkg.Caller) + //m.Define("Callers", pkg.Callers) + //m.Define("CallersFrames", pkg.CallersFrames) + //m.Define("Compiler", pkg.Compiler) + //m.Define("FuncForPC", pkg.FuncForPC) + m.Define("GC", pkg.GC) + m.Define("GOARCH", pkg.GOARCH) + m.Define("GOMAXPROCS", pkg.GOMAXPROCS) + m.Define("GOOS", pkg.GOOS) + m.Define("GOROOT", pkg.GOROOT) + //m.Define("Goexit", pkg.Goexit) + //m.Define("GoroutineProfile", pkg.GoroutineProfile) + //m.Define("Gosched", pkg.Gosched) + //m.Define("LockOSThread", pkg.LockOSThread) + //m.Define("MemProfile", pkg.MemProfile) + //m.Define("MemProfileRate", pkg.MemProfileRate) + //m.Define("NumCPU", pkg.NumCPU) + //m.Define("NumCgoCall", pkg.NumCgoCall) + //m.Define("NumGoroutine", pkg.NumGoroutine) + //m.Define("ReadMemStats", pkg.ReadMemStats) + //m.Define("ReadTrace", pkg.ReadTrace) + //m.Define("SetBlockProfileRate", pkg.SetBlockProfileRate) + //m.Define("SetCPUProfileRate", pkg.SetCPUProfileRate) + //m.Define("SetFinalizer", pkg.SetFinalizer) + //m.Define("Stack", pkg.Stack) + //m.Define("StartTrace", pkg.StartTrace) + //m.Define("StopTrace", pkg.StopTrace) + //m.Define("ThreadCreateProfile", pkg.ThreadCreateProfile) + //m.Define("UnlockOSThread", pkg.UnlockOSThread) + //m.Define("Version", pkg.Version) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/sort/sort.go b/vendor/github.com/mattn/anko/builtins/sort/sort.go new file mode 100644 index 0000000000..72749d7221 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/sort/sort.go @@ -0,0 +1,43 @@ +// Package sort implements sort interface for anko script. +package sort + +import ( + s "sort" + + "github.com/mattn/anko/vm" +) + +type is []interface{} + +func (p is) Len() int { return len(p) } +func (p is) Less(i, j int) bool { return p[i].(int64) < p[j].(int64) } +func (p is) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +type fs []interface{} + +func (p fs) Len() int { return len(p) } +func (p fs) Less(i, j int) bool { return p[i].(float64) < p[j].(float64) } +func (p fs) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +type ss []interface{} + +func (p ss) Len() int { return len(p) } +func (p ss) Less(i, j int) bool { return p[i].(string) < p[j].(string) } +func (p ss) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("sort") + m.Define("Ints", func(ints []interface{}) []interface{} { + s.Sort(is(ints)) + return ints + }) + m.Define("Float64s", func(ints []interface{}) []interface{} { + s.Sort(is(ints)) + return ints + }) + m.Define("Strings", func(ints []interface{}) []interface{} { + s.Sort(is(ints)) + return ints + }) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/strings/strings.go b/vendor/github.com/mattn/anko/builtins/strings/strings.go new file mode 100644 index 0000000000..7adb3e9736 --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/strings/strings.go @@ -0,0 +1,56 @@ +// Package strings implements strings interface for anko script. +package strings + +import ( + pkg "strings" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("strings") + m.Define("Contains", pkg.Contains) + m.Define("ContainsAny", pkg.ContainsAny) + m.Define("ContainsRune", pkg.ContainsRune) + m.Define("Count", pkg.Count) + m.Define("EqualFold", pkg.EqualFold) + m.Define("Fields", pkg.Fields) + m.Define("FieldsFunc", pkg.FieldsFunc) + m.Define("HasPrefix", pkg.HasPrefix) + m.Define("HasSuffix", pkg.HasSuffix) + m.Define("Index", pkg.Index) + m.Define("IndexAny", pkg.IndexAny) + m.Define("IndexByte", pkg.IndexByte) + m.Define("IndexFunc", pkg.IndexFunc) + m.Define("IndexRune", pkg.IndexRune) + m.Define("Join", pkg.Join) + m.Define("LastIndex", pkg.LastIndex) + m.Define("LastIndexAny", pkg.LastIndexAny) + m.Define("LastIndexFunc", pkg.LastIndexFunc) + m.Define("Map", pkg.Map) + m.Define("NewReader", pkg.NewReader) + m.Define("NewReplacer", pkg.NewReplacer) + m.Define("Repeat", pkg.Repeat) + m.Define("Replace", pkg.Replace) + m.Define("Split", pkg.Split) + m.Define("SplitAfter", pkg.SplitAfter) + m.Define("SplitAfterN", pkg.SplitAfterN) + m.Define("SplitN", pkg.SplitN) + m.Define("Title", pkg.Title) + m.Define("ToLower", pkg.ToLower) + m.Define("ToLowerSpecial", pkg.ToLowerSpecial) + m.Define("ToTitle", pkg.ToTitle) + m.Define("ToTitleSpecial", pkg.ToTitleSpecial) + m.Define("ToUpper", pkg.ToUpper) + m.Define("ToUpperSpecial", pkg.ToUpperSpecial) + m.Define("Trim", pkg.Trim) + m.Define("TrimFunc", pkg.TrimFunc) + m.Define("TrimLeft", pkg.TrimLeft) + m.Define("TrimLeftFunc", pkg.TrimLeftFunc) + m.Define("TrimPrefix", pkg.TrimPrefix) + m.Define("TrimRight", pkg.TrimRight) + m.Define("TrimRightFunc", pkg.TrimRightFunc) + m.Define("TrimSpace", pkg.TrimSpace) + m.Define("TrimSuffix", pkg.TrimSuffix) + return m +} diff --git a/vendor/github.com/mattn/anko/builtins/time/time.go b/vendor/github.com/mattn/anko/builtins/time/time.go new file mode 100644 index 0000000000..6739d2e8ba --- /dev/null +++ b/vendor/github.com/mattn/anko/builtins/time/time.go @@ -0,0 +1,28 @@ +// Package time implements time interface for anko script. +package time + +import ( + t "time" + + "github.com/mattn/anko/vm" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewPackage("time") + m.Define("After", t.After) + m.Define("Sleep", t.Sleep) + m.Define("Tick", t.Tick) + m.Define("Since", t.Since) + m.Define("FixedZone", t.FixedZone) + m.Define("LoadLocation", t.LoadLocation) + m.Define("NewTicker", t.NewTicker) + m.Define("Date", t.Date) + m.Define("Now", t.Now) + m.Define("Parse", t.Parse) + m.Define("ParseDuration", t.ParseDuration) + m.Define("ParseInLocation", t.ParseInLocation) + m.Define("Unix", t.Unix) + m.Define("AfterFunc", t.AfterFunc) + m.Define("NewTimer", t.NewTimer) + return m +} diff --git a/vendor/github.com/mattn/anko/misc/vim/ftdetect/ank.vim b/vendor/github.com/mattn/anko/misc/vim/ftdetect/ank.vim new file mode 100644 index 0000000000..13bd684386 --- /dev/null +++ b/vendor/github.com/mattn/anko/misc/vim/ftdetect/ank.vim @@ -0,0 +1 @@ +au BufNewFile,BufRead *.ank setlocal filetype=anko diff --git a/vendor/github.com/mattn/anko/misc/vim/ftplugin/anko/comment.vim b/vendor/github.com/mattn/anko/misc/vim/ftplugin/anko/comment.vim new file mode 100644 index 0000000000..35f52f9174 --- /dev/null +++ b/vendor/github.com/mattn/anko/misc/vim/ftplugin/anko/comment.vim @@ -0,0 +1,11 @@ +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +setlocal comments=s1:# +setlocal commentstring=#\ %s + +let b:undo_ftplugin = "setl com< cms<" + +" vim:ts=4:sw=4:et diff --git a/vendor/github.com/mattn/anko/misc/vim/ftplugin/anko/play.vim b/vendor/github.com/mattn/anko/misc/vim/ftplugin/anko/play.vim new file mode 100644 index 0000000000..6da8751a04 --- /dev/null +++ b/vendor/github.com/mattn/anko/misc/vim/ftplugin/anko/play.vim @@ -0,0 +1,15 @@ +scriptencoding utf-8 + +function! s:play() + let code = join(getline(1, '$'), "\n") + let res = webapi#http#post("http://play-anko.appspot.com/api/play", {"code": code}) + if res.status == "200" + echo iconv(res.content, "utf-8", &encoding) + else + for line in split(res.content, "\n") + echohl Error | echomsg iconv(line, "utf-8", &encoding) | echohl None + endfor + endif +endfunction + +command! -buffer PlayAnko call s:play() diff --git a/vendor/github.com/mattn/anko/misc/vim/syntax/anko.vim b/vendor/github.com/mattn/anko/misc/vim/syntax/anko.vim new file mode 100644 index 0000000000..9be5c837d8 --- /dev/null +++ b/vendor/github.com/mattn/anko/misc/vim/syntax/anko.vim @@ -0,0 +1,100 @@ +if exists("b:current_syntax") + finish +endif + +syn case match + +syn keyword ankoDirective module +syn keyword ankoDeclaration var + +hi def link ankoDirective Statement +hi def link ankoDeclaration Type + +syn keyword ankoStatement return break continue throw +syn keyword ankoConditional if else switch try catch finally +syn keyword ankoLabel case default +syn keyword ankoRepeat for range + +hi def link ankoStatement Statement +hi def link ankoConditional Conditional +hi def link ankoLabel Label +hi def link ankoRepeat Repeat + +syn match ankoDeclaration /\/ +syn match ankoDeclaration /^func\>/ + +syn keyword ankoCast bytes runes string + +hi def link ankoCast Type + +syn keyword ankoBuiltins keys len +syn keyword ankoBuiltins println printf print +syn keyword ankoConstants true false nil + +hi def link ankoBuiltins Keyword +hi def link ankoConstants Keyword + +" Comments; their contents +syn keyword ankoTodo contained TODO FIXME XXX BUG +syn cluster ankoCommentGroup contains=ankoTodo +syn region ankoComment start="#" end="$" contains=@ankoCommentGroup,@Spell + +hi def link ankoComment Comment +hi def link ankoTodo Todo + +" anko escapes +syn match ankoEscapeOctal display contained "\\[0-7]\{3}" +syn match ankoEscapeC display contained +\\[abfnrtv\\'"]+ +syn match ankoEscapeX display contained "\\x\x\{2}" +syn match ankoEscapeU display contained "\\u\x\{4}" +syn match ankoEscapeBigU display contained "\\U\x\{8}" +syn match ankoEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+ + +hi def link ankoEscapeOctal ankoSpecialString +hi def link ankoEscapeC ankoSpecialString +hi def link ankoEscapeX ankoSpecialString +hi def link ankoEscapeU ankoSpecialString +hi def link ankoEscapeBigU ankoSpecialString +hi def link ankoSpecialString Special +hi def link ankoEscapeError Error + +" Strings and their contents +syn cluster ankoStringGroup contains=ankoEscapeOctal,ankoEscapeC,ankoEscapeX,ankoEscapeU,ankoEscapeBigU,ankoEscapeError +syn region ankoString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@ankoStringGroup +syn region ankoRawString start=+`+ end=+`+ + +hi def link ankoString String +hi def link ankoRawString String + +" Characters; their contents +syn cluster ankoCharacterGroup contains=ankoEscapeOctal,ankoEscapeC,ankoEscapeX,ankoEscapeU,ankoEscapeBigU +syn region ankoCharacter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@ankoCharacterGroup + +hi def link ankoCharacter Character + +" Regions +syn region ankoBlock start="{" end="}" transparent fold +syn region ankoParen start='(' end=')' transparent + +" Integers +syn match ankoDecimalInt "\<\d\+\([Ee]\d\+\)\?\>" +syn match ankoHexadecimalInt "\<0x\x\+\>" +syn match ankoOctalInt "\<0\o\+\>" +syn match ankoOctalError "\<0\o*[89]\d*\>" + +hi def link ankoDecimalInt Integer +hi def link ankoHexadecimalInt Integer +hi def link ankoOctalInt Integer +hi def link Integer Number + +" Floating point +syn match ankoFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>" +syn match ankoFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>" +syn match ankoFloat "\<\d\+[Ee][-+]\d\+\>" + +hi def link ankoFloat Float +hi def link ankoImaginary Number + +syn sync minlines=500 + +let b:current_syntax = "anko" diff --git a/vendor/github.com/mattn/anko/parser/Makefile b/vendor/github.com/mattn/anko/parser/Makefile new file mode 100644 index 0000000000..8b33e31724 --- /dev/null +++ b/vendor/github.com/mattn/anko/parser/Makefile @@ -0,0 +1,4 @@ +all : parser.go + +parser.go : parser.go.y + go tool yacc -o $@ parser.go.y diff --git a/vendor/github.com/mattn/anko/parser/lexer.go b/vendor/github.com/mattn/anko/parser/lexer.go new file mode 100644 index 0000000000..ea0fc49300 --- /dev/null +++ b/vendor/github.com/mattn/anko/parser/lexer.go @@ -0,0 +1,530 @@ +// Package parser implements parser for anko. +package parser + +import ( + "errors" + "fmt" + + "github.com/mattn/anko/ast" +) + +const ( + EOF = -1 // End of file. + EOL = '\n' // End of line. +) + +// Error provides a convenient interface for handling runtime error. +// It can be Error inteface with type cast which can call Pos(). +type Error struct { + Message string + Pos ast.Position + Filename string + Fatal bool +} + +// Error returns the error message. +func (e *Error) Error() string { + return e.Message +} + +// Scanner stores informations for lexer. +type Scanner struct { + src []rune + offset int + lineHead int + line int +} + +// opName is correction of operation names. +var opName = map[string]int{ + "func": FUNC, + "return": RETURN, + "var": VAR, + "throw": THROW, + "if": IF, + "for": FOR, + "break": BREAK, + "continue": CONTINUE, + "in": IN, + "else": ELSE, + "new": NEW, + "true": TRUE, + "false": FALSE, + "nil": NIL, + "module": MODULE, + "try": TRY, + "catch": CATCH, + "finally": FINALLY, + "switch": SWITCH, + "case": CASE, + "default": DEFAULT, + "go": GO, + "chan": CHAN, + "make": MAKE, +} + +// Init resets code to scan. +func (s *Scanner) Init(src string) { + s.src = []rune(src) +} + +// Scan analyses token, and decide identify or literals. +func (s *Scanner) Scan() (tok int, lit string, pos ast.Position, err error) { +retry: + s.skipBlank() + pos = s.pos() + switch ch := s.peek(); { + case isLetter(ch): + lit, err = s.scanIdentifier() + if err != nil { + return + } + if name, ok := opName[lit]; ok { + tok = name + } else { + tok = IDENT + } + case isDigit(ch): + tok = NUMBER + lit, err = s.scanNumber() + if err != nil { + return + } + case ch == '"': + tok = STRING + lit, err = s.scanString('"') + if err != nil { + return + } + case ch == '\'': + tok = STRING + lit, err = s.scanString('\'') + if err != nil { + return + } + case ch == '`': + tok = STRING + lit, err = s.scanRawString() + if err != nil { + return + } + default: + switch ch { + case EOF: + tok = EOF + case '#': + for !isEOL(s.peek()) { + s.next() + } + goto retry + case '!': + s.next() + switch s.peek() { + case '=': + tok = NEQ + lit = "!=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '=': + s.next() + switch s.peek() { + case '=': + tok = EQEQ + lit = "==" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '+': + s.next() + switch s.peek() { + case '+': + tok = PLUSPLUS + lit = "++" + case '=': + tok = PLUSEQ + lit = "+=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '-': + s.next() + switch s.peek() { + case '-': + tok = MINUSMINUS + lit = "--" + case '=': + tok = MINUSEQ + lit = "-=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '*': + s.next() + switch s.peek() { + case '*': + tok = POW + lit = "**" + case '=': + tok = MULEQ + lit = "*=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '/': + s.next() + switch s.peek() { + case '=': + tok = DIVEQ + lit = "/=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '>': + s.next() + switch s.peek() { + case '=': + tok = GE + lit = ">=" + case '>': + tok = SHIFTRIGHT + lit = ">>" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '<': + s.next() + switch s.peek() { + case '-': + tok = OPCHAN + lit = "<-" + case '=': + tok = LE + lit = "<=" + case '<': + tok = SHIFTLEFT + lit = "<<" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '|': + s.next() + switch s.peek() { + case '|': + tok = OROR + lit = "||" + case '=': + tok = OREQ + lit = "|=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '&': + s.next() + switch s.peek() { + case '&': + tok = ANDAND + lit = "&&" + case '=': + tok = ANDEQ + lit = "&=" + default: + s.back() + tok = int(ch) + lit = string(ch) + } + case '.': + s.next() + if s.peek() == '.' { + s.next() + if s.peek() == '.' { + tok = VARARG + } else { + err = fmt.Errorf(`syntax error "%s"`, "..") + return + } + } else { + s.back() + tok = int(ch) + lit = string(ch) + } + case '(', ')', ':', ';', '%', '?', '{', '}', ',', '[', ']', '^', '\n': + s.next() + if ch == '[' && s.peek() == ']' { + s.next() + if isLetter(s.peek()) { + s.back() + tok = ARRAYLIT + lit = "[]" + } else { + s.back() + s.back() + tok = int(ch) + lit = string(ch) + } + } else { + s.back() + tok = int(ch) + lit = string(ch) + } + default: + err = fmt.Errorf(`syntax error "%s"`, string(ch)) + return + } + s.next() + } + return +} + +// isLetter returns true if the rune is a letter for identity. +func isLetter(ch rune) bool { + return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' +} + +// isDigit returns true if the rune is a number. +func isDigit(ch rune) bool { + return '0' <= ch && ch <= '9' +} + +// isHex returns true if the rune is a hex digits. +func isHex(ch rune) bool { + return ('0' <= ch && ch <= '9') || ('a' <= ch && ch <= 'f') || ('A' <= ch && ch <= 'F') +} + +// isEOL returns true if the rune is at end-of-line or end-of-file. +func isEOL(ch rune) bool { + return ch == '\n' || ch == -1 +} + +// isBlank returns true if the rune is empty character.. +func isBlank(ch rune) bool { + return ch == ' ' || ch == '\t' || ch == '\r' +} + +// peek returns current rune in the code. +func (s *Scanner) peek() rune { + if s.reachEOF() { + return EOF + } + return s.src[s.offset] +} + +// next moves offset to next. +func (s *Scanner) next() { + if !s.reachEOF() { + if s.peek() == '\n' { + s.lineHead = s.offset + 1 + s.line++ + } + s.offset++ + } +} + +// current returns the current offset. +func (s *Scanner) current() int { + return s.offset +} + +// offset sets the offset value. +func (s *Scanner) set(o int) { + s.offset = o +} + +// back moves back offset once to top. +func (s *Scanner) back() { + s.offset-- +} + +// reachEOF returns true if offset is at end-of-file. +func (s *Scanner) reachEOF() bool { + return len(s.src) <= s.offset +} + +// pos returns the position of current. +func (s *Scanner) pos() ast.Position { + return ast.Position{Line: s.line + 1, Column: s.offset - s.lineHead + 1} +} + +// skipBlank moves position into non-black character. +func (s *Scanner) skipBlank() { + for isBlank(s.peek()) { + s.next() + } +} + +// scanIdentifier returns identifier begining at current position. +func (s *Scanner) scanIdentifier() (string, error) { + var ret []rune + for { + if !isLetter(s.peek()) && !isDigit(s.peek()) { + break + } + ret = append(ret, s.peek()) + s.next() + } + return string(ret), nil +} + +// scanNumber returns number begining at current position. +func (s *Scanner) scanNumber() (string, error) { + var ret []rune + ch := s.peek() + ret = append(ret, ch) + s.next() + if ch == '0' && s.peek() == 'x' { + ret = append(ret, s.peek()) + s.next() + for isHex(s.peek()) { + ret = append(ret, s.peek()) + s.next() + } + } else { + for isDigit(s.peek()) || s.peek() == '.' { + ret = append(ret, s.peek()) + s.next() + } + if s.peek() == 'e' { + ret = append(ret, s.peek()) + s.next() + if isDigit(s.peek()) || s.peek() == '+' || s.peek() == '-' { + ret = append(ret, s.peek()) + s.next() + for isDigit(s.peek()) || s.peek() == '.' { + ret = append(ret, s.peek()) + s.next() + } + } + for isDigit(s.peek()) || s.peek() == '.' { + ret = append(ret, s.peek()) + s.next() + } + } + if isLetter(s.peek()) { + return "", errors.New("identifier starts immediately after numeric literal") + } + } + return string(ret), nil +} + +// scanRawString returns raw-string starting at current position. +func (s *Scanner) scanRawString() (string, error) { + var ret []rune + for { + s.next() + if s.peek() == EOF { + return "", errors.New("unexpected EOF") + break + } + if s.peek() == '`' { + s.next() + break + } + ret = append(ret, s.peek()) + } + return string(ret), nil +} + +// scanString returns string starting at current position. +// This handles backslash escaping. +func (s *Scanner) scanString(l rune) (string, error) { + var ret []rune +eos: + for { + s.next() + switch s.peek() { + case EOL: + return "", errors.New("unexpected EOL") + case EOF: + return "", errors.New("unexpected EOF") + case l: + s.next() + break eos + case '\\': + s.next() + switch s.peek() { + case 'b': + ret = append(ret, '\b') + continue + case 'f': + ret = append(ret, '\f') + continue + case 'r': + ret = append(ret, '\r') + continue + case 'n': + ret = append(ret, '\n') + continue + case 't': + ret = append(ret, '\t') + continue + } + ret = append(ret, s.peek()) + continue + default: + ret = append(ret, s.peek()) + } + } + return string(ret), nil +} + +// Lexer provides inteface to parse codes. +type Lexer struct { + s *Scanner + lit string + pos ast.Position + e error + stmts []ast.Stmt +} + +// Lex scans the token and literals. +func (l *Lexer) Lex(lval *yySymType) int { + tok, lit, pos, err := l.s.Scan() + if err != nil { + l.e = &Error{Message: fmt.Sprintf("%s", err.Error()), Pos: pos, Fatal: true} + } + lval.tok = ast.Token{Tok: tok, Lit: lit} + lval.tok.SetPosition(pos) + l.lit = lit + l.pos = pos + return tok +} + +// Error sets parse error. +func (l *Lexer) Error(msg string) { + l.e = &Error{Message: msg, Pos: l.pos, Fatal: false} +} + +// Parser provides way to parse the code using Scanner. +func Parse(s *Scanner) ([]ast.Stmt, error) { + l := Lexer{s: s} + if yyParse(&l) != 0 { + return nil, l.e + } + return l.stmts, l.e +} + +// ParserSrc provides way to parse the code from source. +func ParseSrc(src string) ([]ast.Stmt, error) { + scanner := &Scanner{ + src: []rune(src), + } + return Parse(scanner) +} diff --git a/vendor/github.com/mattn/anko/parser/parser.go b/vendor/github.com/mattn/anko/parser/parser.go new file mode 100644 index 0000000000..01f5adf689 --- /dev/null +++ b/vendor/github.com/mattn/anko/parser/parser.go @@ -0,0 +1,1997 @@ +//line parser.go.y:2 +package parser + +import __yyfmt__ "fmt" + +//line parser.go.y:2 +import ( + "github.com/mattn/anko/ast" +) + +//line parser.go.y:26 +type yySymType struct { + yys int + compstmt []ast.Stmt + stmt_if ast.Stmt + stmt_default ast.Stmt + stmt_case ast.Stmt + stmt_cases []ast.Stmt + stmts []ast.Stmt + stmt ast.Stmt + typ ast.Type + expr ast.Expr + exprs []ast.Expr + expr_many []ast.Expr + expr_lets ast.Expr + expr_pair ast.Expr + expr_pairs []ast.Expr + expr_idents []string + tok ast.Token + term ast.Token + terms ast.Token + opt_terms ast.Token +} + +const IDENT = 57346 +const NUMBER = 57347 +const STRING = 57348 +const ARRAY = 57349 +const VARARG = 57350 +const FUNC = 57351 +const RETURN = 57352 +const VAR = 57353 +const THROW = 57354 +const IF = 57355 +const ELSE = 57356 +const FOR = 57357 +const IN = 57358 +const EQEQ = 57359 +const NEQ = 57360 +const GE = 57361 +const LE = 57362 +const OROR = 57363 +const ANDAND = 57364 +const NEW = 57365 +const TRUE = 57366 +const FALSE = 57367 +const NIL = 57368 +const MODULE = 57369 +const TRY = 57370 +const CATCH = 57371 +const FINALLY = 57372 +const PLUSEQ = 57373 +const MINUSEQ = 57374 +const MULEQ = 57375 +const DIVEQ = 57376 +const ANDEQ = 57377 +const OREQ = 57378 +const BREAK = 57379 +const CONTINUE = 57380 +const PLUSPLUS = 57381 +const MINUSMINUS = 57382 +const POW = 57383 +const SHIFTLEFT = 57384 +const SHIFTRIGHT = 57385 +const SWITCH = 57386 +const CASE = 57387 +const DEFAULT = 57388 +const GO = 57389 +const CHAN = 57390 +const MAKE = 57391 +const OPCHAN = 57392 +const ARRAYLIT = 57393 +const UNARY = 57394 + +var yyToknames = [...]string{ + "$end", + "error", + "$unk", + "IDENT", + "NUMBER", + "STRING", + "ARRAY", + "VARARG", + "FUNC", + "RETURN", + "VAR", + "THROW", + "IF", + "ELSE", + "FOR", + "IN", + "EQEQ", + "NEQ", + "GE", + "LE", + "OROR", + "ANDAND", + "NEW", + "TRUE", + "FALSE", + "NIL", + "MODULE", + "TRY", + "CATCH", + "FINALLY", + "PLUSEQ", + "MINUSEQ", + "MULEQ", + "DIVEQ", + "ANDEQ", + "OREQ", + "BREAK", + "CONTINUE", + "PLUSPLUS", + "MINUSMINUS", + "POW", + "SHIFTLEFT", + "SHIFTRIGHT", + "SWITCH", + "CASE", + "DEFAULT", + "GO", + "CHAN", + "MAKE", + "OPCHAN", + "ARRAYLIT", + "'='", + "'?'", + "':'", + "','", + "'>'", + "'<'", + "'+'", + "'-'", + "'*'", + "'/'", + "'%'", + "UNARY", + "'{'", + "'}'", + "';'", + "'.'", + "'!'", + "'^'", + "'&'", + "'('", + "')'", + "'['", + "']'", + "'|'", + "'\\n'", +} +var yyStatenames = [...]string{} + +const yyEofCode = 1 +const yyErrCode = 2 +const yyInitialStackSize = 16 + +//line parser.go.y:705 + +//line yacctab:1 +var yyExca = [...]int{ + -1, 0, + 1, 3, + -2, 121, + -1, 1, + 1, -1, + -2, 0, + -1, 2, + 55, 48, + -2, 1, + -1, 10, + 55, 49, + -2, 24, + -1, 43, + 55, 48, + -2, 122, + -1, 85, + 65, 3, + -2, 121, + -1, 88, + 55, 49, + -2, 43, + -1, 90, + 65, 3, + -2, 121, + -1, 97, + 1, 57, + 8, 57, + 45, 57, + 46, 57, + 52, 57, + 54, 57, + 55, 57, + 64, 57, + 65, 57, + 66, 57, + 72, 57, + 74, 57, + 76, 57, + -2, 52, + -1, 99, + 1, 59, + 8, 59, + 45, 59, + 46, 59, + 52, 59, + 54, 59, + 55, 59, + 64, 59, + 65, 59, + 66, 59, + 72, 59, + 74, 59, + 76, 59, + -2, 52, + -1, 127, + 17, 0, + 18, 0, + -2, 85, + -1, 128, + 17, 0, + 18, 0, + -2, 86, + -1, 147, + 55, 49, + -2, 43, + -1, 149, + 65, 3, + -2, 121, + -1, 151, + 65, 3, + -2, 121, + -1, 153, + 65, 1, + -2, 36, + -1, 156, + 65, 3, + -2, 121, + -1, 178, + 65, 3, + -2, 121, + -1, 220, + 55, 50, + -2, 44, + -1, 221, + 1, 45, + 45, 45, + 46, 45, + 52, 45, + 55, 51, + 65, 45, + 66, 45, + 76, 45, + -2, 52, + -1, 228, + 1, 51, + 8, 51, + 45, 51, + 46, 51, + 55, 51, + 65, 51, + 66, 51, + 72, 51, + 74, 51, + 76, 51, + -2, 52, + -1, 230, + 65, 3, + -2, 121, + -1, 232, + 65, 3, + -2, 121, + -1, 245, + 65, 3, + -2, 121, + -1, 256, + 1, 106, + 8, 106, + 45, 106, + 46, 106, + 52, 106, + 54, 106, + 55, 106, + 64, 106, + 65, 106, + 66, 106, + 72, 106, + 74, 106, + 76, 106, + -2, 104, + -1, 258, + 1, 110, + 8, 110, + 45, 110, + 46, 110, + 52, 110, + 54, 110, + 55, 110, + 64, 110, + 65, 110, + 66, 110, + 72, 110, + 74, 110, + 76, 110, + -2, 108, + -1, 269, + 65, 3, + -2, 121, + -1, 274, + 65, 3, + -2, 121, + -1, 275, + 65, 3, + -2, 121, + -1, 280, + 1, 105, + 8, 105, + 45, 105, + 46, 105, + 52, 105, + 54, 105, + 55, 105, + 64, 105, + 65, 105, + 66, 105, + 72, 105, + 74, 105, + 76, 105, + -2, 103, + -1, 281, + 1, 109, + 8, 109, + 45, 109, + 46, 109, + 52, 109, + 54, 109, + 55, 109, + 64, 109, + 65, 109, + 66, 109, + 72, 109, + 74, 109, + 76, 109, + -2, 107, + -1, 287, + 65, 3, + -2, 121, + -1, 288, + 65, 3, + -2, 121, + -1, 291, + 45, 3, + 46, 3, + 65, 3, + -2, 121, + -1, 295, + 65, 3, + -2, 121, + -1, 302, + 45, 3, + 46, 3, + 65, 3, + -2, 121, + -1, 315, + 65, 3, + -2, 121, + -1, 316, + 65, 3, + -2, 121, +} + +const yyNprod = 127 +const yyPrivate = 57344 + +var yyTokenNames []string +var yyStates []string + +const yyLast = 2223 + +var yyAct = [...]int{ + + 81, 169, 237, 10, 217, 238, 45, 6, 92, 211, + 93, 2, 1, 250, 281, 42, 82, 7, 209, 88, + 6, 91, 280, 276, 94, 95, 96, 98, 100, 6, + 7, 11, 40, 154, 246, 173, 105, 93, 108, 7, + 110, 243, 112, 225, 10, 103, 104, 80, 116, 117, + 89, 119, 120, 121, 122, 123, 124, 125, 126, 127, + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, + 138, 102, 172, 139, 140, 141, 142, 166, 144, 145, + 147, 257, 64, 65, 66, 67, 68, 69, 92, 109, + 93, 155, 55, 261, 161, 255, 148, 153, 152, 115, + 115, 78, 199, 158, 320, 259, 182, 262, 164, 143, + 260, 146, 319, 254, 312, 147, 247, 205, 49, 259, + 309, 74, 76, 177, 77, 160, 72, 180, 148, 170, + 239, 240, 268, 308, 305, 304, 167, 301, 101, 292, + 286, 285, 148, 263, 252, 258, 179, 234, 231, 148, + 236, 188, 316, 148, 10, 192, 193, 229, 147, 256, + 186, 196, 187, 315, 189, 190, 200, 150, 295, 194, + 183, 198, 288, 207, 275, 274, 245, 149, 220, 210, + 212, 219, 224, 90, 148, 111, 226, 227, 279, 195, + 114, 222, 269, 115, 271, 213, 175, 157, 79, 176, + 8, 241, 314, 244, 242, 214, 215, 216, 239, 240, + 5, 310, 235, 84, 253, 44, 248, 206, 151, 170, + 282, 249, 223, 251, 218, 208, 204, 203, 165, 118, + 106, 83, 46, 4, 267, 168, 87, 43, 197, 17, + 270, 3, 0, 265, 113, 266, 0, 0, 0, 0, + 227, 0, 0, 278, 44, 61, 63, 0, 273, 0, + 0, 0, 283, 284, 0, 0, 0, 64, 65, 66, + 67, 68, 69, 0, 0, 70, 71, 55, 56, 57, + 0, 0, 289, 291, 0, 0, 78, 293, 294, 0, + 0, 0, 60, 62, 50, 51, 52, 53, 54, 307, + 299, 300, 302, 49, 303, 0, 74, 76, 306, 77, + 0, 72, 0, 0, 0, 311, 58, 59, 61, 63, + 73, 75, 0, 0, 0, 0, 0, 0, 317, 318, + 64, 65, 66, 67, 68, 69, 0, 0, 70, 71, + 55, 56, 57, 0, 0, 0, 0, 0, 0, 78, + 0, 0, 48, 0, 298, 60, 62, 50, 51, 52, + 53, 54, 0, 0, 0, 0, 49, 0, 0, 74, + 76, 297, 77, 0, 72, 58, 59, 61, 63, 73, + 75, 0, 0, 0, 0, 0, 0, 0, 0, 64, + 65, 66, 67, 68, 69, 0, 0, 70, 71, 55, + 56, 57, 0, 0, 0, 0, 0, 0, 78, 0, + 0, 48, 202, 0, 60, 62, 50, 51, 52, 53, + 54, 0, 0, 0, 0, 49, 0, 0, 74, 76, + 0, 77, 201, 72, 58, 59, 61, 63, 73, 75, + 0, 0, 0, 0, 0, 0, 0, 0, 64, 65, + 66, 67, 68, 69, 0, 0, 70, 71, 55, 56, + 57, 0, 0, 0, 0, 0, 0, 78, 0, 0, + 48, 185, 0, 60, 62, 50, 51, 52, 53, 54, + 0, 0, 0, 0, 49, 0, 0, 74, 76, 0, + 77, 184, 72, 58, 59, 61, 63, 73, 75, 0, + 0, 0, 0, 0, 0, 0, 0, 64, 65, 66, + 67, 68, 69, 0, 0, 70, 71, 55, 56, 57, + 0, 0, 0, 0, 0, 0, 78, 0, 0, 48, + 0, 0, 60, 62, 50, 51, 52, 53, 54, 0, + 0, 0, 0, 49, 0, 0, 74, 76, 313, 77, + 0, 72, 58, 59, 61, 63, 73, 75, 0, 0, + 0, 0, 0, 0, 0, 0, 64, 65, 66, 67, + 68, 69, 0, 0, 70, 71, 55, 56, 57, 0, + 0, 0, 0, 0, 0, 78, 0, 0, 48, 0, + 0, 60, 62, 50, 51, 52, 53, 54, 0, 0, + 0, 0, 49, 0, 0, 74, 76, 296, 77, 0, + 72, 58, 59, 61, 63, 73, 75, 0, 0, 0, + 0, 0, 0, 0, 0, 64, 65, 66, 67, 68, + 69, 0, 0, 70, 71, 55, 56, 57, 0, 0, + 0, 0, 0, 0, 78, 0, 0, 48, 290, 0, + 60, 62, 50, 51, 52, 53, 54, 0, 0, 0, + 0, 49, 0, 0, 74, 76, 0, 77, 0, 72, + 58, 59, 61, 63, 73, 75, 0, 0, 0, 0, + 0, 0, 0, 0, 64, 65, 66, 67, 68, 69, + 0, 0, 70, 71, 55, 56, 57, 0, 0, 0, + 0, 0, 0, 78, 0, 0, 48, 0, 0, 60, + 62, 50, 51, 52, 53, 54, 0, 287, 0, 0, + 49, 0, 0, 74, 76, 0, 77, 0, 72, 58, + 59, 61, 63, 73, 75, 0, 0, 0, 0, 0, + 0, 0, 0, 64, 65, 66, 67, 68, 69, 0, + 0, 70, 71, 55, 56, 57, 0, 0, 0, 0, + 0, 0, 78, 0, 0, 48, 0, 0, 60, 62, + 50, 51, 52, 53, 54, 0, 0, 0, 0, 49, + 0, 0, 74, 76, 0, 77, 272, 72, 58, 59, + 61, 63, 73, 75, 0, 0, 0, 0, 0, 0, + 0, 0, 64, 65, 66, 67, 68, 69, 0, 0, + 70, 71, 55, 56, 57, 0, 0, 0, 0, 0, + 0, 78, 0, 0, 48, 0, 0, 60, 62, 50, + 51, 52, 53, 54, 0, 0, 0, 0, 49, 0, + 0, 74, 76, 0, 77, 264, 72, 58, 59, 61, + 63, 73, 75, 0, 0, 0, 0, 0, 0, 0, + 0, 64, 65, 66, 67, 68, 69, 0, 0, 70, + 71, 55, 56, 57, 0, 0, 0, 0, 0, 0, + 78, 0, 0, 48, 0, 0, 60, 62, 50, 51, + 52, 53, 54, 0, 0, 0, 233, 49, 0, 0, + 74, 76, 0, 77, 0, 72, 58, 59, 61, 63, + 73, 75, 0, 0, 0, 0, 0, 0, 0, 0, + 64, 65, 66, 67, 68, 69, 0, 0, 70, 71, + 55, 56, 57, 0, 0, 0, 0, 0, 0, 78, + 0, 0, 48, 0, 0, 60, 62, 50, 51, 52, + 53, 54, 0, 232, 0, 0, 49, 0, 0, 74, + 76, 0, 77, 0, 72, 58, 59, 61, 63, 73, + 75, 0, 0, 0, 0, 0, 0, 0, 0, 64, + 65, 66, 67, 68, 69, 0, 0, 70, 71, 55, + 56, 57, 0, 0, 0, 0, 0, 0, 78, 0, + 0, 48, 0, 0, 60, 62, 50, 51, 52, 53, + 54, 0, 230, 0, 0, 49, 0, 0, 74, 76, + 0, 77, 0, 72, 58, 59, 61, 63, 73, 75, + 0, 0, 0, 0, 0, 0, 0, 0, 64, 65, + 66, 67, 68, 69, 0, 0, 70, 71, 55, 56, + 57, 0, 0, 0, 0, 0, 0, 78, 0, 0, + 48, 181, 0, 60, 62, 50, 51, 52, 53, 54, + 0, 0, 0, 0, 49, 0, 0, 74, 76, 0, + 77, 0, 72, 58, 59, 61, 63, 73, 75, 0, + 0, 0, 0, 0, 0, 0, 0, 64, 65, 66, + 67, 68, 69, 0, 0, 70, 71, 55, 56, 57, + 0, 0, 0, 0, 0, 0, 78, 0, 0, 48, + 0, 0, 60, 62, 50, 51, 52, 53, 54, 0, + 178, 0, 0, 49, 0, 0, 74, 76, 0, 77, + 0, 72, 58, 59, 61, 63, 73, 75, 0, 0, + 0, 0, 0, 0, 0, 0, 64, 65, 66, 67, + 68, 69, 0, 0, 70, 71, 55, 56, 57, 0, + 0, 0, 0, 0, 0, 78, 0, 0, 48, 0, + 0, 60, 62, 50, 51, 52, 53, 54, 0, 0, + 0, 0, 49, 0, 0, 74, 76, 171, 77, 0, + 72, 58, 59, 61, 63, 73, 75, 0, 0, 0, + 0, 0, 0, 0, 0, 64, 65, 66, 67, 68, + 69, 0, 0, 70, 71, 55, 56, 57, 0, 0, + 0, 0, 0, 0, 78, 0, 0, 48, 0, 0, + 60, 62, 50, 51, 52, 53, 54, 0, 159, 0, + 0, 49, 0, 0, 74, 76, 0, 77, 0, 72, + 58, 59, 61, 63, 73, 75, 0, 0, 0, 0, + 0, 0, 0, 0, 64, 65, 66, 67, 68, 69, + 0, 0, 70, 71, 55, 56, 57, 0, 0, 0, + 0, 0, 0, 78, 0, 0, 48, 0, 0, 60, + 62, 50, 51, 52, 53, 54, 0, 156, 0, 0, + 49, 0, 0, 74, 76, 0, 77, 0, 72, 21, + 22, 28, 0, 0, 32, 14, 9, 15, 41, 0, + 18, 0, 0, 0, 0, 0, 0, 0, 36, 29, + 30, 31, 16, 19, 0, 0, 0, 0, 0, 0, + 0, 0, 12, 13, 0, 0, 0, 0, 0, 20, + 0, 0, 37, 0, 38, 39, 0, 0, 0, 0, + 0, 0, 0, 0, 23, 27, 0, 0, 0, 34, + 0, 6, 0, 24, 25, 26, 35, 0, 33, 0, + 0, 7, 58, 59, 61, 63, 73, 75, 0, 0, + 0, 0, 0, 0, 0, 0, 64, 65, 66, 67, + 68, 69, 0, 0, 70, 71, 55, 56, 57, 0, + 0, 0, 0, 0, 0, 78, 0, 47, 48, 0, + 0, 60, 62, 50, 51, 52, 53, 54, 0, 0, + 0, 0, 49, 0, 0, 74, 76, 0, 77, 0, + 72, 58, 59, 61, 63, 73, 75, 0, 0, 0, + 0, 0, 0, 0, 0, 64, 65, 66, 67, 68, + 69, 0, 0, 70, 71, 55, 56, 57, 0, 0, + 0, 0, 0, 0, 78, 0, 0, 48, 0, 0, + 60, 62, 50, 51, 52, 53, 54, 0, 0, 0, + 0, 49, 0, 0, 74, 76, 0, 77, 0, 72, + 58, 59, 61, 63, 73, 75, 0, 0, 0, 0, + 0, 0, 0, 0, 64, 65, 66, 67, 68, 69, + 0, 0, 70, 71, 55, 56, 57, 0, 0, 0, + 0, 0, 0, 78, 0, 0, 48, 0, 0, 60, + 62, 50, 51, 52, 53, 54, 0, 0, 0, 0, + 49, 0, 0, 74, 174, 0, 77, 0, 72, 58, + 59, 61, 63, 73, 75, 0, 0, 0, 0, 0, + 0, 0, 0, 64, 65, 66, 67, 68, 69, 0, + 0, 70, 71, 55, 56, 57, 0, 0, 0, 0, + 0, 0, 78, 0, 0, 48, 0, 0, 60, 62, + 50, 51, 52, 53, 54, 0, 0, 0, 0, 163, + 0, 0, 74, 76, 0, 77, 0, 72, 58, 59, + 61, 63, 73, 75, 0, 0, 0, 0, 0, 0, + 0, 0, 64, 65, 66, 67, 68, 69, 0, 0, + 70, 71, 55, 56, 57, 0, 0, 0, 0, 0, + 0, 78, 0, 0, 48, 0, 0, 60, 62, 50, + 51, 52, 53, 54, 58, 59, 61, 63, 162, 75, + 0, 74, 76, 0, 77, 0, 72, 0, 64, 65, + 66, 67, 68, 69, 0, 0, 70, 71, 55, 56, + 57, 0, 0, 0, 0, 0, 0, 78, 0, 0, + 0, 0, 0, 60, 62, 50, 51, 52, 53, 54, + 58, 59, 61, 63, 49, 0, 0, 74, 76, 0, + 77, 0, 72, 0, 64, 65, 66, 67, 68, 69, + 0, 0, 70, 71, 55, 56, 57, 0, 0, 0, + 0, 0, 0, 78, 0, 0, 0, 0, 0, 60, + 62, 50, 51, 52, 53, 54, 0, 0, 0, 0, + 49, 0, 0, 74, 76, 0, 77, 0, 72, 21, + 22, 191, 0, 0, 32, 14, 9, 15, 41, 0, + 18, 0, 0, 0, 0, 0, 0, 0, 36, 29, + 30, 31, 16, 19, 0, 0, 0, 0, 0, 0, + 0, 0, 12, 13, 0, 0, 0, 0, 0, 20, + 0, 0, 37, 0, 38, 39, 0, 0, 0, 0, + 0, 0, 0, 0, 23, 27, 0, 0, 0, 34, + 0, 0, 0, 24, 25, 26, 35, 0, 33, 21, + 22, 28, 0, 0, 32, 14, 9, 15, 41, 0, + 18, 0, 0, 0, 0, 0, 0, 0, 36, 29, + 30, 31, 16, 19, 0, 0, 0, 0, 0, 0, + 0, 0, 12, 13, 0, 0, 0, 0, 0, 20, + 0, 0, 37, 0, 38, 39, 0, 0, 64, 65, + 66, 67, 68, 69, 23, 27, 70, 71, 55, 34, + 0, 0, 0, 24, 25, 26, 35, 78, 33, 0, + 0, 0, 0, 0, 0, 50, 51, 52, 53, 54, + 228, 22, 28, 0, 49, 32, 0, 74, 76, 0, + 77, 0, 72, 0, 0, 0, 0, 0, 0, 36, + 29, 30, 31, 0, 0, 0, 0, 0, 21, 22, + 28, 0, 0, 32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 37, 0, 38, 39, 36, 29, 30, + 31, 0, 0, 0, 0, 23, 27, 228, 22, 28, + 34, 0, 32, 0, 24, 25, 26, 35, 0, 33, + 277, 37, 0, 38, 39, 0, 36, 29, 30, 31, + 0, 0, 0, 23, 27, 221, 22, 28, 34, 0, + 32, 0, 24, 25, 26, 35, 0, 33, 0, 0, + 37, 0, 38, 39, 36, 29, 30, 31, 0, 0, + 0, 0, 23, 27, 107, 22, 28, 34, 0, 32, + 0, 24, 25, 26, 35, 0, 33, 0, 37, 0, + 38, 39, 0, 36, 29, 30, 31, 0, 0, 0, + 23, 27, 99, 22, 28, 34, 0, 32, 0, 24, + 25, 26, 35, 0, 33, 0, 0, 37, 0, 38, + 39, 36, 29, 30, 31, 0, 0, 0, 0, 23, + 27, 97, 22, 28, 34, 0, 32, 0, 24, 25, + 26, 35, 0, 33, 0, 37, 0, 38, 39, 0, + 36, 29, 30, 31, 0, 0, 0, 23, 27, 86, + 22, 28, 34, 0, 32, 0, 24, 25, 26, 35, + 0, 33, 0, 0, 37, 0, 38, 39, 36, 29, + 30, 31, 0, 0, 0, 0, 23, 27, 0, 0, + 0, 34, 0, 0, 0, 24, 25, 26, 35, 0, + 33, 0, 37, 0, 38, 39, 0, 0, 64, 65, + 66, 67, 68, 69, 23, 27, 0, 0, 55, 85, + 0, 0, 0, 24, 25, 26, 35, 78, 33, 0, + 0, 0, 0, 0, 0, 0, 0, 52, 53, 54, + 0, 0, 0, 0, 49, 0, 0, 74, 76, 0, + 77, 0, 72, +} +var yyPact = [...]int{ + + -59, -1000, 1845, -59, -59, -1000, -1000, -1000, -1000, 228, + 1375, 146, -1000, -1000, 1954, 1954, 227, 199, 2125, 119, + 1954, -63, -1000, 1954, 1954, 1954, 2097, 2068, -1000, -1000, + -1000, -1000, 67, -59, -59, 1954, 226, 2040, 18, 1954, + 130, 1954, -1000, 1315, -1000, 138, -1000, 1954, 1954, 225, + 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, + 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, + -1000, -1000, 1954, 1954, 1954, 1954, 1954, 1954, 1954, 1954, + 129, 1434, 1434, 113, 154, -59, 17, 25, 1243, 145, + -59, 1184, 1954, 1954, 51, 51, 51, -63, 1611, -63, + 1552, 224, 6, 1954, 213, 1125, 1, -36, 1493, 148, + 1434, -59, 1066, -1000, 1954, -59, 1434, 1007, -1000, 2147, + 2147, 51, 51, 51, 1434, 1867, 1867, 236, 236, 1867, + 1867, 1867, 1867, 1434, 1434, 1434, 1434, 1434, 1434, 1434, + 1657, 1434, 1703, 98, 417, 1434, -1000, 1434, -59, -59, + 1954, -59, 100, 1775, 1954, 1954, -59, 1954, 96, -59, + 94, 358, 223, 222, 45, 209, 221, -37, -46, -1000, + 141, -1000, 1954, 1954, 1954, 220, 220, 2011, -59, -1000, + 218, 1954, -29, -1000, -1000, 1954, 1983, 92, 948, 83, + -1000, 141, 889, 830, 82, -1000, 183, 85, 163, -31, + -1000, -1000, 1954, -1000, -1000, 112, -38, 44, 208, -59, + -61, -59, 79, 1954, 41, 87, 73, 38, -1000, 52, + 1434, -63, 78, -1000, 1434, -1000, 771, 1434, -63, -1000, + -59, -1000, -59, 1954, -1000, 128, -1000, -1000, -1000, 1954, + 140, -1000, -1000, -1000, 712, -59, 111, 110, -49, 1926, + -1000, 123, -1000, 1434, -1000, -50, -1000, -58, -1000, 216, + -1000, 1954, 1954, -1000, -1000, 76, 75, 653, 108, -59, + 594, -59, -1000, 74, -59, -59, 104, -1000, -1000, -1000, + -1000, -1000, -1000, 535, 299, -1000, -1000, -59, -59, 72, + -59, -59, -1000, 70, 69, -59, -1000, -1000, 1954, 68, + 55, 181, -59, -1000, -1000, -1000, 49, 476, -1000, 172, + 99, -1000, -1000, -1000, 88, -59, -59, 47, 39, -1000, + -1000, +} +var yyPgo = [...]int{ + + 0, 12, 241, 200, 239, 5, 2, 238, 4, 0, + 32, 31, 236, 1, 235, 6, 11, 233, 210, +} +var yyR1 = [...]int{ + + 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 4, 4, 4, 7, 7, + 7, 7, 7, 6, 5, 13, 14, 14, 14, 15, + 15, 15, 12, 11, 11, 11, 8, 8, 10, 10, + 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 16, 16, 17, 17, 18, 18, +} +var yyR2 = [...]int{ + + 0, 1, 2, 0, 2, 3, 4, 3, 3, 1, + 1, 2, 2, 5, 1, 4, 7, 9, 5, 13, + 12, 9, 8, 5, 1, 7, 5, 5, 0, 2, + 2, 2, 2, 5, 4, 3, 0, 1, 4, 0, + 1, 4, 3, 1, 4, 4, 1, 3, 0, 1, + 4, 4, 1, 1, 2, 2, 2, 2, 4, 2, + 4, 1, 1, 1, 1, 5, 3, 7, 8, 8, + 9, 5, 6, 5, 6, 3, 5, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, + 3, 3, 3, 5, 4, 6, 5, 5, 4, 6, + 5, 4, 4, 6, 6, 5, 7, 7, 9, 3, + 2, 0, 1, 1, 2, 1, 1, +} +var yyChk = [...]int{ + + -1000, -1, -16, -2, -17, -18, 66, 76, -3, 11, + -9, -11, 37, 38, 10, 12, 27, -4, 15, 28, + 44, 4, 5, 59, 68, 69, 70, 60, 6, 24, + 25, 26, 9, 73, 64, 71, 23, 47, 49, 50, + -10, 13, -16, -17, -18, -15, 4, 52, 53, 67, + 58, 59, 60, 61, 62, 41, 42, 43, 17, 18, + 56, 19, 57, 20, 31, 32, 33, 34, 35, 36, + 39, 40, 75, 21, 70, 22, 71, 73, 50, 52, + -10, -9, -9, 4, 14, 64, 4, -12, -9, -11, + 64, -9, 71, 73, -9, -9, -9, 4, -9, 4, + -9, 71, 4, -16, -16, -9, 4, 4, -9, 71, + -9, 55, -9, -3, 52, 55, -9, -9, 4, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -10, -9, -9, -11, -9, 55, 64, + 13, 64, -1, -16, 16, 66, 64, 52, -1, 64, + -10, -9, 67, 67, -15, 4, 71, -10, -14, -13, + 6, 72, 71, 71, 71, 48, 51, -16, 64, -11, + -16, 54, 8, 72, 74, 54, -16, -1, -9, -1, + 65, 6, -9, -9, -1, -11, 65, -7, -16, 8, + 72, 74, 54, 4, 4, 72, 8, -15, 4, 55, + -16, 55, -16, 54, -10, -10, -10, -8, 4, -8, + -9, 4, -1, 4, -9, 72, -9, -9, 4, 65, + 64, 65, 64, 66, 65, 29, 65, -6, -5, 45, + 46, -6, -5, 72, -9, 64, 72, 72, 8, -16, + 74, -16, 65, -9, 72, 8, 72, 8, 72, 67, + 72, 55, 55, 65, 74, -1, -1, -9, 4, 64, + -9, 54, 74, -1, 64, 64, 72, 74, -13, 65, + 72, 72, 4, -9, -9, 65, 65, 64, 64, -1, + 54, -16, 65, -1, -1, 64, 72, 72, 55, -1, + -1, 65, -16, -1, 65, 65, -1, -9, 65, 65, + 30, -1, 65, 72, 30, 64, 64, -1, -1, 65, + 65, +} +var yyDef = [...]int{ + + -2, -2, -2, 121, 122, 123, 125, 126, 4, 39, + -2, 0, 9, 10, 48, 0, 0, 14, 48, 0, + 0, 52, 53, 0, 0, 0, 0, 0, 61, 62, + 63, 64, 0, 121, 121, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 124, 0, 40, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 97, 98, 0, 0, 0, 0, 48, 0, 0, 48, + 11, 49, 12, 0, 0, -2, 52, 0, -2, 0, + -2, 0, 48, 0, 54, 55, 56, -2, 0, -2, + 0, 39, 0, 48, 36, 0, 0, 52, 0, 0, + 120, 121, 0, 5, 48, 121, 7, 0, 66, 77, + 78, 79, 80, 81, 82, 83, 84, -2, -2, 87, + 88, 89, 90, 91, 92, 93, 94, 95, 96, 99, + 100, 101, 102, 0, 0, 119, 8, -2, 121, -2, + 0, -2, 0, -2, 0, 0, -2, 48, 0, 28, + 0, 0, 0, 0, 0, 40, 39, 121, 121, 37, + 0, 75, 48, 48, 48, 0, 0, 0, -2, 6, + 0, 0, 0, 108, 112, 0, 0, 0, 0, 0, + 15, 61, 0, 0, 0, 42, 0, 0, 0, 0, + 104, 111, 0, 58, 60, 0, 0, 0, 40, 121, + 0, 121, 0, 0, 0, 0, 0, 0, 46, 0, + -2, -2, 0, 41, 65, 107, 0, 50, -2, 13, + -2, 26, -2, 0, 18, 0, 23, 31, 32, 0, + 0, 29, 30, 103, 0, -2, 0, 0, 0, 0, + 71, 0, 73, 35, 76, 0, -2, 0, -2, 0, + 115, 0, 0, 27, 114, 0, 0, 0, 0, -2, + 0, 121, 113, 0, -2, -2, 0, 72, 38, 74, + -2, -2, 47, 0, 0, 25, 16, -2, -2, 0, + 121, -2, 67, 0, 0, -2, 116, 117, 0, 0, + 0, 22, -2, 34, 68, 69, 0, 0, 17, 21, + 0, 33, 70, 118, 0, -2, -2, 0, 0, 20, + 19, +} +var yyTok1 = [...]int{ + + 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 76, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 68, 3, 3, 3, 62, 70, 3, + 71, 72, 60, 58, 55, 59, 67, 61, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 54, 66, + 57, 52, 56, 53, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 73, 3, 74, 69, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 64, 75, 65, +} +var yyTok2 = [...]int{ + + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 63, +} +var yyTok3 = [...]int{ + 0, +} + +var yyErrorMessages = [...]struct { + state int + token int + msg string +}{} + +//line yaccpar:1 + +/* parser for yacc output */ + +var ( + yyDebug = 0 + yyErrorVerbose = false +) + +type yyLexer interface { + Lex(lval *yySymType) int + Error(s string) +} + +type yyParser interface { + Parse(yyLexer) int + Lookahead() int +} + +type yyParserImpl struct { + lval yySymType + stack [yyInitialStackSize]yySymType + char int +} + +func (p *yyParserImpl) Lookahead() int { + return p.char +} + +func yyNewParser() yyParser { + return &yyParserImpl{} +} + +const yyFlag = -1000 + +func yyTokname(c int) string { + if c >= 1 && c-1 < len(yyToknames) { + if yyToknames[c-1] != "" { + return yyToknames[c-1] + } + } + return __yyfmt__.Sprintf("tok-%v", c) +} + +func yyStatname(s int) string { + if s >= 0 && s < len(yyStatenames) { + if yyStatenames[s] != "" { + return yyStatenames[s] + } + } + return __yyfmt__.Sprintf("state-%v", s) +} + +func yyErrorMessage(state, lookAhead int) string { + const TOKSTART = 4 + + if !yyErrorVerbose { + return "syntax error" + } + + for _, e := range yyErrorMessages { + if e.state == state && e.token == lookAhead { + return "syntax error: " + e.msg + } + } + + res := "syntax error: unexpected " + yyTokname(lookAhead) + + // To match Bison, suggest at most four expected tokens. + expected := make([]int, 0, 4) + + // Look for shiftable tokens. + base := yyPact[state] + for tok := TOKSTART; tok-1 < len(yyToknames); tok++ { + if n := base + tok; n >= 0 && n < yyLast && yyChk[yyAct[n]] == tok { + if len(expected) == cap(expected) { + return res + } + expected = append(expected, tok) + } + } + + if yyDef[state] == -2 { + i := 0 + for yyExca[i] != -1 || yyExca[i+1] != state { + i += 2 + } + + // Look for tokens that we accept or reduce. + for i += 2; yyExca[i] >= 0; i += 2 { + tok := yyExca[i] + if tok < TOKSTART || yyExca[i+1] == 0 { + continue + } + if len(expected) == cap(expected) { + return res + } + expected = append(expected, tok) + } + + // If the default action is to accept or reduce, give up. + if yyExca[i+1] != 0 { + return res + } + } + + for i, tok := range expected { + if i == 0 { + res += ", expecting " + } else { + res += " or " + } + res += yyTokname(tok) + } + return res +} + +func yylex1(lex yyLexer, lval *yySymType) (char, token int) { + token = 0 + char = lex.Lex(lval) + if char <= 0 { + token = yyTok1[0] + goto out + } + if char < len(yyTok1) { + token = yyTok1[char] + goto out + } + if char >= yyPrivate { + if char < yyPrivate+len(yyTok2) { + token = yyTok2[char-yyPrivate] + goto out + } + } + for i := 0; i < len(yyTok3); i += 2 { + token = yyTok3[i+0] + if token == char { + token = yyTok3[i+1] + goto out + } + } + +out: + if token == 0 { + token = yyTok2[1] /* unknown char */ + } + if yyDebug >= 3 { + __yyfmt__.Printf("lex %s(%d)\n", yyTokname(token), uint(char)) + } + return char, token +} + +func yyParse(yylex yyLexer) int { + return yyNewParser().Parse(yylex) +} + +func (yyrcvr *yyParserImpl) Parse(yylex yyLexer) int { + var yyn int + var yyVAL yySymType + var yyDollar []yySymType + _ = yyDollar // silence set and not used + yyS := yyrcvr.stack[:] + + Nerrs := 0 /* number of errors */ + Errflag := 0 /* error recovery flag */ + yystate := 0 + yyrcvr.char = -1 + yytoken := -1 // yyrcvr.char translated into internal numbering + defer func() { + // Make sure we report no lookahead when not parsing. + yystate = -1 + yyrcvr.char = -1 + yytoken = -1 + }() + yyp := -1 + goto yystack + +ret0: + return 0 + +ret1: + return 1 + +yystack: + /* put a state and value onto the stack */ + if yyDebug >= 4 { + __yyfmt__.Printf("char %v in %v\n", yyTokname(yytoken), yyStatname(yystate)) + } + + yyp++ + if yyp >= len(yyS) { + nyys := make([]yySymType, len(yyS)*2) + copy(nyys, yyS) + yyS = nyys + } + yyS[yyp] = yyVAL + yyS[yyp].yys = yystate + +yynewstate: + yyn = yyPact[yystate] + if yyn <= yyFlag { + goto yydefault /* simple state */ + } + if yyrcvr.char < 0 { + yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval) + } + yyn += yytoken + if yyn < 0 || yyn >= yyLast { + goto yydefault + } + yyn = yyAct[yyn] + if yyChk[yyn] == yytoken { /* valid shift */ + yyrcvr.char = -1 + yytoken = -1 + yyVAL = yyrcvr.lval + yystate = yyn + if Errflag > 0 { + Errflag-- + } + goto yystack + } + +yydefault: + /* default state action */ + yyn = yyDef[yystate] + if yyn == -2 { + if yyrcvr.char < 0 { + yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval) + } + + /* look through exception table */ + xi := 0 + for { + if yyExca[xi+0] == -1 && yyExca[xi+1] == yystate { + break + } + xi += 2 + } + for xi += 2; ; xi += 2 { + yyn = yyExca[xi+0] + if yyn < 0 || yyn == yytoken { + break + } + } + yyn = yyExca[xi+1] + if yyn < 0 { + goto ret0 + } + } + if yyn == 0 { + /* error ... attempt to resume parsing */ + switch Errflag { + case 0: /* brand new error */ + yylex.Error(yyErrorMessage(yystate, yytoken)) + Nerrs++ + if yyDebug >= 1 { + __yyfmt__.Printf("%s", yyStatname(yystate)) + __yyfmt__.Printf(" saw %s\n", yyTokname(yytoken)) + } + fallthrough + + case 1, 2: /* incompletely recovered error ... try again */ + Errflag = 3 + + /* find a state where "error" is a legal shift action */ + for yyp >= 0 { + yyn = yyPact[yyS[yyp].yys] + yyErrCode + if yyn >= 0 && yyn < yyLast { + yystate = yyAct[yyn] /* simulate a shift of "error" */ + if yyChk[yystate] == yyErrCode { + goto yystack + } + } + + /* the current p has no shift on "error", pop stack */ + if yyDebug >= 2 { + __yyfmt__.Printf("error recovery pops state %d\n", yyS[yyp].yys) + } + yyp-- + } + /* there is no state on the stack with an error shift ... abort */ + goto ret1 + + case 3: /* no shift yet; clobber input char */ + if yyDebug >= 2 { + __yyfmt__.Printf("error recovery discards %s\n", yyTokname(yytoken)) + } + if yytoken == yyEofCode { + goto ret1 + } + yyrcvr.char = -1 + yytoken = -1 + goto yynewstate /* try again in the same state */ + } + } + + /* reduction by production yyn */ + if yyDebug >= 2 { + __yyfmt__.Printf("reduce %v in:\n\t%v\n", yyn, yyStatname(yystate)) + } + + yynt := yyn + yypt := yyp + _ = yypt // guard against "declared and not used" + + yyp -= yyR2[yyn] + // yyp is now the index of $0. Perform the default action. Iff the + // reduced production is ε, $1 is possibly out of range. + if yyp+1 >= len(yyS) { + nyys := make([]yySymType, len(yyS)*2) + copy(nyys, yyS) + yyS = nyys + } + yyVAL = yyS[yyp+1] + + /* consult goto table to find next state */ + yyn = yyR1[yyn] + yyg := yyPgo[yyn] + yyj := yyg + yyS[yyp].yys + 1 + + if yyj >= yyLast { + yystate = yyAct[yyg] + } else { + yystate = yyAct[yyj] + if yyChk[yystate] != -yyn { + yystate = yyAct[yyg] + } + } + // dummy call; replaced with literal code + switch yynt { + + case 1: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:65 + { + yyVAL.compstmt = nil + } + case 2: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:69 + { + yyVAL.compstmt = yyDollar[1].stmts + } + case 3: + yyDollar = yyS[yypt-0 : yypt+1] + //line parser.go.y:74 + { + yyVAL.stmts = nil + if l, ok := yylex.(*Lexer); ok { + l.stmts = yyVAL.stmts + } + } + case 4: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:81 + { + yyVAL.stmts = []ast.Stmt{yyDollar[2].stmt} + if l, ok := yylex.(*Lexer); ok { + l.stmts = yyVAL.stmts + } + } + case 5: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:88 + { + if yyDollar[3].stmt != nil { + yyVAL.stmts = append(yyDollar[1].stmts, yyDollar[3].stmt) + if l, ok := yylex.(*Lexer); ok { + l.stmts = yyVAL.stmts + } + } + } + case 6: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:99 + { + yyVAL.stmt = &ast.VarStmt{Names: yyDollar[2].expr_idents, Exprs: yyDollar[4].expr_many} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 7: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:104 + { + yyVAL.stmt = &ast.LetsStmt{Lhss: []ast.Expr{yyDollar[1].expr}, Operator: "=", Rhss: []ast.Expr{yyDollar[3].expr}} + } + case 8: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:108 + { + yyVAL.stmt = &ast.LetsStmt{Lhss: yyDollar[1].expr_many, Operator: "=", Rhss: yyDollar[3].expr_many} + } + case 9: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:112 + { + yyVAL.stmt = &ast.BreakStmt{} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 10: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:117 + { + yyVAL.stmt = &ast.ContinueStmt{} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 11: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:122 + { + yyVAL.stmt = &ast.ReturnStmt{Exprs: yyDollar[2].exprs} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 12: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:127 + { + yyVAL.stmt = &ast.ThrowStmt{Expr: yyDollar[2].expr} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 13: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:132 + { + yyVAL.stmt = &ast.ModuleStmt{Name: yyDollar[2].tok.Lit, Stmts: yyDollar[4].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 14: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:137 + { + yyVAL.stmt = yyDollar[1].stmt_if + yyVAL.stmt.SetPosition(yyDollar[1].stmt_if.Position()) + } + case 15: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:142 + { + yyVAL.stmt = &ast.LoopStmt{Stmts: yyDollar[3].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 16: + yyDollar = yyS[yypt-7 : yypt+1] + //line parser.go.y:147 + { + yyVAL.stmt = &ast.ForStmt{Var: yyDollar[2].tok.Lit, Value: yyDollar[4].expr, Stmts: yyDollar[6].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 17: + yyDollar = yyS[yypt-9 : yypt+1] + //line parser.go.y:152 + { + yyVAL.stmt = &ast.CForStmt{Expr1: yyDollar[2].expr_lets, Expr2: yyDollar[4].expr, Expr3: yyDollar[6].expr, Stmts: yyDollar[8].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 18: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:157 + { + yyVAL.stmt = &ast.LoopStmt{Expr: yyDollar[2].expr, Stmts: yyDollar[4].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 19: + yyDollar = yyS[yypt-13 : yypt+1] + //line parser.go.y:162 + { + yyVAL.stmt = &ast.TryStmt{Try: yyDollar[3].compstmt, Var: yyDollar[6].tok.Lit, Catch: yyDollar[8].compstmt, Finally: yyDollar[12].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 20: + yyDollar = yyS[yypt-12 : yypt+1] + //line parser.go.y:167 + { + yyVAL.stmt = &ast.TryStmt{Try: yyDollar[3].compstmt, Catch: yyDollar[7].compstmt, Finally: yyDollar[11].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 21: + yyDollar = yyS[yypt-9 : yypt+1] + //line parser.go.y:172 + { + yyVAL.stmt = &ast.TryStmt{Try: yyDollar[3].compstmt, Var: yyDollar[6].tok.Lit, Catch: yyDollar[8].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 22: + yyDollar = yyS[yypt-8 : yypt+1] + //line parser.go.y:177 + { + yyVAL.stmt = &ast.TryStmt{Try: yyDollar[3].compstmt, Catch: yyDollar[7].compstmt} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 23: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:182 + { + yyVAL.stmt = &ast.SwitchStmt{Expr: yyDollar[2].expr, Cases: yyDollar[4].stmt_cases} + yyVAL.stmt.SetPosition(yyDollar[1].tok.Position()) + } + case 24: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:187 + { + yyVAL.stmt = &ast.ExprStmt{Expr: yyDollar[1].expr} + yyVAL.stmt.SetPosition(yyDollar[1].expr.Position()) + } + case 25: + yyDollar = yyS[yypt-7 : yypt+1] + //line parser.go.y:195 + { + yyDollar[1].stmt_if.(*ast.IfStmt).ElseIf = append(yyDollar[1].stmt_if.(*ast.IfStmt).ElseIf, &ast.IfStmt{If: yyDollar[4].expr, Then: yyDollar[6].compstmt}) + yyVAL.stmt_if.SetPosition(yyDollar[1].stmt_if.Position()) + } + case 26: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:200 + { + if yyVAL.stmt_if.(*ast.IfStmt).Else != nil { + yylex.Error("multiple else statement") + } else { + yyVAL.stmt_if.(*ast.IfStmt).Else = append(yyVAL.stmt_if.(*ast.IfStmt).Else, yyDollar[4].compstmt...) + } + yyVAL.stmt_if.SetPosition(yyDollar[1].stmt_if.Position()) + } + case 27: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:209 + { + yyVAL.stmt_if = &ast.IfStmt{If: yyDollar[2].expr, Then: yyDollar[4].compstmt, Else: nil} + yyVAL.stmt_if.SetPosition(yyDollar[1].tok.Position()) + } + case 28: + yyDollar = yyS[yypt-0 : yypt+1] + //line parser.go.y:215 + { + yyVAL.stmt_cases = []ast.Stmt{} + } + case 29: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:219 + { + yyVAL.stmt_cases = []ast.Stmt{yyDollar[2].stmt_case} + } + case 30: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:223 + { + yyVAL.stmt_cases = []ast.Stmt{yyDollar[2].stmt_default} + } + case 31: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:227 + { + yyVAL.stmt_cases = append(yyDollar[1].stmt_cases, yyDollar[2].stmt_case) + } + case 32: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:231 + { + for _, stmt := range yyDollar[1].stmt_cases { + if _, ok := stmt.(*ast.DefaultStmt); ok { + yylex.Error("multiple default statement") + } + } + yyVAL.stmt_cases = append(yyDollar[1].stmt_cases, yyDollar[2].stmt_default) + } + case 33: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:242 + { + yyVAL.stmt_case = &ast.CaseStmt{Expr: yyDollar[2].expr, Stmts: yyDollar[5].compstmt} + } + case 34: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:248 + { + yyVAL.stmt_default = &ast.DefaultStmt{Stmts: yyDollar[4].compstmt} + } + case 35: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:254 + { + yyVAL.expr_pair = &ast.PairExpr{Key: yyDollar[1].tok.Lit, Value: yyDollar[3].expr} + } + case 36: + yyDollar = yyS[yypt-0 : yypt+1] + //line parser.go.y:259 + { + yyVAL.expr_pairs = []ast.Expr{} + } + case 37: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:263 + { + yyVAL.expr_pairs = []ast.Expr{yyDollar[1].expr_pair} + } + case 38: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:267 + { + yyVAL.expr_pairs = append(yyDollar[1].expr_pairs, yyDollar[4].expr_pair) + } + case 39: + yyDollar = yyS[yypt-0 : yypt+1] + //line parser.go.y:272 + { + yyVAL.expr_idents = []string{} + } + case 40: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:276 + { + yyVAL.expr_idents = []string{yyDollar[1].tok.Lit} + } + case 41: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:280 + { + yyVAL.expr_idents = append(yyDollar[1].expr_idents, yyDollar[4].tok.Lit) + } + case 42: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:285 + { + yyVAL.expr_lets = &ast.LetsExpr{Lhss: yyDollar[1].expr_many, Operator: "=", Rhss: yyDollar[3].expr_many} + } + case 43: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:291 + { + yyVAL.expr_many = []ast.Expr{yyDollar[1].expr} + } + case 44: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:295 + { + yyVAL.expr_many = append(yyDollar[1].exprs, yyDollar[4].expr) + } + case 45: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:299 + { + yyVAL.expr_many = append(yyDollar[1].exprs, &ast.IdentExpr{Lit: yyDollar[4].tok.Lit}) + } + case 46: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:304 + { + yyVAL.typ = ast.Type{Name: yyDollar[1].tok.Lit} + } + case 47: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:308 + { + yyVAL.typ = ast.Type{Name: yyDollar[1].typ.Name + "." + yyDollar[3].tok.Lit} + } + case 48: + yyDollar = yyS[yypt-0 : yypt+1] + //line parser.go.y:313 + { + yyVAL.exprs = nil + } + case 49: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:317 + { + yyVAL.exprs = []ast.Expr{yyDollar[1].expr} + } + case 50: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:321 + { + yyVAL.exprs = append(yyDollar[1].exprs, yyDollar[4].expr) + } + case 51: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:325 + { + yyVAL.exprs = append(yyDollar[1].exprs, &ast.IdentExpr{Lit: yyDollar[4].tok.Lit}) + } + case 52: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:331 + { + yyVAL.expr = &ast.IdentExpr{Lit: yyDollar[1].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 53: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:336 + { + yyVAL.expr = &ast.NumberExpr{Lit: yyDollar[1].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 54: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:341 + { + yyVAL.expr = &ast.UnaryExpr{Operator: "-", Expr: yyDollar[2].expr} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 55: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:346 + { + yyVAL.expr = &ast.UnaryExpr{Operator: "!", Expr: yyDollar[2].expr} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 56: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:351 + { + yyVAL.expr = &ast.UnaryExpr{Operator: "^", Expr: yyDollar[2].expr} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 57: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:356 + { + yyVAL.expr = &ast.AddrExpr{Expr: &ast.IdentExpr{Lit: yyDollar[2].tok.Lit}} + yyVAL.expr.SetPosition(yyDollar[2].tok.Position()) + } + case 58: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:361 + { + yyVAL.expr = &ast.AddrExpr{Expr: &ast.MemberExpr{Expr: yyDollar[2].expr, Name: yyDollar[4].tok.Lit}} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 59: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:366 + { + yyVAL.expr = &ast.DerefExpr{Expr: &ast.IdentExpr{Lit: yyDollar[2].tok.Lit}} + yyVAL.expr.SetPosition(yyDollar[2].tok.Position()) + } + case 60: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:371 + { + yyVAL.expr = &ast.DerefExpr{Expr: &ast.MemberExpr{Expr: yyDollar[2].expr, Name: yyDollar[4].tok.Lit}} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 61: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:376 + { + yyVAL.expr = &ast.StringExpr{Lit: yyDollar[1].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 62: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:381 + { + yyVAL.expr = &ast.ConstExpr{Value: yyDollar[1].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 63: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:386 + { + yyVAL.expr = &ast.ConstExpr{Value: yyDollar[1].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 64: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:391 + { + yyVAL.expr = &ast.ConstExpr{Value: yyDollar[1].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 65: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:396 + { + yyVAL.expr = &ast.TernaryOpExpr{Expr: yyDollar[1].expr, Lhs: yyDollar[3].expr, Rhs: yyDollar[5].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 66: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:401 + { + yyVAL.expr = &ast.MemberExpr{Expr: yyDollar[1].expr, Name: yyDollar[3].tok.Lit} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 67: + yyDollar = yyS[yypt-7 : yypt+1] + //line parser.go.y:406 + { + yyVAL.expr = &ast.FuncExpr{Args: yyDollar[3].expr_idents, Stmts: yyDollar[6].compstmt} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 68: + yyDollar = yyS[yypt-8 : yypt+1] + //line parser.go.y:411 + { + yyVAL.expr = &ast.FuncExpr{Args: []string{yyDollar[3].tok.Lit}, Stmts: yyDollar[7].compstmt, VarArg: true} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 69: + yyDollar = yyS[yypt-8 : yypt+1] + //line parser.go.y:416 + { + yyVAL.expr = &ast.FuncExpr{Name: yyDollar[2].tok.Lit, Args: yyDollar[4].expr_idents, Stmts: yyDollar[7].compstmt} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 70: + yyDollar = yyS[yypt-9 : yypt+1] + //line parser.go.y:421 + { + yyVAL.expr = &ast.FuncExpr{Name: yyDollar[2].tok.Lit, Args: []string{yyDollar[4].tok.Lit}, Stmts: yyDollar[8].compstmt, VarArg: true} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 71: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:426 + { + yyVAL.expr = &ast.ArrayExpr{Exprs: yyDollar[3].exprs} + if l, ok := yylex.(*Lexer); ok { + yyVAL.expr.SetPosition(l.pos) + } + } + case 72: + yyDollar = yyS[yypt-6 : yypt+1] + //line parser.go.y:431 + { + yyVAL.expr = &ast.ArrayExpr{Exprs: yyDollar[3].exprs} + if l, ok := yylex.(*Lexer); ok { + yyVAL.expr.SetPosition(l.pos) + } + } + case 73: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:436 + { + mapExpr := make(map[string]ast.Expr) + for _, v := range yyDollar[3].expr_pairs { + mapExpr[v.(*ast.PairExpr).Key] = v.(*ast.PairExpr).Value + } + yyVAL.expr = &ast.MapExpr{MapExpr: mapExpr} + if l, ok := yylex.(*Lexer); ok { + yyVAL.expr.SetPosition(l.pos) + } + } + case 74: + yyDollar = yyS[yypt-6 : yypt+1] + //line parser.go.y:445 + { + mapExpr := make(map[string]ast.Expr) + for _, v := range yyDollar[3].expr_pairs { + mapExpr[v.(*ast.PairExpr).Key] = v.(*ast.PairExpr).Value + } + yyVAL.expr = &ast.MapExpr{MapExpr: mapExpr} + if l, ok := yylex.(*Lexer); ok { + yyVAL.expr.SetPosition(l.pos) + } + } + case 75: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:454 + { + yyVAL.expr = &ast.ParenExpr{SubExpr: yyDollar[2].expr} + if l, ok := yylex.(*Lexer); ok { + yyVAL.expr.SetPosition(l.pos) + } + } + case 76: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:459 + { + yyVAL.expr = &ast.NewExpr{Name: yyDollar[2].tok.Lit, SubExprs: yyDollar[4].exprs} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 77: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:464 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "+", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 78: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:469 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "-", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 79: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:474 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "*", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 80: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:479 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "/", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 81: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:484 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "%", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 82: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:489 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "**", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 83: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:494 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "<<", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 84: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:499 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: ">>", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 85: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:504 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "==", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 86: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:509 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "!=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 87: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:514 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: ">", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 88: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:519 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: ">=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 89: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:524 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "<", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 90: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:529 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "<=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 91: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:534 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "+=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 92: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:539 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "-=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 93: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:544 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "*=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 94: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:549 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "/=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 95: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:554 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "&=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 96: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:559 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "|=", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 97: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:564 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "++"} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 98: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:569 + { + yyVAL.expr = &ast.AssocExpr{Lhs: yyDollar[1].expr, Operator: "--"} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 99: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:574 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "|", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 100: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:579 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "||", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 101: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:584 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "&", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 102: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:589 + { + yyVAL.expr = &ast.BinOpExpr{Lhs: yyDollar[1].expr, Operator: "&&", Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 103: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:594 + { + yyVAL.expr = &ast.CallExpr{Name: yyDollar[1].tok.Lit, SubExprs: yyDollar[3].exprs, VarArg: true} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 104: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:599 + { + yyVAL.expr = &ast.CallExpr{Name: yyDollar[1].tok.Lit, SubExprs: yyDollar[3].exprs} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 105: + yyDollar = yyS[yypt-6 : yypt+1] + //line parser.go.y:604 + { + yyVAL.expr = &ast.CallExpr{Name: yyDollar[2].tok.Lit, SubExprs: yyDollar[4].exprs, VarArg: true, Go: true} + yyVAL.expr.SetPosition(yyDollar[2].tok.Position()) + } + case 106: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:609 + { + yyVAL.expr = &ast.CallExpr{Name: yyDollar[2].tok.Lit, SubExprs: yyDollar[4].exprs, Go: true} + yyVAL.expr.SetPosition(yyDollar[2].tok.Position()) + } + case 107: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:614 + { + yyVAL.expr = &ast.AnonCallExpr{Expr: yyDollar[1].expr, SubExprs: yyDollar[3].exprs, VarArg: true} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 108: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:619 + { + yyVAL.expr = &ast.AnonCallExpr{Expr: yyDollar[1].expr, SubExprs: yyDollar[3].exprs} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 109: + yyDollar = yyS[yypt-6 : yypt+1] + //line parser.go.y:624 + { + yyVAL.expr = &ast.AnonCallExpr{Expr: yyDollar[2].expr, SubExprs: yyDollar[4].exprs, VarArg: true, Go: true} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 110: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:629 + { + yyVAL.expr = &ast.AnonCallExpr{Expr: yyDollar[2].expr, SubExprs: yyDollar[4].exprs, Go: true} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 111: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:634 + { + yyVAL.expr = &ast.ItemExpr{Value: &ast.IdentExpr{Lit: yyDollar[1].tok.Lit}, Index: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 112: + yyDollar = yyS[yypt-4 : yypt+1] + //line parser.go.y:639 + { + yyVAL.expr = &ast.ItemExpr{Value: yyDollar[1].expr, Index: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 113: + yyDollar = yyS[yypt-6 : yypt+1] + //line parser.go.y:644 + { + yyVAL.expr = &ast.SliceExpr{Value: &ast.IdentExpr{Lit: yyDollar[1].tok.Lit}, Begin: yyDollar[3].expr, End: yyDollar[5].expr} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 114: + yyDollar = yyS[yypt-6 : yypt+1] + //line parser.go.y:649 + { + yyVAL.expr = &ast.SliceExpr{Value: yyDollar[1].expr, Begin: yyDollar[3].expr, End: yyDollar[5].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 115: + yyDollar = yyS[yypt-5 : yypt+1] + //line parser.go.y:654 + { + yyVAL.expr = &ast.MakeChanExpr{Type: yyDollar[4].typ.Name, SizeExpr: nil} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 116: + yyDollar = yyS[yypt-7 : yypt+1] + //line parser.go.y:659 + { + yyVAL.expr = &ast.MakeChanExpr{Type: yyDollar[4].typ.Name, SizeExpr: yyDollar[6].expr} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 117: + yyDollar = yyS[yypt-7 : yypt+1] + //line parser.go.y:664 + { + yyVAL.expr = &ast.MakeArrayExpr{Type: yyDollar[4].typ.Name, LenExpr: yyDollar[6].expr} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 118: + yyDollar = yyS[yypt-9 : yypt+1] + //line parser.go.y:669 + { + yyVAL.expr = &ast.MakeArrayExpr{Type: yyDollar[4].typ.Name, LenExpr: yyDollar[6].expr, CapExpr: yyDollar[8].expr} + yyVAL.expr.SetPosition(yyDollar[1].tok.Position()) + } + case 119: + yyDollar = yyS[yypt-3 : yypt+1] + //line parser.go.y:674 + { + yyVAL.expr = &ast.ChanExpr{Lhs: yyDollar[1].expr, Rhs: yyDollar[3].expr} + yyVAL.expr.SetPosition(yyDollar[1].expr.Position()) + } + case 120: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:679 + { + yyVAL.expr = &ast.ChanExpr{Rhs: yyDollar[2].expr} + yyVAL.expr.SetPosition(yyDollar[2].expr.Position()) + } + case 123: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:690 + { + } + case 124: + yyDollar = yyS[yypt-2 : yypt+1] + //line parser.go.y:693 + { + } + case 125: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:698 + { + } + case 126: + yyDollar = yyS[yypt-1 : yypt+1] + //line parser.go.y:701 + { + } + } + goto yystack /* stack new state and value */ +} diff --git a/vendor/github.com/mattn/anko/parser/parser.go.y b/vendor/github.com/mattn/anko/parser/parser.go.y new file mode 100644 index 0000000000..9ebe8ae068 --- /dev/null +++ b/vendor/github.com/mattn/anko/parser/parser.go.y @@ -0,0 +1,705 @@ +%{ +package parser + +import ( + "github.com/mattn/anko/ast" +) + +%} + +%type compstmt +%type stmts +%type stmt +%type stmt_if +%type stmt_default +%type stmt_case +%type stmt_cases +%type typ +%type expr +%type exprs +%type expr_many +%type expr_lets +%type expr_pair +%type expr_pairs +%type expr_idents + +%union{ + compstmt []ast.Stmt + stmt_if ast.Stmt + stmt_default ast.Stmt + stmt_case ast.Stmt + stmt_cases []ast.Stmt + stmts []ast.Stmt + stmt ast.Stmt + typ ast.Type + expr ast.Expr + exprs []ast.Expr + expr_many []ast.Expr + expr_lets ast.Expr + expr_pair ast.Expr + expr_pairs []ast.Expr + expr_idents []string + tok ast.Token + term ast.Token + terms ast.Token + opt_terms ast.Token +} + +%token IDENT NUMBER STRING ARRAY VARARG FUNC RETURN VAR THROW IF ELSE FOR IN EQEQ NEQ GE LE OROR ANDAND NEW TRUE FALSE NIL MODULE TRY CATCH FINALLY PLUSEQ MINUSEQ MULEQ DIVEQ ANDEQ OREQ BREAK CONTINUE PLUSPLUS MINUSMINUS POW SHIFTLEFT SHIFTRIGHT SWITCH CASE DEFAULT GO CHAN MAKE OPCHAN ARRAYLIT + +%right '=' +%right '?' ':' +%left OROR +%left ANDAND +%left IDENT +%nonassoc EQEQ NEQ ',' +%left '>' GE '<' LE SHIFTLEFT SHIFTRIGHT + +%left '+' '-' PLUSPLUS MINUSMINUS +%left '*' '/' '%' +%right UNARY + +%% + +compstmt : opt_terms + { + $$ = nil + } + | stmts opt_terms + { + $$ = $1 + } + +stmts : + { + $$ = nil + if l, ok := yylex.(*Lexer); ok { + l.stmts = $$ + } + } + | opt_terms stmt + { + $$ = []ast.Stmt{$2} + if l, ok := yylex.(*Lexer); ok { + l.stmts = $$ + } + } + | stmts terms stmt + { + if $3 != nil { + $$ = append($1, $3) + if l, ok := yylex.(*Lexer); ok { + l.stmts = $$ + } + } + } + +stmt : + VAR expr_idents '=' expr_many + { + $$ = &ast.VarStmt{Names: $2, Exprs: $4} + $$.SetPosition($1.Position()) + } + | expr '=' expr + { + $$ = &ast.LetsStmt{Lhss: []ast.Expr{$1}, Operator: "=", Rhss: []ast.Expr{$3}} + } + | expr_many '=' expr_many + { + $$ = &ast.LetsStmt{Lhss: $1, Operator: "=", Rhss: $3} + } + | BREAK + { + $$ = &ast.BreakStmt{} + $$.SetPosition($1.Position()) + } + | CONTINUE + { + $$ = &ast.ContinueStmt{} + $$.SetPosition($1.Position()) + } + | RETURN exprs + { + $$ = &ast.ReturnStmt{Exprs: $2} + $$.SetPosition($1.Position()) + } + | THROW expr + { + $$ = &ast.ThrowStmt{Expr: $2} + $$.SetPosition($1.Position()) + } + | MODULE IDENT '{' compstmt '}' + { + $$ = &ast.ModuleStmt{Name: $2.Lit, Stmts: $4} + $$.SetPosition($1.Position()) + } + | stmt_if + { + $$ = $1 + $$.SetPosition($1.Position()) + } + | FOR '{' compstmt '}' + { + $$ = &ast.LoopStmt{Stmts: $3} + $$.SetPosition($1.Position()) + } + | FOR IDENT IN expr '{' compstmt '}' + { + $$ = &ast.ForStmt{Var: $2.Lit, Value: $4, Stmts: $6} + $$.SetPosition($1.Position()) + } + | FOR expr_lets ';' expr ';' expr '{' compstmt '}' + { + $$ = &ast.CForStmt{Expr1: $2, Expr2: $4, Expr3: $6, Stmts: $8} + $$.SetPosition($1.Position()) + } + | FOR expr '{' compstmt '}' + { + $$ = &ast.LoopStmt{Expr: $2, Stmts: $4} + $$.SetPosition($1.Position()) + } + | TRY '{' compstmt '}' CATCH IDENT '{' compstmt '}' FINALLY '{' compstmt '}' + { + $$ = &ast.TryStmt{Try: $3, Var: $6.Lit, Catch: $8, Finally: $12} + $$.SetPosition($1.Position()) + } + | TRY '{' compstmt '}' CATCH '{' compstmt '}' FINALLY '{' compstmt '}' + { + $$ = &ast.TryStmt{Try: $3, Catch: $7, Finally: $11} + $$.SetPosition($1.Position()) + } + | TRY '{' compstmt '}' CATCH IDENT '{' compstmt '}' + { + $$ = &ast.TryStmt{Try: $3, Var: $6.Lit, Catch: $8} + $$.SetPosition($1.Position()) + } + | TRY '{' compstmt '}' CATCH '{' compstmt '}' + { + $$ = &ast.TryStmt{Try: $3, Catch: $7} + $$.SetPosition($1.Position()) + } + | SWITCH expr '{' stmt_cases '}' + { + $$ = &ast.SwitchStmt{Expr: $2, Cases: $4} + $$.SetPosition($1.Position()) + } + | expr + { + $$ = &ast.ExprStmt{Expr: $1} + $$.SetPosition($1.Position()) + } + + +stmt_if : + stmt_if ELSE IF expr '{' compstmt '}' + { + $1.(*ast.IfStmt).ElseIf = append($1.(*ast.IfStmt).ElseIf, &ast.IfStmt{If: $4, Then: $6}) + $$.SetPosition($1.Position()) + } + | stmt_if ELSE '{' compstmt '}' + { + if $$.(*ast.IfStmt).Else != nil { + yylex.Error("multiple else statement") + } else { + $$.(*ast.IfStmt).Else = append($$.(*ast.IfStmt).Else, $4...) + } + $$.SetPosition($1.Position()) + } + | IF expr '{' compstmt '}' + { + $$ = &ast.IfStmt{If: $2, Then: $4, Else: nil} + $$.SetPosition($1.Position()) + } + +stmt_cases : + { + $$ = []ast.Stmt{} + } + | opt_terms stmt_case + { + $$ = []ast.Stmt{$2} + } + | opt_terms stmt_default + { + $$ = []ast.Stmt{$2} + } + | stmt_cases stmt_case + { + $$ = append($1, $2) + } + | stmt_cases stmt_default + { + for _, stmt := range $1 { + if _, ok := stmt.(*ast.DefaultStmt); ok { + yylex.Error("multiple default statement") + } + } + $$ = append($1, $2) + } + +stmt_case : + CASE expr ':' opt_terms compstmt + { + $$ = &ast.CaseStmt{Expr: $2, Stmts: $5} + } + +stmt_default : + DEFAULT ':' opt_terms compstmt + { + $$ = &ast.DefaultStmt{Stmts: $4} + } + +expr_pair : + STRING ':' expr + { + $$ = &ast.PairExpr{Key: $1.Lit, Value: $3} + } + +expr_pairs : + { + $$ = []ast.Expr{} + } + | expr_pair + { + $$ = []ast.Expr{$1} + } + | expr_pairs ',' opt_terms expr_pair + { + $$ = append($1, $4) + } + +expr_idents : + { + $$ = []string{} + } + | IDENT + { + $$ = []string{$1.Lit} + } + | expr_idents ',' opt_terms IDENT + { + $$ = append($1, $4.Lit) + } + +expr_lets : expr_many '=' expr_many + { + $$ = &ast.LetsExpr{Lhss: $1, Operator: "=", Rhss: $3} + } + +expr_many : + expr + { + $$ = []ast.Expr{$1} + } + | exprs ',' opt_terms expr + { + $$ = append($1, $4) + } + | exprs ',' opt_terms IDENT + { + $$ = append($1, &ast.IdentExpr{Lit: $4.Lit}) + } + +typ : IDENT + { + $$ = ast.Type{Name: $1.Lit} + } + | typ '.' IDENT + { + $$ = ast.Type{Name: $1.Name + "." + $3.Lit} + } + +exprs : + { + $$ = nil + } + | expr + { + $$ = []ast.Expr{$1} + } + | exprs ',' opt_terms expr + { + $$ = append($1, $4) + } + | exprs ',' opt_terms IDENT + { + $$ = append($1, &ast.IdentExpr{Lit: $4.Lit}) + } + +expr : + IDENT + { + $$ = &ast.IdentExpr{Lit: $1.Lit} + $$.SetPosition($1.Position()) + } + | NUMBER + { + $$ = &ast.NumberExpr{Lit: $1.Lit} + $$.SetPosition($1.Position()) + } + | '-' expr %prec UNARY + { + $$ = &ast.UnaryExpr{Operator: "-", Expr: $2} + $$.SetPosition($2.Position()) + } + | '!' expr %prec UNARY + { + $$ = &ast.UnaryExpr{Operator: "!", Expr: $2} + $$.SetPosition($2.Position()) + } + | '^' expr %prec UNARY + { + $$ = &ast.UnaryExpr{Operator: "^", Expr: $2} + $$.SetPosition($2.Position()) + } + | '&' IDENT %prec UNARY + { + $$ = &ast.AddrExpr{Expr: &ast.IdentExpr{Lit: $2.Lit}} + $$.SetPosition($2.Position()) + } + | '&' expr '.' IDENT %prec UNARY + { + $$ = &ast.AddrExpr{Expr: &ast.MemberExpr{Expr: $2, Name: $4.Lit}} + $$.SetPosition($2.Position()) + } + | '*' IDENT %prec UNARY + { + $$ = &ast.DerefExpr{Expr: &ast.IdentExpr{Lit: $2.Lit}} + $$.SetPosition($2.Position()) + } + | '*' expr '.' IDENT %prec UNARY + { + $$ = &ast.DerefExpr{Expr: &ast.MemberExpr{Expr: $2, Name: $4.Lit}} + $$.SetPosition($2.Position()) + } + | STRING + { + $$ = &ast.StringExpr{Lit: $1.Lit} + $$.SetPosition($1.Position()) + } + | TRUE + { + $$ = &ast.ConstExpr{Value: $1.Lit} + $$.SetPosition($1.Position()) + } + | FALSE + { + $$ = &ast.ConstExpr{Value: $1.Lit} + $$.SetPosition($1.Position()) + } + | NIL + { + $$ = &ast.ConstExpr{Value: $1.Lit} + $$.SetPosition($1.Position()) + } + | expr '?' expr ':' expr + { + $$ = &ast.TernaryOpExpr{Expr: $1, Lhs: $3, Rhs: $5} + $$.SetPosition($1.Position()) + } + | expr '.' IDENT + { + $$ = &ast.MemberExpr{Expr: $1, Name: $3.Lit} + $$.SetPosition($1.Position()) + } + | FUNC '(' expr_idents ')' '{' compstmt '}' + { + $$ = &ast.FuncExpr{Args: $3, Stmts: $6} + $$.SetPosition($1.Position()) + } + | FUNC '(' IDENT VARARG ')' '{' compstmt '}' + { + $$ = &ast.FuncExpr{Args: []string{$3.Lit}, Stmts: $7, VarArg: true} + $$.SetPosition($1.Position()) + } + | FUNC IDENT '(' expr_idents ')' '{' compstmt '}' + { + $$ = &ast.FuncExpr{Name: $2.Lit, Args: $4, Stmts: $7} + $$.SetPosition($1.Position()) + } + | FUNC IDENT '(' IDENT VARARG ')' '{' compstmt '}' + { + $$ = &ast.FuncExpr{Name: $2.Lit, Args: []string{$4.Lit}, Stmts: $8, VarArg: true} + $$.SetPosition($1.Position()) + } + | '[' opt_terms exprs opt_terms ']' + { + $$ = &ast.ArrayExpr{Exprs: $3} + if l, ok := yylex.(*Lexer); ok { $$.SetPosition(l.pos) } + } + | '[' opt_terms exprs ',' opt_terms ']' + { + $$ = &ast.ArrayExpr{Exprs: $3} + if l, ok := yylex.(*Lexer); ok { $$.SetPosition(l.pos) } + } + | '{' opt_terms expr_pairs opt_terms '}' + { + mapExpr := make(map[string]ast.Expr) + for _, v := range $3 { + mapExpr[v.(*ast.PairExpr).Key] = v.(*ast.PairExpr).Value + } + $$ = &ast.MapExpr{MapExpr: mapExpr} + if l, ok := yylex.(*Lexer); ok { $$.SetPosition(l.pos) } + } + | '{' opt_terms expr_pairs ',' opt_terms '}' + { + mapExpr := make(map[string]ast.Expr) + for _, v := range $3 { + mapExpr[v.(*ast.PairExpr).Key] = v.(*ast.PairExpr).Value + } + $$ = &ast.MapExpr{MapExpr: mapExpr} + if l, ok := yylex.(*Lexer); ok { $$.SetPosition(l.pos) } + } + | '(' expr ')' + { + $$ = &ast.ParenExpr{SubExpr: $2} + if l, ok := yylex.(*Lexer); ok { $$.SetPosition(l.pos) } + } + | NEW IDENT '(' exprs ')' + { + $$ = &ast.NewExpr{Name: $2.Lit, SubExprs: $4} + $$.SetPosition($1.Position()) + } + | expr '+' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "+", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '-' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "-", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '*' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "*", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '/' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "/", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '%' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "%", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr POW expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "**", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr SHIFTLEFT expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "<<", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr SHIFTRIGHT expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: ">>", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr EQEQ expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "==", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr NEQ expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "!=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '>' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: ">", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr GE expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: ">=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '<' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "<", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr LE expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "<=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr PLUSEQ expr + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "+=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr MINUSEQ expr + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "-=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr MULEQ expr + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "*=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr DIVEQ expr + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "/=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr ANDEQ expr + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "&=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr OREQ expr + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "|=", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr PLUSPLUS + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "++"} + $$.SetPosition($1.Position()) + } + | expr MINUSMINUS + { + $$ = &ast.AssocExpr{Lhs: $1, Operator: "--"} + $$.SetPosition($1.Position()) + } + | expr '|' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "|", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr OROR expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "||", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr '&' expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "&", Rhs: $3} + $$.SetPosition($1.Position()) + } + | expr ANDAND expr + { + $$ = &ast.BinOpExpr{Lhs: $1, Operator: "&&", Rhs: $3} + $$.SetPosition($1.Position()) + } + | IDENT '(' exprs VARARG ')' + { + $$ = &ast.CallExpr{Name: $1.Lit, SubExprs: $3, VarArg: true} + $$.SetPosition($1.Position()) + } + | IDENT '(' exprs ')' + { + $$ = &ast.CallExpr{Name: $1.Lit, SubExprs: $3} + $$.SetPosition($1.Position()) + } + | GO IDENT '(' exprs VARARG ')' + { + $$ = &ast.CallExpr{Name: $2.Lit, SubExprs: $4, VarArg: true, Go: true} + $$.SetPosition($2.Position()) + } + | GO IDENT '(' exprs ')' + { + $$ = &ast.CallExpr{Name: $2.Lit, SubExprs: $4, Go: true} + $$.SetPosition($2.Position()) + } + | expr '(' exprs VARARG ')' + { + $$ = &ast.AnonCallExpr{Expr: $1, SubExprs: $3, VarArg: true} + $$.SetPosition($1.Position()) + } + | expr '(' exprs ')' + { + $$ = &ast.AnonCallExpr{Expr: $1, SubExprs: $3} + $$.SetPosition($1.Position()) + } + | GO expr '(' exprs VARARG ')' + { + $$ = &ast.AnonCallExpr{Expr: $2, SubExprs: $4, VarArg: true, Go: true} + $$.SetPosition($2.Position()) + } + | GO expr '(' exprs ')' + { + $$ = &ast.AnonCallExpr{Expr: $2, SubExprs: $4, Go: true} + $$.SetPosition($1.Position()) + } + | IDENT '[' expr ']' + { + $$ = &ast.ItemExpr{Value: &ast.IdentExpr{Lit: $1.Lit}, Index: $3} + $$.SetPosition($1.Position()) + } + | expr '[' expr ']' + { + $$ = &ast.ItemExpr{Value: $1, Index: $3} + $$.SetPosition($1.Position()) + } + | IDENT '[' expr ':' expr ']' + { + $$ = &ast.SliceExpr{Value: &ast.IdentExpr{Lit: $1.Lit}, Begin: $3, End: $5} + $$.SetPosition($1.Position()) + } + | expr '[' expr ':' expr ']' + { + $$ = &ast.SliceExpr{Value: $1, Begin: $3, End: $5} + $$.SetPosition($1.Position()) + } + | MAKE '(' CHAN typ ')' + { + $$ = &ast.MakeChanExpr{Type: $4.Name, SizeExpr: nil} + $$.SetPosition($1.Position()) + } + | MAKE '(' CHAN typ ',' expr ')' + { + $$ = &ast.MakeChanExpr{Type: $4.Name, SizeExpr: $6} + $$.SetPosition($1.Position()) + } + | MAKE '(' ARRAYLIT typ ',' expr ')' + { + $$ = &ast.MakeArrayExpr{Type: $4.Name, LenExpr: $6} + $$.SetPosition($1.Position()) + } + | MAKE '(' ARRAYLIT typ ',' expr ',' expr ')' + { + $$ = &ast.MakeArrayExpr{Type: $4.Name, LenExpr: $6, CapExpr: $8} + $$.SetPosition($1.Position()) + } + | expr OPCHAN expr + { + $$ = &ast.ChanExpr{Lhs: $1, Rhs: $3} + $$.SetPosition($1.Position()) + } + | OPCHAN expr + { + $$ = &ast.ChanExpr{Rhs: $2} + $$.SetPosition($2.Position()) + } + +opt_terms : /* none */ + | terms + ; + + +terms : term + { + } + | terms term + { + } + ; + +term : ';' + { + } + | '\n' + { + } + ; + +%% diff --git a/vendor/github.com/mattn/anko/t/01-let.ank b/vendor/github.com/mattn/anko/t/01-let.ank new file mode 100644 index 0000000000..d6591538da --- /dev/null +++ b/vendor/github.com/mattn/anko/t/01-let.ank @@ -0,0 +1,31 @@ +a = nil +is(nil, a, "let nil") + +a = 1 +is(1, a, "let int") + +a = 1.2 +is(1.2, a, "let float") + +a = "foo" +is("foo", a, "let string") + +a = nil +is(nil, a, "let nil") + +a = true +is(true, a, "let true") + +a = false +is(false, a, "let false") + +a = [1,2,3] +is([1,2,3], a, "let array") + +a = {"foo": "bar", "bar": "baz"} +is({"bar": "baz", "foo": "bar"}, a, "let map") + +a = {"foo": "bar", "bar": {"blah": true, "blah!": [1.3e3, true]}} +is({"foo": "bar", "bar": {"blah": true, "blah!": [1.3e3, true]}}, a, "let map deep") + +# vim: set ft=anko: diff --git a/vendor/github.com/mattn/anko/t/02-toString.ank b/vendor/github.com/mattn/anko/t/02-toString.ank new file mode 100644 index 0000000000..e4d8f90c62 --- /dev/null +++ b/vendor/github.com/mattn/anko/t/02-toString.ank @@ -0,0 +1,7 @@ +is("1", toString(1), "toString(int)") +is("1.2", toString(1.2), "toString(float)") +is("true", toString(true), "toString(true)") +is("false", toString(false), "toString(false)") +is("foo", toString("foo"), "toString(\"foo\")") + +# vim: set ft=anko: diff --git a/vendor/github.com/mattn/anko/t/03-op.ank b/vendor/github.com/mattn/anko/t/03-op.ank new file mode 100644 index 0000000000..a7d37c9d74 --- /dev/null +++ b/vendor/github.com/mattn/anko/t/03-op.ank @@ -0,0 +1,68 @@ +#!anko + +ok(1 > 0, "1 > 0") +ok(1 == 1.0, "1 == 1.0") +ok(1 != "1", "1 != \"1\"") +ok(1 == 1, "1 == 1") +ok(1.1 == 1.1, "1.1 == 1.1") +ok("1" == "1", "\"1\" == \"1\"") + +ok(false != "1", "false != \"1\"") +ok(false != true, "false != true") +ok(false == false, "false == false") +ok(true == true, "true == true") +ok(false == false, "false == false") +ok(nil == nil, "nil == nil") + +ok(1 <= 1, "1 <= 1") +ok(1.0 <= 1.0, "1.0 <= 1.0") + +is(true, 1 <= 2 ? true : false, "1 == 1 ? true : false") + +a = 1; a += 1 +is(2, a, "+=") + +a = 2; a -= 1 +is(1, a, "-=") + +a = 2; a *= 2 +is(4, a, "*=") + +a = 3; a /= 2 +is(1.5, a, "/=") + +a = 2; a++ +is(3, a, "++") + +a = 2; a-- +is(1, a, "--") + +a = 2**3 +is(8, a, "**") + +a = 1; a &= 2 +is(0, a, "&=") + +a = 1; a |= 2 +is(3, a, "|=") + +a = !3 +is(false, a, "!3") + +a = !true +is(false, a, "!true") + +a = !false +is(true, a, "!false") + +a = ^3 +is(-4, a, "^3") + +a = 3 << 2 +is(12, a, "3 << 2") + +a = 11 >> 2 +is(2, a, "11 >> 2") + +# vim: set ft=anko: + diff --git a/vendor/github.com/mattn/anko/t/04-func.ank b/vendor/github.com/mattn/anko/t/04-func.ank new file mode 100644 index 0000000000..0440e1595e --- /dev/null +++ b/vendor/github.com/mattn/anko/t/04-func.ank @@ -0,0 +1,23 @@ +func a() { return 2 } +is(2, a(), "func a() { return 2 }") + +func b(x) { return x + 1 } +is(3, b(2), "func b(x) { return x + 1 }") + +func c(x) { return x, x + 1 } +is([2,3], c(2), "func c(x) { return x, x + 1 }") + +func d(x) { return func() { return x + 1 } } +is(3, d(2)(), "func d(x) { return func() { return x + 1 } }") + +var x = func(x) { + return func(y) { + x(y) + } +}(func(z) { + return "Yay! " + z +})("hello world") + +is("Yay! hello world", x, "...") + +# vim: set ft=anko: diff --git a/vendor/github.com/mattn/anko/t/05-len.ank b/vendor/github.com/mattn/anko/t/05-len.ank new file mode 100644 index 0000000000..fd4072893f --- /dev/null +++ b/vendor/github.com/mattn/anko/t/05-len.ank @@ -0,0 +1,5 @@ +is(3, len("foo"), "len(\"foo\")") +is(0, len(""), "len(\"\")") +is(4, len([1,2,true,["foo"]]), "len([1,2,true,[\"foo\"]])") + +# vim: set ft=anko: diff --git a/vendor/github.com/mattn/anko/t/06-for.ank b/vendor/github.com/mattn/anko/t/06-for.ank new file mode 100644 index 0000000000..22a1e449e8 --- /dev/null +++ b/vendor/github.com/mattn/anko/t/06-for.ank @@ -0,0 +1,74 @@ +x = 0 +for a in [1,2,3] { + x += 1 +} +is(3, x, "for a in range [1,2,3]") + +x = 0 + +for { + x += 1 + if (x > 3) { + break + } +} +is(4, x, "for loop") + +func loop_with_return_stmt() { + y = 0 + for { + if y == 5 { + return y + } + y++ + } + return 1 +} +is(5, loop_with_return_stmt(), "loop with return stmt") + +func for_with_return_stmt() { + y = 0 + for k in range(0, 10) { + if k == 5 { + return y + } + y++ + } + return 1 +} +is(5, for_with_return_stmt(), "for loop with return stmt") + +x = 0 +for a = 0; a < 10; a++ { + x++ +} +is(10, x, "C-style for loop") + +func cstylefor_with_return_stmt() { + y = 0 + for i = 0; i < 10; i++ { + if i == 5 { + return y + } + y++ + } + + return 1 +} + +is(5, cstylefor_with_return_stmt(), "C-style for loop with return statement") + +resp = { + "items": [{ + "someData": 2, + }] +} + +x = 0 +for item in resp.items { + x += item.someData +} + +is(2, x, "dereference slice element") + +# vim: set ft=anko: diff --git a/vendor/github.com/mattn/anko/t/07-switch.ank b/vendor/github.com/mattn/anko/t/07-switch.ank new file mode 100644 index 0000000000..707814f35c --- /dev/null +++ b/vendor/github.com/mattn/anko/t/07-switch.ank @@ -0,0 +1,39 @@ +x = 0 +r = -1 +switch x { +case 0: + r = 0 +case 1: + r = 1 +case 2: + r = 2 +} +is(0, r, "switch/case") + +x = 3 +r = -1 +switch x { +case 0: + r = 0 +case 1: + r = 1 +case 2: + r = 2 +} +is(-1, r, "switch/case") + +x = 3 +r = -1 +switch x { +case 0: + r = 0 +case 1: + r = 1 +case 2: + r = 2 +default: + r = 3 +} +is(3, r, "switch/default") + +# vim: set ft=anko: diff --git a/vendor/github.com/mattn/anko/t/08-if.ank b/vendor/github.com/mattn/anko/t/08-if.ank new file mode 100644 index 0000000000..5e92cded3b --- /dev/null +++ b/vendor/github.com/mattn/anko/t/08-if.ank @@ -0,0 +1,15 @@ +#!anko + +r = -1 +if (false) { + r = 1 +} else if (false) { + r = 2 +} else if (false) { + r = 3 +} else { + r = 4 +} +is(4, r, "if") + +# vim: set ft=anko: diff --git a/vendor/github.com/mattn/anko/t/09-toBytes.ank b/vendor/github.com/mattn/anko/t/09-toBytes.ank new file mode 100644 index 0000000000..20153e8a56 --- /dev/null +++ b/vendor/github.com/mattn/anko/t/09-toBytes.ank @@ -0,0 +1,11 @@ +a = toByteSlice("あいうえお") +b = [227, 129, 130, 227, 129, 132, 227, 129, 134, 227, 129, 136, 227, 129, 138] +x = 0 +for i = 0; i < len(a); i++ { + if (a[i] == b[i]) { + x++ + } +} +is(x, len(a), "toByteSlice(str)") + +# vim: set ft=anko: diff --git a/vendor/github.com/mattn/anko/t/10-toRunes.ank b/vendor/github.com/mattn/anko/t/10-toRunes.ank new file mode 100644 index 0000000000..7b0f14efc8 --- /dev/null +++ b/vendor/github.com/mattn/anko/t/10-toRunes.ank @@ -0,0 +1,11 @@ +a = toRuneSlice("あいうえお") +b = [12354, 12356, 12358, 12360, 12362] +x = 0 +for i = 0; i < len(a); i++ { + if (a[i] == b[i]) { + x++ + } +} +is(x, len(a), "toRuneSlice(str)") + +# vim: set ft=anko: diff --git a/vendor/github.com/mattn/anko/t/lib/tester.ank b/vendor/github.com/mattn/anko/t/lib/tester.ank new file mode 100644 index 0000000000..1699e552ec --- /dev/null +++ b/vendor/github.com/mattn/anko/t/lib/tester.ank @@ -0,0 +1,43 @@ +var colortext = import("github.com/daviddengcn/go-colortext") + +count = func() { + var n = 0 + return func() { + n += 1 + return n + } +}() + +func is(expect, got, name) { + if (expect == got) { + printf("%03d: %s: ", count(), name) + colortext.ChangeColor("green", true) + println("OK") + colortext.ResetColor() + } else { + printf("%03d: %s: %v %v ", count(), name, expect, got) + colortext.ChangeColor("red", true) + println("NG") + colortext.ResetColor() + } +} + +func ok(expect, name) { + if (expect) { + printf("%03d: %s: ", count(), name) + colortext.ChangeColor("green", true) + println("OK") + colortext.ResetColor() + } else { + printf("%03d: %s: ", count(), name) + colortext.ChangeColor("red", true) + println("NG") + colortext.ResetColor() + throw name + ": expected " + expect + " but got " + got + } +} + +if (len(args) > 0) { + println(args[0]) + load(args[0]) +} diff --git a/vendor/github.com/mattn/anko/t/test.bat b/vendor/github.com/mattn/anko/t/test.bat new file mode 100644 index 0000000000..2d47f61dad --- /dev/null +++ b/vendor/github.com/mattn/anko/t/test.bat @@ -0,0 +1,13 @@ +@echo off + +setlocal enabledelayedexpansion +set DIR=%~dp0 +(cd %DIR%.. && go build) +if !ERRORLEVEL! neq 0 goto error +for %%i in (%DIR%*.ank) do ( + %DIR%..\anko %DIR%lib\tester.ank %%i + if !ERRORLEVEL! neq 0 goto error +) +exit /b 0 +:error +exit /b 1 diff --git a/vendor/github.com/mattn/anko/t/test.sh b/vendor/github.com/mattn/anko/t/test.sh new file mode 100644 index 0000000000..2f44d31ba1 --- /dev/null +++ b/vendor/github.com/mattn/anko/t/test.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +DIR=$(cd $(dirname $0);pwd) + +ls $DIR/*.ank |\ +while read f; do + $DIR/../anko $DIR/lib/tester.ank $f +done diff --git a/vendor/github.com/mattn/anko/tool/makebuiltin.go b/vendor/github.com/mattn/anko/tool/makebuiltin.go new file mode 100644 index 0000000000..c08a2fad27 --- /dev/null +++ b/vendor/github.com/mattn/anko/tool/makebuiltin.go @@ -0,0 +1,128 @@ +package main + +import ( + "fmt" + "go/ast" + "go/parser" + "go/token" + "log" + "os" + "os/exec" + "path/filepath" + "sort" + "strings" +) + +func pkgName(f string) string { + file, err := parser.ParseFile(token.NewFileSet(), f, nil, parser.PackageClauseOnly) + if err != nil || file == nil { + return "" + } + return file.Name.Name +} + +func isGoFile(dir os.FileInfo) bool { + return !dir.IsDir() && + !strings.HasPrefix(dir.Name(), ".") && // ignore .files + filepath.Ext(dir.Name()) == ".go" +} + +func isPkgFile(dir os.FileInfo) bool { + return isGoFile(dir) && !strings.HasSuffix(dir.Name(), "_test.go") // ignore test files +} + +func parseDir(p string) (map[string]*ast.Package, error) { + _, pn := filepath.Split(p) + + isGoDir := func(d os.FileInfo) bool { + if isPkgFile(d) { + name := pkgName(p + "/" + d.Name()) + return name == pn + } + return false + } + + pkgs, err := parser.ParseDir(token.NewFileSet(), p, isGoDir, parser.ParseComments) + if err != nil { + return nil, err + } + return pkgs, nil +} + +func main() { + pkg := "flag" + if len(os.Args) == 2 { + pkg = os.Args[1] + } + b, err := exec.Command("go", "env", "GOROOT").CombinedOutput() + if err != nil { + log.Fatal(err) + } + paths := []string{filepath.Join(strings.TrimSpace(string(b)), "src")} + b, err = exec.Command("go", "env", "GOPATH").CombinedOutput() + if err != nil { + log.Fatal(err) + } + for _, p := range strings.Split(strings.TrimSpace(string(b)), string(filepath.ListSeparator)) { + paths = append(paths, filepath.Join(p, "src")) + } + for _, p := range paths { + pp := filepath.Join(p, pkg) + pkgs, err := parseDir(pp) + if err != nil { + continue + } + names := map[string]bool{} + for _, pp := range pkgs { + for _, f := range pp.Files { + for _, d := range f.Decls { + switch decl := d.(type) { + case *ast.GenDecl: + for _, spec := range decl.Specs { + if vspec, ok := spec.(*ast.ValueSpec); ok { + for _, n := range vspec.Names { + c := n.Name[0] + if c < 'A' || c > 'Z' { + continue + } + names[n.Name] = true + } + } + } + case *ast.FuncDecl: + if decl.Recv != nil { + continue + } + c := decl.Name.Name[0] + if c < 'A' || c > 'Z' { + continue + } + names[decl.Name.Name] = true + } + } + } + } + keys := []string{} + for k, _ := range names { + keys = append(keys, k) + } + sort.Strings(keys) + _, pn := filepath.Split(pkg) + fmt.Printf(`// Package %s implements %s interface for anko script. +package %s + +import ( + "github.com/mattn/anko/vm" + pkg "%s" +) + +func Import(env *vm.Env) *vm.Env { + m := env.NewModule("%s") +`, pn, pkg, pn, pkg, pn) + for _, k := range keys { + fmt.Printf("\t"+`m.Define("%s", pkg.%s)`+"\n", k, k) + } + fmt.Println("\treturn m") + fmt.Println("}") + } +} diff --git a/vendor/github.com/mattn/anko/vm/doc.go b/vendor/github.com/mattn/anko/vm/doc.go new file mode 100644 index 0000000000..6bbb194516 --- /dev/null +++ b/vendor/github.com/mattn/anko/vm/doc.go @@ -0,0 +1,2 @@ +// Package vm implements virtual-machine for anko. +package vm diff --git a/vendor/github.com/mattn/anko/vm/env.go b/vendor/github.com/mattn/anko/vm/env.go new file mode 100644 index 0000000000..0e431e2b33 --- /dev/null +++ b/vendor/github.com/mattn/anko/vm/env.go @@ -0,0 +1,258 @@ +package vm + +import ( + "fmt" + "reflect" + "strings" + "sync" + + "github.com/mattn/anko/parser" +) + +// Env provides interface to run VM. This mean function scope and blocked-scope. +// If stack goes to blocked-scope, it will make new Env. +type Env struct { + name string + env map[string]reflect.Value + typ map[string]reflect.Type + parent *Env + interrupt *bool + sync.RWMutex +} + +// NewEnv creates new global scope. +func NewEnv() *Env { + b := false + + return &Env{ + env: make(map[string]reflect.Value), + typ: make(map[string]reflect.Type), + parent: nil, + interrupt: &b, + } +} + +// NewEnv creates new child scope. +func (e *Env) NewEnv() *Env { + return &Env{ + env: make(map[string]reflect.Value), + typ: make(map[string]reflect.Type), + parent: e, + name: e.name, + interrupt: e.interrupt, + } +} + +func NewPackage(n string) *Env { + b := false + + return &Env{ + env: make(map[string]reflect.Value), + typ: make(map[string]reflect.Type), + parent: nil, + name: n, + interrupt: &b, + } +} + +func (e *Env) NewPackage(n string) *Env { + return &Env{ + env: make(map[string]reflect.Value), + typ: make(map[string]reflect.Type), + parent: e, + name: n, + interrupt: e.interrupt, + } +} + +// Destroy deletes current scope. +func (e *Env) Destroy() { + e.Lock() + defer e.Unlock() + + if e.parent == nil { + return + } + for k, v := range e.parent.env { + if v.IsValid() && v.Interface() == e { + delete(e.parent.env, k) + } + } + e.parent = nil + e.env = nil +} + +// NewModule creates new module scope as global. +func (e *Env) NewModule(n string) *Env { + m := &Env{ + env: make(map[string]reflect.Value), + parent: e, + name: n, + } + e.Define(n, m) + return m +} + +// SetName sets a name of the scope. This means that the scope is module. +func (e *Env) SetName(n string) { + e.Lock() + e.name = n + e.Unlock() +} + +// GetName returns module name. +func (e *Env) GetName() string { + e.RLock() + defer e.RUnlock() + + return e.name +} + +// Addr returns pointer value which specified symbol. It goes to upper scope until +// found or returns error. +func (e *Env) Addr(k string) (reflect.Value, error) { + e.RLock() + defer e.RUnlock() + + if v, ok := e.env[k]; ok { + return v.Addr(), nil + } + if e.parent == nil { + return NilValue, fmt.Errorf("Undefined symbol '%s'", k) + } + return e.parent.Addr(k) +} + +// Type returns type which specified symbol. It goes to upper scope until +// found or returns error. +func (e *Env) Type(k string) (reflect.Type, error) { + e.RLock() + defer e.RUnlock() + + if v, ok := e.typ[k]; ok { + return v, nil + } + if e.parent == nil { + return NilType, fmt.Errorf("Undefined type '%s'", k) + } + return e.parent.Type(k) +} + +// Get returns value which specified symbol. It goes to upper scope until +// found or returns error. +func (e *Env) Get(k string) (reflect.Value, error) { + e.RLock() + defer e.RUnlock() + + if v, ok := e.env[k]; ok { + return v, nil + } + if e.parent == nil { + return NilValue, fmt.Errorf("Undefined symbol '%s'", k) + } + return e.parent.Get(k) +} + +// Set modifies value which specified as symbol. It goes to upper scope until +// found or returns error. +func (e *Env) Set(k string, v interface{}) error { + e.Lock() + defer e.Unlock() + + if _, ok := e.env[k]; ok { + val, ok := v.(reflect.Value) + if !ok { + val = reflect.ValueOf(v) + } + e.env[k] = val + return nil + } + if e.parent == nil { + return fmt.Errorf("Unknown symbol '%s'", k) + } + return e.parent.Set(k, v) +} + +// DefineGlobal defines symbol in global scope. +func (e *Env) DefineGlobal(k string, v interface{}) error { + if e.parent == nil { + return e.Define(k, v) + } + return e.parent.DefineGlobal(k, v) +} + +// DefineType defines type which specifis symbol in global scope. +func (e *Env) DefineType(k string, t interface{}) error { + if strings.Contains(k, ".") { + return fmt.Errorf("Unknown symbol '%s'", k) + } + global := e + keys := []string{k} + + e.RLock() + for global.parent != nil { + if global.name != "" { + keys = append(keys, global.name) + } + global = global.parent + } + e.RUnlock() + + for i, j := 0, len(keys)-1; i < j; i, j = i+1, j-1 { + keys[i], keys[j] = keys[j], keys[i] + } + + typ, ok := t.(reflect.Type) + if !ok { + typ = reflect.TypeOf(t) + } + + global.Lock() + global.typ[strings.Join(keys, ".")] = typ + global.Unlock() + + return nil +} + +// Define defines symbol in current scope. +func (e *Env) Define(k string, v interface{}) error { + if strings.Contains(k, ".") { + return fmt.Errorf("Unknown symbol '%s'", k) + } + val, ok := v.(reflect.Value) + if !ok { + val = reflect.ValueOf(v) + } + + e.Lock() + e.env[k] = val + e.Unlock() + + return nil +} + +// String return the name of current scope. +func (e *Env) String() string { + e.RLock() + defer e.RUnlock() + + return e.name +} + +// Dump show symbol values in the scope. +func (e *Env) Dump() { + e.RLock() + for k, v := range e.env { + fmt.Printf("%v = %#v\n", k, v) + } + e.RUnlock() +} + +// Execute parses and runs source in current scope. +func (e *Env) Execute(src string) (reflect.Value, error) { + stmts, err := parser.ParseSrc(src) + if err != nil { + return NilValue, err + } + return Run(stmts, e) +} diff --git a/vendor/github.com/mattn/anko/vm/env_test.go b/vendor/github.com/mattn/anko/vm/env_test.go new file mode 100644 index 0000000000..36fb47172a --- /dev/null +++ b/vendor/github.com/mattn/anko/vm/env_test.go @@ -0,0 +1,202 @@ +package vm + +import ( + "reflect" + "testing" +) + +func TestGet(t *testing.T) { + env := NewEnv() + env.Define("foo", "bar") + + v, err := env.Get("foo") + if err != nil { + t.Fatalf(`Can't Get value for "foo"`) + } + if v.Kind() != reflect.String { + t.Fatalf(`Can't Get string value for "foo"`) + } + if v.String() != "bar" { + t.Fatalf("Expected %v, but %v:", "bar", v.String()) + } +} + +func TestDefine(t *testing.T) { + env := NewEnv() + env.Define("foo", "bar") + sub := env.NewEnv() + + v, err := sub.Get("foo") + if err != nil { + t.Fatalf(`Can't Get value for "foo"`) + } + if v.Kind() != reflect.String { + t.Fatalf(`Can't Get string value for "foo"`) + } + if v.String() != "bar" { + t.Fatalf("Expected %v, but %v:", "bar", v.String()) + } +} + +func TestDefineModify(t *testing.T) { + env := NewEnv() + env.Define("foo", "bar") + sub := env.NewEnv() + sub.Define("foo", true) + + v, err := sub.Get("foo") + if err != nil { + t.Fatalf(`Can't Get value for "foo"`) + } + if v.Kind() != reflect.Bool { + t.Fatalf(`Can't Get bool value for "foo"`) + } + if v.Bool() != true { + t.Fatalf("Expected %v, but %v:", true, v.Bool()) + } + + v, err = env.Get("foo") + if err != nil { + t.Fatalf(`Can't Get value for "foo"`) + } + if v.Kind() != reflect.String { + t.Fatalf(`Can't Get string value for "foo"`) + } + if v.String() != "bar" { + t.Fatalf("Expected %v, but %v:", "bar", v.String()) + } +} + +func TestDefineType(t *testing.T) { + env := NewEnv() + env.DefineType("int", int(0)) + sub := env.NewEnv() + sub.DefineType("str", "") + pkg := env.NewPackage("pkg") + pkg.DefineType("Bool", true) + + for _, e := range []*Env{env, sub, pkg} { + typ, err := e.Type("int") + if err != nil { + t.Fatalf(`Can't get Type for "int"`) + } + if typ.Kind() != reflect.Int { + t.Fatalf(`Can't get int Type for "int"`) + } + + typ, err = e.Type("str") + if err != nil { + t.Fatalf(`Can't get Type for "str"`) + } + if typ.Kind() != reflect.String { + t.Fatalf(`Can't get string Type for "str"`) + } + + typ, err = e.Type("pkg.Bool") + if err != nil { + t.Fatalf(`Can't get Type for "pkg.Bool"`) + } + if typ.Kind() != reflect.Bool { + t.Fatalf(`Can't get bool Type for "pkg.Bool"`) + } + } +} + +func TestEnvRaces(t *testing.T) { + // Create env + env := NewEnv() + + // Define some values in parallel + go env.Define("foo", "bar") + go env.Define("bar", "foo") + go env.Define("one", "two") + go env.Define("hello", "there") + go env.Define("hey", "ho") + + // Get some values in parallel + go func(env *Env, t *testing.T) { + _, err := env.Get("foo") + if err != nil { + t.Fatalf(`Can't Get value for "foo"`) + } + }(env, t) + + go func(env *Env, t *testing.T) { + _, err := env.Get("bar") + if err != nil { + t.Fatalf(`Can't Get value for "bar"`) + } + }(env, t) + + go func(env *Env, t *testing.T) { + _, err := env.Get("one") + if err != nil { + t.Fatalf(`Can't Get value for "one"`) + } + }(env, t) + + go func(env *Env, t *testing.T) { + _, err := env.Get("hello") + if err != nil { + t.Fatalf(`Can't Get value for "hello"`) + } + }(env, t) + + go func(env *Env, t *testing.T) { + _, err := env.Get("hey") + if err != nil { + t.Fatalf(`Can't Get value for "hey"`) + } + }(env, t) + + // Get subs + go func(env *Env, t *testing.T) { + sub := env.NewEnv() + + _, err := sub.Get("foo") + if err != nil { + t.Fatalf(`Can't Get value for "foo"`) + } + }(env, t) + + go func(env *Env, t *testing.T) { + sub := env.NewEnv() + + _, err := sub.Get("one") + if err != nil { + t.Fatalf(`Can't Get value for "one"`) + } + }(env, t) + + go func(env *Env, t *testing.T) { + sub := env.NewEnv() + + _, err := sub.Get("bar") + if err != nil { + t.Fatalf(`Can't Get value for "bar"`) + } + }(env, t) + + // Define some types + go env.DefineType("int", int(0)) + go env.DefineType("str", "") + + // Define packages + go func(env *Env, t *testing.T) { + pkg := env.NewPackage("pkg") + pkg.DefineType("Bool", true) + }(env, t) + + go func(env *Env, t *testing.T) { + pkg := env.NewPackage("pkg2") + pkg.DefineType("Bool", true) + }(env, t) + + // Get some types + go env.Type("int") + go env.Type("str") + go env.Type("int") + go env.Type("str") + go env.Type("int") + go env.Type("str") +} diff --git a/vendor/github.com/mattn/anko/vm/example_test.go b/vendor/github.com/mattn/anko/vm/example_test.go new file mode 100644 index 0000000000..55148c559f --- /dev/null +++ b/vendor/github.com/mattn/anko/vm/example_test.go @@ -0,0 +1,48 @@ +package vm_test + +import ( + "fmt" + "log" + "time" + + "github.com/mattn/anko/parser" + "github.com/mattn/anko/vm" +) + +func ExampleInterrupt() { + env := vm.NewEnv() + + var sleepFunc = func(spec string) { + if d, err := time.ParseDuration(spec); err != nil { + panic(err) + } else { + time.Sleep(d) + } + } + + env.Define("println", fmt.Println) + env.Define("sleep", sleepFunc) + + script := ` +sleep("2s") +# Should interrupt here. +# The next line will not be executed. +println("") +` + stmts, err := parser.ParseSrc(script) + if err != nil { + log.Fatal() + } + + // Interrupts after 1 second. + go func() { + time.Sleep(time.Second) + vm.Interrupt(env) + }() + + // Run script + v, err := vm.Run(stmts, env) + fmt.Println(v, err) + // output: + // Execution interrupted +} diff --git a/vendor/github.com/mattn/anko/vm/vm.go b/vendor/github.com/mattn/anko/vm/vm.go new file mode 100644 index 0000000000..7e85d5b438 --- /dev/null +++ b/vendor/github.com/mattn/anko/vm/vm.go @@ -0,0 +1,1504 @@ +package vm + +import ( + "errors" + "fmt" + "math" + "os" + "reflect" + "strconv" + "strings" + + "github.com/mattn/anko/ast" + "github.com/mattn/anko/parser" +) + +var ( + NilValue = reflect.ValueOf((*interface{})(nil)) + NilType = reflect.TypeOf((*interface{})(nil)) + TrueValue = reflect.ValueOf(true) + FalseValue = reflect.ValueOf(false) +) + +// Error provides a convenient interface for handling runtime error. +// It can be Error interface with type cast which can call Pos(). +type Error struct { + Message string + Pos ast.Position +} + +var ( + BreakError = errors.New("Unexpected break statement") + ContinueError = errors.New("Unexpected continue statement") + ReturnError = errors.New("Unexpected return statement") + InterruptError = errors.New("Execution interrupted") +) + +// NewStringError makes error interface with message. +func NewStringError(pos ast.Pos, err string) error { + if pos == nil { + return &Error{Message: err, Pos: ast.Position{1, 1}} + } + return &Error{Message: err, Pos: pos.Position()} +} + +// NewErrorf makes error interface with message. +func NewErrorf(pos ast.Pos, format string, args ...interface{}) error { + return &Error{Message: fmt.Sprintf(format, args...), Pos: pos.Position()} +} + +// NewError makes error interface with message. +// This doesn't overwrite last error. +func NewError(pos ast.Pos, err error) error { + if err == nil { + return nil + } + if err == BreakError || err == ContinueError || err == ReturnError { + return err + } + if pe, ok := err.(*parser.Error); ok { + return pe + } + if ee, ok := err.(*Error); ok { + return ee + } + return &Error{Message: err.Error(), Pos: pos.Position()} +} + +// Error returns the error message. +func (e *Error) Error() string { + return e.Message +} + +// Func is function interface to reflect functions internaly. +type Func func(args ...reflect.Value) (reflect.Value, error) + +func (f Func) String() string { + return fmt.Sprintf("[Func: %p]", f) +} + +func ToFunc(f Func) reflect.Value { + return reflect.ValueOf(f) +} + +// Run executes statements in the specified environment. +func Run(stmts []ast.Stmt, env *Env) (reflect.Value, error) { + rv := NilValue + var err error + for _, stmt := range stmts { + if _, ok := stmt.(*ast.BreakStmt); ok { + return NilValue, BreakError + } + if _, ok := stmt.(*ast.ContinueStmt); ok { + return NilValue, ContinueError + } + rv, err = RunSingleStmt(stmt, env) + if err != nil { + return rv, err + } + if _, ok := stmt.(*ast.ReturnStmt); ok { + return reflect.ValueOf(rv), ReturnError + } + } + return rv, nil +} + +// Interrupts the execution of any running statements in the specified environment. +// +// Note that the execution is not instantly aborted: after a call to Interrupt, +// the current running statement will finish, but the next statement will not run, +// and instead will return a NilValue and an InterruptError. +func Interrupt(env *Env) { + env.Lock() + *(env.interrupt) = true + env.Unlock() +} + +// RunSingleStmt executes one statement in the specified environment. +func RunSingleStmt(stmt ast.Stmt, env *Env) (reflect.Value, error) { + env.Lock() + if *(env.interrupt) { + *(env.interrupt) = false + env.Unlock() + + return NilValue, InterruptError + } + env.Unlock() + + switch stmt := stmt.(type) { + case *ast.ExprStmt: + rv, err := invokeExpr(stmt.Expr, env) + if err != nil { + return rv, NewError(stmt, err) + } + return rv, nil + case *ast.VarStmt: + rv := NilValue + var err error + rvs := []reflect.Value{} + for _, expr := range stmt.Exprs { + rv, err = invokeExpr(expr, env) + if err != nil { + return rv, NewError(expr, err) + } + rvs = append(rvs, rv) + } + result := []interface{}{} + for i, name := range stmt.Names { + if i < len(rvs) { + env.Define(name, rvs[i]) + result = append(result, rvs[i].Interface()) + } + } + return reflect.ValueOf(result), nil + case *ast.LetsStmt: + rv := NilValue + var err error + vs := []interface{}{} + for _, rhs := range stmt.Rhss { + rv, err = invokeExpr(rhs, env) + if err != nil { + return rv, NewError(rhs, err) + } + if rv == NilValue { + vs = append(vs, nil) + } else if rv.IsValid() && rv.CanInterface() { + vs = append(vs, rv.Interface()) + } else { + vs = append(vs, nil) + } + } + rvs := reflect.ValueOf(vs) + if len(stmt.Lhss) > 1 && rvs.Len() == 1 { + item := rvs.Index(0) + if item.Kind() == reflect.Interface { + item = item.Elem() + } + if item.Kind() == reflect.Slice { + rvs = item + } + } + for i, lhs := range stmt.Lhss { + if i >= rvs.Len() { + break + } + v := rvs.Index(i) + if v.Kind() == reflect.Interface { + v = v.Elem() + } + _, err = invokeLetExpr(lhs, v, env) + if err != nil { + return rvs, NewError(lhs, err) + } + } + if rvs.Len() == 1 { + return rvs.Index(0), nil + } + return rvs, nil + case *ast.IfStmt: + // If + rv, err := invokeExpr(stmt.If, env) + if err != nil { + return rv, NewError(stmt, err) + } + if toBool(rv) { + // Then + newenv := env.NewEnv() + defer newenv.Destroy() + rv, err = Run(stmt.Then, newenv) + if err != nil { + return rv, NewError(stmt, err) + } + return rv, nil + } + done := false + if len(stmt.ElseIf) > 0 { + for _, stmt := range stmt.ElseIf { + stmt_if := stmt.(*ast.IfStmt) + // ElseIf + rv, err = invokeExpr(stmt_if.If, env) + if err != nil { + return rv, NewError(stmt, err) + } + if !toBool(rv) { + continue + } + // ElseIf Then + done = true + rv, err = Run(stmt_if.Then, env) + if err != nil { + return rv, NewError(stmt, err) + } + break + } + } + if !done && len(stmt.Else) > 0 { + // Else + newenv := env.NewEnv() + defer newenv.Destroy() + rv, err = Run(stmt.Else, newenv) + if err != nil { + return rv, NewError(stmt, err) + } + } + return rv, nil + case *ast.TryStmt: + newenv := env.NewEnv() + defer newenv.Destroy() + _, err := Run(stmt.Try, newenv) + if err != nil { + // Catch + cenv := env.NewEnv() + defer cenv.Destroy() + if stmt.Var != "" { + cenv.Define(stmt.Var, reflect.ValueOf(err)) + } + _, e1 := Run(stmt.Catch, cenv) + if e1 != nil { + err = NewError(stmt.Catch[0], e1) + } else { + err = nil + } + } + if len(stmt.Finally) > 0 { + // Finally + fenv := env.NewEnv() + defer fenv.Destroy() + _, e2 := Run(stmt.Finally, newenv) + if e2 != nil { + err = NewError(stmt.Finally[0], e2) + } + } + return NilValue, NewError(stmt, err) + case *ast.LoopStmt: + newenv := env.NewEnv() + defer newenv.Destroy() + for { + if stmt.Expr != nil { + ev, ee := invokeExpr(stmt.Expr, newenv) + if ee != nil { + return ev, ee + } + if !toBool(ev) { + break + } + } + + rv, err := Run(stmt.Stmts, newenv) + if err != nil { + if err == BreakError { + err = nil + break + } + if err == ContinueError { + err = nil + continue + } + if err == ReturnError { + return rv, err + } + return rv, NewError(stmt, err) + } + } + return NilValue, nil + case *ast.ForStmt: + val, ee := invokeExpr(stmt.Value, env) + if ee != nil { + return val, ee + } + if val.Kind() == reflect.Interface { + val = val.Elem() + } + if val.Kind() != reflect.Array && val.Kind() != reflect.Slice { + return NilValue, NewStringError(stmt, "Invalid operation for non-array value") + } + newenv := env.NewEnv() + defer newenv.Destroy() + + for i := 0; i < val.Len(); i++ { + iv := val.Index(i) + if val.Index(i).Kind() == reflect.Interface || val.Index(i).Kind() == reflect.Ptr { + iv = iv.Elem() + } + newenv.Define(stmt.Var, iv) + rv, err := Run(stmt.Stmts, newenv) + if err != nil { + if err == BreakError { + err = nil + break + } + if err == ContinueError { + err = nil + continue + } + if err == ReturnError { + return rv, err + } + return rv, NewError(stmt, err) + } + } + return NilValue, nil + case *ast.CForStmt: + newenv := env.NewEnv() + defer newenv.Destroy() + _, err := invokeExpr(stmt.Expr1, newenv) + if err != nil { + return NilValue, err + } + for { + fb, err := invokeExpr(stmt.Expr2, newenv) + if err != nil { + return NilValue, err + } + if !toBool(fb) { + break + } + + rv, err := Run(stmt.Stmts, newenv) + if err != nil { + if err == BreakError { + err = nil + break + } + if err == ContinueError { + err = nil + continue + } + if err == ReturnError { + return rv, err + } + return rv, NewError(stmt, err) + } + _, err = invokeExpr(stmt.Expr3, newenv) + if err != nil { + return NilValue, err + } + } + return NilValue, nil + case *ast.ReturnStmt: + rvs := []interface{}{} + switch len(stmt.Exprs) { + case 0: + return NilValue, nil + case 1: + rv, err := invokeExpr(stmt.Exprs[0], env) + if err != nil { + return rv, NewError(stmt, err) + } + return rv, nil + } + for _, expr := range stmt.Exprs { + rv, err := invokeExpr(expr, env) + if err != nil { + return rv, NewError(stmt, err) + } + if isNil(rv) { + rvs = append(rvs, nil) + } else if rv.IsValid() { + rvs = append(rvs, rv.Interface()) + } else { + rvs = append(rvs, nil) + } + } + return reflect.ValueOf(rvs), nil + case *ast.ThrowStmt: + rv, err := invokeExpr(stmt.Expr, env) + if err != nil { + return rv, NewError(stmt, err) + } + if !rv.IsValid() { + return NilValue, NewError(stmt, err) + } + return rv, NewStringError(stmt, fmt.Sprint(rv.Interface())) + case *ast.ModuleStmt: + newenv := env.NewEnv() + newenv.SetName(stmt.Name) + rv, err := Run(stmt.Stmts, newenv) + if err != nil { + return rv, NewError(stmt, err) + } + env.DefineGlobal(stmt.Name, reflect.ValueOf(newenv)) + return rv, nil + case *ast.SwitchStmt: + rv, err := invokeExpr(stmt.Expr, env) + if err != nil { + return rv, NewError(stmt, err) + } + done := false + var default_stmt *ast.DefaultStmt + for _, ss := range stmt.Cases { + if ssd, ok := ss.(*ast.DefaultStmt); ok { + default_stmt = ssd + continue + } + case_stmt := ss.(*ast.CaseStmt) + cv, err := invokeExpr(case_stmt.Expr, env) + if err != nil { + return rv, NewError(stmt, err) + } + if !equal(rv, cv) { + continue + } + rv, err = Run(case_stmt.Stmts, env) + if err != nil { + return rv, NewError(stmt, err) + } + done = true + break + } + if !done && default_stmt != nil { + rv, err = Run(default_stmt.Stmts, env) + if err != nil { + return rv, NewError(stmt, err) + } + } + return rv, nil + default: + return NilValue, NewStringError(stmt, "unknown statement") + } +} + +// toString converts all reflect.Value-s into string. +func toString(v reflect.Value) string { + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.String { + return v.String() + } + if !v.IsValid() { + return "nil" + } + return fmt.Sprint(v.Interface()) +} + +// toBool converts all reflect.Value-s into bool. +func toBool(v reflect.Value) bool { + if v.Kind() == reflect.Interface { + v = v.Elem() + } + + switch v.Kind() { + case reflect.Float32, reflect.Float64: + return v.Float() != 0.0 + case reflect.Int, reflect.Int32, reflect.Int64: + return v.Int() != 0 + case reflect.Bool: + return v.Bool() + case reflect.String: + if v.String() == "true" { + return true + } + if toInt64(v) != 0 { + return true + } + } + return false +} + +// toFloat64 converts all reflect.Value-s into float64. +func toFloat64(v reflect.Value) float64 { + if v.Kind() == reflect.Interface { + v = v.Elem() + } + switch v.Kind() { + case reflect.Float32, reflect.Float64: + return v.Float() + case reflect.Int, reflect.Int32, reflect.Int64: + return float64(v.Int()) + } + return 0.0 +} + +func isNil(v reflect.Value) bool { + if !v.IsValid() || v.Kind().String() == "unsafe.Pointer" { + return true + } + if (v.Kind() == reflect.Interface || v.Kind() == reflect.Ptr) && v.IsNil() { + return true + } + return false +} + +func isNum(v reflect.Value) bool { + switch v.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64: + return true + } + return false +} + +// equal returns true when lhsV and rhsV is same value. +func equal(lhsV, rhsV reflect.Value) bool { + lhsIsNil, rhsIsNil := isNil(lhsV), isNil(rhsV) + if lhsIsNil && rhsIsNil { + return true + } + if (!lhsIsNil && rhsIsNil) || (lhsIsNil && !rhsIsNil) { + return false + } + if lhsV.Kind() == reflect.Interface || lhsV.Kind() == reflect.Ptr { + lhsV = lhsV.Elem() + } + if rhsV.Kind() == reflect.Interface || rhsV.Kind() == reflect.Ptr { + rhsV = rhsV.Elem() + } + if !lhsV.IsValid() || !rhsV.IsValid() { + return true + } + if isNum(lhsV) && isNum(rhsV) { + if rhsV.Type().ConvertibleTo(lhsV.Type()) { + rhsV = rhsV.Convert(lhsV.Type()) + } + } + if lhsV.CanInterface() && rhsV.CanInterface() { + return reflect.DeepEqual(lhsV.Interface(), rhsV.Interface()) + } + return reflect.DeepEqual(lhsV, rhsV) +} + +// toInt64 converts all reflect.Value-s into int64. +func toInt64(v reflect.Value) int64 { + if v.Kind() == reflect.Interface { + v = v.Elem() + } + switch v.Kind() { + case reflect.Float32, reflect.Float64: + return int64(v.Float()) + case reflect.Int, reflect.Int32, reflect.Int64: + return v.Int() + case reflect.String: + s := v.String() + var i int64 + var err error + if strings.HasPrefix(s, "0x") { + i, err = strconv.ParseInt(s, 16, 64) + } else { + i, err = strconv.ParseInt(s, 10, 64) + } + if err == nil { + return int64(i) + } + } + return 0 +} + +func invokeLetExpr(expr ast.Expr, rv reflect.Value, env *Env) (reflect.Value, error) { + switch lhs := expr.(type) { + case *ast.IdentExpr: + if env.Set(lhs.Lit, rv) != nil { + if strings.Contains(lhs.Lit, ".") { + return NilValue, NewErrorf(expr, "Undefined symbol '%s'", lhs.Lit) + } + env.Define(lhs.Lit, rv) + } + return rv, nil + case *ast.MemberExpr: + v, err := invokeExpr(lhs.Expr, env) + if err != nil { + return v, NewError(expr, err) + } + + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Slice { + v = v.Index(0) + } + + if !v.IsValid() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + if v.Kind() == reflect.Struct { + v = v.FieldByName(lhs.Name) + if !v.CanSet() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + v.Set(rv) + } else if v.Kind() == reflect.Map { + v.SetMapIndex(reflect.ValueOf(lhs.Name), rv) + } else { + if !v.CanSet() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + v.Set(rv) + } + return v, nil + case *ast.ItemExpr: + v, err := invokeExpr(lhs.Value, env) + if err != nil { + return v, NewError(expr, err) + } + i, err := invokeExpr(lhs.Index, env) + if err != nil { + return i, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Array || v.Kind() == reflect.Slice { + if i.Kind() != reflect.Int && i.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + ii := int(i.Int()) + if ii < 0 || ii >= v.Len() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + vv := v.Index(ii) + if !vv.CanSet() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + vv.Set(rv) + return rv, nil + } + if v.Kind() == reflect.Map { + if i.Kind() != reflect.String { + return NilValue, NewStringError(expr, "Map key should be string") + } + v.SetMapIndex(i, rv) + return rv, nil + } + return v, NewStringError(expr, "Invalid operation") + case *ast.SliceExpr: + v, err := invokeExpr(lhs.Value, env) + if err != nil { + return v, NewError(expr, err) + } + rb, err := invokeExpr(lhs.Begin, env) + if err != nil { + return rb, NewError(expr, err) + } + re, err := invokeExpr(lhs.End, env) + if err != nil { + return re, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Array || v.Kind() == reflect.Slice { + if rb.Kind() != reflect.Int && rb.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + if re.Kind() != reflect.Int && re.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + ii := int(rb.Int()) + if ii < 0 || ii >= v.Len() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + ij := int(re.Int()) + if ij < 0 || ij >= v.Len() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + vv := v.Slice(ii, ij) + if !vv.CanSet() { + return NilValue, NewStringError(expr, "Cannot assignable") + } + vv.Set(rv) + return rv, nil + } + return v, NewStringError(expr, "Invalid operation") + } + return NilValue, NewStringError(expr, "Invalid operation") +} + +// invokeExpr evaluates one expression. +func invokeExpr(expr ast.Expr, env *Env) (reflect.Value, error) { + switch e := expr.(type) { + case *ast.NumberExpr: + if strings.Contains(e.Lit, ".") || strings.Contains(e.Lit, "e") { + v, err := strconv.ParseFloat(e.Lit, 64) + if err != nil { + return NilValue, NewError(expr, err) + } + return reflect.ValueOf(float64(v)), nil + } + var i int64 + var err error + if strings.HasPrefix(e.Lit, "0x") { + i, err = strconv.ParseInt(e.Lit[2:], 16, 64) + } else { + i, err = strconv.ParseInt(e.Lit, 10, 64) + } + if err != nil { + return NilValue, NewError(expr, err) + } + return reflect.ValueOf(i), nil + case *ast.IdentExpr: + return env.Get(e.Lit) + case *ast.StringExpr: + return reflect.ValueOf(e.Lit), nil + case *ast.ArrayExpr: + a := make([]interface{}, len(e.Exprs)) + for i, expr := range e.Exprs { + arg, err := invokeExpr(expr, env) + if err != nil { + return arg, NewError(expr, err) + } + a[i] = arg.Interface() + } + return reflect.ValueOf(a), nil + case *ast.MapExpr: + m := make(map[string]interface{}) + for k, expr := range e.MapExpr { + v, err := invokeExpr(expr, env) + if err != nil { + return v, NewError(expr, err) + } + m[k] = v.Interface() + } + return reflect.ValueOf(m), nil + case *ast.DerefExpr: + v := NilValue + var err error + switch ee := e.Expr.(type) { + case *ast.IdentExpr: + v, err = env.Get(ee.Lit) + if err != nil { + return v, err + } + case *ast.MemberExpr: + v, err := invokeExpr(ee.Expr, env) + if err != nil { + return v, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Slice { + v = v.Index(0) + } + if v.IsValid() && v.CanInterface() { + if vme, ok := v.Interface().(*Env); ok { + m, err := vme.Get(ee.Name) + if !m.IsValid() || err != nil { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + return m, nil + } + } + + m := v.MethodByName(ee.Name) + if !m.IsValid() { + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + if v.Kind() == reflect.Struct { + m = v.FieldByName(ee.Name) + if !m.IsValid() { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + } else if v.Kind() == reflect.Map { + m = v.MapIndex(reflect.ValueOf(ee.Name)) + if !m.IsValid() { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + } else { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + v = m + } else { + v = m + } + default: + return NilValue, NewStringError(expr, "Invalid operation for the value") + } + if v.Kind() != reflect.Ptr { + return NilValue, NewStringError(expr, "Cannot deference for the value") + } + return v.Addr(), nil + case *ast.AddrExpr: + v := NilValue + var err error + switch ee := e.Expr.(type) { + case *ast.IdentExpr: + v, err = env.Get(ee.Lit) + if err != nil { + return v, err + } + case *ast.MemberExpr: + v, err := invokeExpr(ee.Expr, env) + if err != nil { + return v, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Slice { + v = v.Index(0) + } + if v.IsValid() && v.CanInterface() { + if vme, ok := v.Interface().(*Env); ok { + m, err := vme.Get(ee.Name) + if !m.IsValid() || err != nil { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + return m, nil + } + } + + m := v.MethodByName(ee.Name) + if !m.IsValid() { + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + if v.Kind() == reflect.Struct { + m = v.FieldByName(ee.Name) + if !m.IsValid() { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + } else if v.Kind() == reflect.Map { + m = v.MapIndex(reflect.ValueOf(ee.Name)) + if !m.IsValid() { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + } else { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", ee.Name)) + } + v = m + } else { + v = m + } + default: + return NilValue, NewStringError(expr, "Invalid operation for the value") + } + if !v.CanAddr() { + i := v.Interface() + return reflect.ValueOf(&i), nil + } + return v.Addr(), nil + case *ast.UnaryExpr: + v, err := invokeExpr(e.Expr, env) + if err != nil { + return v, NewError(expr, err) + } + switch e.Operator { + case "-": + if v.Kind() == reflect.Float64 { + return reflect.ValueOf(-v.Float()), nil + } + return reflect.ValueOf(-v.Int()), nil + case "^": + return reflect.ValueOf(^toInt64(v)), nil + case "!": + return reflect.ValueOf(!toBool(v)), nil + default: + return NilValue, NewStringError(e, "Unknown operator ''") + } + case *ast.ParenExpr: + v, err := invokeExpr(e.SubExpr, env) + if err != nil { + return v, NewError(expr, err) + } + return v, nil + case *ast.FuncExpr: + f := reflect.ValueOf(func(expr *ast.FuncExpr, env *Env) Func { + return func(args ...reflect.Value) (reflect.Value, error) { + if !expr.VarArg { + if len(args) != len(expr.Args) { + return NilValue, NewStringError(expr, "Arguments Number of mismatch") + } + } + newenv := env.NewEnv() + if expr.VarArg { + newenv.Define(expr.Args[0], reflect.ValueOf(args)) + } else { + for i, arg := range expr.Args { + newenv.Define(arg, args[i]) + } + } + rr, err := Run(expr.Stmts, newenv) + if err == ReturnError { + err = nil + rr = rr.Interface().(reflect.Value) + } + return rr, err + } + }(e, env)) + env.Define(e.Name, f) + return f, nil + case *ast.MemberExpr: + v, err := invokeExpr(e.Expr, env) + if err != nil { + return v, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Slice { + v = v.Index(0) + } + if v.IsValid() && v.CanInterface() { + if vme, ok := v.Interface().(*Env); ok { + m, err := vme.Get(e.Name) + if !m.IsValid() || err != nil { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", e.Name)) + } + return m, nil + } + } + + m := v.MethodByName(e.Name) + if !m.IsValid() { + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + if v.Kind() == reflect.Struct { + m = v.FieldByName(e.Name) + if !m.IsValid() { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", e.Name)) + } + } else if v.Kind() == reflect.Map { + m = v.MapIndex(reflect.ValueOf(e.Name)) + if !m.IsValid() { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", e.Name)) + } + } else { + return NilValue, NewStringError(expr, fmt.Sprintf("Invalid operation '%s'", e.Name)) + } + } + return m, nil + case *ast.ItemExpr: + v, err := invokeExpr(e.Value, env) + if err != nil { + return v, NewError(expr, err) + } + i, err := invokeExpr(e.Index, env) + if err != nil { + return i, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Array || v.Kind() == reflect.Slice { + if i.Kind() != reflect.Int && i.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + ii := int(i.Int()) + if ii < 0 || ii >= v.Len() { + return NilValue, nil + } + return v.Index(ii), nil + } + if v.Kind() == reflect.Map { + if i.Kind() != reflect.String { + return NilValue, NewStringError(expr, "Map key should be string") + } + return v.MapIndex(i), nil + } + if v.Kind() == reflect.String { + rs := []rune(v.Interface().(string)) + ii := int(i.Int()) + if ii < 0 || ii >= len(rs) { + return NilValue, nil + } + return reflect.ValueOf(rs[ii]), nil + } + return v, NewStringError(expr, "Invalid operation") + case *ast.SliceExpr: + v, err := invokeExpr(e.Value, env) + if err != nil { + return v, NewError(expr, err) + } + rb, err := invokeExpr(e.Begin, env) + if err != nil { + return rb, NewError(expr, err) + } + re, err := invokeExpr(e.End, env) + if err != nil { + return re, NewError(expr, err) + } + if v.Kind() == reflect.Interface { + v = v.Elem() + } + if v.Kind() == reflect.Array || v.Kind() == reflect.Slice { + if rb.Kind() != reflect.Int && rb.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + if re.Kind() != reflect.Int && re.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + ii := int(rb.Int()) + if ii < 0 || ii > v.Len() { + return NilValue, nil + } + ij := int(re.Int()) + if ij < 0 || ij > v.Len() { + return v, nil + } + return v.Slice(ii, ij), nil + } + if v.Kind() == reflect.String { + if rb.Kind() != reflect.Int && rb.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + if re.Kind() != reflect.Int && re.Kind() != reflect.Int64 { + return NilValue, NewStringError(expr, "Array index should be int") + } + r := []rune(v.String()) + ii := int(rb.Int()) + if ii < 0 || ii >= len(r) { + return NilValue, nil + } + ij := int(re.Int()) + if ij < 0 || ij >= len(r) { + return NilValue, nil + } + return reflect.ValueOf(string(r[ii:ij])), nil + } + return v, NewStringError(expr, "Invalid operation") + case *ast.AssocExpr: + switch e.Operator { + case "++": + if alhs, ok := e.Lhs.(*ast.IdentExpr); ok { + v, err := env.Get(alhs.Lit) + if err != nil { + return v, err + } + if v.Kind() == reflect.Float64 { + v = reflect.ValueOf(toFloat64(v) + 1.0) + } else { + v = reflect.ValueOf(toInt64(v) + 1) + } + if env.Set(alhs.Lit, v) != nil { + env.Define(alhs.Lit, v) + } + return v, nil + } + case "--": + if alhs, ok := e.Lhs.(*ast.IdentExpr); ok { + v, err := env.Get(alhs.Lit) + if err != nil { + return v, err + } + if v.Kind() == reflect.Float64 { + v = reflect.ValueOf(toFloat64(v) - 1.0) + } else { + v = reflect.ValueOf(toInt64(v) - 1) + } + if env.Set(alhs.Lit, v) != nil { + env.Define(alhs.Lit, v) + } + return v, nil + } + } + + v, err := invokeExpr(&ast.BinOpExpr{Lhs: e.Lhs, Operator: e.Operator[0:1], Rhs: e.Rhs}, env) + if err != nil { + return v, err + } + + if v.Kind() == reflect.Interface { + v = v.Elem() + } + return invokeLetExpr(e.Lhs, v, env) + case *ast.LetExpr: + rv, err := invokeExpr(e.Rhs, env) + if err != nil { + return rv, NewError(e, err) + } + if rv.Kind() == reflect.Interface { + rv = rv.Elem() + } + return invokeLetExpr(e.Lhs, rv, env) + case *ast.LetsExpr: + rv := NilValue + var err error + vs := []interface{}{} + for _, rhs := range e.Rhss { + rv, err = invokeExpr(rhs, env) + if err != nil { + return rv, NewError(rhs, err) + } + if rv == NilValue { + vs = append(vs, nil) + } else if rv.IsValid() && rv.CanInterface() { + vs = append(vs, rv.Interface()) + } else { + vs = append(vs, nil) + } + } + rvs := reflect.ValueOf(vs) + if len(e.Lhss) > 1 && rvs.Len() == 1 { + item := rvs.Index(0) + if item.Kind() == reflect.Interface { + item = item.Elem() + } + if item.Kind() == reflect.Slice { + rvs = item + } + } + for i, lhs := range e.Lhss { + if i >= rvs.Len() { + break + } + v := rvs.Index(i) + if v.Kind() == reflect.Interface { + v = v.Elem() + } + _, err = invokeLetExpr(lhs, v, env) + if err != nil { + return rvs, NewError(lhs, err) + } + } + if rvs.Len() == 1 { + return rvs.Index(0), nil + } + return rvs, nil + //case *ast.NewExpr: + // println("NEW") + // return NilValue, nil + case *ast.BinOpExpr: + lhsV := NilValue + rhsV := NilValue + var err error + + lhsV, err = invokeExpr(e.Lhs, env) + if err != nil { + return lhsV, NewError(expr, err) + } + if lhsV.Kind() == reflect.Interface { + lhsV = lhsV.Elem() + } + if e.Rhs != nil { + rhsV, err = invokeExpr(e.Rhs, env) + if err != nil { + return rhsV, NewError(expr, err) + } + if rhsV.Kind() == reflect.Interface { + rhsV = rhsV.Elem() + } + } + switch e.Operator { + case "+": + if lhsV.Kind() == reflect.String || rhsV.Kind() == reflect.String { + return reflect.ValueOf(toString(lhsV) + toString(rhsV)), nil + } + if (lhsV.Kind() == reflect.Array || lhsV.Kind() == reflect.Slice) && (rhsV.Kind() != reflect.Array && rhsV.Kind() != reflect.Slice) { + return reflect.Append(lhsV, rhsV), nil + } + if (lhsV.Kind() == reflect.Array || lhsV.Kind() == reflect.Slice) && (rhsV.Kind() == reflect.Array || rhsV.Kind() == reflect.Slice) { + return reflect.AppendSlice(lhsV, rhsV), nil + } + if lhsV.Kind() == reflect.Float64 || rhsV.Kind() == reflect.Float64 { + return reflect.ValueOf(toFloat64(lhsV) + toFloat64(rhsV)), nil + } + return reflect.ValueOf(toInt64(lhsV) + toInt64(rhsV)), nil + case "-": + if lhsV.Kind() == reflect.Float64 || rhsV.Kind() == reflect.Float64 { + return reflect.ValueOf(toFloat64(lhsV) - toFloat64(rhsV)), nil + } + return reflect.ValueOf(toInt64(lhsV) - toInt64(rhsV)), nil + case "*": + if lhsV.Kind() == reflect.String && (rhsV.Kind() == reflect.Int || rhsV.Kind() == reflect.Int32 || rhsV.Kind() == reflect.Int64) { + return reflect.ValueOf(strings.Repeat(toString(lhsV), int(toInt64(rhsV)))), nil + } + if lhsV.Kind() == reflect.Float64 || rhsV.Kind() == reflect.Float64 { + return reflect.ValueOf(toFloat64(lhsV) * toFloat64(rhsV)), nil + } + return reflect.ValueOf(toInt64(lhsV) * toInt64(rhsV)), nil + case "/": + return reflect.ValueOf(toFloat64(lhsV) / toFloat64(rhsV)), nil + case "%": + return reflect.ValueOf(toInt64(lhsV) % toInt64(rhsV)), nil + case "==": + return reflect.ValueOf(equal(lhsV, rhsV)), nil + case "!=": + return reflect.ValueOf(equal(lhsV, rhsV) == false), nil + case ">": + return reflect.ValueOf(toFloat64(lhsV) > toFloat64(rhsV)), nil + case ">=": + return reflect.ValueOf(toFloat64(lhsV) >= toFloat64(rhsV)), nil + case "<": + return reflect.ValueOf(toFloat64(lhsV) < toFloat64(rhsV)), nil + case "<=": + return reflect.ValueOf(toFloat64(lhsV) <= toFloat64(rhsV)), nil + case "|": + return reflect.ValueOf(toInt64(lhsV) | toInt64(rhsV)), nil + case "||": + if toBool(lhsV) { + return lhsV, nil + } + return rhsV, nil + case "&": + return reflect.ValueOf(toInt64(lhsV) & toInt64(rhsV)), nil + case "&&": + if toBool(lhsV) { + return rhsV, nil + } + return lhsV, nil + case "**": + if lhsV.Kind() == reflect.Float64 { + return reflect.ValueOf(math.Pow(toFloat64(lhsV), toFloat64(rhsV))), nil + } + return reflect.ValueOf(int64(math.Pow(toFloat64(lhsV), toFloat64(rhsV)))), nil + case ">>": + return reflect.ValueOf(toInt64(lhsV) >> uint64(toInt64(rhsV))), nil + case "<<": + return reflect.ValueOf(toInt64(lhsV) << uint64(toInt64(rhsV))), nil + default: + return NilValue, NewStringError(expr, "Unknown operator") + } + case *ast.ConstExpr: + switch e.Value { + case "true": + return reflect.ValueOf(true), nil + case "false": + return reflect.ValueOf(false), nil + } + return reflect.ValueOf(nil), nil + case *ast.AnonCallExpr: + f, err := invokeExpr(e.Expr, env) + if err != nil { + return f, NewError(expr, err) + } + if f.Kind() == reflect.Interface { + f = f.Elem() + } + if f.Kind() != reflect.Func { + return f, NewStringError(expr, "Unknown function") + } + return invokeExpr(&ast.CallExpr{Func: f, SubExprs: e.SubExprs, VarArg: e.VarArg, Go: e.Go}, env) + case *ast.CallExpr: + f := NilValue + + if e.Func != nil { + f = e.Func.(reflect.Value) + } else { + var err error + ff, err := env.Get(e.Name) + if err != nil { + return f, err + } + f = ff + } + _, isReflect := f.Interface().(Func) + + args := []reflect.Value{} + l := len(e.SubExprs) + for i, expr := range e.SubExprs { + arg, err := invokeExpr(expr, env) + if err != nil { + return arg, NewError(expr, err) + } + + if i < f.Type().NumIn() { + if !f.Type().IsVariadic() { + it := f.Type().In(i) + if arg.Kind().String() == "unsafe.Pointer" { + arg = reflect.New(it).Elem() + } + if arg.Kind() != it.Kind() && arg.IsValid() && arg.Type().ConvertibleTo(it) { + arg = arg.Convert(it) + } else if arg.Kind() == reflect.Func { + if _, isFunc := arg.Interface().(Func); isFunc { + rfunc := arg + arg = reflect.MakeFunc(it, func(args []reflect.Value) []reflect.Value { + for i := range args { + args[i] = reflect.ValueOf(args[i]) + } + if e.Go { + go func() { + rfunc.Call(args) + }() + return []reflect.Value{} + } + return rfunc.Call(args)[:it.NumOut()] + }) + } + } else if !arg.IsValid() { + arg = reflect.Zero(it) + } + } + } + if !arg.IsValid() { + arg = NilValue + } + + if !isReflect { + if e.VarArg && i == l-1 { + for j := 0; j < arg.Len(); j++ { + args = append(args, arg.Index(j).Elem()) + } + } else { + args = append(args, arg) + } + } else { + if arg.Kind() == reflect.Interface { + arg = arg.Elem() + } + if e.VarArg && i == l-1 { + for j := 0; j < arg.Len(); j++ { + args = append(args, reflect.ValueOf(arg.Index(j).Elem())) + } + } else { + args = append(args, reflect.ValueOf(arg)) + } + } + } + ret := NilValue + var err error + fnc := func() { + defer func() { + if os.Getenv("ANKO_DEBUG") == "" { + if ex := recover(); ex != nil { + if e, ok := ex.(error); ok { + err = e + } else { + err = errors.New(fmt.Sprint(ex)) + } + } + } + }() + if f.Kind() == reflect.Interface { + f = f.Elem() + } + rets := f.Call(args) + if isReflect { + ev := rets[1].Interface() + if ev != nil { + err = ev.(error) + } + ret = rets[0].Interface().(reflect.Value) + } else { + for i, expr := range e.SubExprs { + if ae, ok := expr.(*ast.AddrExpr); ok { + if id, ok := ae.Expr.(*ast.IdentExpr); ok { + invokeLetExpr(id, args[i].Elem().Elem(), env) + } + } + } + if f.Type().NumOut() == 1 { + ret = rets[0] + } else { + var result []interface{} + for _, r := range rets { + result = append(result, r.Interface()) + } + ret = reflect.ValueOf(result) + } + } + } + if e.Go { + go fnc() + return NilValue, nil + } + fnc() + if err != nil { + return ret, NewError(expr, err) + } + return ret, nil + case *ast.TernaryOpExpr: + rv, err := invokeExpr(e.Expr, env) + if err != nil { + return rv, NewError(expr, err) + } + if toBool(rv) { + lhsV, err := invokeExpr(e.Lhs, env) + if err != nil { + return lhsV, NewError(expr, err) + } + return lhsV, nil + } + rhsV, err := invokeExpr(e.Rhs, env) + if err != nil { + return rhsV, NewError(expr, err) + } + return rhsV, nil + case *ast.MakeChanExpr: + typ, err := env.Type(e.Type) + if err != nil { + return NilValue, err + } + var size int + if e.SizeExpr != nil { + rv, err := invokeExpr(e.SizeExpr, env) + if err != nil { + return NilValue, err + } + size = int(toInt64(rv)) + } + return func() (reflect.Value, error) { + defer func() { + if os.Getenv("ANKO_DEBUG") == "" { + if ex := recover(); ex != nil { + if e, ok := ex.(error); ok { + err = e + } else { + err = errors.New(fmt.Sprint(ex)) + } + } + } + }() + return reflect.MakeChan(reflect.ChanOf(reflect.BothDir, typ), size), nil + }() + case *ast.MakeArrayExpr: + typ, err := env.Type(e.Type) + if err != nil { + return NilValue, err + } + var alen int + if e.LenExpr != nil { + rv, err := invokeExpr(e.LenExpr, env) + if err != nil { + return NilValue, err + } + alen = int(toInt64(rv)) + } + var acap int + if e.CapExpr != nil { + rv, err := invokeExpr(e.CapExpr, env) + if err != nil { + return NilValue, err + } + acap = int(toInt64(rv)) + } else { + acap = alen + } + return func() (reflect.Value, error) { + defer func() { + if os.Getenv("ANKO_DEBUG") == "" { + if ex := recover(); ex != nil { + if e, ok := ex.(error); ok { + err = e + } else { + err = errors.New(fmt.Sprint(ex)) + } + } + } + }() + return reflect.MakeSlice(reflect.SliceOf(typ), alen, acap), nil + }() + case *ast.ChanExpr: + rhs, err := invokeExpr(e.Rhs, env) + if err != nil { + return NilValue, NewError(expr, err) + } + + if e.Lhs == nil { + if rhs.Kind() == reflect.Chan { + rv, _ := rhs.Recv() + return rv, nil + } + } else { + lhs, err := invokeExpr(e.Lhs, env) + if err != nil { + return NilValue, NewError(expr, err) + } + if lhs.Kind() == reflect.Chan { + lhs.Send(rhs) + return NilValue, nil + } else if rhs.Kind() == reflect.Chan { + rv, _ := rhs.Recv() + return invokeLetExpr(e.Lhs, rv, env) + } + } + return NilValue, NewStringError(expr, "Invalid operation for chan") + default: + return NilValue, NewStringError(expr, "Unknown expression") + } +} diff --git a/vendor/github.com/mattn/anko/vm/vm_test.go b/vendor/github.com/mattn/anko/vm/vm_test.go new file mode 100644 index 0000000000..1dfd0b2e11 --- /dev/null +++ b/vendor/github.com/mattn/anko/vm/vm_test.go @@ -0,0 +1,54 @@ +package vm + +import ( + "fmt" + "log" + "testing" + "time" + + "github.com/mattn/anko/parser" +) + +func testInterrupt() { + env := NewEnv() + + var sleepFunc = func(spec string) { + if d, err := time.ParseDuration(spec); err != nil { + panic(err) + } else { + time.Sleep(d) + } + } + + env.Define("println", fmt.Println) + env.Define("sleep", sleepFunc) + + script := ` +sleep("2s") +# Should interrupt here. +# The next line will not be executed. +println("") +` + stmts, err := parser.ParseSrc(script) + if err != nil { + log.Fatal() + } + + // Interrupts after 1 second. + go func() { + time.Sleep(time.Second) + Interrupt(env) + }() + + _, err = Run(stmts, env) + if err != nil { + log.Fatal() + } +} + +func TestInterruptRaces(t *testing.T) { + // Run example several times + for i := 0; i < 100; i++ { + go testInterrupt() + } +} diff --git a/vendor/github.com/spf13/pflag/verify/all.sh b/vendor/github.com/spf13/pflag/verify/all.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/spf13/pflag/verify/gofmt.sh b/vendor/github.com/spf13/pflag/verify/gofmt.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/spf13/pflag/verify/golint.sh b/vendor/github.com/spf13/pflag/verify/golint.sh old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/plan9/mkall.sh b/vendor/golang.org/x/sys/plan9/mkall.sh old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/plan9/mkerrors.sh b/vendor/golang.org/x/sys/plan9/mkerrors.sh old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/plan9/mksyscall.pl b/vendor/golang.org/x/sys/plan9/mksyscall.pl old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/plan9/mksysnum_plan9.sh b/vendor/golang.org/x/sys/plan9/mksysnum_plan9.sh old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/unix/linux/mksysnum.pl b/vendor/golang.org/x/sys/unix/linux/mksysnum.pl old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/unix/mkall.sh b/vendor/golang.org/x/sys/unix/mkall.sh old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/unix/mksyscall.pl b/vendor/golang.org/x/sys/unix/mksyscall.pl old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl b/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl b/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/unix/mksysnum_darwin.pl b/vendor/golang.org/x/sys/unix/mksysnum_darwin.pl old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl b/vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl b/vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl b/vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl old mode 100755 new mode 100644 diff --git a/vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl b/vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl old mode 100755 new mode 100644