support single and double quotes in key value pairs also

escape characters not supported in double quotes
This commit is contained in:
Sharan Roongta 2021-07-24 17:40:27 +02:00
parent a5c4e7232c
commit ae49920256
2 changed files with 10 additions and 10 deletions

View File

@ -6,29 +6,29 @@ homogenization:
phase:
Aluminum:
lattice: "cF"
"lattice": 'cF'
mechanical:
output: [F, P, F_e, F_p, L_p, O]
elastic: {type: "Hooke", C_11: 106.75e+9, C_12: 60.41e+9, C_44: 28.34e+9}
plastic:
type: phenopowerlaw
N_sl: [12]
'type': "phenopowerlaw"
"N_sl": [12]
a_sl: 2.25
atol_xi: 1.0
dot_gamma_0_sl: 0.001
h_0_sl-sl: 75.e+6
h_sl-sl: [1, 1, 1.4, 1.4, 1.4, 1.4, 1.4]
n_sl: 20
output: ["xi_sl"]
'output': ['xi_sl']
xi_0_sl: [31.e+6]
xi_inf_sl: [63.e+6]
material:
- homogenization: SX
constituents:
- phase: Aluminum
v: 1.0
O: [1.0, 0.0, 0.0, 0.0]
- 'phase': "Aluminum"
'v': 1.0
"O": [1.0, 0.0, 0.0, 0.0]
- homogenization: SX
constituents:
- phase: Aluminum

View File

@ -71,8 +71,8 @@ recursive function parse_flow(YAML_flow) result(node)
s = e
d = s + scan(flow_string(s+1:),':')
e = d + find_end(flow_string(d+1:),'}')
key = trim(adjustl(flow_string(s+1:d-1)))
if (key(1:1) == '"' .or. key(1:1) == "'" ) key = key(2:len(key)-1)
myVal => parse_flow(flow_string(d+1:e-1)) ! parse items (recursively)
select type (node)
@ -97,7 +97,7 @@ recursive function parse_flow(YAML_flow) result(node)
allocate(tScalar::node)
select type (node)
class is (tScalar)
if(flow_string(1:1) == '"') then
if (flow_string(1:1) == '"' .or. flow_string(1:1) == "'") then
node = trim(adjustl(flow_string(2:len(flow_string)-1)))
else
node = trim(adjustl(flow_string))
@ -125,7 +125,7 @@ integer function find_end(str,e_char)
N_cu = 0
i = 1
do while(i<=len_trim(str))
if (str(i:i) == '"') i = i + scan(str(i+1:),'"')
if (str(i:i) == '"' .or. str(i:i) == "'") i = i + scan(str(i+1:),str(i:i))
if (N_sq==0 .and. N_cu==0 .and. scan(str(i:i),e_char//',') == 1) exit
N_sq = N_sq + merge(1,0,str(i:i) == '[')
N_cu = N_cu + merge(1,0,str(i:i) == '{')