Home » Archived » Orion (Archived) » Grammar for complex language
Grammar for complex language [message #1404624] |
Mon, 04 August 2014 14:22 |
Frederic Delhoume Messages: 8 Registered: July 2009 |
Junior Member |
|
|
Hi,
I am writing a syntax.js file for a custom language.
I have some nice results, but also some difficulties for advanced constructs.
The language allows embedded Javascript code using syntax
execute OPTIONAL_NAME {
var i;
}
I would like to recognize this pattern an use already existing JS syntax.js.
I am using :
{
// TODO: nested {} detection
begin: "(execute)\\s+[A-z]*\\s*\\{",
end: "\\}",
captures: {
1: {name: "keyword.mod"}
},
contentName: "js.embedded.mod",
patterns: [
{
include: "orion.js"
}
]
}, {
match : "\\b(?:" + keywords.join("|") + ")\\b",
name : "keyword.mod"
},
It works quite well, except when there are multiple execute blocks in the input (see attachments). I would also like this to work for nested {} statements in embedded JS code.
Is there's a solution for all these issues ?
index.html and opleditor.js are to be placed at folder up to orion
syntax.js should be in orion/editor/text_mod/
opleditor.css should be in orion/editor/themes/
-
Attachment: index.html
(Size: 2.28KB, Downloaded 317 times) -
Attachment: opleditor.js
(Size: 7.39KB, Downloaded 312 times) -
Attachment: syntax.js
(Size: 3.15KB, Downloaded 315 times) -
Attachment: oplide.css
(Size: 0.93KB, Downloaded 206 times) -
Attachment: orion_editor.jpg
(Size: 58.44KB, Downloaded 290 times)
|
|
|
Re: Grammar for complex language [message #1413946 is a reply to message #1404624] |
Fri, 29 August 2014 20:57 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi Frederic, sorry for the late response,
I don't understand the problem, I've changed the example to include
three 'execute's and they each style their contained javascript
(screenshot attached). I assume I'm trying the wrong thing.
If your previously-attached screenshot shows the problem then can you
specify which text in it is not styled as you need?
Thanks,
Grant
On 8/4/2014 10:22 AM, Frederic Delhoume wrote:
> Hi,
>
> I am writing a syntax.js file for a custom language.
> I have some nice results, but also some difficulties for advanced constructs.
> The language allows embedded Javascript code using syntax
>
> execute OPTIONAL_NAME {
> var i;
> }
>
>
> I would like to recognize this pattern an use already existing JS syntax.js.
>
> I am using :
> {
> // TODO: nested {} detection
> begin: "(execute)\\s+[A-z]*\\s*\\{",
> end: "\\}",
> captures: {
> 1: {name: "keyword.mod"}
> },
> contentName: "js.embedded.mod",
> patterns: [
> {
> include: "orion.js"
> }
> ]
> }, {
> match : "\\b(?:" + keywords.join("|") + ")\\b",
> name : "keyword.mod"
> },
>
> It works quite well, except when there are multiple execute blocks in the input (see attachments). I would also like this to work for nested {} statements in embedded JS code.
>
> Is there's a solution for all these issues ?
>
> index.html and opleditor.js are to be placed at folder up to orion
> syntax.js should be in orion/editor/text_mod/
> opleditor.css should be in orion/editor/themes/
>
>
>
>
|
|
|
Re: Grammar for complex language [message #1414780 is a reply to message #1413946] |
Mon, 01 September 2014 09:36 |
Frederic Delhoume Messages: 8 Registered: July 2009 |
Junior Member |
|
|
Hi,
Thanks for your answer.
The issue is that so-called execute blocks can be mixed with normal grammar statements, as in :
execute {
var i;
}
dvar int foo;
execute BLOCK {
var j;
}
execute keywords are part of the normal grammar, and should be colored in blue, along with dvar. And contents enclosed in execute block should be in other color.
So far I anderstand that the rule for detecting the first execute block matches until the end of the second block, and I would like it to stop at first matching }, so that dvar is colored in blue.
[Updated on: Mon, 01 September 2014 09:37] Report message to a moderator
|
|
| | | | |
Goto Forum:
Current Time: Thu Apr 25 17:37:41 GMT 2024
Powered by FUDForum. Page generated in 0.03196 seconds
|