Browse Source

more work on refactoring / rewriting parsers

tempestpy_adaptions
gereon 12 years ago
parent
commit
2cf8f3baec
  1. 123
      src/parser/readLabFile.cpp
  2. 19
      src/parser/readLabFile.h
  3. 107
      src/parser/readTraFile.cpp
  4. 19
      src/parser/readTraFile.h
  5. 181
      src/parser/read_lab_file.cpp
  6. 24
      src/parser/read_lab_file.h
  7. 20
      src/parser/read_tra_file.h

123
src/parser/readLabFile.cpp

@ -0,0 +1,123 @@
/*
* readLabFile.cpp
*
* Created on: 21.11.2012
* Author: Gereon Kremer
*/
#include "parser.h"
#include "readLabFile.h"
#include "src/exceptions/wrong_file_format.h"
#include "src/exceptions/file_IO_exception.h"
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <clocale>
#include <iostream>
#include <errno.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <locale.h>
#include <pantheios/pantheios.hpp>
#include <pantheios/inserters/integer.hpp>
namespace mrmc {
namespace parser {
/*!
* Reads a .lab file and puts the result in a labeling structure.
*
* Labelings created with this method have to be freed with the delete operator.
* @param node_count the number of states.
* @param filename input .lab file's name.
* @return The pointer to the created labeling object.
*/
mrmc::models::AtomicPropositionsLabeling * readLabFile(int node_count, const char * filename)
{
/*!
* open file and map to memory
*/
struct stat st;
int f = open(filename, O_RDONLY);
if ((f < 0) || (stat(filename, &st) != 0)) {
/*!
*
*/
pantheios::log_ERROR("File could not be opened.");
throw mrmc::exceptions::file_IO_exception();
return NULL;
}
char* data = (char*) mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, f, 0);
if (data == (char*)-1)
{
pantheios::log_ERROR("File could not be mapped. Something went wrong with mmap.");
close(f);
throw mrmc::exceptions::file_IO_exception();
return NULL;
}
char* buf = data;
char sep[] = " \n\t";
uint_fast32_t proposition_count = 0;
size_t cnt = 0;
do {
buf += cnt;
cnt = strcspn(buf, sep);
if (cnt > 0) {
if (strncmp(buf, "#DECLARATION", cnt) == 0) continue;
if (strncmp(buf, "#END", cnt) == 0) break;
proposition_count++;
}
else cnt = 1;
} while (cnt > 0);
mrmc::models::AtomicPropositionsLabeling* result = new mrmc::models::AtomicPropositionsLabeling(node_count, proposition_count);
char proposition[128];
buf = data;
cnt = 0;
do {
buf += cnt;
cnt = strcspn(buf, sep);
if (cnt > 0) {
if (strncmp(buf, "#DECLARATION", cnt) == 0) continue;
if (strncmp(buf, "#END", cnt) == 0) break;
strncpy(proposition, buf, cnt);
proposition[cnt] = '\0';
result->addAtomicProposition(proposition);
}
else cnt = 1;
} while (cnt > 0);
buf += 4;
uint_fast32_t node;
while (1) {
node = strtol(buf, &buf, 10);
while (*buf != '\0') {
cnt = strcspn(buf, sep);
if (cnt == 0) buf++;
else break;
}
strncpy(proposition, buf, cnt);
proposition[cnt] = '\0';
result->addAtomicPropositionToState(proposition, node);
buf += cnt;
}
munmap(data, st.st_size);
close(f);
return result;
}
} //namespace parser
} //namespace mrmc

19
src/parser/readLabFile.h

