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((!canonical_ || (tag is null)) &&
|
||||
(style_ == ScalarStyle.Plain ? event_.implicit : event_.implicit_2))
|
||||
(style_ == ScalarStyle.Plain ? event_.implicit : !event_.implicit && (tag is null)))
|
||||
{
|
||||
preparedTag_ = null;
|
||||
return;
|
||||
|
|
|
@ -12,7 +12,6 @@ module dyaml.event;
|
|||
|
||||
import std.array;
|
||||
import std.conv;
|
||||
import std.typecons;
|
||||
|
||||
import dyaml.encoding;
|
||||
import dyaml.exception;
|
||||
|
@ -81,8 +80,6 @@ struct Event
|
|||
*/
|
||||
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 encoding;
|
||||
///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.
|
||||
/// style = Scalar style.
|
||||
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
|
||||
{
|
||||
Event result;
|
||||
|
@ -247,7 +244,6 @@ Event scalarEvent(const Mark start, const Mark end, const string anchor, const s
|
|||
|
||||
result.id = EventID.Scalar;
|
||||
result.scalarStyle = style;
|
||||
result.implicit = implicit[0];
|
||||
result.implicit_2 = implicit[1];
|
||||
result.implicit = implicit;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -465,10 +465,9 @@ final class Parser
|
|||
: cast(string)token.value;
|
||||
|
||||
implicit = (token.style == ScalarStyle.Plain && tag is null) || tag == "!";
|
||||
bool implicit_2 = (!implicit) && tag is null;
|
||||
state_ = popState();
|
||||
return scalarEvent(startMark, token.endMark, anchor, tag,
|
||||
tuple(implicit, implicit_2), value, token.style);
|
||||
implicit, value, token.style);
|
||||
}
|
||||
|
||||
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.
|
||||
return scalarEvent(startMark, endMark, anchor, tag,
|
||||
tuple(implicit, false) , "");
|
||||
implicit , "");
|
||||
}
|
||||
|
||||
const token = scanner_.peekToken();
|
||||
|
@ -935,6 +934,6 @@ final class Parser
|
|||
///Return an empty scalar.
|
||||
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");
|
||||
auto value = node.as!string;
|
||||
const detectedTag = resolver_.resolve(NodeID.Scalar, null, value, true);
|
||||
const defaultTag = resolver_.resolve(NodeID.Scalar, null, value, false);
|
||||
bool isDetected = node.tag_ == detectedTag;
|
||||
bool isDefault = node.tag_ == defaultTag;
|
||||
|
||||
emitter_.emit(scalarEvent(Mark(), Mark(), aliased, node.tag_,
|
||||
tuple(isDetected, isDefault), value, node.scalarStyle));
|
||||
isDetected, value, node.scalarStyle));
|
||||
return;
|
||||
}
|
||||
if(node.isSequence)
|
||||
|
|
|
@ -56,7 +56,7 @@ bool compareEvents(Event[] events1, Event[] events2) @system
|
|||
if(e1.id == EventID.Scalar)
|
||||
{
|
||||
//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)
|
||||
{
|
||||
return false;
|
||||
|
@ -157,7 +157,7 @@ void testEmitterStyles(string dataFilename, string canonicalFilename) @system
|
|||
if(event.id == EventID.Scalar)
|
||||
{
|
||||
event = scalarEvent(Mark(), Mark(), event.anchor, event.tag,
|
||||
tuple(event.implicit, event.implicit_2),
|
||||
event.implicit,
|
||||
event.value, style);
|
||||
}
|
||||
else if(event.id == EventID.SequenceStart)
|
||||
|
|
Loading…
Reference in a new issue