Commit Graph

17 Commits

Author SHA1 Message Date
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
b1a9c0bd6d ExtVar support 2017-09-28 23:14:53 -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
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
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
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
Stanisław Barzowski
899b931c07 Fix unicode escape sequences & some desugaring 2017-08-16 12:08:28 -04:00
Stanisław Barzowski
a94bfef764 Add verbatim string support 2017-08-10 17:29:04 -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
09c7c8c7c0 Pass through JSON 2016-04-04 02:16:03 -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
Dave Cunningham
563bbe12f4 First end-to-end test (addition of numbers) 2016-03-08 01:17:44 -05:00