LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
srvn_reader.h File Reference

SRVN input format (the LQNS .in / .lqn text grammar) for layered models, the C++ twin of python/line_solver/io/srvn_io.py, MATLAB srvn2lqnx.m and the JAR's jline.io.SRVN2LQNX. More...

#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <map>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "line/lang/lqn/lqn_reader.h"
#include "line/util/error.h"
Include dependency graph for srvn_reader.h:

Go to the source code of this file.

Classes

struct  line::lqn::srvn_detail::Tok
struct  line::lqn::srvn_detail::Val
 A number as written: its source spelling and its value. More...
struct  line::lqn::srvn_detail::Call
struct  line::lqn::srvn_detail::Work
 An entry phase or an activity: the s, c, f, Z, M values and the calls. More...
struct  line::lqn::srvn_detail::Proc
struct  line::lqn::srvn_detail::Group
struct  line::lqn::srvn_detail::Task
struct  line::lqn::srvn_detail::Entry
struct  line::lqn::srvn_detail::Conn
struct  line::lqn::srvn_detail::Acts
struct  line::lqn::srvn_detail::Model
class  line::lqn::srvn_detail::Parser

Namespaces

namespace  line
 Conservation laws of a layered queueing network, enumerated from its structure.
namespace  line::lqn
namespace  line::lqn::srvn_detail

Enumerations

enum class  line::lqn::srvn_detail::TK {
  line::lqn::srvn_detail::STR , line::lqn::srvn_detail::NUM , line::lqn::srvn_detail::ID , line::lqn::srvn_detail::VAR ,
  line::lqn::srvn_detail::OBS , line::lqn::srvn_detail::P
}

Functions

bool line::lqn::srvn_detail::is_space (char c)
 Python's str.isspace over ASCII, which also counts the four separators 0x1c-0x1f.
bool line::lqn::srvn_detail::is_digit (char c)
bool line::lqn::srvn_detail::is_alnum (char c)
bool line::lqn::srvn_detail::is_ident (char c)
 [A-Za-z0-9_.
std::string line::lqn::srvn_detail::strip (const std::string &s)
std::string line::lqn::srvn_detail::py_repr (const std::string &s)
 Python's repr of an ASCII string, so messages read as the reference's do.
InputError line::lqn::srvn_detail::err (const std::string &msg, int line=-1)
std::string line::lqn::srvn_detail::esc (const std::string &s)
bool line::lqn::srvn_detail::nz (const Val &v)
std::string line::lqn::srvn_detail::lstrip_plus (const std::string &s)
double line::lqn::srvn_detail::to_double (const std::string &s)
std::size_t line::lqn::srvn_detail::match_number (const std::string &src, std::size_t i)
 End of [-+]?(?
bool line::lqn::srvn_detail::pragma_body (const std::string &line, std::string &body)
 #\s*pragma\s+(.
void line::lqn::srvn_detail::tokenize (const std::string &src, std::vector< Tok > &toks, std::vector< std::pair< std::string, std::string > > &pragmas)
const char * line::lqn::srvn_detail::proc_sched (const std::string &k)
const char * line::lqn::srvn_detail::task_sched (const std::string &k)
const char * line::lqn::srvn_detail::rwlock_kind (const std::string &k)
std::string line::lqn::format_number (double x)
 Shortest C g spelling that round-trips x; the four codebases share this rule.
std::string line::lqn::srvn_detail::attr (const char *name, const Val &v)
std::string line::lqn::srvn_detail::activity_attrs (const Work &a, std::vector< const Call * > &calls)
void line::lqn::srvn_detail::emit_activity (std::vector< std::string > &out, const std::string &ind, const std::string &head, const Work &a)
void line::lqn::srvn_detail::emit_task (std::vector< std::string > &out, const std::string &ind, const Task &t, const Model &m)
std::string line::lqn::srvn_detail::stem (const std::string &path)
 Python's os.path.splitext(os.path.basename(path))[0].
std::string line::lqn::srvn_detail::read_text (const std::string &path)
 The file as Python's text mode reads it: universal newlines, so \r\n and \r become \n.
std::string line::lqn::srvn2lqnx (const std::string &src, const std::string &name=std::string("model"))
 Translate SRVN text into an LQN XML document.
bool line::lqn::is_srvn_file (const std::string &path)
 True when path holds SRVN text rather than XML: its first non-blank character is not '<'.
bool line::lqn::is_srvn_path (const std::string &path)
 Whether path should be read as SRVN: a .in file, or a .lqn file that is not XML.
std::string line::lqn::srvn_file_to_lqnx (const std::string &path)
 Translate the SRVN file path to .lqnx text, model name = its basename without extension.
template<class T>
LqnModel< T > line::lqn::read_srvn_model (const std::string &path)
 Read an SRVN file (.in, or a .lqn that is not XML) into the intermediate LqnModel, via its .lqnx translation.
template<class T>
LqnStruct< T > line::lqn::read_srvn (const std::string &path)
 read_srvn_model followed by lqn_finalize: the struct SolverLN consumes, as read_lqnx is.

Detailed Description

SRVN input format (the LQNS .in / .lqn text grammar) for layered models, the C++ twin of python/line_solver/io/srvn_io.py, MATLAB srvn2lqnx.m and the JAR's jline.io.SRVN2LQNX.

The reader TRANSLATES an SRVN document into the LQN XML interchange and hands that to read_lqnx_model, so loading model.in builds exactly the model that loading the .lqnx written by lqn2xml -Oxml model.in builds. The translation is deterministic and BYTE-IDENTICAL across the four codebases: test/testsLQNS/srvn/expected in line-test.git is the shared golden.

Grammar covered (LQNS 6): the G, P, U, T, E, A and R sections; processor, task, group, entry and activity declarations with every option LQNS accepts; fan-in/fan-out (I/O); semaphore and rwlock entries; activity precedence (sequence, AND/OR fork and join, quorum join, loop, reply lists); #pragma lines; and SPEX scalar parameters ($x = expr), which are substituted. A SPEX sweep ($x = [ ... ]) used by the model is refused (LINE:unsupported:Format), since one layered model carries one value per parameter. SPEX observations (u $U), histogram requests (H) and the R result list are requests for output, not model content, and are skipped.

NUMBERS ARE COPIED AS WRITTEN: an attribute carries the source token, leading '+' stripped, so the document never depends on how a codebase prints a double. Only a COMPUTED parameter ($x = 2 * $y) is printed, by format_number, whose rule the four codebases share.

Definition in file srvn_reader.h.