Commits

Georg Brandl  committed 986f270 Merge
  • Participants
  • Parent commits f73bbeb, 4317c7e

Comments (0)

Files changed (4)

File pygments/lexers/_mapping.py

     'DjangoLexer': ('pygments.lexers.templates', 'Django/Jinja', ('django', 'jinja'), (), ('application/x-django-templating', 'application/x-jinja')),
     'DuelLexer': ('pygments.lexers.web', 'Duel', ('duel', 'Duel Engine', 'Duel View', 'JBST', 'jbst', 'JsonML+BST'), ('*.duel', '*.jbst'), ('text/x-duel', 'text/x-jbst')),
     'DylanLexer': ('pygments.lexers.compiled', 'Dylan', ('dylan',), ('*.dylan', '*.dyl'), ('text/x-dylan',)),
+    'eCLexer': ('pygments.lexers.compiled', 'eC', ('ec',), ('*.ec', '*.eh'), ('text/x-echdr', 'text/x-ecsrc')),
     'ErbLexer': ('pygments.lexers.templates', 'ERB', ('erb',), (), ('application/x-ruby-templating',)),
     'ErlangLexer': ('pygments.lexers.functional', 'Erlang', ('erlang',), ('*.erl', '*.hrl'), ('text/x-erlang',)),
     'ErlangShellLexer': ('pygments.lexers.functional', 'Erlang erl session', ('erl',), ('*.erl-sh',), ('text/x-erl-shellsession',)),

File pygments/lexers/compiled.py

 # backwards compatibility
 from pygments.lexers.functional import OcamlLexer
 
-__all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'JavaLexer',
+__all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'eCLexer', 'JavaLexer',
            'ScalaLexer', 'DylanLexer', 'OcamlLexer', 'ObjectiveCLexer',
            'FortranLexer', 'GLShaderLexer', 'PrologLexer', 'CythonLexer',
            'ValaLexer', 'OocLexer', 'GoLexer', 'FelixLexer', 'AdaLexer',
     }
 
 
+class eCLexer(RegexLexer):
+    """
+    For eC source code with preprocessor directives.
+    """
+    name = 'eC'
+    aliases = ['ec']
+    filenames = ['*.ec', '*.eh']
+    mimetypes = ['text/x-echdr', 'text/x-ecsrc']
+
+    #: optional Comment or Whitespace
+    _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
+
+    tokens = {
+        'whitespace': [
+            # preprocessor directives: without whitespace
+            ('^#if\s+0', Comment.Preproc, 'if0'),
+            ('^#', Comment.Preproc, 'macro'),
+            # or with whitespace
+            ('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'),
+            ('^' + _ws + '#', Comment.Preproc, 'macro'),
+            (r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(?!:))', bygroups(Text, Name.Label)),
+            (r'\n', Text),
+            (r'\s+', Text),
+            (r'\\\n', Text), # line continuation
+            (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
+            (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
+        ],
+        'statements': [
+            (r'L?"', String, 'string'),
+            (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
+            (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
+            (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
+            (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
+            (r'0[0-7]+[LlUu]*', Number.Oct),
+            (r'\d+[LlUu]*', Number.Integer),
+            (r'\*/', Error),
+            (r'[~!%^&*+=|?:<>/-]', Operator),
+            (r'[()\[\],.]', Punctuation),
+            (r'\b(case)(.+?)(:)', bygroups(Keyword, using(this), Text)),
+            (r'(auto|break|case|const|continue|default|do|else|enum|extern|'
+             r'for|goto|if|register|restricted|return|sizeof|static|struct|'
+             r'switch|typedef|union|volatile|virtual|while|class|private|public|'
+             r'property|import|delete|new|new0|renew|renew0|define|get|set|remote|dllexport|dllimport|stdcall|'
+             r'subclass|__on_register_module|namespace|using|typed_object|any_object|incref|register|watch|'
+             r'stopwatching|firewatchers|watchable|class_designer|class_fixed|class_no_expansion|isset|'
+             r'class_default_property|property_category|class_data|class_property|virtual|thisclass|'
+             r'dbtable|dbindex|database_open|dbfield)\b', Keyword),
+            (r'(int|long|float|short|double|char|unsigned|signed|void)\b',
+             Keyword.Type),
+            (r'(uint|uint16|uint32|uint64|bool|byte|unichar|int64)\b',
+             Keyword.Type),
+            (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
+            (r'(_{0,2}inline|naked|restrict|thread|typename)\b', Keyword.Reserved),
+            (r'__(asm|int8|based|except|int16|stdcall|cdecl|fastcall|int32|'
+             r'declspec|finally|int64|try|leave)\b', Keyword.Reserved),
+            (r'(true|false|null|value|this|NULL)\b', Name.Builtin),
+            ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+        ],
+        'root': [
+            include('whitespace'),
+            # functions
+            (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))'    # return arguments
+             r'([a-zA-Z_][a-zA-Z0-9_]*)'             # method name
+             r'(\s*\([^;]*?\))'                      # signature
+             r'(' + _ws + r')({)',
+             bygroups(using(this), Name.Function, using(this), using(this),
+                      Punctuation),
+             'function'),
+            # function declarations
+            (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))'    # return arguments
+             r'([a-zA-Z_][a-zA-Z0-9_]*)'             # method name
+             r'(\s*\([^;]*?\))'                      # signature
+             r'(' + _ws + r')(;)',
+             bygroups(using(this), Name.Function, using(this), using(this),
+                      Punctuation)),
+            ('', Text, 'statement'),
+        ],
+        'classname': [
+            (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
+            # template specification
+            (r'\s*(?=>)', Text, '#pop'),
+        ],
+        'statement' : [
+            include('whitespace'),
+            include('statements'),
+            ('[{}]', Punctuation),
+            (';', Punctuation, '#pop'),
+        ],
+        'function': [
+            include('whitespace'),
+            include('statements'),
+            (';', Punctuation),
+            ('{', Punctuation, '#push'),
+            ('}', Punctuation, '#pop'),
+        ],
+        'string': [
+            (r'"', String, '#pop'),
+            (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
+            (r'[^\\"\n]+', String), # all other characters
+            (r'\\\n', String), # line continuation
+            (r'\\', String), # stray backslash
+        ],
+        'macro': [
+            (r'[^/\n]+', Comment.Preproc),
+            (r'/[*](.|\n)*?[*]/', Comment.Multiline),
+            (r'//.*?\n', Comment.Single, '#pop'),
+            (r'/', Comment.Preproc),
+            (r'(?<=\\)\n', Comment.Preproc),
+            (r'\n', Comment.Preproc, '#pop'),
+        ],
+        'if0': [
+            (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
+            (r'^\s*#el(?:se|if).*\n', Comment.Preproc, '#pop'),
+            (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
+            (r'.*?\n', Comment),
+        ]
+    }
+
+    stdlib_types = ['size_t', 'ssize_t', 'off_t', 'wchar_t', 'ptrdiff_t',
+            'sig_atomic_t', 'fpos_t', 'clock_t', 'time_t', 'va_list',
+            'jmp_buf', 'FILE', 'DIR', 'div_t', 'ldiv_t', 'mbstate_t',
+            'wctrans_t', 'wint_t', 'wctype_t']
+    c99_types = ['_Bool', '_Complex', 'int8_t', 'int16_t', 'int32_t', 'int64_t',
+            'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int_least8_t',
+            'int_least16_t', 'int_least32_t', 'int_least64_t',
+            'uint_least8_t', 'uint_least16_t', 'uint_least32_t',
+            'uint_least64_t', 'int_fast8_t', 'int_fast16_t', 'int_fast32_t',
+            'int_fast64_t', 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t',
+            'uint_fast64_t', 'intptr_t', 'uintptr_t', 'intmax_t', 'uintmax_t']
+
+    def __init__(self, **options):
+        self.stdlibhighlighting = get_bool_opt(options,
+                'stdlibhighlighting', True)
+        self.c99highlighting = get_bool_opt(options,
+                'c99highlighting', True)
+        RegexLexer.__init__(self, **options)
+
+    def get_tokens_unprocessed(self, text):
+        for index, token, value in \
+            RegexLexer.get_tokens_unprocessed(self, text):
+            if token is Name:
+                if self.stdlibhighlighting and value in self.stdlib_types:
+                    token = Keyword.Type
+                elif self.c99highlighting and value in self.c99_types:
+                    token = Keyword.Type
+            yield index, token, value
+
 class DLexer(RegexLexer):
     """
     For D source.

File tests/examplefiles/test.ec

+namespace gui;
+
+import "Window"
+
+public struct AnchorValue
+{
+   AnchorValueType type;
+
+   union
+   {
+      int distance;
+      float percent;      
+   };
+   property int
+   {
+      set { distance = value; type = offset; }
+      get { return distance; }
+   }
+   property double
+   {
+      set { percent = (float) value; type = relative; }
+      get { return (double) percent; }
+   }
+
+   char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
+   {
+      if(type == offset)
+      {
+         sprintf(stringOutput, "%d", distance);
+      }
+      else if(type == relative)
+      {
+         int c;
+         int last = 0;
+         sprintf(stringOutput, "%f", percent);
+         c = strlen(stringOutput)-1;
+         for( ; c >= 0; c--)
+         {
+            if(stringOutput[c] != '0') 
+               last = Max(last, c);
+            if(stringOutput[c] == '.')
+            {
+               if(last == c)
+               {
+                  stringOutput[c+1] = '0';
+                  stringOutput[c+2] = 0;
+               }
+               else
+                  stringOutput[last+1] = 0;
+               break;
+            }
+         }
+      }
+      if(needClass) *needClass = false;
+      return stringOutput;
+   }
+
+   bool OnGetDataFromString(char * stringOutput)
+   {
+      char * end;
+      if(strchr(stringOutput, '.'))
+      {
+         float percent = (float)strtod(stringOutput, &end);
+         
+         if(end != stringOutput)
+         {
+            this.percent = percent;
+            type = relative;
+            return true;
+         }
+      }
+      else if(stringOutput[0])
+      {
+         int distance = strtol(stringOutput, &end, 0);
+         if(end != stringOutput)
+         {
+            this.distance = distance;
+            type = offset;
+            return true;
+         }
+      }
+      else
+      {
+         distance = 0;
+         type = 0;
+      }
+      return false;
+   }
+};
+
+public struct MiddleAnchorValue
+{
+   AnchorValueType type;
+
+   union
+   {
+      int distance;
+      float percent;      
+   };
+   property int
+   {
+      set { distance = value; type = none; }
+      get { return distance; }
+   }
+   property double
+   {
+      set { percent = (float) value; type = middleRelative; }
+      get { return (double) percent; }
+   }
+
+   char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
+   {
+      if(type == middleRelative)
+      {
+         int c;
+         int last = 0;
+         sprintf(stringOutput, "%f", percent);
+         c = strlen(stringOutput)-1;
+         for( ; c >= 0; c--)
+         {
+            if(stringOutput[c] != '0') 
+               last = Max(last, c);
+            if(stringOutput[c] == '.')
+            {
+               if(last == c)
+               {
+                  stringOutput[c+1] = '0';
+                  stringOutput[c+2] = 0;
+               }
+               else
+                  stringOutput[last+1] = 0;
+               break;
+            }
+         }
+      }
+      else if(type == none && distance)
+      {
+         sprintf(stringOutput, "%d", distance);
+      }
+      if(needClass) *needClass = false;
+      return stringOutput;
+   }
+
+   bool OnGetDataFromString(char * stringOutput)
+   {
+      if(strchr(stringOutput, '.'))
+      {
+         percent = (float)strtod(stringOutput, null);
+         type = middleRelative;
+      }
+      else
+      {
+         distance = strtol(stringOutput, null, 0);
+         type = none;
+      }
+      return true;
+   }
+};
+
+public enum AnchorValueType { none, offset, relative, middleRelative, cascade, vTiled, hTiled };
+
+public struct Anchor
+{
+   union { AnchorValue left; MiddleAnchorValue horz; };
+   union { AnchorValue top; MiddleAnchorValue vert; };
+   AnchorValue right, bottom;      
+
+   char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
+   {
+      char tempString[256];
+      char * anchorValue;
+      bool subNeedClass;
+
+      tempString[0] = '\0';
+      anchorValue = left.OnGetString(tempString, null, &subNeedClass);
+      if(anchorValue[0]) { if(stringOutput[0]) strcat(stringOutput, ", "); strcat(stringOutput, "left = "); strcat(stringOutput, anchorValue); }
+      
+      //if(((!left.type && !right.type) && horz.distance) || horz.type == middleRelative)
+      if(!right.type && ((!left.type && horz.distance) || horz.type == middleRelative))
+      {
+         tempString[0] = '\0';
+         anchorValue = horz.OnGetString(tempString, null, &subNeedClass);
+         if(anchorValue[0]) { if(stringOutput[0]) strcat(stringOutput, ", "); strcat(stringOutput, "horz = "); strcat(stringOutput, anchorValue); }
+      }
+      
+      tempString[0] = '\0';
+      anchorValue = top.OnGetString(tempString, null, &subNeedClass);
+      if(anchorValue[0]) { if(stringOutput[0]) strcat(stringOutput, ", "); strcat(stringOutput, "top = "); strcat(stringOutput, anchorValue); }
+      
+      tempString[0] = '\0';
+      anchorValue = right.OnGetString(tempString, null, &subNeedClass);
+      if(anchorValue[0]) { if(stringOutput[0]) strcat(stringOutput, ", "); strcat(stringOutput, "right = "); strcat(stringOutput, anchorValue); }
+
+      // if(((!top.type && !bottom.type) && vert.distance) || vert.type == middleRelative)
+      if(!bottom.type && ((!top.type && vert.distance) || vert.type == middleRelative))
+      {
+         tempString[0] = '\0';
+         anchorValue = vert.OnGetString(tempString, null, &subNeedClass);
+         if(anchorValue[0]) { if(stringOutput[0]) strcat(stringOutput, ", "); strcat(stringOutput, "vert = "); strcat(stringOutput, anchorValue); }
+      }
+      
+      tempString[0] = '\0';
+      anchorValue = bottom.OnGetString(tempString, null, &subNeedClass);
+      if(anchorValue[0]) { if(stringOutput[0]) strcat(stringOutput, ", "); strcat(stringOutput, "bottom = "); strcat(stringOutput, anchorValue); }
+      
+      return stringOutput;
+   }
+
+   bool OnGetDataFromString(char * string)
+   {
+      this = Anchor {};
+      return class::OnGetDataFromString(string);
+   }
+
+   bool OnSaveEdit(DropBox dropBox, void * object)
+   {
+      return dropBox.Save();
+   }
+
+   Window OnEdit(Window listBox, Window master, int x, int y, int w, int h, Window control)
+   {
+      char * string = "";
+      AnchorDropBox comboBox
+      {
+         editText = true;
+         parent = listBox;
+         master = master;
+         position = Point { x, y };
+         //clientSize = Size { h = h };
+         //size.w = w;
+         size = { w, h };
+         anchorValue = this;
+         control = control;
+         borderStyle = 0;
+      };
+      
+      comboBox.Create();
+
+      {
+         char tempString[MAX_F_STRING] = "";
+         bool needClass = false;
+         char * result = OnGetString(tempString, null, &needClass);
+         if(result) string = result;
+      }
+      comboBox.contents = string;
+      return comboBox;
+   }
+};
+
+private class AnchorButton : Button
+{
+   toggle = true, bevel = false;
+
+   void OnRedraw(Surface surface)
+   {
+      int cw = clientSize.w;
+      int ch = clientSize.h;
+
+      surface.SetForeground(black);
+      if(checked)
+      {
+         surface.SetBackground(Color { 85,85,85 });
+         surface.Area(0,0, cw-1, ch-1);
+      }
+      else
+         surface.LineStipple(0xAAAA);
+
+      surface.Rectangle(0,0,cw-1,ch-1);
+
+      if(active)
+      {
+         surface.LineStipple(0xAAAA);
+         surface.Rectangle(2,2,cw-3,ch-3);
+      }
+   }
+
+   bool AnchorEditor::NotifyClicked(Button button, int x, int y, Modifiers mods)
+   {
+      AnchorDropBox anchorDropBox = (AnchorDropBox)master;
+      Anchor anchor = anchorDropBox.anchorValue;
+      Window control = anchorDropBox.control;
+      DataBox dropMaster = (DataBox)anchorDropBox.master;
+      int id = button.id;
+
+      switch(id)
+      {
+         case 0: anchor.left.type   = button.checked ? offset : none; break;
+         case 1: anchor.top.type    = button.checked ? offset : none; break;
+         case 2: anchor.right.type  = button.checked ? offset : none; break;
+         case 3: anchor.bottom.type = button.checked ? offset : none; break;
+      }
+
+      if(anchor.horz.type == middleRelative && (id == 0 || id == 2))
+      {
+         anchorDropBox.relButtons[0].checked = false;
+         anchorDropBox.relButtons[2].checked = false;
+      }
+      if(anchor.vert.type == middleRelative && (id == 1 || id == 3))
+      {
+         anchorDropBox.relButtons[1].checked = false;
+         anchorDropBox.relButtons[3].checked = false;
+      }
+      anchorDropBox.relButtons[id].checked = false;
+
+      //anchor.horz.type = none;
+      //anchor.vert.type = none;
+
+      {
+         int vpw, vph;
+         int x,y,w,h;
+         Window parent = control.parent;
+
+         // Fix Anchor
+         x = control.position.x;
+         y = control.position.y;
+         w = control.size.w;
+         h = control.size.h;
+
+         vpw = parent.clientSize.w;
+         vph = parent.clientSize.h;
+         if(control.nonClient)
+         {
+            vpw = parent.size.w;
+            vph = parent.size.h;
+         }
+         else if(((BorderBits)control.borderStyle).fixed)
+         {
+            if(!control.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
+            if(!control.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
+         }
+
+         if(anchor.left.type == offset) anchor.left.distance = x;
+         else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
+         if(anchor.top.type == offset) anchor.top.distance = y;
+         else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
+         if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
+         //else if(anchor.right.type == relative) anchor.right.percent = (float) (x + w) / vpw;
+         else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
+         if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
+         //else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (y + h) / vph;
+         else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
+
+         if(!anchor.left.type && !anchor.right.type)
+         {
+            anchor.horz.distance = (x + w / 2) - (vpw / 2);
+            //anchor.horz.type = anchor.horz.distance ? offset : 0;
+         }
+         else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
+         if(!anchor.top.type && !anchor.bottom.type)
+         {
+            anchor.vert.distance = (y + h / 2) - (vph / 2);
+            //anchor.vert.type = anchor.vert.distance ? offset : 0;
+         }
+         else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
+      }
+
+      {
+         char tempString[1024] = "";
+         bool needClass = false;
+         char * string = anchor.OnGetString(tempString, null, &needClass);
+         anchorDropBox.contents = string;
+      }
+
+      dropMaster.SetData(&anchor, false);
+      anchorDropBox.anchorValue = anchor;
+      return true;
+   }
+}
+
+private class AnchorRelButton : Button
+{
+   toggle = true;
+   bevel = false;
+   text = "%";
+   //bevelOver = true;
+
+   void OnRedraw(Surface surface)
+   {
+      int cw = clientSize.w;
+      int ch = clientSize.h;
+      
+      if(checked)
+      {
+         surface.SetForeground(black);
+      }
+      else
+      {
+         surface.SetForeground(Color{170,170,170});
+      }
+      surface.WriteText(5,2, "%", 1);
+
+      if(active)
+      {
+         surface.LineStipple(0xAAAA);
+         surface.Rectangle(3,3,cw-4,ch-4);
+      }
+   }
+
+   bool AnchorEditor::NotifyClicked(Button button, int x, int y, Modifiers mods)
+   {
+      AnchorDropBox anchorDropBox = (AnchorDropBox)master;
+      Anchor anchor = anchorDropBox.anchorValue;
+      Window control = anchorDropBox.control;
+      DataBox dropMaster = (DataBox)anchorDropBox.master;
+      int id = button.id;
+
+      if((id == 0 || id == 2) && ((!anchor.left.type && !anchor.right.type) || anchor.left.type == middleRelative))
+      {
+         if(button.checked) anchor.horz.type = middleRelative; else anchor.horz.type = none;
+         anchorDropBox.relButtons[(id + 2)%4].checked = button.checked;
+      }
+      else if((id == 1 || id == 3) && ((!anchor.top.type && !anchor.bottom.type) || anchor.top.type == middleRelative))
+      {
+         if(button.checked) anchor.vert.type = middleRelative; else anchor.vert.type = none;
+         anchorDropBox.relButtons[(id + 2)%4].checked = button.checked;
+      }
+      else
+      {
+         switch(id)
+         {
+            case 0: anchor.left.type   = button.checked ? relative : (anchor.left.type   ? offset : none); break;
+            case 1: anchor.top.type    = button.checked ? relative : (anchor.top.type    ? offset : none); break;
+            case 2: anchor.right.type  = button.checked ? relative : (anchor.right.type  ? offset : none); break;
+            case 3: anchor.bottom.type = button.checked ? relative : (anchor.bottom.type ? offset : none); break;
+         }
+         anchorDropBox.buttons[id].checked = true;
+         if(anchor.horz.type == middleRelative) anchor.horz.type = none;
+         if(anchor.vert.type == middleRelative) anchor.vert.type = none;
+      }
+
+      {
+         int vpw, vph;
+         int x,y,w,h;
+         Window parent = control.parent;
+
+         // Fix Anchor
+         x = control.position.x;
+         y = control.position.y;
+         w = control.size.w;
+         h = control.size.h;
+
+         vpw = parent.clientSize.w;
+         vph = parent.clientSize.h;
+         if(control.nonClient)
+         {
+            vpw = parent.size.w;
+            vph = parent.size.h;
+         }
+         else if(((BorderBits)control.borderStyle).fixed)
+         {
+            if(!control.dontScrollHorz && parent.scrollArea.w)  vpw = parent.scrollArea.w;
+            if(!control.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
+         }
+
+         if(anchor.left.type == offset) anchor.left.distance = x;
+         else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
+         if(anchor.top.type == offset) anchor.top.distance = y;
+         else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
+         if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
+         //else if(anchor.right.type == relative) anchor.right.percent = (float) (x + w) / vpw;
+         else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
+         if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
+         //else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (y + h) / vph;
+         else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
+
+         if(!anchor.left.type && !anchor.right.type)
+         {
+            anchor.horz.distance = (x + w / 2) - (vpw / 2);
+            //anchor.horz.type = anchor.horz.distance ? offset : none;
+         }
+         else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
+         if(!anchor.top.type && !anchor.bottom.type) 
+         {
+            anchor.vert.distance = (y + h / 2) - (vph / 2);
+            //anchor.vert.type = anchor.vert.distance ? offset : none;
+         }
+         else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
+      }
+
+      {
+         char tempString[1024] = "";
+         bool needClass = false;
+         char * string = anchor.OnGetString(tempString, null, &needClass);
+         anchorDropBox.contents = string;
+      }
+
+      dropMaster.SetData(&anchor, false);
+      anchorDropBox.anchorValue = anchor;
+      return true;
+   }
+}
+
+private class AnchorEditor : Window
+{
+   interim = true;
+   borderStyle = deepContour;
+   size.h = 92;
+
+   bool OnKeyDown(Key key, unichar ch)
+   {
+      if(key == escape)
+         return master.OnKeyDown(key, ch);
+      return true;
+   }
+}
+
+private class AnchorDropBox : DropBox
+{
+   Anchor anchorValue;
+   Window control;
+   Button relButtons[4], buttons[4];
+
+   AnchorEditor anchorEditor
+   {
+      master = this;
+      autoCreate = false;
+   };
+
+   Window OnDropDown()
+   {
+      int c;
+      Button
+      {
+         anchorEditor,
+         anchor = Anchor { left = 28, top = 28, right = 28, bottom = 28 },
+         inactive = true, disabled = true
+      };
+      for(c = 0; c<4; c++)
+      {
+         Button button = buttons[c] = AnchorButton 
+         { 
+            anchorEditor, id = c,
+            size = Size { (c%2)?10:28, (c%2)?28:10 }
+         };
+         Button relButton = relButtons[c] = AnchorRelButton
+         {
+            anchorEditor, id = c;
+         };
+
+         switch(c)
+         {
+            case 0:
+               if(anchorValue.left.type && anchorValue.left.type != middleRelative) button.checked = true;
+               if(anchorValue.left.type == relative || anchorValue.horz.type == middleRelative) relButton.checked = true;
+               
+               button.anchor = Anchor { left = 0 };
+               relButton.anchor = Anchor { left = 5, vert = 16 };
+               break;
+            case 1:
+               if(anchorValue.top.type && anchorValue.top.type != middleRelative) button.checked = true;
+               if(anchorValue.top.type == relative || anchorValue.vert.type == middleRelative) relButton.checked = true;
+
+               button.anchor = Anchor { top = 0 };
+               relButton.anchor = Anchor { top = 5, horz = 16 };
+               break;
+            case 2: 
+               if(anchorValue.right.type && anchorValue.right.type != middleRelative) button.checked = true;
+               if(anchorValue.right.type == relative || anchorValue.horz.type == middleRelative) relButton.checked = true;
+               
+               button.anchor = Anchor { right = 0 };
+               relButton.anchor = Anchor { right = 5, vert = 16 };
+               break;
+            case 3: 
+               if(anchorValue.bottom.type && anchorValue.bottom.type != middleRelative) button.checked = true;
+               if(anchorValue.bottom.type == relative || anchorValue.vert.type == middleRelative) relButton.checked = true;
+
+               button.anchor = Anchor { bottom = 0 };
+               relButton.anchor = Anchor { bottom = 5, horz = 16 };
+               break;
+         }
+      }
+      anchorEditor.Create();
+      return anchorEditor;
+   }
+      
+   void OnCloseDropDown(Window anchorEditor)
+   {
+      // TOFIX: Patch for update bug
+      master.Update(null);
+      anchorEditor.Destroy(0);
+   }
+
+   bool DataBox::NotifyTextEntry(AnchorDropBox dropBox, char * string, bool save)
+   {
+      Anchor anchor = dropBox.anchorValue;
+      Window control = dropBox.control;
+
+      if(save)
+      {
+         if(anchor.OnGetDataFromString(string))
+         {
+            SetData(&anchor, false);
+            dropBox.anchorValue = anchor;
+         }
+      }
+      else
+      {
+         char tempString[1024] = "";
+         bool needClass = false;
+         char * string = anchor.OnGetString(tempString, null, &needClass);
+         dropBox.contents = string;
+      }
+      return true;
+   }
+}

File tests/examplefiles/test.eh

+/* A Bison parser, made by GNU Bison 2.0.  */
+
+/* Skeleton parser for Yacc-like parsing with Bison,
+   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* As a special exception, when this file is copied by Bison into a
+   Bison output file, you may use that output file without restriction.
+   This special exception was added by the Free Software Foundation
+   in version 1.24 of Bison.  */
+
+/* Tokens.  */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+   /* Put the tokens into the symbol table, so that GDB and other debuggers
+      know about them.  */
+   enum yytokentype {
+     IDENTIFIER = 258,
+     CONSTANT = 259,
+     STRING_LITERAL = 260,
+     SIZEOF = 261,
+     PTR_OP = 262,
+     INC_OP = 263,
+     DEC_OP = 264,
+     LEFT_OP = 265,
+     RIGHT_OP = 266,
+     LE_OP = 267,
+     GE_OP = 268,
+     EQ_OP = 269,
+     NE_OP = 270,
+     AND_OP = 271,
+     OR_OP = 272,
+     MUL_ASSIGN = 273,
+     DIV_ASSIGN = 274,
+     MOD_ASSIGN = 275,
+     ADD_ASSIGN = 276,
+     SUB_ASSIGN = 277,
+     LEFT_ASSIGN = 278,
+     RIGHT_ASSIGN = 279,
+     AND_ASSIGN = 280,
+     XOR_ASSIGN = 281,
+     OR_ASSIGN = 282,
+     TYPE_NAME = 283,
+     TYPEDEF = 284,
+     EXTERN = 285,
+     STATIC = 286,
+     AUTO = 287,
+     REGISTER = 288,
+     CHAR = 289,
+     SHORT = 290,
+     INT = 291,
+     UINT = 292,
+     INT64 = 293,
+     LONG = 294,
+     SIGNED = 295,
+     UNSIGNED = 296,
+     FLOAT = 297,
+     DOUBLE = 298,
+     CONST = 299,
+     VOLATILE = 300,
+     VOID = 301,
+     VALIST = 302,
+     STRUCT = 303,
+     UNION = 304,
+     ENUM = 305,
+     ELLIPSIS = 306,
+     CASE = 307,
+     DEFAULT = 308,
+     IF = 309,
+     SWITCH = 310,
+     WHILE = 311,
+     DO = 312,
+     FOR = 313,
+     GOTO = 314,
+     CONTINUE = 315,
+     BREAK = 316,
+     RETURN = 317,
+     IFX = 318,
+     ELSE = 319,
+     CLASS = 320,
+     THISCLASS = 321,
+     CLASS_NAME = 322,
+     PROPERTY = 323,
+     SETPROP = 324,
+     GETPROP = 325,
+     NEWOP = 326,
+     RENEW = 327,
+     DELETE = 328,
+     EXT_DECL = 329,
+     EXT_STORAGE = 330,
+     IMPORT = 331,
+     DEFINE = 332,
+     VIRTUAL = 333,
+     EXT_ATTRIB = 334,
+     PUBLIC = 335,
+     PRIVATE = 336,
+     TYPED_OBJECT = 337,
+     ANY_OBJECT = 338,
+     _INCREF = 339,
+     EXTENSION = 340,
+     ASM = 341,
+     TYPEOF = 342,
+     WATCH = 343,
+     STOPWATCHING = 344,
+     FIREWATCHERS = 345,
+     WATCHABLE = 346,
+     CLASS_DESIGNER = 347,
+     CLASS_NO_EXPANSION = 348,
+     CLASS_FIXED = 349,
+     ISPROPSET = 350,
+     CLASS_DEFAULT_PROPERTY = 351,
+     PROPERTY_CATEGORY = 352,
+     CLASS_DATA = 353,
+     CLASS_PROPERTY = 354,
+     SUBCLASS = 355,
+     NAMESPACE = 356,
+     NEW0OP = 357,
+     RENEW0 = 358,
+     VAARG = 359,
+     DBTABLE = 360,
+     DBFIELD = 361,
+     DBINDEX = 362,
+     DATABASE_OPEN = 363
+   };
+#endif
+#define IDENTIFIER 258
+#define CONSTANT 259
+#define STRING_LITERAL 260
+#define SIZEOF 261
+#define PTR_OP 262
+#define INC_OP 263
+#define DEC_OP 264
+#define LEFT_OP 265
+#define RIGHT_OP 266
+#define LE_OP 267
+#define GE_OP 268
+#define EQ_OP 269
+#define NE_OP 270
+#define AND_OP 271
+#define OR_OP 272
+#define MUL_ASSIGN 273
+#define DIV_ASSIGN 274
+#define MOD_ASSIGN 275
+#define ADD_ASSIGN 276
+#define SUB_ASSIGN 277
+#define LEFT_ASSIGN 278
+#define RIGHT_ASSIGN 279
+#define AND_ASSIGN 280
+#define XOR_ASSIGN 281
+#define OR_ASSIGN 282
+#define TYPE_NAME 283
+#define TYPEDEF 284
+#define EXTERN 285
+#define STATIC 286
+#define AUTO 287
+#define REGISTER 288
+#define CHAR 289
+#define SHORT 290
+#define INT 291
+#define UINT 292
+#define INT64 293
+#define LONG 294
+#define SIGNED 295
+#define UNSIGNED 296
+#define FLOAT 297
+#define DOUBLE 298
+#define CONST 299
+#define VOLATILE 300
+#define VOID 301
+#define VALIST 302
+#define STRUCT 303
+#define UNION 304
+#define ENUM 305
+#define ELLIPSIS 306
+#define CASE 307
+#define DEFAULT 308
+#define IF 309
+#define SWITCH 310
+#define WHILE 311
+#define DO 312
+#define FOR 313
+#define GOTO 314
+#define CONTINUE 315
+#define BREAK 316
+#define RETURN 317
+#define IFX 318
+#define ELSE 319
+#define CLASS 320
+#define THISCLASS 321
+#define CLASS_NAME 322
+#define PROPERTY 323
+#define SETPROP 324
+#define GETPROP 325
+#define NEWOP 326
+#define RENEW 327
+#define DELETE 328
+#define EXT_DECL 329
+#define EXT_STORAGE 330
+#define IMPORT 331
+#define DEFINE 332
+#define VIRTUAL 333
+#define EXT_ATTRIB 334
+#define PUBLIC 335
+#define PRIVATE 336
+#define TYPED_OBJECT 337
+#define ANY_OBJECT 338
+#define _INCREF 339
+#define EXTENSION 340
+#define ASM 341
+#define TYPEOF 342
+#define WATCH 343
+#define STOPWATCHING 344
+#define FIREWATCHERS 345
+#define WATCHABLE 346
+#define CLASS_DESIGNER 347
+#define CLASS_NO_EXPANSION 348
+#define CLASS_FIXED 349
+#define ISPROPSET 350
+#define CLASS_DEFAULT_PROPERTY 351
+#define PROPERTY_CATEGORY 352
+#define CLASS_DATA 353
+#define CLASS_PROPERTY 354
+#define SUBCLASS 355
+#define NAMESPACE 356
+#define NEW0OP 357
+#define RENEW0 358
+#define VAARG 359
+#define DBTABLE 360
+#define DBFIELD 361
+#define DBINDEX 362
+#define DATABASE_OPEN 363
+
+
+
+
+#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
+#line 42 "grammar.y"
+typedef union YYSTYPE {
+   SpecifierType specifierType;
+   int i;
+   AccessMode declMode;
+   Identifier id;
+   Expression exp;
+   Specifier specifier;
+   OldList * list;
+   Enumerator enumerator;
+   Declarator declarator;
+   Pointer pointer;
+   Initializer initializer;
+   InitDeclarator initDeclarator;
+   TypeName typeName;
+   Declaration declaration;
+   Statement stmt;
+   FunctionDefinition function;
+   External external;
+   Context context;
+   AsmField asmField;
+
+   Instantiation instance;
+   MembersInit membersInit;
+   MemberInit memberInit;
+   ClassFunction classFunction;
+   ClassDefinition _class;
+   ClassDef classDef;
+   PropertyDef prop;
+   char * string;
+   Symbol symbol;
+   PropertyWatch propertyWatch;
+   TemplateParameter templateParameter;
+   TemplateArgument templateArgument;
+   TemplateDatatype templateDatatype;
+   
+   DBTableEntry dbtableEntry;
+   DBIndexItem dbindexItem;
+   DBTableDef dbtableDef;
+} YYSTYPE;
+/* Line 1318 of yacc.c.  */
+#line 293 "grammar.eh"
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+extern YYSTYPE yylval;
+
+#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
+typedef struct YYLTYPE
+{
+  int first_line;
+  int first_column;
+  int last_line;
+  int last_column;
+} YYLTYPE;
+# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
+# define YYLTYPE_IS_DECLARED 1
+# define YYLTYPE_IS_TRIVIAL 1
+#endif
+
+extern YYLTYPE yylloc;
+
+