Commit Graph

178 Commits

Author SHA1 Message Date
Felix Krause 9290ca0d91 Load objects with transient fields 2016-10-19 22:04:46 +02:00
Felix Krause 3ab3dc7ad0 Dump variant objects with transient fields
* tuples not working yet
 * loading not woring yet
 * added tests
2016-10-15 17:58:29 +02:00
Felix Krause 29352fa4fe Use global tag handle for NimYAML
* NimYAML now uses the tag prefix tag:nimyaml.org,2016:
 * That tag handle is shortened to !n! when presenting
 * Also fixed some minor bugs dealing with tag handles
2016-10-10 20:16:54 +02:00
Felix Krause 98c16afb47 This might finally fix travis 2016-10-09 15:53:47 +02:00
Felix Krause ea90b4d2db Debugging remaining travis issues 2016-10-09 15:42:43 +02:00
Felix Krause 636ee81295 Still working on travis 2016-10-09 15:37:20 +02:00
Felix Krause e1f3ac9b07 Another try to fix travis build 2016-10-09 15:30:50 +02:00
Felix Krause d2e5c9e0a9 Hopefully fixes travis build 2016-10-09 15:21:27 +02:00
Felix Krause 846b836e92 Integrated parser and quickstart tests
* Now executed when calling `nim tests`
 * Refactored parser tests to use unittest
 * Fixed some pwd issues in tests
2016-10-09 15:05:18 +02:00
Felix Krause 4bde3a7986 Fixed issues in quickstart and taglib
* Updated expected YAML in 02
 * Fixed duplicate TagIds in taglib
2016-10-09 11:48:52 +02:00
Felix Krause 0f2e077b87 Added automatic test for quickstart snippets
* There are errors which indicate real bugs!
2016-10-08 23:35:33 +02:00
Felix Krause 3942e80d9b Improved error messages and test them. 2016-09-24 16:45:49 +02:00
Felix Krause 2ad41d349e Improved and fixed issues with error reporting 2016-09-23 15:42:24 +02:00
Felix Krause d987b607e5 Check for custom object errors when loading
* Ensure no duplicate fields
 * Ensure no missing fields
 * Ensure no unknown fields
 * Implemented for both tuples and objects,
   including variant objects
2016-09-21 15:40:03 +02:00
Felix Krause 12960b2e31 Restructuring: no more includes 2016-09-20 21:53:38 +02:00
Felix Krause 8b3f8f5282 Made test names more consistent 2016-09-20 19:22:31 +02:00
GaveUp 6f8dfdcd00 Code cleanup per comments 2016-09-19 15:51:33 -05:00
GaveUp 2c470c8aa9 Add octal/hex support. Add multi doc support. 2016-09-19 14:40:03 -05:00
Felix Krause 2f3a809738 Support JS string output in presenter 2016-09-19 19:33:29 +02:00
Felix Krause 2bb7f45354 Improved tests, benchs, shallowCopies 2016-09-14 18:31:09 +02:00
Felix Krause 92504c1893 JSON tests working again. Other tests TODO 2016-09-13 10:39:54 +02:00
Felix Krause 92f5a7a6fd got parse.nim to compile again
* it is still pretty broken
2016-09-12 21:38:56 +02:00
Felix Krause a1f900ae44 Enhanced empty line processing 2016-09-11 19:20:02 +02:00
Felix Krause b9286fa550 Implemented lookahead 2016-09-11 18:23:47 +02:00
Felix Krause 4e97e53489 Implemented anchors and aliases 2016-09-11 13:04:10 +02:00
Felix Krause 4d1a444f61 Implemented tag handles 2016-09-11 12:52:24 +02:00
Felix Krause 279d233c4f Implemented adjacent values in flow style 2016-09-11 12:13:51 +02:00
Felix Krause 383f1ab016 Made lexer non-generic 2016-09-11 11:28:05 +02:00
Felix Krause 8e7b3b32bb lexer: Flow indicators 2016-09-10 17:33:58 +02:00
Felix Krause ba02b41555 lexer: worked on block scalars and stuff 2016-09-10 17:19:37 +02:00
Felix Krause 79f432a27d lexer: implemented quoted scalars 2016-09-10 13:38:42 +02:00
Felix Krause 68a157e173 First compiling version (incomplete) 2016-09-10 12:38:03 +02:00
Felix Krause d51872f9e7 Started work on new lexer 2016-09-10 10:30:40 +02:00
Felix Krause ad18db5113 Do not use first class iterators in serialization
* needed for JS backend
2016-09-01 20:56:34 +02:00
Felix Krause 34cbe61479 Got rid of lots of compiler warnings 2016-08-17 22:50:37 +02:00
Felix Krause 01b34290b7 Parser refactoring
* refactored parser to not use first class iterators
   (not available for JS backend)
 * Current state misses flow style handling and fails tests
