208 Commits

Author SHA1 Message Date
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
Stanisław Barzowski
660c09fe39 Fix bug messing up newlines
When the lexer backed up, no matter from what character it went
to the previous line.
2017-08-07 19:44:55 -04:00
Dave Cunningham
137523a545 Merge pull request #17 from sbarzowski/bindbug
Fix local bind body not being desugared
2017-08-07 15:06:55 -04:00
Stanisław Barzowski
fd77883a3f Fix local bind body not being desugared
In Go `for i, val := range arr` creates a *copy*
so it was changing some temporary value.
2017-08-04 15:03:42 -04:00
Dave Cunningham
f81573cb4e Merge pull request #15 from sbarzowski/strings
Allow adding strings
2017-08-01 19:54:12 -04:00
Stanisław Barzowski
badeb833bb Tests + default + better panic message 2017-07-31 11:49:20 -04:00
Stanisław Barzowski
964c4bc0df Allow adding strings 2017-07-28 17:23:27 -04:00
Dave Cunningham
70da0b879d Merge pull request #12 from sparkprime/json_pass_through
Pass through JSON
2016-05-02 00:33:13 -04:00
Dave Cunningham
c5225a1b3a address jbeda's comments 2016-05-02 00:20:08 -04:00
Dave Cunningham
09c7c8c7c0 Pass through JSON 2016-04-04 02:16:03 -04:00
Dave Cunningham
c3e4c805f2 Merge pull request #10 from jbeda/fix-lint
Fix up lint errors.
2016-03-16 13:44:00 -04:00
Joe Beda
0eedf437b1 Fix up lint errors.
Also:
* Made all types used in errors public.
* Made interpreter receiver a pointer.  This will reduce GC load for deep stacks.
2016-03-14 12:50:42 +00:00
Joe Beda
bf2c1df9e5 Merge pull request #9 from sparkprime/skeleton
First end-to-end test (add numbers)
2016-03-14 12:32:35 +00:00
Dave Cunningham
db9caa7a2d Change British English to American English 2016-03-08 01:19:57 -05:00
Dave Cunningham
563bbe12f4 First end-to-end test (addition of numbers) 2016-03-08 01:17:44 -05:00
Dave Cunningham
c0060affd2 Merge pull request #8 from jbeda/parser
Finish writing unit tests for parser
2016-03-07 22:04:50 -05:00
Joe Beda
d8dc42a151 Finish unit tests for parser. 2016-03-07 17:19:27 -08:00
Joe Beda
964a6e854e Remove unneeded astKind type. 2016-03-07 15:36:35 -08:00
Joe Beda
566a2cf4f2 Happy case tests for parser.
No testing of error cases or location reporting yet.
2016-03-07 15:26:16 -08:00
Joe Beda
2b23986b9a Merge pull request #7 from jbeda/parser
Finish up blocking out the parser.
2016-03-01 17:12:58 -08:00
Joe Beda
142b77c41f Finish up blocking out the parser.
There is the most minimal of tests and so this probably doesn't work well yet.  Adding tests is the next job.
2016-03-01 17:08:35 -08:00
Joe Beda
3b5fc97c33 Merge pull request #6 from jbeda/fix-lint
Fix lint issues and add package comment
2016-02-26 04:59:33 -08:00
Joe Beda
e70cc51c68 Fix lint issues and add package comment 2016-02-25 17:09:44 -08:00
Joe Beda
04c51f7034 Merge pull request #5 from sparkprime/lexer_changes
Port lexer changes from google/jsonnet 0c96da7 to 27ddf2c Fix #1
2016-02-25 17:05:16 -08:00
Dave Cunningham
c3f136d987 Port lexer changes from google/jsonnet 0c96da7 to 27ddf2c Fix #1 2016-02-22 22:25:41 -05:00
Dave Cunningham
2282fdf13e Merge pull request #3 from jbeda/readme-fix
Fix up repo paths in the README.
2016-02-21 11:49:09 -05:00
Dave Cunningham
1cbeb25e84 Merge pull request #2 from jbeda/copyright-notice
Add copyright notice to all files.
2016-02-21 00:35:09 -05:00
Joe Beda
a469f9615b Fix up repo paths in the README. 2016-02-20 18:34:59 -08:00
Joe Beda
6a29151819 Add copyright notice to all files.
With this commit, I grant a Copyright License in this project submitted up until now to Google under the terms of the Google CLA.  See https://cla.developers.google.com/about/google-individual.
2016-02-20 18:31:21 -08:00