Commit Graph

40 Commits

Author SHA1 Message Date
Stanisław Barzowski
b70cbd441a Anonymous Import Locations
We used to treat dummy paths like <stdin>, <std>, <extvar> as
real import locations, which causes obvious problem for importers.

After this change we consistently pass "" (an empty string) as location
for non-imported paths.

We exposed new functions to properly handle all paths.

The first function family, EvaluateFile* which allow evaluating
a Jsonnet program at a specified importable path. It should
be used in most cases.

The second function family, EvaluateAnonymousSnippet* allows evaluating
a snippet without an importable path. It should be used for situations
like the code passed as a commandline argument, stdin, etc.

The old function family, EvaluateSnippet* is now deprecated, but
works the same as before, i.e. the passed filenames are treated
as imported paths.

Changes are required to custom importers to make sure they satisfy
the refined contract.

Fixes #329.
2020-09-08 17:27:47 +02:00
Varun B Patil
2e346e53e7 jsonnet-deps: Jsonnet static dependency parser
Fixes #833
2020-08-08 19:59:36 +02:00
Stanisław Barzowski
d1c1457520 Release v0.16.0 2020-05-22 19:13:53 +02:00
Stanisław Barzowski
70a6b3d419 Release 0.15.0. 2020-02-09 23:57:46 +01:00
Alexander Petrov
d8f0505fc9 Implemented python gojsonnet get_version 2019-12-19 18:09:09 +01:00
Stanisław Barzowski
21c00f1b9e Better importing (caching & public API)
* It adds new API which allows using VM for importing
  files in external tools "just as Jsonnet would". This is
  primarily intended for use in static analysis tools.
* Imports are now cached between evaluate calls. This may improve
  performance significantly for some users. I would like to add
  some way of achieving this with commandline in the future.
* Additional layer of caching was internally added - AST level.
  This was necessary so that Jsonnet could always return the same
  exact AST when asked multiple times (meaning the same pointers).
