Posted 15 years ago by David
Version: 4.0.0282
Avatar
Hi, i'm evaluating the syntax editor because it looks great. I've looked through the samples and it certainly is powerful, much better than other editors i've worked with.
So now it's time for start building some stuff. The documentation is very overwhelming and a little intimidating. I know how to load a XML file into the editor and get it to highlight stuff, i just need a few questions answering before i begin.

Here is the specification for the language i'm creating...

* C-style language.
* Can not be merged with other languages.
* Requires intelliprompt support, that shows function parameters, descriptions etc.
* Would be great if it can show tooltips when hovering over keywords.
* Requires snippet support.
* Outlinging would be handy.
* Allows the end-user to add their own keywords.

Another thing that i want to have in my language is that it can show intelliprompt for a custom class. So if i have a class called "Car" if i do something like...

Car hi = new Car()

... Then when i type "hi." it will show properties like "colour","model","price" in the intelliprompt. I don't need it to be dynamic and search for the properties because the classes i will be using will have fixed properties.

Finally, i read in the documentation that you can define the language using an XML file or you can construct it programatically. I'm unsure how to do it programmatically, do you just create a class and derive from "DynamicSyntaxLanguage"? I havent found an exact example of this yet.

I don't really want an external XML file, because it can be changed outside my application, or maybe i can embed it into my application?

So do you think my proposed language is feasible?

I will dig a little deeper into the documentation, but like i said it is a bit confusing to see how something is done exactly.

Thanks for your time.

Comments (6)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi David,

To see a sample of making a programmatic lexical parser, you can look at our Simple language sample. That one is a "simple" implementation of a language that shows programmatic lexers, building an AST from a document using a grammar, using the AST to drive outlining, IntelliPrompt quick info and member lists, etc. We tried to cover all the bases of what you essentially were mentioning, so yes, you can definitely do all those features.

You can use a dynamic lexical parser (XML defined) instead and have the XML live in your project as a Resource. That way people can't change it. Programmatic lexical parsers aren't as easy to get up and running with (since you write the code yourself) but once you have them, they are typically faster and a little more flexible than dynamic lexical parsers.

The grammar file is used to pass to our Grammar Designer and generates a semantic parser. This is what helps you build an AST. That process can be time consuming depending on the complexity of your language however once you have it working, it opens up all the doors to making things like automated IntelliPrompt pretty easy since you have a document structure you can examine, and it's all built on a separate thread.

We know that right now getting started can be a bit confusing which is why as we continue working on our next gen framework that we're prototyping out with our WPF version, we're focusing on making more step-by-step walkthroughs and making a Language Designer tool (still WIP) that will help automate a lot of the work needed to get up and running. Feel free to ask questions here or email us and we'll be happy to help.


Actipro Software Support

Posted 15 years ago by David
Avatar
Thanks, that was helpful but for the moment i think i'll stick with a dynamic language using an XML defintion, it seems pretty simple compared to writing my own parser.

I've been changing the xml document, and it is working great! So now i'm looking into the intelliprompt...

As far as i can see you define the intelliprompt stuff inside a C# class, that the XML file references in its "SyntaxLanguageTypeName" tag. You provide the key trigger in the XML file.I have got the memberlist showing fine, but so far i have it only responding when the "." character is pressed. Can i make it pop-up when any letter is pressed by providing some sort of regex statement like "[A-Z]"?

Also I dont really understand how ParameterInfo works. I thought there would have been an argument in the constructor of an IntelliPromptMemberListItem that you can provide the parameter info. It seems the samples use a "behind the scenes" mechanism and don't explicitly add the information, so i'm unsure what to do exactly.

Finally, i'm providing keywords to highlight in the xml file. Can you tell me which methods i can use to add additional keywords programatically?

Thanks again.

[Modified at 09/14/2009 10:20 PM]
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
David,

To show a member list when a character is typed, you'd have to do that manually. That is something we are looking into for a possible automated feature as we develop our next gen framework though. What you could do for now is handle the KeyTyped event and look for an A-Z being typed. If the character is at the start of a word and no member list is open, then show your member list. That should achieve the effect you want.

With parameter info you need to tell it when and where to show. It doesn't really have a relationship with member lists. So say you show a member list and insert some method name. Then the user types '(' so you want to show a parameter list. That is where you'd configure parameter info based on the method name before the '('. In our advanced add-on languages, we use a combination of token scanning and AST examination to determine what to show for member lists and parameter info.

Our Simple language sample shows both too. In SimpleSyntaxLanguage, if you search for ParameterInfo you'll see everywhere that we wrote code to implement it for the Simple language. In the next gen framework we're designing (prototyping with our WPF version), we're making IntelliPrompt a lot easier to work with and have multiple individual samples for each type of IntelliPrompt feature too. We're trying hard as we move forward to show more simple and step-by-step samples of this sort of thing.

Dynamic languages allow you to modify the object model programmatically. So you could define an ExplicitPatternGroup in your DefaultState and give it a Key to identify it. Assign it a TokenKey and Style too, but don't define any patterns. That all is in your XML definition. Then in your code when you go to update the user keyword list, set language.IsUpdating = true, go to the default state and get that pattern group, add patterns for each user keyword, and set language.IsUpdating = false. Then it should be updated with your custom keywords.

Hope that helps.


Actipro Software Support

Posted 15 years ago by David
Avatar
Thanks, thats very informative. I'm glad you're working on the new framework to help users like me get up and running even faster, good luck with it!

[Modified at 09/16/2009 08:26 AM]
Posted 15 years ago by David
Avatar
How can i get down to the patterngroup level?

I've got "editor.Document.Language.LexicalStates[0]" which is my default state but that doesn't contain a "patterngroups" member. I'm trying to find a specific patterngroup so i can add patterns programatically.
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
If you are using a dynamic language, then cast the lexical state to a DynamicLexicalState. That has a LexicalPatternGroups property on it.


Actipro Software Support

The latest build of this product (v24.1.0) was released 5 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.