Codejock Forums Homepage
Forum Home Forum Home > General > Articles and Tutorials
  New Posts New Posts RSS Feed - Syntax Edit Lex Schema Help
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Syntax Edit Lex Schema Help

 Post Reply Post Reply
Author
Message
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (1) Thanks(1)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Topic: Syntax Edit Lex Schema Help
    Posted: 22 March 2011 at 11:22am
***		Lex class description	***                                      

lexClass object is a block of text with defined begin and end sequence;
for which can be specified some font and colors attributes.
One lex class can contain others inside itself;
also it can have some relations to other classes.

lex schema is defined as a set of lexClasses.
It contains a root class with parent type 'file'
(which defines a files extensions to apply this schema to,
and some global schema attributes).

--- Lex schemes

Lex schemes are defined in *.schclass files.
Lex class properties (attributes) can be compound, like:
parent:dyn, previous:tag:separators.

--- Multiple values

For multiple value properties the following syntax is allowed:

propertyX = value1, value2, value3, ....
propertyX = valueA1, valueA2, ...
propertyX = valueN1
propertyX = valueN2
....

--- String values

String(character) values are defined in single quotation marks:
'stringValue'
There are a few special chars (as in C++):
'\\', '\'', '\t', '\r', '\n'

And predefined constants:
@alpha = a-z, A-Z
@digit = 0-9
@HexDdigit = 0-9, a-f, A-F
@specs = "~`!@#$%^&*()_-+=\\|{}[];:'\",.<>/?"
@EOL = End Of Line

NOT operation supported for constants comparisons,
example: @alpha:not


--- Comments
//
Two slashes are used to define a single line comment in Lex schema files.
(same as in C++)

--- Section
lexClass:
This keyword begins a lex class section.

--- name -- Property (required)
name
Define a lexClass name. Must be unique withing same lex schema (*.schclass file).

EXAMPLE:
name = c_CPPString

--- parent -- Property (required)
parent
Defines a direct parent of lex class. (parent class name)

parent:dyn
Defines a dynamic parent of lex class. (parent class name)
Dynamic means that parent class can be not only direct parent,
but parent of its parent [of parent ...] until the top class/block.

parent:file
Defines a top schema class. (as file extensions list <*.ext1|*.ext2>)

Only one of mentioned above 'parent' properties can be used for each class.

EXAMPLE:
parent:file = <*.c|*.cpp|*.h|*.inl|*.tli|*.tlh|*.rc|*.rc2>
parent = c_CPP
parent:dyn = c_CPP

--- children -- Property (optional)
children
Defines an allowed direct children for lex class.
(as comma separated class names or zero to restrict any child)

Parent-child relation is defined by 'parent' property. This property helps
to restrict create parent-child relation for classes other than specified
or define that class has no children.

EXAMPLE:
children = 0 // has no children
children = class1, class2, ...

--- RecurrenceDepth -- Property (optional)
RecurrenceDepth
Defines maximum depth of nested classes (blocks).
(as a number, default value 1).

Class A can be parent for class B. And Class B can be parent for class A.
Possible situation when A=B. (for example '{}' block in C++)
This property defines maximum depth of A->B->A->B->... nested construction.

EXAMPLE:
RecurrenceDepth = 32

--- previous -- Property (optional)
'previous' property used to set condition to start lex class as previous
tag or class. The difference from 'start' property that objects specified
in this property is not included in class(block).
Can be used alone or together with 'start' property.

previous:class
This class is started only if previous determined class name in collection
specified in this property.
(as one or more class names)

previous:tag
This class is started only if start condition is true and previous tag is
in collection specified in this property.
(as one or more tags)

previous:tag:separators
separators set for previous:tag values.

Previous 'tag' and 'class' conditions can be specified separately or together.

EXAMPLE:
previous:class = c_HTMLelement_SCRIPT_lang_VB, c_HTMLelement_SCRIPT_lang_JS
previous:tag = '='
previous:tag:separators = ' ', '\t', @eol

--- start -- Property (optional)
'start' property used to set condition to start lex class as tag or class.
The difference from 'previous' property that objects specified in this
property is included in class(block).
Can be used alone or together with 'previous' property.

start:class
This class is started only if previous determined class name in collection
specified in this property.
(as one or more class names)

start:Tag
This class is started if current tag is in collection specified in this property.
(as one or more tags)

Start 'tag' and 'class' conditions can be specified separately or together.

--- end -- Property (optional)
'end' property used to set end lex class condition as tag or class.

end:class
This class is ended if previous determined class name in collection
specified in this property.
(as one or more class names)

end:Tag
This class is ended if current tag is in collection specified in this property.
(as one or more tags)

end:separators
This class is ended if tag after current position is in collection specified
in this property. Difference from end:Tag is that end:Tag specify tags before
current position and end:Tag included in this block but end:separators not
included..
(as one or more tags)

End 'class', 'tag' and 'separators' conditions can be specified separately or together.

--- skip -- Property (optional)
skip:Tag
Used to skip some tags from parsing. Useful to support special tags
part of which can be a begin of end tag.
(as one or more tags)

EXAMPLES (for start, end, skip):

start:Tag ='/*'
end:Tag ='*/'

//-------------------------------------------
start:Tag = '"'
skip:Tag = '\\"', '\\\r\n', '\\\n\r', '\\\n', '\\\r'
end:Tag = '"', @eol

