HippoEDIT homepage Welcome, Guest. Please login or register.
September 10, 2010, 09:04:13 pm
Home Help Search Login Register

+  HippoEDIT - Programmers text editor
|-+  General Category
| |-+  Syntax Files (Moderators: alex, Stefan)
| | |-+  HippoEDIT explained: the Syntax xml files
« previous next »
Pages: [1] Print
Author Topic: HippoEDIT explained: the Syntax xml files  (Read 358 times)
Stefan
Administrator
Hero Member
*****

Karma: +6/-0
Offline Offline

Posts: 684



View Profile
« on: November 03, 2009, 05:52:02 pm »

Welcome to "HippoEDIT explained"

Today we will learn something about the language - "Syntax" files (see picture on the end)

Please note that Alex have explain the basic about this in the topic "Adding new Language Syntax"
and also in this topic "What means All, Default, Default source, Text etc" already.

I only take this information and test it how this works to get an better understanding for it.
This may be from interest for others, so i share here my experiences on the way to succeed  Grin
(Please note that english isn't my mother language, so perhaps something may be not well written)




Preamble:

To know how to highlight the syntax, where to fold the code,
what are the keywords and to provide you with Code Templates
HippoEDIT store this information in Language Syntax Files (LSF) in XML format.

This LSF are stored in an SYNTAX-sub-folder of the HippoEDIT (HE) DATA-folder.
For example: if you have installed HE on "X:\HippoEDIT"
then the syntax files are found in "X:\HippoEDIT\Data\Syntax" (see (1) in picture)
(Note: you can change this path, but that's not an topic of this post)

{todo - note that data folder is searched recursively with all sub-folders }





Inheritance

HippoEDIT use an clever technic that allow you to  add and modify common definitions for one,
two or many (programming) languages at only one single place, inheritance.
That means that there is an basic LSF which holds common rules* and other LSF can
be advised to inherit this rules. The inherited and the own rules are combined with an ingenious
algorithm to an new, just-in-time rule. This strategy works  across several LSF too, if needed,
Dummy Example: Basic-LSF < Common-Language-LSF < Language-LSF < YourOwn-LSF   (see (2) in picture)

*Rules: which rules that are is explained later.



Inheritance Explanation:

In the picture at point (2) you can see how the LSF's are inherited.

Note: You don't have to use this inheritance feature. You can still modify every LSF on its own,
but then you may do the work twice. So its proposed to get familiar with some basic of this
to understand how HE works and to make your work more easy and boost your performance.


- Inherit-Level 1
  First there is an LSF called def_spec.xml (DEFinition SPECification)
  In def_spec.xml  are all rules defined which should be set for all other LSF which inherit from this def-LSF.
  In theory on this level there could be an "stand alone", independent syntax, which inherit from nothing,  too.

 
- Inherit-Level 2
  Then there is an fork. Two other basic LSF inherit from def : defsource_spec.xml and deftext_spec.xml
  * defsource is the basic LSF for all languages dealing with source code (c++, php, css etc)
  * deftext is the basic LSF for text based (Plain text, xml, html etc) documents.

- Inherit-Level 3
  On this level there are LSF with different purposes:
  A  Just an "stand alone" LSF for an language as  xxxxxxx e.g.
  B  An LSF as f.ex. basic_spec (basic means the BASIC language),
      which works "stand alone" for the BASIC language itself
      and in turn is an Common-Basic-LSF for other BASIC-like languages as VB and VBS.
  C  Dedicated Common-Basic-LSF.
      Example: Since all C-language dialects may have the same basic rules there is in consistence
      an cBase_spec which is the starting-point for all following c-language like syntaxes, as C++_spec e.g.


- Inherit-Level 4
  Here are LSF which have an Common-Basic-LSF, as VBS_spec has basic_spec as ancestor.
  (BTW: again, there is no strict advice that you have to use this Inherit-Level-thinggy, you may also create
  an xyz_spec for your own use without any inherit-instruction and put all rules there in. It's up to you)


- Inherit-Level 5
  I don't know if there is any LSF on this level right now.
  But you could for example create your own LSF which you can advice to inherit from vbs_spec.
  This way it must be possible to create user-own syntax files which no installer overwrites never.
  I will test this too since this is an common question.



What means Inheritance? - What is inherited from ancestor?






How to break Inheritance? - How to use other rule as the ancestor has defined?








todo, will come soon (i hope  Tongue )
Accessing the LanguageSyntaxFiles:
(see (3) and (4) in picture)

- to have a overview of the inheritance Tools or Help manage dialogs can be use with Show All Syntaxes




todo, will come soon (i hope  Tongue )
The Rules:


*  <FILEINFO author="HippoEDIT.com" type="LangSpec"/>

*  <SYNTAX id="cpp" name="C++" inherit="cbased" inherit_url="cbase_spec.xml">

* SPECIFICATION
      <FilePattern mask="*.c;*.cpp;*.cxx;*.hpp;*.hxx;*.inl;*.h">
        <Pair file1="*.cpp" file2="*.h"/>


* Keywords How to make keyword list for syntax file at easy

* Styles
http://forum.hippoedit.com/index.php/topic,83.msg883.html#msg883
<Blocks>
<Containers>

* Scopes / Code Folding => HowTo fold your code with code folding
Where does "Region Name" being referenced from
http://forum.hippoedit.com/index.php/topic,204.0.html

* Highlighting

* Labels / Code Explorer => "Navigation Bar", "Function List", "Code Browser"

* Code Templates Code Templates Tricks & Tips
http://forum.hippoedit.com/index.php/topic,137.0.html




todo, will come soon (i hope  Tongue )
User specific LanguageSyntaxFiles
<lang>_user.xml:

(see (5) in picture)







XML Syntax Rules
What do you have to know about HippoEDIT XML files?

First: you should use HippoEDITs build-in possibilities
         to modify the syntax files to always get an proper formated syntax file.

However, if you are an experienced user you may  want to edit the files directly in editor.
So here are some rules generally about XML and specially for HippoEDIT:

* Tag elements must be nested with care: first close an tag before open an another one.

   Example Tree:
   <root>
     <childtag>
       <subchild>.....</subchild>
         <elementtag> value value value </elementtag>
         <element attribute="value"/>
     </childtag>
     <!-- <element> element commented out </element> -->
     <settings>switch</settings>
   </root>

* There is no specific order in XML tags necessary. E.g. it's no matter if SCOPES came first or STYLE.
    But for keywords-list it is better to keep alphabetic order - this way internal loading is faster.
* All XML tags and attributes are case sensitive.
* The opening and closing tags must be written with the same case.
* You can use comments in XML by using: <!-- comment -->
* All not English text should be correctly encoded in UTF-8
* Attribute "values" mostly have to be quoted with double quotes "...".
  But not always. For code template the template itself and for <settings>...</settings> there are no quotes needed.
  Just take an look into the default distributed syntax files to get an idea where quotes are needed and where not.

 The best is you let HippoEDIT modify the LSF for you. He knows best which signs where to exchange with entities.

* Entity List:
   &lt;    <    less than
   &gt;    >    greater than
   &amp;    &    ampersand
   &apos;    '    apostrophe
   &quot;    "    quotation mark

* Special chars in values:   
   \t       tab
   \n       new line (line break)
   \\       backslash


Extern Links about XML:
http://de.wikipedia.org/wiki/Extensible_Markup_Language
http://en.wikipedia.org/wiki/XML


.


* HEExplaint_SynatxRules001_c200.png (62.68 KB, 635x831 - viewed 31 times.)
« Last Edit: November 06, 2009, 11:59:58 am by Stefan » Logged

Stefan, HippoEDIT beta tester  (HippoEDIT News On Twitter: http://twitter.com/hippoedit/)
Stefan
Administrator
Hero Member
*****

Karma: +6/-0
Offline Offline

Posts: 684



View Profile
« Reply #1 on: November 03, 2009, 05:52:20 pm »

B
Logged

Stefan, HippoEDIT beta tester  (HippoEDIT News On Twitter: http://twitter.com/hippoedit/)
alex
Developer
Global Moderator
Hero Member
*****

Karma: +19/-2
Online Online

Gender: Male
Posts: 1336



View Profile WWW
« Reply #2 on: November 03, 2009, 06:51:38 pm »

Thanks Stefan.
I am sure this would be useful for a lot of users.
Logged

Stefan
Administrator
Hero Member
*****

Karma: +6/-0
Offline Offline

Posts: 684



View Profile
« Reply #3 on: November 04, 2009, 07:40:07 am »

Hi Alex, if you got some time please take an look to my post above
if you can life with my style and see if i take it right. You are allowed to modify my post. Thanks.
Logged

Stefan, HippoEDIT beta tester  (HippoEDIT News On Twitter: http://twitter.com/hippoedit/)
alex
Developer
Global Moderator
Hero Member
*****

Karma: +19/-2
Online Online

Gender: Male
Posts: 1336



View Profile WWW
« Reply #4 on: November 04, 2009, 01:06:41 pm »

Hi Stefan,

I have read. Everything is correct and well described. Here is two points you can add (integrate some where in your post):

- note that data folder is searched recursively with all sub-folders (you got problems with it and later I got once more similar question)
- to have a overview of the inheritance Tools or Help manage dialogs can be use with Show All Syntaxes

and then delete this post, to not duplicate stuff.

Best regards,
Alex.

Logged

Pages: [1] Print 
« previous next »
Jump to:  


Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC