Own syntax schemes

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Re: Own syntax schemes

Postby Taneeda » Fri Apr 27, 2012 1:29 pm

After a first and fast test, it seems that the syntax highlighting and folding works very well...
Also, the border highlighting to { } ... works in most cases.

Example:
at \lstset{...} the borders around { } are shown, but at \begin{lstlisting} they aren't. Is that a consciously behavior?
Image
User avatar
Taneeda
 
Posts: 10
Joined: Fri Jun 19, 2009 12:35 pm
Location: Oldenburg, Germany

Re: Own syntax schemes

Postby robert » Sun Apr 29, 2012 3:58 pm

Good point, thanks. Fixed in SVN, as well as a folding bug for LaTeX. It'll be in the next release of RSTA; until then, you can grab it from there.
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

Postby Kyrremann » Wed May 16, 2012 10:41 pm

Hi
I've been trying to make my own language today, but I'm having a problem. I'm not sure what to write in this method:

java code:

atmf.putMapping("text/thingml", "org.fife.ui.rsyntaxtextarea.SyntaxScheme");


What I've done for now is to make the .flex file and used JFlex to make the .java file where I removed the two methods. Then I added my language to the SyntaxConstats.java. So I'm wondering if I've skipped a step, and if my putMapping(...); is correct?
Kyrremann
 
Posts: 14
Joined: Wed May 16, 2012 10:07 pm
Location: Oslo, Norway

Re: Own syntax schemes

Postby robert » Thu May 17, 2012 12:16 pm

I'm guessing you replaced "org.fife.ui.rsyntaxtextarea.SyntaxScheme" with the name of your TokenMaker class in your putMapping() call? You'd want to do that before creating an RSyntaxTextArea and setting setSyntaxEditingStyle("text/thingml").

If you have any more trouble, try to cobble up a simple example of what you're doing that's not working, and either post it or email it to me.
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

Postby Kyrremann » Fri May 18, 2012 8:57 am

I got it to working, I have misunderstood the last parameter in putMapping(). So now my syntax highlighter works. My next step is making a parser.

Is there some tutorials or helps out there about how to implement my own CUP parser into RSyntaxTextArea? I'm going to dig into the code in RSTALanguageSupport.
My RSytaxTextArea master blogg http://thingmlosf.tumblr.com/ and source code https://github.com/Kyrremann/ThingML
Kyrremann
 
Posts: 14
Joined: Wed May 16, 2012 10:07 pm
Location: Oslo, Norway

Re: Own syntax schemes

Postby robert » Tue May 22, 2012 2:46 am

Glad you're getting farther! As for implementing custom parsers, I don't know of anybody who integrated a CUP parser. Working examples are XmlParser (shipped with the RSyntaxTextArea project), and everything in RSTALanguageSupport, but those are hand-made parsers. There has been a little work done by someone to create an ANTLR-based parser, but I personally don't know/use ANTLR otherwise I'd cobble up an example myself. :) If you get something working using CUP, I'd be glad to help out with any finer points, and if it's clean enough we can post an example of it somewhere on the site (I'm sure folks would be happy to use standard parsing tools like ANTLR and CUP if they could).
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

Postby Kyrremann » Wed May 23, 2012 10:13 pm

Hi. I got my CUP and jFlex working! I'm currently working on my master essay (a ten/fifteen page introduction). It's about lightweight editor framework that support important features like Code-completion, Refactoring, Syntax highlighting, Error-reporting, so I'm using your framework as one of the cases. You can read some of my thought on my master tumblr: http://thingmlosf.tumblr.com/. There you can also see the example language I'm using for now.

"Anywho", When I'm done with my paper, due June 1. I'll try to make a tutorial on how to implement CUP and Jflex, so that other can use those tools too. So they don't have to use their weekend to try it out them self ;) I've also manage to implement the Sourcetree.

But...there are two things I've still have problems with (which I think can be solved with the same solution).
When you highlight something, either as an error (squigglie-line) or with the use of the source tree, every marking happens only on the first line. For the error reporting I am sending the correct line, but it doesn't help. Even when I hard code another line then the first it still end up marking the first line.
when using the source tree I'm guess the problem lies in that the code is using textarea.select(), which doesn't handle lines.

Any tips for solutions? I'm thinking about using a search to fix the tree marking and just count the offset from start till the word. Or try to get it from my CUP file.
My RSytaxTextArea master blogg http://thingmlosf.tumblr.com/ and source code https://github.com/Kyrremann/ThingML
Kyrremann
 
Posts: 14
Joined: Wed May 16, 2012 10:07 pm
Location: Oslo, Norway

Re: Own syntax schemes

Postby robert » Thu May 24, 2012 11:37 am

Excellent news! I'd love to see what you came up with.

When you highlight something, either as an error (squigglie-line) or with the use of the source tree, every marking happens only on the first line. For the error reporting I am sending the correct line, but it doesn't help. Even when I hard code another line then the first it still end up marking the first line.


Strange, not sure I've seen this before. Perhaps the simplest parser to look at to compare is org/fife/ui/rsyntaxtextarea/parser/XmlParser.java (though perhaps you've already looked at it). Are you creating your parser notices differently than that XmlParser is? I noticed that DefaultParserNotice has a constructor that allows no offset/length to be passed in, but I don't really use that anywhere. It seems like that would prevent the tool tip popup windows displaying the syntax error from appearing if you used that constructor, although it wouldn't cause your problem.