2016-08-15 21:30:49 +02:00
Felix Krause 7cad7b5478 Fixed and properly implemented variant objects 2016-06-08 19:15:50 +02:00
Felix Krause 273093e390 improved setTagUri
* renamed setTagUriForType to setTagUri
 * generated TagId is now const (can be used in case etc)
 * Uses compile-time counter independent from tag library
2016-04-21 18:58:53 +02:00
Felix Krause 4ca4b2c87e Support nil strings and seqs 2016-04-04 21:21:24 +02:00
Felix Krause 58b9b92895 Support int, uint and float types. 2016-04-04 20:44:16 +02:00
Felix Krause 6ad7e33bb5 Reduced dead code and compiler warnings 2016-04-03 11:45:48 +02:00
Felix Krause f2c83cc170 Support array types. Updated documentation 2016-04-03 11:29:49 +02:00
Felix Krause a267f73e0a Serialization: support sets 2016-04-02 18:29:26 +02:00
Felix Krause cde346b85c Switched to indentation of 2 spaces 2016-04-02 17:48:22 +02:00
Felix Krause 5ec086081c Implemented serialization of OrderedMap 2016-03-25 22:22:42 +01:00
Felix Krause 42ddfbe5c5 Fixes #13.
* Separated into representObject and in representChild and
   representObject. Makes it possible for multiple types to
   use the same representObject proc.
2016-03-25 21:27:41 +01:00
Felix Krause 28ccdcc5a6 Handle block scalars line-per-line. Fixes #10 2016-03-25 18:17:37 +01:00
Felix Krause 4d4e3c94e1 Added fplDocument, fixes #11
* Do not use -1 for unknown indentation, because the document level is -1.
 * Use const UnknownIndentation in code instead of magic number
 * Added fplDocument level which is used as root of the ancestry
 * Added debugFail() template to better locate internal errors
2016-03-19 22:45:24 +01:00
Felix Krause ae933d90a1 Fixes to block scalars and yamlTestSuite
* Properly handle empty block scalars and trailing lines
 * Fixed a bug in yamlTestSuite that led to lots of open file handles
2016-03-18 22:29:35 +01:00
Felix Krause 1c61486739 Fixed small bugs
* allow '!' at beginning of tag URI in %TAG directive
 * recognise \t as start of more indented line in block flow scalar
 * Made testEventParser more robust
2016-03-16 19:20:18 +01:00
Felix Krause 9c251584a0 Fixed YAML test suite to conform to naming changes 2016-03-14 18:20:20 +01:00
Felix Krause 16d1a1bceb Various code style and naming fixes
* Renamed some symbols for consistency, fixes #6:
   - yamlStartSequence -> yamlStartSeq
   - yamlEndSequence   -> yamlEndSeq
   - yamlStartDocument -> yamlStartDoc
   - yamlEndDocument   -> yamlEndDoc
   - yTagMap           -> yTagMapping
 * Improved code formatting at some places
 * Fixed code documentation at some places
 * Added generic objects to TODO list
 * Removed obsolete parsing tests, these are superseeded
   by yaml-dev-kit test suite integration
2016-03-14 18:10:34 +01:00
Felix Krause afc5306da5 event parser: support \b and \t escape sequences 2016-03-11 17:58:15 +01:00
Felix Krause de7f821696 Improved YAML test suite integration
* Support for anchors and aliases
 * Continue with next test on exception
 * Better naming
2016-03-09 20:15:43 +01:00
Felix Krause 121492d4c6 Support updated yaml-dev-kit data layout 2016-03-04 21:23:13 +01:00
Felix Krause 778799e4ff Added option to validate against YAML test suite 2016-03-04 19:10:48 +01:00
Felix Krause 5933605591 Added copyright notices to files where missing 2016-02-27 13:09:50 +01:00
Felix Krause 46913867e2 Presenter: Let user decide about newline style
* Added PresentationOptions object; merged PresentationStyle,
   indentationStep and NewLineStyle in it
 * Updated signatures of relevant procs
 * Implemented user-defined newline style in presenter