//-------------------------------------------
start:tag = @alpha
skip:tag = @digit
end:separators = @alpha:not

//-------------------------------------------
start:CLASS = c_CPPAfxInsertBlock_Start
end:CLASS = c_CPPAfxInsertBlock_End

--- token -- Property (optional)
'token' property is used to set lex class as some token(s).
It could be useful to define keywords.
Can be used alone or together with 'previous' property.
It must not be used together with 'start'-'end' condition.

token:tag
This class is a word from this collection.
(as one or more tags)

Token:start:separators
Start separators set for token:tag values.

Token:end:separators
End separators set for token:tag values.

Token 'tag' is main condition. Token 'separators' additional conditions.
'separators' without 'tag' have no sense.

EXAMPLE:

token:start:separators = ' ', '\t', '<%=', '<%', @specs, @eol
token:end:separators = ' ', '\t', '%>', @specs, @eol

token:tag = 'if', 'for', 'while', 'do'
token:tag = 'break'
token:tag = 'case'
token:tag = 'catch'


--- TEXT Attributes

txt:XXX defines a few text properties for lex class (block of text).
All of them are optional and if some text attribute is not specified -
it is inherited from parent class or set to default value for a top (file) lex class.

txt:colorFG
Fore color value in hex format (like 0xffc0c0).
default: black

txt:colorBK
Background color value in hex format (like 0xffFFff).
default: white

txt:colorSelFG
Selected text fore color value in hex format (like 0xffFFff).
default: white

txt:colorSelBK = 0xffc0c0 // color value in hex format. default:
Selected text background color value in hex format (like 0xab0077).
default: black

txt:Bold
Bold font attribute. Values {1, 0}
default: 0

txt:Italic
Italic font attribute. Values {1, 0}
default: 0

txt:Underline
Underline font attribute. Values {1, 0}
default: 0

EXAMPLE:
txt:colorFG = 0x0fc0c0
txt:colorBK = 0xffffff

txt:colorSelFG = 0xffffff
txt:colorSelBK = 0x0fc0c0

txt:Bold = 1
txt:Italic = 0
txt:Underline = 1

--- caseSensitive -- Property (optional)
caseSensitive
Define compare method for this lex class tags: case sensitive or insensitive.
Inheritable from parent class.
Values {1, 0}
default: 0

--- Collapsable -- Property (optional)
Collapsable
Define is this block Collapsable or not. Inheritable from parent class.
Values {1, 0}
default: 0

--- CollapsedText -- Property (optional)
CollapsedText
Collapsed block string.
(as quoted string value)
default: '[..]'

--- ParseOnScreen
ParseOnScreen
Values {1, 0}
default: 0
If set to 1 - lex class will be parsed only before drawing on the screen in
the main thread. Useful for keywords and other single line text blocks, which
are parsed very fast.

*** Global attributes ***
'global' attributes let to adjust some common parser parameters for each
lex schema separately. They can be used only in top layer lex class
(parent type file).

global:FirstParseInSeparateThread
Values {1, 0}
default: 1
Define is first parse (when file opening) will run in the main or
additional thread.

global:EditReparceInSeparateThread
Values {1, 0}
default: 1
Define is reparse after text edited will run in the main or
additional thread.

global:ConfigChangedReparceInSeparateThread= 1 // {0,1} default=1
Values {1, 0}
default: 1
Define is reparse text after schema file (*.schclass) will run
in the main or additional thread.

global:EditReparceTimeout_ms
as time in milliseconds;
default: 500
Time out to start reparse after last key was pressed.

global:MaxBackParseOffset
as number (chars);
default: 100
Some times parser look back for the text from current position.
This parameter define maximum back buffer size.

global:OnScreenSchCacheLifeTime_sec = 180
as time in seconds; -1 and 0 means infinite;
default= 180
When piece of text is displayed, edit control run parser to parse
lexClasses with 'ParseOnScreen' attribute set and cache this
information to do not run parser every time for this lines. For each
entry in this cache last access time is stored.
This parameter define time period from last access time after which
cached entries will be removed (for memory using optimization).

global:ParserThreadIdleLifeTime_sec
as time in seconds; -1 and 0 means infinite;
default: 60
Idle time out for parser thread. If no parse requests (no editing operations)
additional parser thread will be exited. It will be recreated again
when necessary (to system resources optimization).
Back to Top
davbrat View Drop Down
Groupie
Groupie
Avatar

Joined: 30 September 2009
Location: California
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote davbrat Quote  Post ReplyReply Direct Link To This Post Posted: 26 May 2011 at 3:00pm
Thank you!
Thank you!
Thank you!

Mario...

You'd da Man!

Product: Xtreme SuitePro (ActiveX) version 18.4.0 Platform: Windows XP SP2+ & Windows 7 (32bit & 64Bit)
Windows 8/8.1/10

Language: Clarion 5.0/5.5/6.3/7.3/8/9/9.1/10
Back to Top
franji1 View Drop Down
Groupie
Groupie
Avatar

Joined: 28 June 2005
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote franji1 Quote  Post ReplyReply Direct Link To This Post Posted: 10 June 2022 at 5:03pm
Found the CJ scheme file for CJ scheme files.  Excellent!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.266 seconds.