trying new structure to have better yaml error messages
This commit is contained in:
parent
109ad378c2
commit
5d51da11e5
|
@ -310,8 +310,6 @@ function tNode_asScalar(self) result(scalar)
|
||||||
select type(self)
|
select type(self)
|
||||||
class is(tScalar)
|
class is(tScalar)
|
||||||
scalar => self
|
scalar => self
|
||||||
class default
|
|
||||||
call IO_error(706,ext_msg='Expected "scalar"')
|
|
||||||
end select
|
end select
|
||||||
|
|
||||||
end function tNode_asScalar
|
end function tNode_asScalar
|
||||||
|
@ -328,8 +326,6 @@ function tNode_asList(self) result(list)
|
||||||
select type(self)
|
select type(self)
|
||||||
class is(tList)
|
class is(tList)
|
||||||
list => self
|
list => self
|
||||||
class default
|
|
||||||
call IO_error(706,ext_msg='Expected "list"')
|
|
||||||
end select
|
end select
|
||||||
|
|
||||||
end function tNode_asList
|
end function tNode_asList
|
||||||
|
@ -346,8 +342,6 @@ function tNode_asDict(self) result(dict)
|
||||||
select type(self)
|
select type(self)
|
||||||
class is(tDict)
|
class is(tDict)
|
||||||
dict => self
|
dict => self
|
||||||
class default
|
|
||||||
call IO_error(706,ext_msg='Expected "dict"')
|
|
||||||
end select
|
end select
|
||||||
|
|
||||||
end function tNode_asDict
|
end function tNode_asDict
|
||||||
|
@ -417,7 +411,12 @@ function tNode_get_byIndex(self,i) result(node)
|
||||||
class(tItem), pointer :: item
|
class(tItem), pointer :: item
|
||||||
integer :: j
|
integer :: j
|
||||||
|
|
||||||
self_ => self%asList()
|
if(self%isList()) then
|
||||||
|
self_ => self%asList()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected List')
|
||||||
|
endif
|
||||||
|
|
||||||
if(i < 1 .or. i > self_%length) call IO_error(150,ext_msg='tNode_get_byIndex')
|
if(i < 1 .or. i > self_%length) call IO_error(150,ext_msg='tNode_get_byIndex')
|
||||||
|
|
||||||
j = 1
|
j = 1
|
||||||
|
@ -444,8 +443,12 @@ function tNode_get_byIndex_asFloat(self,i) result(nodeAsFloat)
|
||||||
type(tScalar), pointer :: scalar
|
type(tScalar), pointer :: scalar
|
||||||
|
|
||||||
node => self%get(i)
|
node => self%get(i)
|
||||||
scalar => node%asScalar()
|
if(node%isScalar()) then
|
||||||
nodeAsFloat = scalar%asFloat()
|
scalar => node%asScalar()
|
||||||
|
nodeAsFloat = scalar%asFloat()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected Scalar')
|
||||||
|
endif
|
||||||
|
|
||||||
end function tNode_get_byIndex_asFloat
|
end function tNode_get_byIndex_asFloat
|
||||||
|
|
||||||
|
@ -463,8 +466,12 @@ function tNode_get_byIndex_asInt(self,i) result(nodeAsInt)
|
||||||
type(tScalar), pointer :: scalar
|
type(tScalar), pointer :: scalar
|
||||||
|
|
||||||
node => self%get(i)
|
node => self%get(i)
|
||||||
scalar => node%asScalar()
|
if(node%isScalar()) then
|
||||||
nodeAsInt = scalar%asInt()
|
scalar => node%asScalar()
|
||||||
|
nodeAsInt = scalar%asInt()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected Scalar')
|
||||||
|
endif
|
||||||
|
|
||||||
end function tNode_get_byIndex_asInt
|
end function tNode_get_byIndex_asInt
|
||||||
|
|
||||||
|
@ -482,8 +489,12 @@ function tNode_get_byIndex_asBool(self,i) result(nodeAsBool)
|
||||||
type(tScalar), pointer :: scalar
|
type(tScalar), pointer :: scalar
|
||||||
|
|
||||||
node => self%get(i)
|
node => self%get(i)
|
||||||
scalar => node%asScalar()
|
if(node%isScalar()) then
|
||||||
nodeAsBool = scalar%asBool()
|
scalar => node%asScalar()
|
||||||
|
nodeAsBool = scalar%asBool()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected Scalar')
|
||||||
|
endif
|
||||||
|
|
||||||
end function tNode_get_byIndex_asBool
|
end function tNode_get_byIndex_asBool
|
||||||
|
|
||||||
|
@ -501,8 +512,12 @@ function tNode_get_byIndex_asString(self,i) result(nodeAsString)
|
||||||
type(tScalar), pointer :: scalar
|
type(tScalar), pointer :: scalar
|
||||||
|
|
||||||
node => self%get(i)
|
node => self%get(i)
|
||||||
scalar => node%asScalar()
|
if(node%isScalar()) then
|
||||||
nodeAsString = scalar%asString()
|
scalar => node%asScalar()
|
||||||
|
nodeAsString = scalar%asString()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected Scalar')
|
||||||
|
endif
|
||||||
|
|
||||||
end function tNode_get_byIndex_asString
|
end function tNode_get_byIndex_asString
|
||||||
|
|
||||||
|
@ -520,8 +535,12 @@ function tNode_get_byIndex_asFloats(self,i) result(nodeAsFloats)
|
||||||
class(tList), pointer :: list
|
class(tList), pointer :: list
|
||||||
|
|
||||||
node => self%get(i)
|
node => self%get(i)
|
||||||
list => node%asList()
|
if(node%isList()) then
|
||||||
nodeAsFloats = list%asFloats()
|
list => node%asList()
|
||||||
|
nodeAsFloats = list%asFloats()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected list')
|
||||||
|
endif
|
||||||
|
|
||||||
end function tNode_get_byIndex_asFloats
|
end function tNode_get_byIndex_asFloats
|
||||||
|
|
||||||
|
@ -539,8 +558,12 @@ function tNode_get_byIndex_asInts(self,i) result(nodeAsInts)
|
||||||
class(tList), pointer :: list
|
class(tList), pointer :: list
|
||||||
|
|
||||||
node => self%get(i)
|
node => self%get(i)
|
||||||
list => node%asList()
|
if(node%isList()) then
|
||||||
nodeAsInts = list%asInts()
|
list => node%asList()
|
||||||
|
nodeAsInts = list%asInts()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected list')
|
||||||
|
endif
|
||||||
|
|
||||||
end function tNode_get_byIndex_asInts
|
end function tNode_get_byIndex_asInts
|
||||||
|
|
||||||
|
@ -558,8 +581,12 @@ function tNode_get_byIndex_asBools(self,i) result(nodeAsBools)
|
||||||
class(tList), pointer :: list
|
class(tList), pointer :: list
|
||||||
|
|
||||||
node => self%get(i)
|
node => self%get(i)
|
||||||
list => node%asList()
|
if(node%isList()) then
|
||||||
nodeAsBools = list%asBools()
|
list => node%asList()
|
||||||
|
nodeAsBools = list%asBools()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected list')
|
||||||
|
endif
|
||||||
|
|
||||||
end function tNode_get_byIndex_asBools
|
end function tNode_get_byIndex_asBools
|
||||||
|
|
||||||
|
@ -577,8 +604,12 @@ function tNode_get_byIndex_asStrings(self,i) result(nodeAsStrings)
|
||||||
type(tList), pointer :: list
|
type(tList), pointer :: list
|
||||||
|
|
||||||
node => self%get(i)
|
node => self%get(i)
|
||||||
list => node%asList()
|
if(node%isList()) then
|
||||||
nodeAsStrings = list%asStrings()
|
list => node%asList()
|
||||||
|
nodeAsStrings = list%asStrings()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected list')
|
||||||
|
endif
|
||||||
|
|
||||||
end function tNode_get_byIndex_asStrings
|
end function tNode_get_byIndex_asStrings
|
||||||
|
|
||||||
|
@ -596,16 +627,20 @@ function tNode_getKey_byIndex(self,i) result(key)
|
||||||
type(tDict), pointer :: dict
|
type(tDict), pointer :: dict
|
||||||
type(tItem), pointer :: item
|
type(tItem), pointer :: item
|
||||||
|
|
||||||
dict => self%asDict()
|
if(self%isDict()) then
|
||||||
item => dict%first
|
dict => self%asDict()
|
||||||
do j = 1, dict%length
|
item => dict%first
|
||||||
if(j == i) then
|
do j = 1, dict%length
|
||||||
key = item%key
|
if(j == i) then
|
||||||
exit
|
key = item%key
|
||||||
else
|
exit
|
||||||
item => item%next
|
else
|
||||||
endif
|
item => item%next
|
||||||
enddo
|
endif
|
||||||
|
enddo
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected dict')
|
||||||
|
endif
|
||||||
|
|
||||||
end function tNode_getKey_byIndex
|
end function tNode_getKey_byIndex
|
||||||
|
|
||||||
|
@ -641,7 +676,7 @@ function tNode_contains(self,k) result(exists)
|
||||||
endif
|
endif
|
||||||
enddo
|
enddo
|
||||||
else
|
else
|
||||||
call IO_error(706,ext_msg='Expected "list" or "dict"')
|
call IO_error(706,ext_msg='Expected "list" or "dict"')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
end function tNode_contains
|
end function tNode_contains
|
||||||
|
@ -664,8 +699,12 @@ function tNode_get_byKey(self,k,defaultVal) result(node)
|
||||||
|
|
||||||
found = present(defaultVal)
|
found = present(defaultVal)
|
||||||
if(found) node => defaultVal
|
if(found) node => defaultVal
|
||||||
|
|
||||||
self_ => self%asDict()
|
if(self%isDict()) then
|
||||||
|
self_ => self%asDict()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected Dict for key '//k)
|
||||||
|
endif
|
||||||
|
|
||||||
j = 1
|
j = 1
|
||||||
item => self_%first
|
item => self_%first
|
||||||
|
@ -702,8 +741,12 @@ function tNode_get_byKey_asFloat(self,k,defaultVal) result(nodeAsFloat)
|
||||||
|
|
||||||
if(self%contains(k)) then
|
if(self%contains(k)) then
|
||||||
node => self%get(k)
|
node => self%get(k)
|
||||||
scalar => node%asScalar()
|
if(node%isScalar()) then
|
||||||
nodeAsFloat = scalar%asFloat()
|
scalar => node%asScalar()
|
||||||
|
nodeAsFloat = scalar%asFloat()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected Scalar for key '//k)
|
||||||
|
endif
|
||||||
elseif(present(defaultVal)) then
|
elseif(present(defaultVal)) then
|
||||||
nodeAsFloat = defaultVal
|
nodeAsFloat = defaultVal
|
||||||
else
|
else
|
||||||
|
@ -728,8 +771,12 @@ function tNode_get_byKey_asInt(self,k,defaultVal) result(nodeAsInt)
|
||||||
|
|
||||||
if(self%contains(k)) then
|
if(self%contains(k)) then
|
||||||
node => self%get(k)
|
node => self%get(k)
|
||||||
scalar => node%asScalar()
|
if(node%isScalar()) then
|
||||||
nodeAsInt = scalar%asInt()
|
scalar => node%asScalar()
|
||||||
|
nodeAsInt = scalar%asInt()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected Scalar for key '//k)
|
||||||
|
endif
|
||||||
elseif(present(defaultVal)) then
|
elseif(present(defaultVal)) then
|
||||||
nodeAsInt = defaultVal
|
nodeAsInt = defaultVal
|
||||||
else
|
else
|
||||||
|
@ -754,8 +801,12 @@ function tNode_get_byKey_asBool(self,k,defaultVal) result(nodeAsBool)
|
||||||
|
|
||||||
if(self%contains(k)) then
|
if(self%contains(k)) then
|
||||||
node => self%get(k)
|
node => self%get(k)
|
||||||
scalar => node%asScalar()
|
if(node%isScalar()) then
|
||||||
nodeAsBool = scalar%asBool()
|
scalar => node%asScalar()
|
||||||
|
nodeAsBool = scalar%asBool()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected Scalar for key '//k)
|
||||||
|
endif
|
||||||
elseif(present(defaultVal)) then
|
elseif(present(defaultVal)) then
|
||||||
nodeAsBool = defaultVal
|
nodeAsBool = defaultVal
|
||||||
else
|
else
|
||||||
|
@ -780,8 +831,12 @@ function tNode_get_byKey_asString(self,k,defaultVal) result(nodeAsString)
|
||||||
|
|
||||||
if(self%contains(k)) then
|
if(self%contains(k)) then
|
||||||
node => self%get(k)
|
node => self%get(k)
|
||||||
scalar => node%asScalar()
|
if(node%isScalar()) then
|
||||||
nodeAsString = scalar%asString()
|
scalar => node%asScalar()
|
||||||
|
nodeAsString = scalar%asString()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected Scalar for key '//k)
|
||||||
|
endif
|
||||||
elseif(present(defaultVal)) then
|
elseif(present(defaultVal)) then
|
||||||
nodeAsString = defaultVal
|
nodeAsString = defaultVal
|
||||||
else
|
else
|
||||||
|
@ -808,8 +863,12 @@ function tNode_get_byKey_asFloats(self,k,defaultVal,requiredSize) result(nodeAsF
|
||||||
|
|
||||||
if(self%contains(k)) then
|
if(self%contains(k)) then
|
||||||
node => self%get(k)
|
node => self%get(k)
|
||||||
list => node%asList()
|
if(node%isList()) then
|
||||||
nodeAsFloats = list%asFloats()
|
list => node%asList()
|
||||||
|
nodeAsFloats = list%asFloats()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected list for key '//k)
|
||||||
|
endif
|
||||||
elseif(present(defaultVal)) then
|
elseif(present(defaultVal)) then
|
||||||
nodeAsFloats = defaultVal
|
nodeAsFloats = defaultVal
|
||||||
else
|
else
|
||||||
|
@ -839,8 +898,12 @@ function tNode_get_byKey_asInts(self,k,defaultVal,requiredSize) result(nodeAsInt
|
||||||
|
|
||||||
if(self%contains(k)) then
|
if(self%contains(k)) then
|
||||||
node => self%get(k)
|
node => self%get(k)
|
||||||
list => node%asList()
|
if(node%isList()) then
|
||||||
nodeAsInts = list%asInts()
|
list => node%asList()
|
||||||
|
nodeAsInts = list%asInts()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected list for key '//k)
|
||||||
|
endif
|
||||||
elseif(present(defaultVal)) then
|
elseif(present(defaultVal)) then
|
||||||
nodeAsInts = defaultVal
|
nodeAsInts = defaultVal
|
||||||
else
|
else
|
||||||
|
@ -869,8 +932,12 @@ function tNode_get_byKey_asBools(self,k,defaultVal) result(nodeAsBools)
|
||||||
|
|
||||||
if(self%contains(k)) then
|
if(self%contains(k)) then
|
||||||
node => self%get(k)
|
node => self%get(k)
|
||||||
list => node%asList()
|
if(node%isList())then
|
||||||
nodeAsBools = list%asBools()
|
list => node%asList()
|
||||||
|
nodeAsBools = list%asBools()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected list for key '//k)
|
||||||
|
endif
|
||||||
elseif(present(defaultVal)) then
|
elseif(present(defaultVal)) then
|
||||||
nodeAsBools = defaultVal
|
nodeAsBools = defaultVal
|
||||||
else
|
else
|
||||||
|
@ -895,8 +962,12 @@ function tNode_get_byKey_asStrings(self,k,defaultVal) result(nodeAsStrings)
|
||||||
|
|
||||||
if(self%contains(k)) then
|
if(self%contains(k)) then
|
||||||
node => self%get(k)
|
node => self%get(k)
|
||||||
list => node%asList()
|
if(node%isList()) then
|
||||||
nodeAsStrings = list%asStrings()
|
list => node%asList()
|
||||||
|
nodeAsStrings = list%asStrings()
|
||||||
|
else
|
||||||
|
call IO_error(706,ext_msg='Expected list for key '//k)
|
||||||
|
endif
|
||||||
elseif(present(defaultVal)) then
|
elseif(present(defaultVal)) then
|
||||||
nodeAsStrings = defaultVal
|
nodeAsStrings = defaultVal
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue