remove redundant implicit_2 (#155)
remove redundant implicit_2 merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
This commit is contained in:
parent
6040c7bb78
commit
ab0e2c0519
|
@ -796,7 +796,7 @@ struct Emitter
|
||||||
{
|
{
|
||||||
if(style_ == ScalarStyle.Invalid){style_ = chooseScalarStyle();}
|
if(style_ == ScalarStyle.Invalid){style_ = chooseScalarStyle();}
|
||||||
if((!canonical_ || (tag is null)) &&
|
if((!canonical_ || (tag is null)) &&
|
||||||
(style_ == ScalarStyle.Plain ? event_.implicit : event_.implicit_2))
|
(style_ == ScalarStyle.Plain ? event_.implicit : !event_.implicit && (tag is null)))
|
||||||
{
|
{
|
||||||
preparedTag_ = null;
|
preparedTag_ = null;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -12,7 +12,6 @@ module dyaml.event;
|
||||||
|
|
||||||
import std.array;
|
import std.array;
|
||||||
import std.conv;
|
import std.conv;
|
||||||
import std.typecons;
|
|
||||||
|
|
||||||
import dyaml.encoding;
|
import dyaml.encoding;
|
||||||
import dyaml.exception;
|
import dyaml.exception;
|
||||||
|
@ -81,8 +80,6 @@ struct Event
|
||||||
*/
|
*/
|
||||||
bool explicitDocument;
|
bool explicitDocument;
|
||||||
}
|
}
|
||||||
///TODO figure this out - Unknown, used by PyYAML with Scalar events.
|
|
||||||
bool implicit_2;
|
|
||||||
///Encoding of the stream, if this is a StreamStart.
|
///Encoding of the stream, if this is a StreamStart.
|
||||||
Encoding encoding;
|
Encoding encoding;
|
||||||
///Collection style, if this is a SequenceStart or MappingStart.
|
///Collection style, if this is a SequenceStart or MappingStart.
|
||||||
|
@ -234,7 +231,7 @@ Event documentEndEvent(const Mark start, const Mark end, const bool explicit) pu
|
||||||
/// value = String value of the scalar.
|
/// value = String value of the scalar.
|
||||||
/// style = Scalar style.
|
/// style = Scalar style.
|
||||||
Event scalarEvent(const Mark start, const Mark end, const string anchor, const string tag,
|
Event scalarEvent(const Mark start, const Mark end, const string anchor, const string tag,
|
||||||
const Tuple!(bool, bool) implicit, const string value,
|
const bool implicit, const string value,
|
||||||
const ScalarStyle style = ScalarStyle.Invalid) @safe pure nothrow @nogc
|
const ScalarStyle style = ScalarStyle.Invalid) @safe pure nothrow @nogc
|
||||||
{
|
{
|
||||||
Event result;
|
Event result;
|
||||||
|
@ -247,7 +244,6 @@ Event scalarEvent(const Mark start, const Mark end, const string anchor, const s
|
||||||
|
|
||||||
result.id = EventID.Scalar;
|
result.id = EventID.Scalar;
|
||||||
result.scalarStyle = style;
|
result.scalarStyle = style;
|
||||||
result.implicit = implicit[0];
|
result.implicit = implicit;
|
||||||
result.implicit_2 = implicit[1];
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -465,10 +465,9 @@ final class Parser
|
||||||
: cast(string)token.value;
|
: cast(string)token.value;
|
||||||
|
|
||||||
implicit = (token.style == ScalarStyle.Plain && tag is null) || tag == "!";
|
implicit = (token.style == ScalarStyle.Plain && tag is null) || tag == "!";
|
||||||
bool implicit_2 = (!implicit) && tag is null;
|
|
||||||
state_ = popState();
|
state_ = popState();
|
||||||
return scalarEvent(startMark, token.endMark, anchor, tag,
|
return scalarEvent(startMark, token.endMark, anchor, tag,
|
||||||
tuple(implicit, implicit_2), value, token.style);
|
implicit, value, token.style);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(scanner_.checkToken(TokenID.FlowSequenceStart))
|
if(scanner_.checkToken(TokenID.FlowSequenceStart))
|
||||||
|
@ -512,7 +511,7 @@ final class Parser
|
||||||
|
|
||||||
//Empty scalars are allowed even if a tag or an anchor is specified.
|
//Empty scalars are allowed even if a tag or an anchor is specified.
|
||||||
return scalarEvent(startMark, endMark, anchor, tag,
|
return scalarEvent(startMark, endMark, anchor, tag,
|
||||||
tuple(implicit, false) , "");
|
implicit , "");
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = scanner_.peekToken();
|
const token = scanner_.peekToken();
|
||||||
|
@ -935,6 +934,6 @@ final class Parser
|
||||||
///Return an empty scalar.
|
///Return an empty scalar.
|
||||||
Event processEmptyScalar(const Mark mark) @safe pure nothrow const @nogc
|
Event processEmptyScalar(const Mark mark) @safe pure nothrow const @nogc
|
||||||
{
|
{
|
||||||
return scalarEvent(mark, mark, null, null, tuple(true, false), "");
|
return scalarEvent(mark, mark, null, null, true, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,12 +182,10 @@ struct Serializer
|
||||||
assert(node.isType!string, "Scalar node type must be string before serialized");
|
assert(node.isType!string, "Scalar node type must be string before serialized");
|
||||||
auto value = node.as!string;
|
auto value = node.as!string;
|
||||||
const detectedTag = resolver_.resolve(NodeID.Scalar, null, value, true);
|
const detectedTag = resolver_.resolve(NodeID.Scalar, null, value, true);
|
||||||
const defaultTag = resolver_.resolve(NodeID.Scalar, null, value, false);
|
|
||||||
bool isDetected = node.tag_ == detectedTag;
|
bool isDetected = node.tag_ == detectedTag;
|
||||||
bool isDefault = node.tag_ == defaultTag;
|
|
||||||
|
|
||||||
emitter_.emit(scalarEvent(Mark(), Mark(), aliased, node.tag_,
|
emitter_.emit(scalarEvent(Mark(), Mark(), aliased, node.tag_,
|
||||||
tuple(isDetected, isDefault), value, node.scalarStyle));
|
isDetected, value, node.scalarStyle));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(node.isSequence)
|
if(node.isSequence)
|
||||||
|
|
|
@ -56,7 +56,7 @@ bool compareEvents(Event[] events1, Event[] events2) @system
|
||||||
if(e1.id == EventID.Scalar)
|
if(e1.id == EventID.Scalar)
|
||||||
{
|
{
|
||||||
//Different scalar tag (if applicable).
|
//Different scalar tag (if applicable).
|
||||||
if(![e1.implicit, e1.implicit_2, e2.implicit, e2.implicit_2].canFind(true)
|
if(!(e1.implicit || e2.implicit)
|
||||||
&& e1.tag != e2.tag)
|
&& e1.tag != e2.tag)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -157,7 +157,7 @@ void testEmitterStyles(string dataFilename, string canonicalFilename) @system
|
||||||
if(event.id == EventID.Scalar)
|
if(event.id == EventID.Scalar)
|
||||||
{
|
{
|
||||||
event = scalarEvent(Mark(), Mark(), event.anchor, event.tag,
|
event = scalarEvent(Mark(), Mark(), event.anchor, event.tag,
|
||||||
tuple(event.implicit, event.implicit_2),
|
event.implicit,
|
||||||
event.value, style);
|
event.value, style);
|
||||||
}
|
}
|
||||||
else if(event.id == EventID.SequenceStart)
|
else if(event.id == EventID.SequenceStart)
|
||||||
|
|
Loading…
Reference in a new issue