2016-02-26 21:55:59 +01:00
Felix Krause 349cb19912 Refactoring of serialization code
* Made some procs/templates private that have been public without need
 * Improved documentation of procs
2016-02-26 21:13:40 +01:00
Felix Krause c9dae4430c Fixes #5 2016-02-25 21:16:03 +01:00
Felix Krause 27670f63c9 Implemented and documented DOM 2016-02-22 21:56:30 +01:00
Felix Krause 33a7f93480 Code cleanup; reduced compiler hints 2016-02-19 18:25:01 +01:00
Felix Krause f2f340c0b6 Fixes #2 2016-02-19 17:31:57 +01:00
Felix Krause 43e10f496a Fixes #3 2016-02-18 22:32:25 +01:00
Felix Krause bc9229d0c5 Fixes #1 2016-02-18 22:14:24 +01:00
Felix Krause 9be97ff386 Added constructChild for better serialization.
- Handle tag and anchor checks and ref types in constructChild
 - Added tests for using custom representObject and constructObject
   procs
 - Code cleanup
2016-02-16 19:24:55 +01:00
Felix Krause 0a7f87a539 Improved docs. Fixed serialization problem.
* Added serialization.txt to doc
 * Fixed rendering problem in api.txt
 * Use explicit tag when ref type renders to a scalar that can be
   parsed to !!null
 * Added test cases for this ref type fix
2016-02-15 22:54:05 +01:00
Felix Krause 02e505959a Added setTagUriForType. Used it. Improved docs. 2016-02-15 19:46:21 +01:00
Felix Krause 325e3ec18f Made serialization part of yaml. Improved doc. 2016-02-12 20:44:38 +01:00
Felix Krause c6c13eb044 Better doc index. YamlStream now an object.
* Also various fixes to serialization and presentation
2016-02-12 19:53:25 +01:00
Felix Krause 32c42054f7 Renamed serialize() to represent() to better conform to YAML spec 2016-02-02 18:19:40 +01:00
Felix Krause e89a9a5b14 Serialization: Support enum types 2016-02-01 20:16:35 +01:00
Felix Krause e967038d06 Support custom types without serialize macro 2016-02-01 19:48:42 +01:00
Felix Krause 620ab55899 Added tests for ref serialization 2016-01-28 22:57:14 +01:00
Felix Krause 5162c310ce Serialization: Better proc names
* renamed serialize to serializeObject and construct to constructObject
 * added new serialize() and construct() procs that handle document
   start & end
 * re-raise AssertionError instead of swallowing it
2016-01-26 20:51:21 +01:00
Felix Krause 4c3f7cd485 Better and more system types for serialization
* Use int[8|16|32|64] and float[32|64] instead of int and float
 * Support uint[8|16|32|64]
 * Support char
2016-01-26 20:00:28 +01:00
Felix Krause 8436026250 Sanitized exception handling in serialization 2016-01-24 20:38:30 +01:00
Felix Krause 42df37bbbe Added JSON construction tests 2016-01-24 19:19:03 +01:00
Felix Krause a08f4c1e4e Sanitized exceptions and raises pragmas
* Added raises pragma to every proc in yaml.nim
 * Properly encapsulate exceptions from YamlStreams
 * Discovered a Nim compiler bug and added a workaround
 * Added possibility to query line, column and line content from
   YamlParser
 * Updated rst documentation
 * Actually call callback in fastparse if available
 * Fixed parsing YAML version
2016-01-24 18:24:09 +01:00
Felix Krause fdcc699768 Removed old lexer/parser impl in favor of new one
* fastparse now used for everything
 * private/[lexer|parser].nim gone
 * Made fastparse use YamlParser object
 * Got all tests working with fastparse
 * Some more smaller changes to API
