56 integer,
intent(out):: tokentype
57 integer,
intent(out):: ivalue(5)
58 real(DP),
intent(out):: dvalue
59 character(*),
intent(out):: cvalue
60 integer:: iend, istr, ilen, ios
64 iend = len_trim(thisline)
68 call match(
"^##", thisline(i:), istr, ilen)
75 call match(
"^#s+", thisline(i:), istr, ilen)
81 call match(
"^@", thisline(i:), istr, ilen)
82 if (istr <= 0)
call match(
"^from", thisline(i:), istr, ilen)
83 if (istr <= 0)
call match(
"^at", thisline(i:), istr, ilen)
87 cvalue = thisline(i: i+ilen-1)
91 call match(
"^#a#w*#a", thisline(i:), istr, ilen)
92 if (istr <= 0)
call match(
"^[#a'""]", thisline(i:), istr, ilen)
95 cvalue = thisline(i: i+ilen-1)
100 call match(
"^#^", thisline(i:), istr, ilen)
101 if (istr <= 0)
call match(
"^#*#*", thisline(i:), istr, ilen)
103 tokentype = s_exponent
104 cvalue = thisline(i: i+ilen-1)
109 call match(
"^#.[^#d]", thisline(i:), istr, ilen)
110 if (istr <= 0)
call match(
"^#*", thisline(i:), istr, ilen)
112 tokentype = s_multiply
113 cvalue = thisline(i: i+ilen-1)
118 call match(
"^[-+]?#d*#.#d*[EeDd][-+]?#d+", thisline(i:), istr, ilen)
119 if (istr <= 0)
call match(
"^[-+]?#d*#.#d*", thisline(i:), istr, ilen)
121 read(thisline(i: i+ilen-1), fmt=*, &
123 if (ios /= 0) dvalue = huge(dvalue)
124 cvalue = thisline(i: i+ilen-1)
130 call match(
"^[-+]?#d+", thisline(i:), istr, ilen)
132 read(thisline(i: i+ilen-1), fmt=*, &
133 & iostat=ios) ivalue(1)
134 if (ios /= 0) ivalue(1) = huge(1)
135 cvalue = thisline(i: i+ilen-1)
136 tokentype = s_integer
141 if (thisline(i:i) ==
'/')
then 143 cvalue = thisline(i:i)
147 if (thisline(i:i) ==
'(')
then 148 tokentype = s_openpar
149 cvalue = thisline(i:i)
153 if (thisline(i:i) ==
')')
then 154 tokentype = s_closepar
155 cvalue = thisline(i:i)
160 tokentype = ichar(thisline(i:i))
161 cvalue = thisline(i:i)
Provide simple regular expression subroutine: 'match'.
subroutine, public match(pattern, text, start, length)