Shop OBEX P1 Docs P2 Docs Learn Events
Open source IDE ideas - Page 4 — Parallax Forums

Open source IDE ideas

124»

Comments

  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-03-04 16:54
    Maybe its time to add a new language to your toolbox?

    Yes it probably is! In decoding how this Realbasic code works, I'm learning three languages at once - realbasic, xml and Regular Expressions, and at the same time trying to decode the style of the programmers code.

    I think it would be fair to say that this realbasic code is able to do all the syntax highlighting that an IDE might need, for at least Spin, Pasm, C and Basic. Whether I can get it there is another matter.

    I'll highlight some of the issues:

    1) The concept of object oriented programming. This appears to me to be a very nice way to encapsulate code. The upside is that the rules are neat, simple and make coding even more modular than using functions/subroutines. The downside is when a program appears to break those rules - eg the "Testfield" part of the program running the screenshot above, where some of the methods are in one part of the code and the rest are somewhere hidden where I can't seem to find them (despite DavidM's very kind advice via PMs). I know those methods are there because when you hit .Tab they show up.

    2) The difficulties working out the structure of code when many objects have been custom written and where only the author really understands what those objects do. For someone working within such a structure who wrote those objects, it is no doubt faster. For someone decoding the structure, a linear text file is much easier to understand IMHO.

    3) Minor irritations with Realbasic. eg - it insists on always compiling for a mac before compiling for windows, which means a build takes twice as long and it is not obvious how to turn off the build for a mac. Also, when it creates an .exe for windows, if there already is an exe then it does not overwrite this one. So you have to remember to delete the old one first, then rebuild. And another irritation - when you run (which is quicker than building) it creates a temporary disk structure that it then deletes afterwards. So it is hard to put the .xml files in the local folder, so you either have to put them in another folder, or put the .xml data inside the program or use build instead of run. I'm sure these are all solvable.

    4) An understanding of what the code is doing. After much opening and closing of the tree structure, it appears what is happening is that there is an .xml file which contains some rules about things like bold, and text color, and indents and comment colors. xml is a language in itself. http://en.wikipedia.org/wiki/XML Some things are quite simple eg
    <highlightContext name="Comment" highlightColor="#7F0000" italic="true">
    

    xml can provide a neat way of defining the rules for each language. The catch is whether *all* the rules can be defined in xml. To answer that question, more exploring through the code searching for how much 'special' code may or may not be present that modifies the xml rules.

    5) Regular expressions. These are just another way of writing rules for parsing strings. http://en.wikipedia.org/wiki/Regular_expression and we can start to see some regular expressions in the .xml code. I know very little about regular expressions, but I am assuming that in this example for comments, the ' finds the start, and the \n\r is the end
      <startRegEx>'</startRegEx> 
      <endRegEx>[\n\r]</endRegEx> 
    

    6) Regular expression parsing. I'm still trying to work out exactly what is included in realbasic, ie how much the language can parse regular expressions and how much you have to code yourself. Again, it is back to the tree structure opening and closing every thing that might have some code in it trying to find whether code exists. I think there does appear to be code written in there to parse regular expressions. This is good, because it is not such a mystery how to process text.

    7) Working out all the things xml can do. In the xml definitions is this "<blockStartMarker indent" and this is interesting because this gets to the heart of what we are trying to achieve with those little arrows. The good news is that "blockStartMarker indent" is part of xml. The bad news is that if you type this into google, the top hit is this forum thread! The second hit is on the realbasic forum. I hope we are not the only people using this? We have xml definitions for C, for Java and a few others. Let's take a look at the xml file for the Basic syntax:
      <name>REALbasic</name> 
      <blockStartMarker indent="1">^\s*(?:if.+?then\s*(?!.+?)|for|while|select|class|module|try|catch|^\s*(?:protected|private)?\s*(?<!end)\s*(?:sub|function)|else)</blockStartMarker> 
      <blockEndMarker>^\s*(?:end|wend|next|else|catch|elseif)(?:\s+|$)</blockEndMarker> 
    

    All the + and ? and | are the rules for the regular expression. These are initially unintelligible but at the same time, very powerful. But to anyone who codes basic, what this is saying is that if you have an If or a For or a While then that is the start of an indent, and if you have Wend or a Next or an Else, that is the end of a block. Add in some special rules and lo and behold, it is possible to hit the Reindent button on some messy code and tidy it all up.

    This might be helpful for spin!

    So - into the Proptool to work out what some of the rules are. Try typing "repeat a from 0 to 10" and then go to the next line. The cursor will be right under the "r" and there is no little arrow. If you type one space, the arrow starts to appear, and if you type two spaces it is all visible. If the line under that is indented by the same or more number of spaces, the arrow appears. If the line is indented by the same or less than the "repeat" then the arrow disappears.

    I think we might be able to start to write the regular expression rules for that:

    1) Keywords for the start of indents. "repeat" and "if" and we can add others.
    2) If keyword True and indent > start of keyword, then add arrow
    3) Continue with arrows if next line is blank (as per the prop tool)
    4) Block end if any non whitespace text appears on the same line as the start of the keyword

    In summary, I think comments and comment blocks and keyword highlighting are going to be relatively easy to write in .xml
    The hard part is writing the indent/outdent rules as regular expressions, ie 2,3,4 above.

    Anyone an expert in regular expressions?!

    Attached - "Basic" syntax in xml, with Basic comments in green and C comments in red. From the xml file
    - <highlightContext name="Comment" highlightColor="#007F00" italic="false">
      <startRegEx>'</startRegEx> 
      <endRegEx>[\n\r]</endRegEx> 
      </highlightContext>
    - <highlightContext name="C-Comment" highlightColor="#7F0000" italic="true">
      <startRegEx>//</startRegEx> 
      <endRegEx>[\n\r]</endRegEx> 
    
    1022 x 728 - 143K
  • DavidMDavidM Posts: 630
    edited 2011-03-04 18:17
    Dr_Acula wrote: »

    1) The concept of object oriented programming. This appears to me to be a very nice way to encapsulate code. The upside is that the rules are neat, simple and make coding even more modular than using functions/subroutines. The downside is when a program appears to break those rules - eg the "Testfield" part of the program running the screenshot above, where some of the methods are in one part of the code and the rest are somewhere hidden where I can't seem to find them (despite DavidM's very kind advice via PMs). I know those methods are there because when you hit .Tab they show up.

    Hi Dr_Acula,

    The example you are working with, is probably not the best to show the best implementation of OOP, But Generally, You create a CLASS and put all its code ( methods,constants and events etc) IN THAT CLASS.

    When you use that class, and in this case, its a CONTROL OBJECT, you drag that to the window where you want to use it.

    Now depending on the behaviour of that class, The only code you may need to add to it , will be its particular property settings, These may be called by an event ( i.e Open Event). Or to Interact with other objects or data within that window ( via method calls ) which are the HOOKS to other objects/class's, MOST of the processing should be done within that CLASS and this code is "Hidden" from the occurrence in the window.

    This should, if done properly , minimise the programming required when IMPLEMENTING the class, and that's only if that class is designed that way, Now if its your own class, Ideally you should be putting all the code in the class, you need to keep it generic, but now that class will be updated and the SAME for all instances of that class where ever it is used.

    Here are some Video Tutorials, click on the one that says "Classes"
    http://www.vtc.com/products/Real-Studio-Tutorials.htm

    Dave M
  • jazzedjazzed Posts: 11,803
    edited 2011-03-04 18:24
    Dr_Acula wrote: »
    Anyone an expert in regular expressions?!
    You may as well learn Perl. :zombie:
  • DavidMDavidM Posts: 630
    edited 2011-03-04 18:37
    jazzed wrote: »
    You may as well learn Perl. :zombie:

    If you decide to use realbasic, theres no need to learn perl, Regular expressions are Built Into it, just start using,

    In answer to the question , I don't know anything about REGEX, perhaps some one else can chip in.

    but here's a link that may help

    http://www.regular-expressions.info/realbasic.html

    Dave M
  • jazzedjazzed Posts: 11,803
    edited 2011-03-04 18:49
    I find it very strange that DR A seems to care so much about knowing RegEx just now after digging into this project =D
  • DavidMDavidM Posts: 630
    edited 2011-03-04 18:55
    Hi Jazzed,

    Why is it strange?, he seems to be going hard at it! and having a go, rather that bitching about who's software is the best to use, Maybe he's onto something, maybe he' just discovered that Realbasic may be the best way to go!

    cheers,

    Dave M
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-03-04 19:25
    Thanks for that link David. It answers my next question I was about to ask, which was whether RegEx was part of the language, or whether it was some class the programmer had defined somewhere.

    I don't know where this will all end up. Perl looks interesting and there are some synergies here. I guess the code that David gave a link to does about 95% of what is needed, so I can see an end in sight (coupled with code already written to shell out to all the command line compilers).

    Maybe what I am looking for now is an "almost written IDE interface where the code can be edited to handle Spin syntax". Is there one like that in Perl or Eclipse?

    It is most useful that .xml files can do so much. That means that if you have an IDE and someone wants strings to be in blue instead of red, they can just edit the .xml file
  • DavidMDavidM Posts: 630
    edited 2011-03-04 20:19
    Hi Dr_Acula,

    Have you tried changing just a few of the values in the Spin.xml file to see what the effect is, I bet most can be modified and get a lot converted, the regex stuff may take some time to investigate.

    I do remember reading in the NOTES of the EditFiled example that a guy Called Alex, Who wrote this, offered to "HELP" with defining a XML definition file, to your specifications. You may want to ask him as he knows how it works.

    But a FULL SPIN Definition is required and I don't know if we have that?

    Another thing, I would try to get this to do as much of the parsing as possible, don't worry about all the other issues just yet, Creating a full IDE should not be impossible, Realbasic can do it.

    heres some more info..

    http://www.realsoftware.com/realstudio/fastdevelopment.php

    http://www.realsoftware.com/realstudio/qualityapps.php


    regards

    Dave M
  • jazzedjazzed Posts: 11,803
    edited 2011-03-04 20:34
    I don't really care what language people use. I do find heavy promotion of one language very irritating though. Such fanaticism should be scrutinized. Nothing is free. I find your appearances here suspect, especially with your foul language.

    However in a forum hosted by a company that practically reinvented BASIC from that crazy old numbered language it used to be, you expect to find a few BASIC fans.

    Perl uses RegEx extensively - it's practically a standard feature there, and there are benefits. Perl is a little strange though. Some languages are better than others at different tasks, and we all have personal preferences. Do whatever makes you happy.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-03-04 20:56
    I do remember reading in the NOTES of the EditFiled example that a guy Called Alex, Who wrote this, offered to "HELP" with defining a XML definition file, to your specifications. You may want to ask him as he knows how it works.

    But a FULL SPIN Definition is required and I don't know if we have that?

    That would be most helpful. I think that looking at the Java, C and Basic xml files, there is enough information to get almost all of a definition for Spin. Maybe everything except those block arrows.

    As for a spin definition, what I think I might do next is take some existing spin programs and put them in the proptool and then try to change the xml definitions so they look similar. I've already done a lot of this already in vb.net so it is just a matter of checking things one at a time.

    As for realbasic - a neat review here http://rb.thevbzone.com/l_intro.htm which explains the bloatware thing about vb.net (part of my motivation for abandoning a working multilanguage IDE), also it answers the . thing, and it explains the quirk about building menus (RB ought to look at fixing that one).

    RB isn't perfect but it looks suitable for this job. Any other suggestions/screenshots are all most welcome.
  • DavidMDavidM Posts: 630
    edited 2011-03-04 21:38
    Hi Dr_Acula,

    That link is way Old 2004 A lot has changed since then!

    Creating menus is easy, but like anything you need to have a small go at it.

    I think one of the reason they do menus the way they do is because of OOP.

    For example, Lets say you have a method that saves a file, This can be activated from both a menu item or a button or even within the app itself, meaning that the one function has multiple ways of activating it, RB Encourages you to make this generic and then linking it up to whatever "CONTROL" you need.

    Dave M
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-03-04 22:26
    Yes I see what you mean with menus. In vb.net I tend to double click the menu, which opens up a subroutine, and I often find myself adding a call to another subroutine so that other subroutines can call the same code. eg I might have a menu to compile, and I might have a button to compile too. I need to start thinking in "object"!

    I have a generic question others might like to consider. What is a good layout for an IDE?

    In C and Basic the program is likely to be one single text file. But spin has a structure, with objects and sub objects. The proptool puts these in tabs. When you build the spin program it saves that little text file with the structure of the program. I am wondering about replicating that in a treeview.

    And I'm also thinking of loading in all the sub objects that are referenced in the main program. Then the IDE can add them when you type the . eg the main program references strings.spin which has strings.left and strings.right, so when you type strings. it will give you the options.

    This is more "object oriented". But at the same time, it is slightly different to the tabs that the proptool uses. What do people think?
  • Heater.Heater. Posts: 21,230
    edited 2011-03-04 22:38
    In C and Basic the program is likely to be one single text file.
    What?
    Even in the micro controller world pretty much every usefull C application I have ever seen has consisted of many files.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-03-04 23:01
    Ok, well if there are multiple files, would they have a tree structure? I guess they do if you think about #include files.
  • Heater.Heater. Posts: 21,230
    edited 2011-03-04 23:12
    Entirely up to the programmer. No reason a function in file A can't call a function in file B which calls a function in C which call's something back in A.

    That's probably not a wise way to organize programs though.

    Normally a tree structure, as you suggest, makes more sense.
  • DavidMDavidM Posts: 630
    edited 2011-03-04 23:14
    HI Dr_Acula

    There are many ways this can be done, but keep this in mind..

    1) We need .SPIN files from the OBEX, and ones we make ourselves and view these in a library of some sort.
    2) We need to view each one or maybe view each BLOCK separate.
    3) A TOP object files has dependent files.
    4) We need to modify each .spin file but MUST know if any spin file is used elsewhere
    5) Should the TOP Spin file be the "LINK" to all other files, OR should we have a PROJECT FILE that holds file links to each spin files as well as other things, like Documentation, Schematics, Pics, Web links etc and other support files.
    6) I would love some kind of "WHERE USED" viewer, so may be the projects files could be managed with an SWL Database, to keep track of everything.
    7) What if you what to support other types, like C files or any other language.
    8) The compiler need informations in a certain format,
    9) We need to make binaries for uploading so these need to be kept some where
    10) It would be nice to have a good "LIBRARY Viewer.
    11) The library can be a file list or a "TREE" list.
    12) Do we want to make use of VERSIONS? I would love something like that
    13) Again Do we want to just reference external files or do we want to keep the data in some kind of other format.
    14) A code snippets library would be good as well.
    15 Do we want to work on more than one "PROJECT" at a time? How will this be presented, One window view per project with separate tabs for each file, if you have a lot of files this looks messy, so would a tree view be better?
    16 ) Do we want a separate LIBRARY Window? where we we can drag and drop from/to
    17) What about an integrated Debugger? Who would this work and look like?
    18) What about a way of LOCKING Files so that can't accidentally changed?
    19) The hardest thing to do would be an UNDO SYSTEM.
    20) It would be nice to be able to have some kind of to do list for each project, Mark certain code as "Done/Tested/Working", priority for fixing etc

    Dave M
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-03-06 01:26
    Some good ideas there!

    Ok, I'm trying to get something very simple working first. I need to get "File Open..." in the menu. First issue is which directory this defaults to. I've spent a few hours researching this and it is a little complicated when you start to consider writing a program for three operating systems. Windows uses
    c:\program files\realbasic\mydirectory
    Apple seems to swap the \ for a :, and on Linux I think it is a forward slash instead of a backslash.

    Generic question - is it better to default to opening in a specific directory or in the current working directory?

    With respect to specific directories, if one is using this to write code for Catalina (or BCX) it may be necessary to specify the directory. Catalina has a number of features that depend on fixed locations. So one will need to think about how to code this for different operating systems.

    But I thought I would just start with opening in the current directory.
    dim file as FolderItem = GetOpenFolderItem("????")
    

    but this opens in the windows root directory.

    I have some code that can return the current directory in a msgbox
      dim f as string
      f = GetFolderItem( "" ).ShellPath ' current directory where the .exe program is running from
      msgbox(f)
    

    but I'm not sure how to link this with the GetOpenFolderItem. There are websites that talk about using OpenDialog instead, but I couldn't find any code on those sites.

    I think down the track, it will probably be necessary to add a file treeview like the proptool has. There is a dialog to do this but (silly me) I didn't bookmark it and I can't find it now.

    And then there is another complication - when you hit the "run" green triangle, it creates a temporary directory. So it is not possible to put things like the .xml files in this directory because it does not exist until the program is run.

    So...for debugging purposes what I would like to do initially is replicate this simple bit of vb.net code, but on all three operating systems:
            Dim Filepath As String
            Filepath = "C:\Program Files\Catalina\Demos" ' folder where files are stored
            OpenFileDialog1.InitialDirectory = Filepath ' set the folder
            OpenFileDialog1.FileName = "*.C" ' look for all files ending in .C
            OpenFileDialog1.ShowDialog() ' open the "Open File" dialog box
    

    @davidM, do you think this would be hard to code?
  • Jose PortoJose Porto Posts: 3
    edited 2011-10-10 14:24
    It's been a few months since your last posts and I just finished reading the thread for the first time. Let me try to explain my point of view.

    1. That thing about REALBasic not being Open Source, was a complete waste of time. Really! You guys are developing an Open Source IDE for a third party language. Wether this is developed in a closed source language, is not the problem. BTW, if this thing is good I would pay 50$ to or more. I develop in Mac OS and I go crazy with BST.

    2. The debugging is not mandatory right now, in my opinion. But if you can integrate a terminal in the IDE, to get values from the USB/RS232 that would be good. Less ALT+TAB.

    3. Now, the .completion is a PLUS, for me it's the $50 feature of this IDE. Spin needs it. And I would do another thing. You should get a project file of some sort, to speed up things, like keeping the methods, the linkage between files. But I guess it's really important to maintain backward compatibility. So, we need to still be able to open the files in simple, raw, Propeller Spin Tool. My thought on this is that, you could keep in the project file, the ritchtext updated, so that we ALWAYS edit the so called project file, and when we save, the IDE converts everything to the proper, raw spin files! But it has to have a both way method to do this. So, if I open a spin "top" file, it should be able to construct a project file with all the code already in the right "ritchtext" format and all the extra data. And when you save, it should be able to create the multiple "or single" files in spin.

    I have done this in the past, in vb6 for another purpose. I was coding a game at that time, and we developed a scripting language to "create" the plot. I developed a tool to edit those scripts so that the guys that would wright the story, could do it faster and more productively. Honestly, this was so long ago, I guess I still had a Windows 98 machine. And I'm not that fresh anymore with vb nor REALBasic, but I guess I can get up to speed.

    Last but not least, I'm working on a huge propeller project, and YES, I do need a better way to organize my stuph, otherwise I'll go crazy with so many files and so different ways of declaring variables, since it takes so long to keep up with the small snippets of code that are spread trough so many .spin files, I have already lost any sense of convention. So this tool is a must and you guys are right from the beginning. And right now, the most solid way to get it to run on the three major platforms, is indeed, REALBasic.

    Keep up the good work
  • frank freedmanfrank freedman Posts: 1,983
    edited 2011-10-10 16:26
    Kye wrote: »
    http://www.eclipse.org/

    Eclispe is good... =)

    never mind, ended up in middle of thread not realizing it. Much to read before comment..........


    Ok, now that I have had time to review this whole thread, the question that brought me here was:
    Has anyone come up with the necessary infrastructure to use spin and PASM inside of the Eclipse IDE in the same way as either Java or the C/CPP environments?

    I will check back later for any answers after I scrape off my boots and hose down all the previous er, content......

    Frank

    Seriously NOT a normal parallax/propeller mode of discussion.......

    One final note, if anyone has downloaded and run the NXP's Expresso Code Red development kit, look carefully and if you don't recognize it check under help about............ say just above the last line crediting some of the apache stuff.......
  • jmgjmg Posts: 15,185
    edited 2011-10-10 20:52
    If you need a reference point for FreeBASIC IDE, this debugger I thought was quite impressive :
    http://www.freebasic.net/forum/viewtopic.php?t=13935&postdays=0&postorder=asc&start=0&sid=07d955925e436607330f87eaf1cc57b9

    tho I know Step and Watch variables (etc) are not such a focus with Prop users..
Sign In or Register to comment.