2016-01-24 11:44:10 +01:00
Felix Krause 971218314e fastparse: made it pass the parsing tests
* Scan for implicit map key as soon as a property is encountered
 * Proper handling of node properties throughout parser
 * Fixed an issue where plain scalars sometimes contained garbage
   when yielded
 * Catch reserved chars @ and `
 * Fixed some test cases
 * Made parser test cases use fastparse
2016-01-23 17:44:50 +01:00
Felix Krause 9c731cb6d1 Refactoring lexer, part 1 2016-01-15 00:06:57 +01:00
Felix Krause 56d3537920 Refactoring: Shorter type names 2016-01-14 22:51:30 +01:00
Felix Krause 551c8b0dd1 Refactoring: Extracted type guessing from lexer 2016-01-14 19:58:38 +01:00
Felix Krause 18753b1a4a Got rid of yamlWarning, use YamlPresenterError
* Added YamlWarningCallback that may be used to capture
   parser warnings
 * Removed yamlWarning as event kind
 * Replaced checks for well-formedness in presenter with asserts
 * Added checks for JSON compatibility of YamlStream in presenter
 * Added proper type hints for special float values in
   serializer to be able to check for them in the presenter
2016-01-05 19:06:55 +01:00
Felix Krause d2baa1749e Got rid of yamlError.
* Replaced yielding yamlError tokens with raising a YamlParserError
 * Renamed sequential.nim to parser.nim because it's the parser (duh)
2016-01-05 18:14:11 +01:00
Felix Krause aa98c5863e Properly handle ytsRootOnly
* Yield tag of custom type serialization when using ytsRootOnly,
   but don't yield tags of map keys or values
 * Yield proper tag of Table[K, V] serialization if requested
 * renamed dumper.nim to presenter.nim to conform to YAML spec
2016-01-04 22:18:55 +01:00
Felix Krause 507c621aaf Implemented local tags for serialization
* Fixed a bug in the lexer where an error would be raised if
   characters not allowed in tag shorthands are used in local tags
 * Fixed processing of object tags for all kinds of root nodes in Parser
 * Improved dumper to output a space after a local tag
 * Renamed some enumeration types to conform better to the YAML spec
 * Added secondaryPrefix to YamlTagLibrary
 * Added possibility to control tag output style independently from
   presentation style in serializer
 * Created local tags for all types that are serialized and use them in
   construction and serialization
2016-01-04 21:46:33 +01:00
Felix Krause a094089fb9 Various improvements
* Better JSON serialization (map bool literals to true/false if
   possible)
 * Fixed a problem where the tag of block sequence would be
   wrongly placed
 * Always output "" when dumping empty strings
 * Added helper functions to create YamlStreamEvents.
 * Moved procs for YamlStreamEvents to private/events.nim
 * renamed dump() to present()
 * Added dump() and load() to yaml.serialization
2015-12-29 18:22:55 +01:00
Felix Krause 9ff93efb11 Implemented basic serialization
* added serialize() procs for some basic types
 * extended make_serializable to generate serialize() proc
2015-12-29 16:10:47 +01:00
Felix Krause dc1a3c0fe2 Can construct basic types and custom objects
* Added construct() procs for some basic types
 * Added macro make_serializable
2015-12-29 15:09:37 +01:00
Felix Krause d828f4ddc5 Added benchmark. Fixed processing empty flow sets. 2015-12-29 00:14:47 +01:00
Felix Krause 238faf82ab Source restructuring, added config.nims
* moved src/* to .
 * added config.nims to build library and run tests
 * reduced compiler warnings
2015-12-28 22:03:16 +01:00
Felix Krause b1e828eae6 Added documentation comments 2015-12-27 23:40:27 +01:00
Felix Krause f2527efd46 Support additional boolean scalars
* on, off, yes, no, literals with leading or complete capital letters
 * added documentation
2015-12-27 21:36:47 +01:00
Felix Krause 2c9d065ecb Support tags for sequences and maps in block style 2015-12-27 17:37:42 +01:00
Felix Krause d7f1e726ab Added dump() and transform()
* Added a hint "mapMayHaveKeyObjects" to yamlMap
 * Added dumper.nim
 * Improved generated documentation a bit
2015-12-27 16:36:32 +01:00
Felix Krause 075cf8b8ef Worked on tag URI interface
* Added YamlTagLibrary
 * adhere to explicit tags in JSON
 * Fixed lexer type hints before YAML flow special characters
2015-12-26 18:40:23 +01:00
Felix Krause ca0f5d1741 Refactoring, less heap objects
* YamlParserEvent -> YamlStreamEvent
 * YamlStreamEvent is no longer a `ref` object. Test suite now
   runs in a small fraction of a second (compared to several
   seconds before)
 * Introduced YamlStream
2015-12-26 13:39:43 +01:00
Felix Krause 2c4e681f0b Finished JSON parser. Restructuring.
* Made JSON parser resolve anchors and aliases
 * Moved exported consts and types to yaml.nim
2015-12-26 13:16:57 +01:00