@ -0,0 +1,19 @@
/*
* read_lab_file.h
*
*/
#pragma once
#include "src/models/atomic_propositions_labeling.h"
namespace mrmc {
namespace parser {
mrmc::models::AtomicPropositionsLabeling * readLabFile(int node_count, const char * filename);
}
sp/GSW_AI_LAB - GSW_AI_LAB - Gitea: Git with a cup of tea
The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

286 lines
3.8 KiB

2 months ago
  1. .model adj49
  2. .inputs CA
  3. .inputs WA
  4. .inputs OR
  5. .inputs NV
  6. .inputs ID
  7. .inputs UT
  8. .inputs AZ
  9. .inputs MT
  10. .inputs WY
  11. .inputs CO
  12. .inputs NM
  13. .inputs ND
  14. .inputs SD
  15. .inputs NE
  16. .inputs KS
  17. .inputs OK
  18. .inputs TX
  19. .inputs MN
  20. .inputs IA
  21. .inputs MO
  22. .inputs AR
  23. .inputs LA
  24. .inputs WI
  25. .inputs IL
  26. .inputs MS
  27. .inputs MI
  28. .inputs IN
  29. .inputs KY
  30. .inputs TN
  31. .inputs AL
  32. .inputs OH
  33. .inputs WV
  34. .inputs VA
  35. .inputs GA
  36. .inputs FL
  37. .inputs PA
  38. .inputs MD
  39. .inputs DC
  40. .inputs NC
  41. .inputs SC
  42. .inputs VT
  43. .inputs NY
  44. .inputs NJ
  45. .inputs DE
  46. .inputs NH
  47. .inputs MA
  48. .inputs CT
  49. .inputs ME
  50. .inputs RI
  51. .outputs indep
  52. .names CA OR caor
  53. 11 0
  54. .names CA NV canv
  55. 11 0
  56. .names CA AZ caaz
  57. 11 0
  58. .names WA OR waor
  59. 11 0
  60. .names WA ID waid
  61. 11 0
  62. .names OR ID orid
  63. 11 0
  64. .names OR NV ornv
  65. 11 0
  66. .names NV ID nvid
  67. 11 0
  68. .names NV UT nvut
  69. 11 0
  70. .names NV AZ nvaz
  71. 11 0
  72. .names ID MT idmt
  73. 11 0
  74. .names ID WY idwy
  75. 11 0
  76. .names ID UT idut
  77. 11 0
  78. .names UT WY utwy
  79. 11 0
  80. .names UT CO utco
  81. 11 0
  82. .names UT AZ utaz
  83. 11 0
  84. .names AZ NM aznm
  85. 11 0
  86. .names MT ND mtnd
  87. 11 0
  88. .names MT SD mtsd
  89. 11 0
  90. .names MT WY mtwy
  91. 11 0
  92. .names WY SD wysd
  93. 11 0
  94. .names WY NE wyne
  95. 11 0
  96. .names WY CO wyco
  97. 11 0
  98. .names CO NE cone
  99. 11 0
  100. .names CO KS coks
  101. 11 0
  102. .names CO OK cook
  103. 11 0
  104. .names CO NM conm
  105. 11 0
  106. .names NM OK nmok
  107. 11 0
  108. .names NM TX nmtx
  109. 11 0
  110. .names ND MN ndmn
  111. 11 0
  112. .names ND SD ndsd
  113. 11 0
  114. .names SD MN sdmn
  115. 11 0
  116. .names SD IA sdia
  117. 11 0
  118. .names SD NE sdne
  119. 11 0
  120. .names NE IA neia
  121. 11 0
  122. .names NE MO nemo
  123. 11 0
  124. .names NE KS neks
  125. 11 0
  126. .names KS MO ksmo
  127. 11 0
  128. .names KS OK ksok
  129. 11 0
  130. .names OK MO okmo
  131. 11 0
  132. .names OK AR okar
  133. 11 0
  134. .names OK TX oktx
  135. 11 0
  136. .names TX AR txar
  137. 11 0
  138. .names TX LA txla
  139. 11 0
  140. .names MN WI mnwi
  141. 11 0
  142. .names MN IA mnia
  143. 11 0
  144. .names IA WI iawi
  145. 11 0
  146. .names IA IL iail
  147. 11 0
  148. .names IA MO iamo
  149. 11 0
  150. .names MO IL moil
  151. 11 0
  152. .names MO KY moky
  153. 11 0
  154. .names MO TN motn
  155. 11 0
  156. .names MO AR moar
  157. 11 0
  158. .names AR TN artn
  159. 11 0
  160. .names AR MS arms
  161. 11 0
  162. .names AR LA arla
  163. 11 0
  164. .names LA MS lams
  165. 11 0
  166. .names WI MI wimi
  167. 11 0
  168. .names WI IL wiil
  169. 11 0
  170. .names IL IN ilin
  171. 11 0
  172. .names IL KY ilky
  173. 11 0
  174. .names MS TN mstn
  175. 11 0
  176. .names MS AL msal
  177. 11 0
  178. .names MI OH mioh
  179. 11 0
  180. .names MI IN miin
  181. 11 0
  182. .names IN OH inoh
  183. 11 0
  184. .names IN KY inky
  185. 11 0
  186. .names KY OH kyoh
  187. 11 0
  188. .names KY WV kywv
  189. 11 0
  190. .names KY VA kyva
  191. 11 0
  192. .names KY TN kytn
  193. 11 0
  194. .names TN VA tnva
  195. 11 0
  196. .names TN NC tnnc
  197. 11 0
  198. .names TN GA tnga
  199. 11 0
  200. .names TN AL tnal
  201. 11 0
  202. .names AL GA alga
  203. 11 0
  204. .names AL FL alfl
  205. 11 0
  206. .names OH PA ohpa
  207. 11 0
  208. .names OH WV ohwv
  209. 11 0
  210. .names WV PA wvpa
  211. 11 0
  212. .names WV MD wvmd
  213. 11 0
  214. .names WV VA wvva
  215. 11 0
  216. .names VA MD vamd
  217. 11 0
  218. .names VA DC vadc
  219. 11 0
  220. .names VA NC vanc
  221. 11 0
  222. .names GA NC ganc
  223. 11 0
  224. .names GA SC gasc
  225. 11 0
  226. .names GA FL gafl
  227. 11 0
  228. .names PA NY pany
  229. 11 0
  230. .names PA NJ panj
  231. 11 0
  232. .names PA DE pade
  233. 11 0
  234. .names PA MD pamd
  235. 11 0
  236. .names MD DE mdde
  237. 11 0
  238. .names MD DC mddc
  239. 11 0
  240. .names NC SC ncsc
  241. 11 0
  242. .names VT NH vtnh
  243. 11 0
  244. .names VT MA vtma
  245. 11 0
  246. .names VT NY vtny
  247. 11 0
  248. .names NY MA nyma
  249. 11 0
  250. .names NY CT nyct
  251. 11 0
  252. .names NY NJ nynj
  253. 11 0
  254. .names NJ DE njde
  255. 11 0
  256. .names NH ME nhme
  257. 11 0
  258. .names NH MA nhma
  259. 11 0
  260. .names MA RI mari
  261. 11 0
  262. .names MA CT mact
  263. 11 0
  264. .names CT RI ctri
  265. 11 0
  266. .names caor canv caaz waor waid orid ornv nvid nvut nvaz idmt idwy w0
  267. 111111111111 1
  268. .names idut utwy utco utaz aznm mtnd mtsd mtwy wysd wyne wyco cone w1
  269. 111111111111 1
  270. .names coks cook conm nmok nmtx ndmn ndsd sdmn sdia sdne neia nemo w2
  271. 111111111111 1
  272. .names neks ksmo ksok okmo okar oktx txar txla mnwi mnia iawi iail w3
  273. 111111111111 1
  274. .names iamo moil moky motn moar artn arms arla lams wimi wiil ilin ilky w4
  275. 1111111111111 1
  276. .names mstn msal mioh miin inoh inky kyoh kywv kyva kytn tnva tnnc w5
  277. 111111111111 1
  278. .names tnga tnal alga alfl ohpa ohwv wvpa wvmd wvva vamd vadc vanc w6
  279. 111111111111 1
  280. .names ganc gasc gafl pany panj pade pamd mdde mddc ncsc vtnh vtma vtny w7
  281. 1111111111111 1
  282. .names nyma nyct nynj njde nhme nhma mari mact ctri w8
  283. 1111111111 1
  284. .names w0 w1 w2 w3 w4 w5 w6 w7 w8 indep
  285. 111111111 1
  286. .end
0