Hello,
I would try to write some instruction here, based on your questions and then would move the thread to FAQ brunch.
The definition of the programming language (syntax) in HippoEDIT is based on two files: {lang_name}_spec.xml and {lang_name}_user.xml. Names of the file is not important – definition recognized by XML header. {lang_name}_spec.xml contains general definition of the syntax and is obligatory. {lang_name}_user.xml contains definition of the user specific settings for language (such as code templates, programming language specific tools, language help urls etc.) and is optional. Definition files should be placed in directory defined in Tools -> Options -> General -> Settings Path. By default this is {HippoEDIT_InstallDir}\data\syntax.
To create your own syntax I would suggest to search some existing schema for language similar to one you want to have and copy + rename files.
Then open new files and search for something similar to this:
<SYNTAX id="asm" name="ASM" inherit="def_source" inherit_url="defsource_spec.xml">
Attributes:
- id (any string, preferable low case, without spaces and symbol : ) – unique id of the language (obligatory)
- name (any string) – description of the language that would be used in UI
- inherit (any id) – name of base (parent) schema. New schema would inherit all settings, styles of parent. Normally you need to inherit from def or def_text or def_source. These schemes contain base definition for styles, without them a lot of functionality would not be available.
- inhertit_url (file path, relative or absolute) – name of parent schema file. Used only fir navigation between schemes when opened in browser (optional).
After creating of the definition files and copying them into {Data} folder, HippoEDIT should load definitions and display them in Available Languages list (
Tools->Options->Available Languages).
This node contains base settings for syntax (as file pattern, braces list, case sensitive flag etc).
Here:
Operators - set of single symbols, which will be treated as operator symbols by HE and displayed with
operator style, if it is defined/inherited for current schema.
Operator style is one of special HE known styles (as comments fex).
Delimiters - set of single symbols, which used to determine delimiter symbol (symbol which stops/starts word). You can place here only that symbols which do not come to operators or OpenClose node. If they will intersect, it is not problem. But if some of the delimiter symbols will be forgotten, HE will "stop" on it during next word navigation, for example.
STYLESSCOPESThis node contains Scopes that used for parsing outlining (folding). Inheritable from parent.
This node described specific scope. Scope should have one [1] open, can be more than one [1.n] close tags and none or more middle tags [0..n].
<Scope open="Class" close="End Class" has_name="true" separator="true"/>
Attributes:
- open (any string) – is open tag
- close (any string) – is close tag
- has_name (true|false|0|1) – indicates that name of the scope follows open tag
- separator (true|false|0|1) – draw separator after close tag (if enabled in editor settings)
- strict (true|false|0|1) – flag tells HE to not take seriously missing close text for this scope. So you would not get a error displayed for open tag. The attribute also used for better solving of outlining constructions (strict scopes have higher priority than non-strict ).
LABELS<LABELS>
<Label group="Subroutine" match="\<(sub|function)[\s\[]+(\w+)[\s\]]*(\([^)]*\))" name="\2" descr="\1 \2 \3" image="8" scope="1">
<Image if="\1" equal="sub" value="8"/>
</Label>
<Label group="Class" match="\<(public|private)?\s+class\s+(\w+)\s*" name="\2" descr="Class \2" image="4" scope="1">
<SubImage if="\1" equal="public" value="1"/>
</Label>
</LABELS>
Labels give you a way fo quick navigation inside the document with Navigation Bar (can be also called as Function List). It can be as a method or function definition, as include definition. Generally it can be any part of the code you want to refer.
Labels are described with help of regular expression.
HippoEDIT uses BOOST regular expression engine, which use
perl regular expression syntax.
For testing of the label definition I am using
RegexLib service.
Attributes:
- group (any string) - group of the label, currently not used, but would be used later for displaying labels in Function List window grouped by label name
- match (any valid regular expression), obligatory - regular expression describing the label. Expression can be multi line and greedy. You can use sub matches (grouping) for later referring.
- name (any string) - any string describing found label. name is displayed in left filtered list in Navigation Bar. You can refer to results of the match using regular expression replace tags as \0 complete match, \1 - firts group, \2 second and so on...
- descr (any string) - wider description of found label. descr is displayed in right (description) field in Navigation Bar. You can refer to results of the match using regular expression replace tags as \0 complete match, \1 - firts group, \2 second and so on...
- descr_match (any valid regular expression), obligatory - additional regular expression for better resolving of the description. Applied to result of the match. If exist, results of descr_match would be used for description back references.
- image (enumeration from 5 till 20, none=default=0) - image associated with label. Image is displayed as in left list of Navigation Bar as in right description field.
- sub_image (enumeration from 2 till 4, none=default=0) - sub image associated with label (image drawn on top of main image). Usually used for visualization of label visibility (public, protected, private).
- scope (0|1|2) - defines relation of the label to any scope. 0 - not related to scope, 1 - label includes relevant scope start, 2 - scope includes relevant scope end. If label is related to scope (1|2) HippoEDIT would try to find appropriate scope and associate label with it. Then you would see label description as name of the scope while navigating in Navigation Bar and in Scroll Info Tip.
- navigation (true|false, default = true) - if set, then label would not be shown in Navigation Bar, but would be used in Smart Navigate and when Go button pressed in Navigation Bar. For example to navigate to include file.
- navigation (true|false, default = true) - if set, then label would not be shown in Navigation Bar, but would be used in Smart Navigate and when Go button pressed in Navigation Bar. For example to navigate to include file.
In addition to listed before properties, you can have some overriding of the label properties, depending on regular expression match.
Skip condition:<Skip if="\2" equal="if"/>
If you want to skip some labels depending on result of the match, you can use a
Skip Condition defined inside of Label node.
Attributes:
- if (some regular expression string with back references to match) - regular expression with back references to match which would be compared to equal
- equal - string to compare with result of regular expression replace from attribute if
If
if equals to
equal the label would be skipped.
Image/SubImage condition:<Image if="\1" equal="sub" value="8"/>
<SubImage if="\1" equal="private" value="3"/>
If you want to adopt image or subimage based on result of label match, you can use
Image/SubImage Condition defined inside of Label node.
Attributes:
- if (some regex string with back references to match) - regular expression with back references to match which would be compared to equal
- equal - string to compare with result of regular expression replace from attribute if
- value - enumeration value of the image or sub image
If
if equals to
equal the label would have image or sub image defined in value.
To restrict label for some style, you can also use
Containers node inside Label node.
<Containers open="preprocessor"/>
CONTAINERS - how to useThe logic is following:
1) You have styles. Styles are described by Blocks, Keywords, and Words conditions and applied to some interval of the text (text block).
2) Styles can be referred by style
id. If
id is not defined HE uses
name attribute.
3) When you define
container (or
containers) for
Scope or another schema object, you allow this
Scope,
Style or
Label etc to be recognized only in the style specified by container id.
For example this mean:
<Scope open="{" close="}">
<containers open="test_container_name"/>
</Scope>
Scope with open tag "{" allowed only in the style "test_container_name". If it would be found in some other style, it would be skipped. If you do not specify containers, HE assumes that this object (scope, style or label) allowed only in
normal style (style with id = normal, defined in def_spec.xml).
For objects as
Scope and
Style you can define containers as for open part, as for close part (for scopes also for middle part). For example CSS block in HTML can be started in normal style of HTML code and can be closed inside CSS normal or comment style.
<Containers>
<Close id="css:normal"/>
<Close id="css:comment"/>
</Containers>
If you do not define open container, it would be normal style of current language.
If you want to refer to a style from another syntax schema, you can do this as well, by giving syntax id before style id separated with ":" :
<Style id="style" name="CSS" include="css:normal" ...
This is including of the CSS block in HTML syntax schema.
IMAGES