when using the source tree I'm guess the problem lies in that the code is using textarea.select(), which doesn't handle lines.


The source tree stuff just recently went through some major changes. Are you basing it off of the JavaSourceTree or JavaScriptSourceTree in RSTALanguageSupport (since that's where the actual selection code is)? If so, make sure that your tree nodes are returning absolute offsets into the Document, not relative to the start of the line on which they're found.

I may have questions about your usage of the library later. Feel free to contribute patches or the like if you find areas that could be simpler or more robust.
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

Postby Guest » Fri May 25, 2012 7:47 am

This is my error repoting, based on the XmlParser, and I've even tried to hardcode an int instead of using parser.errorLine. So I'm guessing the error comes later or something...I'll look some more into it. Was just hoping someone had experimented the problem before ;)

java code:

DefaultParserNotice notice = new DefaultParserNotice(this,
parser.errorValue, parser.errorLine, parser.errorColumn,
parser.errorValue.length());
notice.setLevel(ParserNotice.ERROR);
result.addNotice(notice);


About the .select(): If it' true as you said that the offset need to be from the start of the documents, then It's a problem with my CUP as it's return are based on the line the token is on. So guess I need to find a workaround there. Should be that hard I think...we'll see what I end up doing.

I'll see what I'll manage to bring to the table :) And I'm happy to answer any questions you may have.
Guest
 

Re: Own syntax schemes

Postby Kyrremann » Fri May 25, 2012 7:57 am

That last one was me, guess I forgot to log in :) So you can just delete it.

This is my error repoting, based on the XmlParser, and I've even tried to hardcode an int instead of using parser.errorLine. So I'm guessing the error comes later or something...I'll look some more into it. Was just hoping someone had experimented the problem before

java code:

DefaultParserNotice notice = new DefaultParserNotice(this,
parser.errorValue, parser.errorLine, parser.errorColumn,
parser.errorValue.length());
notice.setLevel(ParserNotice.ERROR);
result.addNotice(notice);



About the .select(): If it' true as you said that the offset need to be from the start of the documents, then It's a problem with my CUP as it's return are based on the line the token is on. So guess I need to find a workaround there. Should be that hard I think...we'll see what I end up doing.

I'll see what I'll manage to bring to the table And I'm happy to answer any questions you may have.
My RSytaxTextArea master blogg http://thingmlosf.tumblr.com/ and source code https://github.com/Kyrremann/ThingML
Kyrremann
 
Posts: 14
Joined: Wed May 16, 2012 10:07 pm
Location: Oslo, Norway

PreviousNext

Return to Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron