From b699a36444a03a6f7b312e805de31395a2d2ff9c Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 2 Jun 2021 12:58:08 -0400 Subject: JSONBuilder (#1865) * #include an absolute path didn't work - because paths were taken to always be relative. * WIP JSONWriter/JSONParser. * Checking different Layout styles for JSON. * Add slang-json-parser.h/.cpp * WIP JSONValue. * Added JSONValue::destroy/Recursive. * Improvement to JSONValue. * Improve text double conversion precision. Testing. * Simplify double parsing (just use atof). JSON comparison More testing of conversions and start of JSONValue. * Add for isnan, isinf etc. * Small improvement with object comparison. * Fix typo in getArgsByName. * Removed use of isnan and isinf as includes don't work on linux. * Improve JSON unit test. * Added asInteger/asFloat/asBool to JSONValue. * Add SourceLoc to JSONListener. * Added ability to walk the JSONValue * JSONBuilder. * Add converting from lexemes via JSONBuilder. * Fix VS warning. * Fix warning for res not being used. --- source/compiler-core/slang-json-lexer.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/compiler-core/slang-json-lexer.cpp') diff --git a/source/compiler-core/slang-json-lexer.cpp b/source/compiler-core/slang-json-lexer.cpp index 261d5f413..9f96ef4f5 100644 --- a/source/compiler-core/slang-json-lexer.cpp +++ b/source/compiler-core/slang-json-lexer.cpp @@ -80,6 +80,17 @@ bool JSONLexer::advanceIf(JSONTokenType type) return false; } +bool JSONLexer::advanceIf(JSONTokenType type, JSONToken& out) +{ + if (type == peekType()) + { + out = m_token; + advance(); + return true; + } + return false; +} + UnownedStringSlice JSONLexer::getLexeme(const JSONToken& tok) const { auto offset = m_sourceView->getRange().getOffset(tok.loc); -- cgit v1.2.3