Commit Graph

386 Commits

Author SHA1 Message Date
Stanisław Barzowski
544fe25700 Simplistic argument checking
To be expanded when optional arguments arrive.
2017-09-27 22:45:41 -04:00
Stanisław Barzowski
a92b30146a Some placeholders and experiments for C library
We want to provide go version of libjsonnet.
2017-09-27 22:01:29 -04:00
Stanisław Barzowski
78b4794523 Object comprehensions 2017-09-27 18:00:30 -04:00
Stanisław Barzowski
850575cf34 More tests for log and exp 2017-09-26 12:17:08 -04:00
Stanisław Barzowski
650825cd5a Change test file extension 2017-09-22 18:28:02 -04:00
Stanisław Barzowski
97a80b94cd Fix inheritance of hidden fields, closes #70 2017-09-22 18:11:05 -04:00
Stanisław Barzowski
02f86ba308 Fix extenstions of test files (merging order issue) 2017-09-22 18:10:44 -04:00
Stanisław Barzowski
fe62ec46a8 Improve imports (#66)
* Improve imports

* Nonexistent file is now a runtime error (used to be ignored)
* Permission denied is a runtime error (used to be an internal error)
* Basic tests added for imports
* Renamed tests from .input to .jsonnet
	* It's standard
	* It's compatible with C++ test suite
	* Editors enable syntax highlighting based on extension
	* Importing .input looks weird
2017-09-22 18:03:00 -04:00
Stanisław Barzowski
8638a21287 Object invariants (#62)
* Object invariants
2017-09-22 18:02:05 -04:00
Stanisław Barzowski
9047718ad0 Add std.filter 2017-09-22 13:45:52 -04:00
Stanisław Barzowski
2cf7443b91 Add support for % operator 2017-09-22 13:26:04 -04:00
Stanisław Barzowski
cab0cc887e std.codepoint, std.char + a bunch of tests 2017-09-22 11:53:25 -04:00
Davor Kapsa
4c5938c1f0 travis: update go version 2017-09-19 23:48:34 -04:00
Stanisław Barzowski
8a80309137 std.md5 2017-09-14 17:09:57 -04:00
Stanisław Barzowski
999ff267f1 Remove unused autogenerated code 2017-09-12 17:10:36 -04:00
Stanisław Barzowski
a94b877d4b Add std.exponent and std.mantissa 2017-09-12 17:10:21 -04:00
Stanisław Barzowski
ad4be04fc1 Fix desugaring of assertions 2017-09-11 16:38:37 -04:00
Stanisław Barzowski
4d5365f5e2 Add a bunch of tests for fundamental builtins
Support std.length on objects
2017-09-11 16:35:59 -04:00
Stanisław Barzowski
7ebcb06c98 Support for ifs in array comprehensions 2017-09-11 16:34:14 -04:00
Stanisław Barzowski
1e4797071f Even more builtins
Fix a bunch of bugs:
- Reverse meaning of boolean argument to objectFieldsEx and objectHasEx
- Slice desugaring using `std.slice` instead of `slice` as a field name.

Support + on string and something else.
Support + on arrays

assertEqual should now work properly
2017-09-08 14:19:19 -04:00
Stanisław Barzowski
6b040a9afe Actually unparse field names
Instead of just wrapping in "".
2017-09-08 14:14:32 -04:00
Stanisław Barzowski
860c3e6e70 Add more builtins 2017-09-07 15:41:41 -04:00
Stanisław Barzowski
3c94bde4dc String indexing, change of string representation (#34)
* String indexing, change of string representation

Also std.pow
2017-09-07 11:56:11 -04:00
Stanisław Barzowski
c26c50c04b Array comprehensions (#35)
* Array comprehensions

Implemented using flatMap.

The representation in AST was changed - now it expresses
the semantic structure better.

Ifs in comprehensions are not supported yet, but easy.
2017-09-07 11:55:33 -04:00
Stanisław Barzowski
c9e23d4ff3 Merge pull request #36 from sbarzowski/toString
Add toString builtin
2017-09-06 18:39:19 -04:00
Stanisław Barzowski
77b8b9e335 Optional args parser/lexer/ast support (#33)
* Optional args parser/lexer/ast support

Just "frontend" part. They are ignored during actual execution.
2017-09-06 11:53:10 -04:00
Stanisław Barzowski
5cd467fd18 More builtins 2017-08-30 01:38:36 -04:00
Stanisław Barzowski
b1427d563b Parser & desugarer support for "in" 2017-08-29 22:14:12 -04:00
Stanisław Barzowski
a4456d8ecf Add desugaring of standalone assertions 2017-08-29 22:09:40 -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
Dave Cunningham
8c8668650d Merge pull request #26 from sevki/refactor-tests
Refactor tests
2017-08-23 14:08:09 -04:00
Sevki
7b875bd141 change the diff function
the proposed change would remove the dependency of a diff binary
in favour of using a library

Signed-off-by: Sevki <s@sevki.org>
2017-08-18 00:19:43 +02:00
Sevki
f53577632f refactor golden tests to look more like std library tests
this commit proposes using a file based golden tests approach,
parts of this refactor uses code and conventions from the go std
library. At it's current state go-jsonnet does not support many of
the examples on http://jsonnet.org/docs/demo.html, motive behind
the refactor is to add the demo examples to the test suite and
the demo examples are too big to be inlined.

Signed-off-by: Sevki <s@sevki.org>
2017-08-16 23:59:55 +02:00
Sevki
4582b1c4ae remove errString from main_test.go
since non of the test cases actually use the err string field and
the golden file testing pattern does not really need it, this commit
proposes the removal of the errString field from tests

Signed-off-by: Sevki <s@sevki.org>
2017-08-16 23:07:31 +02:00
Sevki
640983c125 use t.Run for tests
using `t.Run` instead including the test name in error message is
a more idiomatic way of testing things in go. Since this feature
was added to go in 1.7 release and the travis config explicitly
specifies 1.4 and 1.5 (2 and 2,5 year old releases) as test targets
this change will break the CI builds, therefore this commit also
proposes dropping those releases in favour of adding a newer
version of go (1.8) as the test target.

Signed-off-by: Sevki <s@sevki.org>
2017-08-16 23:03:05 +02:00
Dave Cunningham
1826830452 Merge pull request #25 from sevki/extmap
initialize the extMap
2017-08-16 17:02:56 -04:00
Sevki
a582c5cbae initialize the extMap
Given the following scenario

	vm := jsonnet.MakeVM()
	vm.ExtVar("foo", "bar")

calling the `ExtVar` and `ExtCode` methods of a vm result in a panic
because the map has not been initialized, this patch adds
initializes the map.

Signed-off-by: Sevki <s@sevki.org>
2017-08-16 22:14:15 +02:00
Stanisław Barzowski
899b931c07 Fix unicode escape sequences & some desugaring 2017-08-16 12:08:28 -04:00
Stanisław Barzowski
91e1162cdd Make it possible to evaluate stdlib (#20)
* New features in parser and desugarer

Support for slices
Support for methods
Support for function sugar in locals
Prevent crashes with obj/arr comprehensions

After this change evaluating stdlib doesn't crash.
2017-08-15 14:08:15 -04:00
Dave Cunningham
7588ed5bc0 Merge pull request #22 from sbarzowski/parser_comprehensions
Fix parser - support for locals in comprehensions
2017-08-14 15:55:03 -04:00
Stanisław Barzowski
9743ad756f Fix parser - support for locals in comprehensions 2017-08-14 14:32:49 -04:00
Dave Cunningham
ace9ab7444 Merge pull request #21 from sbarzowski/verbatim_strings
Add verbatim string support
2017-08-14 12:14:15 -04:00
Stanisław Barzowski
a94bfef764 Add verbatim string support 2017-08-10 17:29:04 -04:00
Dave Cunningham
da7c66ad55 Merge pull request #19 from sbarzowski/lexer_newline_bug
Fix bug messing up newlines
2017-08-09 17:01:08 -04:00
Dave Cunningham
dee39c1163 Merge pull request #18 from sbarzowski/cmd
Basic commandline (so we can start testing compatibility)
2017-08-08 16:27:54 -04:00
Stanisław Barzowski
370534ccc4 Basic commandline (so we can start testing compatibility) 2017-08-08 14:30:44 -04:00