2019-09-23 15:37:10 +02:00
Stanisław Barzowski
fbde25be21 Release v0.14.0 2019-09-16 16:15:48 +02:00
Stanisław Barzowski
e6c74ca7a6 Address review comments 2019-08-28 20:16:47 +01:00
Stanisław Barzowski
82f949e7fe Extract AST processing to separate packages
Making it independent from the jsonnet package breaks the circular
dependency during stdast generation.
2019-08-28 20:16:47 +01:00
Stanisław Barzowski
11e63b6703 Make golint happy (#296) 2019-07-24 13:02:12 -04:00
Dave Cunningham
0d560aff58 Update for version v0.13.0 2019-06-03 18:46:24 +01:00
Stanisław Barzowski
aa47869bc4 Add basic tests for Children and add missing cases 2019-03-20 10:23:24 -04:00
Alexandre Bourget
ce90e53336 Expose Evaluate functions, to be able to reuse the AST from SnippetToAST.
Right now, SnippetToAST provides a `Node` but nothing consumes it it seems.
2019-03-11 12:03:15 -04:00
Stanisław Barzowski
9348a5d2b1 Update cpp-jsonnet submodule and stdlib
Current go-jsonnet is not really 0.12.1 - it even
reports 0.12.0. This brings all the good stuff
from recent cpp-jsonnet commits and actually syncs
the version.
2019-03-04 09:45:11 -05:00
Dave Cunningham
493c45a403 Update cpp-jsonnet and bump version to 0.12.0 2018-12-18 14:32:59 -05:00
Dave Cunningham
6144c57d2a Update cpp-jsonnet & bump version 2018-07-19 16:09:27 -04:00
Luke Granger-Brown
643210d274 Add string output support for multifile output (#220)
* Add test support for multi-file output.

* Add -update support for multi-file output tests.

* Add support for string output in multi-file output mode.

* Rename 'stringOutput' to 'stringOutputMode' to better express what it does

* Refactor main_test to make it less nested.

This also causes the -update flag to output a list of files which
have been updated. This does not include the paths which are deleted
for multi-file tests.
2018-05-09 11:49:07 -04:00
Dave Cunningham
dfddf2b4e3 Update version 2018-03-16 22:34:36 -04:00
Marcelo Cantos
ed5f280c59 Apply golint recommendations (#196)
* Apply golint recommendations
2018-02-26 14:12:25 -05:00
Stanisław Barzowski
5fc25a6e75 Remove unnecessary type alias 2018-01-12 14:26:54 -05:00
Daniel Theophanes
83abda5985 jsonnet: fix docs, correct EvaluateSnippetMulti
EvaluateSnippetMulti comment was copied from another function by mistake.
Add a space between the license and the package name.
Add a few periods after the comments.

Fixes google/go-jsonnet#160
2017-12-13 18:09:05 -05:00
Daniel Theophanes
691e8d4f3c Remove unused dependencies
The imports in "_gen.go" were not used, compiled, or
apparently useful so remove.

The color field in the ErrorFormatter was never set
to true and never used. This brought in many unused
dependencies including x/sys/unix that aren't ever
used. Move the color dependencies to the jsonnet main
package and set the colorized output there. Turn the
exported ErrorFormatter into an interface. In the future
it could be used to export JSON or HTML output.

Fixes google/go-jsonnet#131
2017-12-12 00:05:28 -05:00
Liang Mingqiang
aeda6138e5 experiment dump ast to source code (#101)
* Add facility to dump part of Go heap as Go code.

* Generate stdlib AST as Go code

* Use hardcoded stdlib AST instead of parsing it
2017-11-07 23:31:11 -05:00
Dave Cunningham
c60056c75f
Feature-complete commandline interface (#138)
* Feature-complete commandline interface
* Make errors match cpp implementation
2017-11-03 22:00:30 -04:00
Dave Cunningham
f965f9ee04
For compatability, emit the \n within the library, not the cmd (#137)
* For compatability, emit the \n within the library, not the commandline tool
* Also add manifestString to library
2017-10-29 21:41:01 -04:00
Dave Cunningham
e8f6d25f61 Add Version() 2017-10-25 20:19:19 -04:00
Dave Cunningham
968ae23435 Make NativeFunction members public (#135)
* Make NativeFunction members public
2017-10-24 23:00:40 -04:00
Alex Clemmer
52d2fdcfde Rename jsonnet.nativeFunction -> jsonnet.NativeFunction
Currently, `jsonnet.VM#NativeFunction` takes a single argument of type
`jsonnet.nativeFunction`. This is ok for internal use, but because this
type is private to the `jsonnet` package, it is not possible for a
third party to call this function (since it can't instantiate the type).

This commit makes this type public to remedy this problem.
2017-10-24 21:53:52 -04:00
Stanisław Barzowski
ed281bc563 Support for native callbacks 2017-10-13 15:49:06 -04:00
Stanisław Barzowski
2db3d1c3cc TLA support 2017-10-12 20:00:45 -04:00
Stanisław Barzowski
0c43340142 Support for import callbacks
It was already there, it was a matter of exposing it in the API
2017-10-10 00:31:02 -04:00
Stanisław Barzowski
f0f70419f8 Clean up some TODOs
Some were stale, some were transformed into issues, some were fixed
2017-10-05 22:13:09 -04:00
Stanisław Barzowski
a4058fc177 Support for stack trace size limit 2017-10-05 03:31:16 -04:00
Stanisław Barzowski
c3459153df Location, error formatting and stack trace improvements (#59)
* Location, error formatting and stack trace improvements

* Static context for AST nodes
* Thunks no longer need `name`
* Prototype for showing snippets in error messages (old format still
available)
* Use ast.Function to represent methods and local function sugar.
* Change tests so that the error output is pretty
2017-10-03 14:27:44 -04:00
Stanisław Barzowski
78b4794523 Object comprehensions 2017-09-27 18:00:30 -04:00
Alex Clemmer
0d716ae56f Move parser to its own package 2017-08-25 00:30:56 -04:00
Alex Clemmer
0cd1ad28cd Make parser members public 2017-08-25 00:30:56 -04:00
Alex Clemmer
ad56a074aa Move AST to its own package 2017-08-25 00:30:56 -04:00
Alex Clemmer
c610dec2ef Make AST data structures public 2017-08-25 00:30:56 -04:00
Stanisław Barzowski
5da57ac417 Interpreter & runtime - minimal usable version (#24)
* Interpreter & runtime - minimal usable version

Accomplishments in this commit:
* Majority of language features implemented:
	* Unary operators
	* Binary operators
	* Conditionals
	* Errors
	* Indexing arrays
	* Indexing objects
	* Object inheritance
	* Imports
	* Functions
	* Function calls
* There is a quite nice way for creating builtins
* Static analyzer is there with most of the functionality
* Standard library is included and parts unaffected by missing features
work
* Some bugs in existing parts fixed
* Most positive tests from C++ version pass, the rest is failing mostly
due to missing builtins and comprehensions.
* Some initial structure was created that should allow more incremental
  and focused changes in the future PRs.
* Some comments/explanations added
* Panics translated to a little bit more gentle internal errors (with a
  link to issues on github).

What still sucks:
* Stack traces & error messages (there's some stuff in place)
* Almost everything is in the same package
* Stuff is exported or unexporeted randomly (see above)
* Missing a few lexing/parsing features
* Missing builtins
* Missing support for extvars and top-level-args
* Checking function arguments is missing
* No clean Go API that commandline and compatibility layer to C can use
* No compatibility layer to C
* Assertions don't work (desugaring level, assertEquals works).
* Manifestation stack traces (and generally it could use some work).
* The way environments are constructed is sometimes suboptimal/clumsy.
2017-08-24 20:09:10 -04:00