Import

package
v0.0.0-...-1802cdc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2020 License: Artistic-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Expression = compiler.Expression{
	Detect: func(c *compiler.Compiler) compiler.Type {
		if Import, ok := Imports[c.Token()]; ok {

			c.Expecting("(")

			var Arguments []Type

			for c.Peek() != ")" {
				Arguments = append(Arguments, c.ToString(c.ScanExpression()))
				if c.Peek() != ")" {
					c.Expecting(",")
				}
			}
			c.Expecting(")")

			c.Trace()
			return c.External(c.String(Import.Command)).Call(Arguments...)
		}

		return nil
	},
}
View Source
var Imports = make(map[string]Import)

TODO merge this into Compiler

View Source
var Name = compiler.Translatable{
	compiler.English: "import",
}
View Source
var Statement = compiler.Statement{
	Name: Name,

	OnScan: func(c *compiler.Compiler) {
		var Package = c.Scan()

		Imports[Package] = Import{
			Command: Package,
		}
	},

	Detect: func(c *compiler.Compiler) bool {

		if Import, ok := Imports[c.Token()]; ok {

			c.Expecting("(")

			var Arguments []Type

			for c.Peek() != ")" {
				Arguments = append(Arguments, c.ToString(c.ScanExpression()))
				if c.Peek() != ")" {
					c.Expecting(",")
				}
			}
			c.Expecting(")")

			c.Trace()
			c.External(c.String(Import.Command)).Run(Arguments...)
			return true
		}

		return false
	},
}

Functions

This section is empty.

Types

type Import

type Import struct {
	Command string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL