Back to index

texmacs  1.0.7.15
language.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : language.hpp
00004 * DESCRIPTION: language specific features, which include
00005 *              - punctuation rules
00006 *              - hyphenation
00007 *              - (future) dictionary and grammar rumes for spell-checker
00008 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00009 *******************************************************************************
00010 * This software falls under the GNU general public license version 3 or later.
00011 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00012 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00013 ******************************************************************************/
00014 
00015 #ifndef LANGUAGE_H
00016 #define LANGUAGE_H
00017 #include "space.hpp"
00018 #include "array.hpp"
00019 #include "resource.hpp"
00020 
00021 RESOURCE(language);
00022 
00023 /******************************************************************************
00024 * The text property class
00025 ******************************************************************************/
00026 
00027 #define TP_NORMAL     0
00028 #define TP_HYPH       1
00029 #define TP_SPACE      2
00030 #define TP_DSPACE     3
00031 #define TP_BLANK      4
00032 #define TP_PERIOD     5
00033 #define TP_OPERATOR   6
00034 #define TP_SHORTOP    7
00035 #define TP_OTHER      8
00036 
00037 #define SPC_NONE      0
00038 #define SPC_SPACE     1
00039 #define SPC_DSPACE    2
00040 #define SPC_PERIOD    3
00041 #define SPC_TINY      4
00042 #define SPC_HALF      5
00043 #define SPC_OPERATOR  6
00044 #define SPC_BIGOP     7
00045 
00046 #define HYPH_STD      10000
00047 #define HYPH_PANIC    1000000
00048 #define HYPH_INVALID  100000000
00049 
00050 #define OP_UNKNOWN            0
00051 #define OP_TEXT               1
00052 #define OP_SKIP               2
00053 #define OP_SYMBOL             3
00054 #define OP_UNARY              4
00055 #define OP_BINARY             5
00056 #define OP_N_ARY              6
00057 #define OP_PREFIX             7
00058 #define OP_POSTFIX            8
00059 #define OP_INFIX              9
00060 #define OP_APPLY             10
00061 #define OP_SEPARATOR         11
00062 #define OP_OPENING_BRACKET   12
00063 #define OP_MIDDLE_BRACKET    13
00064 #define OP_CLOSING_BRACKET   14
00065 #define OP_BIG               15
00066 #define OP_TOTAL             16
00067 
00068 #define LIMITS_NONE           0
00069 #define LIMITS_DISPLAY        1
00070 #define LIMITS_ALWAYS         2
00071 
00072 struct text_property_rep {
00073   int  type;
00074   int  spc_before;
00075   int  spc_after;
00076   int  pen_before;
00077   int  pen_after;
00078 
00079   int  op_type;
00080   int  priority;
00081   int  limits;
00082 
00083   text_property_rep (int type= TP_OTHER,
00084                    int spc_before= SPC_NONE, int spc_after= SPC_NONE,
00085                    int pen_before= 0, int pen_after= HYPH_INVALID,
00086                    int op_type= OP_SYMBOL, int priority= 1000,
00087                    int limits= LIMITS_NONE);
00088 };
00089 
00090 typedef text_property_rep* text_property;
00091 
00092 /******************************************************************************
00093 * Possible successions of mathematical operators
00094 ******************************************************************************/
00095 
00096 #define SUCCESSION_OK         0
00097 #define REMOVE_SPACE_BEFORE   1
00098 #define REMOVE_CURRENT_SPACE  2
00099 #define REMOVE_ALL_SPACE      3
00100 
00101 extern int succession_status_table [OP_TOTAL * OP_TOTAL];
00102 inline int succession_status (int op1, int op2) {
00103   return succession_status_table [op1 * OP_TOTAL + op2]; }
00104 //int succession_status (int op1, int op2);
00105 void init_succession_status_table ();
00106 
00107 /******************************************************************************
00108 * The language structure
00109 ******************************************************************************/
00110 
00111 struct language_rep: rep<language> {
00112   string lan_name;  // name of the language
00113   int hl_lan;
00114   language_rep (string s);
00115   virtual text_property advance (tree t, int& pos) = 0;
00116   virtual array<int> get_hyphens (string s) = 0;
00117   virtual void hyphenate (string s, int after, string& l, string& r) = 0;
00118   virtual string get_group (string s);
00119   virtual array<string> get_members (string s);
00120   virtual void highlight (tree t);
00121   virtual string get_color (tree t, int start, int end);
00122 };
00123 
00124 language text_language (string s);
00125 language math_language (string s);
00126 language prog_language (string s);
00127 
00128 string locale_to_language (string s);
00129 string language_to_locale (string s);
00130 string get_locale_language ();
00131 #if defined(__MINGW__) || defined(__MINGW32__) || defined(OS_WIN32)
00132 namespace win32 {
00133   string get_date (string lan, string fm);
00134 }
00135 #endif
00136 string get_date (string lan, string fm);
00137 
00138 string math_symbol_group (string s, string lan= "std-math");
00139 array<string> math_group_members (string s, string lan= "std-math");
00140 string math_symbol_type (string s, string lan= "std-math");
00141 
00142 #endif // defined LANGUAGE_H