//////////////////////////////////////////////////////////////////////////////// // // Simple API for Block Parser // #ifndef SAB_PARSER_H #define SAB_PARSER_H #include <stdbool.h> /** * */ typedef struct _SABParserBlock { bool allowInnerBock; //< 内部のブロックを許容する bool allowNesting; //< ネストを許容する bool canEscape; //< ESCAPE 可能 const char* sString; //< 開始文字列 const char* eString; //< 終了文字列 void* info; //< 任意の追加情報 } SABParserBlock; typedef struct _LinkedStream { int lineNo; char* line; struct _LinkedStream* _next; char lineData[]; } typedef struct _SABParserConfig { // Block 情報 SABParserBlock* lv1Blocks; //< Lv1のブロックリスト size_t lv1BlocksSize; //< Lv1のブロックリストサイズ SABParserBlock* lv2Blocks; //< Lv2のブロックリスト size_t lv2BlocksSize; //< Lv2のブロックリストサイズ SABParserBlock* lv3Blocks; //< Lv3のブロックリスト size_t lv3BlocksSize; //< Lv3のブロックリストサイズ } SABParserConfig; typedef struct _SABParserBlockStream { } typedef struct _LineInfo { int no; const char* line; } LineInfo; LineBasedStream { LineInfo* nextLine(); } void sab_parser_parser(SABParserConfig* config, char*,void (*handler)(SABParserBlock* block, KKcStream* stream) { KcStream* } #endif // SAB_PARSER_H // BLOCK // /+ --- +/ LV 0, INNER BLOCK : 許可, ESCAPE 不可, NEST 可 // # --- [EOL] LV 0, INNER BLOCK : 許可, ESCAPE 不可, NEST 不可 // // --- [EOL] LV 0, INNER BLOCK : 許可, ESCAPE 不可, NEST 不可 // /* --- */ LV 0, INNER BLOCK : 不可, ESCAPE 不可, NEST 不可 // ``` --- ``` LV 0, INNER BLOCK : 不可, ESCAPE 不可, NEST 不可 // """ --- """ LV 0, INNER BLOCK : 不可, ESCAPE 不可, NEST 不可 // { --- } LV 0, ESCAPE 不可, NEST 可 // ( --- ) LV 0, ESCAPE 不可, NEST 可 // [ --- ] LV 0, ESCAPE 不可, NEST 可 // < --- > LV 0, ESCAPE 不可, NEST 可 // ` --- ` LV 1, ESCAPE 可, NEST 不可 // ' --- ' LV 2, ESCAPE 可, NEST 不可 // " --- " LV 2, ESCAPE 可, NEST 不可 // // 自分より LV の高いブロックは中に入れ込むことができる。 // Ex.1) { "abc" : " } " } // Ex.2) `echo "exec `command`"` #ifndef LANG_BLOCK_PARSER_HPP #define LANG_BLOCK_PARSER_HPP /** * ブロック情報。 */ typedef struct { bool allow_innter_block; //!< 中のブロックを許容する bool allow_nesting; //!< ネストを許容する bool can_escape; //!< ESCAPE可能 int lv; //!< ブロックレベル const char* s_str; //!< 開始文字列 const char* e_str; //!< 終了文字列 } BlockInfo; typedef struct { int block_info_id; unsigned char* data; } BlockData; #endif // LANG_BLOCK_PARSER_HPP