Code Monkey home page Code Monkey logo

bake's Introduction

bake's People

Contributors

alexgustafsson avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

haifenghuang

bake's Issues

Implement type conversions

Implement simple conversions between types such as strings, bools etc. This makes it possible to convert, for example, an string environment variable to an int.

Evaluate how to handle shell usage

Should it always be output?
Should it optionally be output?
Should it explicitly be output (like it is now with print)?
Should a failing shell statement block the execution of the function or scope?

Create an explicit stdlib

There's a possibility that the current builtin mechanics will not scale well. Instead, create a stdlib where the imports have paths like std/io to use like so:

io::print("hello")

Perhaps some functions, such as print should be kept a builtin? Others, such as split, range etc. should perhaps not. They could even become a "property function" like in JS - "hello".split("\n"), Array.range(0, 2) etc.

Fix prism shell grammar

The shell grammardDoesn't work for context.shell.stdout.string etc. as shell* will be marked as a string. Add an assert for only whitespace before the shell expression

Evaluate alternatives to TreeError

The AST-based TreeError struct may be solved in a better way. Evaluate alternatives and see if the error formatting may be done in a less memory-intensive manner.

Make comments accessible via AST methods

Comments have been solved in a hacky way. Whenever the parser sees a comment, it discards it and moves on. This makes it harder to keep the comments in the correct place in the AST. It's possible, however, to make them accessible via another channel. From the code:

// TODO: Hacky way of ignoring comments. Have them in a separate channel?
// or just add them to a separate structure for future referencing:
// comments.At(line, column) -> comment
for {
	item := parser.lexer.NextItem()
	if item.Type != lexing.ItemComment {
		return item
	}
}

Allow functions to be declared anywhere

Functions and rule functions should be able to be declared anywhere. In a perfect world, aliases and rules would to - but they may use top-level code and variables.

We want:

let prefix = get_prefix()
let version = "v0.1.0"
let commit = get_commit()
let go_version = get_go_version()
let compile_time = get_compile_time()
let build_variables = "-X \"$(prefix).Version=$(version)\" -X \"$(prefix).Commit=$(commit)\" -X \"$(prefix).GoVersion=$(go_version)\" -X \"$(prefix).CompileTime=$(compile_time)\""
let build_flags = "-ldflags '$(build_variables)'"

func get_prefix {
  shell go list ./internal/version
  return context.shell.stdout
}

func get_commit {
 shell git rev-parse --short HEAD 2>/dev/null
 return context.shell.stdout
}

func get_go_version {
  shell go version
  return context.shell.stdout
}

export func get_compile_time {
  shell LC_ALL=en_US date
  return context.shell.stdout
}

// Build tools
export alias tools: [vscode, nano, prism]

// Copy the nanorc file to the build output
export alias nano : ["tools/nano/bake.nanorc"]
"tools/nano/bake.nanorc" {
  shell {
    mkdir -p build
    cp tools/nano/bake.nanorc build
  }
}

// Build the vscode tool
export func vscode {
  shell {
    bake run --in tools/vscode package
    mkdir -p build
    cp tools/vscode/bake-lsp*.vsix build
  }
}

// Build the PrismJS grammar
export func prism {
  shell {
    bake run --in tools/prism build
    mkdir -p build
    cp tools/prism/build/* build/
  }
}

We have:

func get_prefix {
  shell go list ./internal/version
  return context.shell.stdout
}

func get_commit {
 shell git rev-parse --short HEAD 2>/dev/null
 return context.shell.stdout
}

func get_go_version {
  shell go version
  return context.shell.stdout
}

export func get_compile_time {
  shell LC_ALL=en_US date
  return context.shell.stdout
}

let prefix = get_prefix()
let version = "v0.1.0"
let commit = get_commit()
let go_version = get_go_version()
let compile_time = get_compile_time()
let build_variables = "-X \"$(prefix).Version=$(version)\" -X \"$(prefix).Commit=$(commit)\" -X \"$(prefix).GoVersion=$(go_version)\" -X \"$(prefix).CompileTime=$(compile_time)\""
let build_flags = "-ldflags '$(build_variables)'"

// Copy the nanorc file to the build output
export alias nano : ["tools/nano/bake.nanorc"]
"tools/nano/bake.nanorc" {
  shell {
    mkdir -p build
    cp tools/nano/bake.nanorc build
  }
}

// Build the vscode tool
export func vscode {
  shell {
    bake run --in tools/vscode package
    mkdir -p build
    cp tools/vscode/bake-lsp*.vsix build
  }
}

// Build the PrismJS grammar
export func prism {
  shell {
    bake run --in tools/prism build
    mkdir -p build
    cp tools/prism/build/* build/
  }
}

// Build tools
export alias tools: [vscode, nano, prism]

Evaluate parser whitespace limits

Whitespace is generally ignored by the parser, but newlines are not. This makes the parser explicitly deal with newlines here and there, which may hurt flexibility in the syntax.

let object = {
  is_this_legal:
   1,
  // ?
}
[0,

1, 2

]
func (
 a,
 b
)
{
  // helllo
}

Fix assignments

Assignments are not full featured. They don't handle assigning to object properties and the value they assign to may not always be what the user actually wants.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.