* In the help, allow the creation of links between modules with the following 59/3059/17
Calixte DENIZET [Fri, 28 Jan 2011 16:13:17 +0000 (17:13 +0100)]
syntax:
<link type="scilab" linkend="mytoolbox.help/myfun">myfun</link>

* In the help, allow the execution of a script with the following syntax:
<link type="scilab" linkend="mytoolbox.exec/macros/fooexec.sce">macros/fooexec.sce</link>

* In the help, allow the creation of links between a module to the Scilab
documentation with the following syntax:
<link type="scilab" linkend="scilab.help/bvode">bvode</link>

* In the help, allow the execution and the edition of any example.

* In the help, allow the execution of the demos with the following syntax:
<link type="scilab" linkend="scilab.demos/gui/demos/uicontrol_plot3d.dem">Uicontrol demo</link>
or <link type="scilab" linkend="mytoolbox.demos/mydemo">My demo</link>

Change-Id: I274c4358dc2b8b45d218bdba838628e8f44e69bb

31 files changed:
scilab/CHANGES_5.3.X
scilab/modules/core/help/en_US/keywords/CHAPTER
scilab/modules/core/help/fr_FR/keywords/CHAPTER
scilab/modules/core/help/pt_BR/keywords/CHAPTER
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/CallScilabBridge.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/helpbrowser/SwingScilabHelpBrowser.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/helpbrowser/SwingScilabHelpBrowserViewer.java
scilab/modules/gui/src/java/org/scilab/modules/gui/helpbrowser/ScilabHelpBrowser.java
scilab/modules/gui/tests/unit_tests/helpviewer_links.tst [new file with mode: 0644]
scilab/modules/helptools/data/css/style.css
scilab/modules/helptools/data/pages/ban_en_US.png [new file with mode: 0644]
scilab/modules/helptools/data/pages/error.html [new file with mode: 0644]
scilab/modules/helptools/data/pages/homepage-en_US.html [new file with mode: 0644]
scilab/modules/helptools/demos/about.sce [new file with mode: 0644]
scilab/modules/helptools/etc/SciDocConf.xml [new file with mode: 0644]
scilab/modules/helptools/help/en_US/howtolinktoolbox.xml [new file with mode: 0644]
scilab/modules/helptools/macros/xmltoformat.sci
scilab/modules/helptools/sci_gateway/cpp/sci_buildDocv2.cpp
scilab/modules/helptools/src/java/jflex/scilab.jflex
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/CHMDocbookTagConverter.java
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/HTMLDocbookTagConverter.java
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/JavaHelpDocbookTagConverter.java
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/SciDocConfiguration.java [new file with mode: 0644]
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/SciDocMain.java
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/AbstractScilabCodeHandler.java
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/HTMLScilabCodeHandler.java
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/scilab/ScilabLexer.java
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/source/ScilabSourceBrowser.java
scilab/modules/helptools/src/jni/BuildDocObjectv2.giws.xml
scilab/modules/helptools/src/jni/SciDocMain.cpp
scilab/modules/helptools/src/jni/SciDocMain.hxx

index de928f1..940b82f 100644 (file)
@@ -55,6 +55,19 @@ Demonstration:
 Documentation:
 ==============
 
+* In the help, allow the creation of links between modules with the following
+syntax: 
+<link type="scilab" linkend="mytoolbox/exec/macros/fooexec.sce">macros/fooexec.sce</link>
+
+* In the help, allow the creation of links between a module to the Scilab
+documentation with the following syntax: 
+<link type="scilab" linkend="scilab/help/bvode">bvode</link>
+
+* In the help, allow the execution and the edition of any example.
+
+* In the help, allow the execution of the demos with the following syntax:
+<link type="scilab" linkend="scilab/demos/gui/demos/uicontrol_plot3d.dem">Uicontrol demo</link>
+
 * In an example in the documentation, when an undocumented function is used,
 trigger a warning and do not add a link on the function name.
 
index 686418e..72b8450 100644 (file)
@@ -2096,6 +2096,7 @@ public class CallScilabBridge {
      */
     public static void launchHelpBrowser(String[] helps, String language) {
         ScilabHelpBrowser.createHelpBrowser(helps, language);
+        ScilabHelpBrowser.startHomePage();
     }
 
     /**
index de6d980..dbdf8ca 100644 (file)
@@ -1,14 +1,15 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2008 - INRIA - Vincent Couvert
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at       
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
+
 package org.scilab.modules.gui.bridge.helpbrowser;
 import java.awt.Cursor;
 import java.io.File;
@@ -42,249 +43,264 @@ import org.scilab.modules.localization.Messages;
  * @author Vincent COUVERT
  */
 public class SwingScilabHelpBrowser extends JHelp implements SimpleHelpBrowser {
-       
-       private static final long serialVersionUID = 5306766011092074961L;
-       
-       private String jarExtension = "_help.jar";
-       private String mainJarPath = System.getenv("SCI") + "/modules/helptools/jar/scilab_";
-       private String defaultLanguage = "en_US";
-       private String currentLanguage = "";
-       private HelpSet helpSet;
-       /* We are storing the HelpHistory model to be able to 
-        * use the back/forward feature from the jpopupmenu
-        */
-       private static DefaultHelpHistoryModel helpHistory;
-               
-       static {
-               SwingHelpUtilities.setContentViewerUI("org.scilab.modules.gui.bridge.helpbrowser.SwingScilabHelpBrowserViewer");        
-       }
-       
-       /**
-        * Return the History model
-        * @return The DefaultHelpHistoryModel which is called
-        * from the popup menu
-        */
-       public static DefaultHelpHistoryModel getHelpHistory() {
-               return helpHistory;
-       }
-
-       /**
-        * Constructor
-        * @param helps help chapters and directories
-        * @param language Scilab current language
-        */             
-       public SwingScilabHelpBrowser(String[] helps, String language) {
-               super();
-                       
-               /* Send information to the user using status bar and cursor */
-               if (ScilabConsole.isExistingConsole() && ScilabConsole.getConsole().getInfoBar() != null) {
-                       ScilabConsole.getConsole().getInfoBar().setText(Messages.gettext("Loading help browser..."));
-                       ScilabConsole.getConsole().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-               }
-               
-               File[] jarFiles;
-               if (helps != null) {
-                       jarFiles = new File[helps.length + 1]; /* +1 because of Scilab main help jar file */
-               } else {
-                       jarFiles = new File[1]; /* Scilab main help jar file */
-               }
-
-               /* Main Jar file */
-               File mainJar = new File(mainJarPath + language + jarExtension);
-               currentLanguage = language;
-               if (!mainJar.exists()) {
-                       mainJar = new File(mainJarPath + defaultLanguage + jarExtension);
-                       currentLanguage = defaultLanguage;
-               }
-               
-               if (!mainJar.exists()) {
-                       String message = "'" + mainJarPath + defaultLanguage + jarExtension + "' has not been found on the system. " 
-                               + "" + "Are you sure you built it? The help will not be available.";
-                       if (ScilabConsole.isExistingConsole()) {
-                               MessageBox messageBox = ScilabMessageBox.createMessageBox();
-                               messageBox.setMessage(message);
-                               messageBox.setModal(true);
-                               messageBox.setIcon("error");
-                               messageBox.displayAndWait();
-                       } else {
-                               System.out.println(message);
-                       }
-                       return;
-               }
-               
-               int nbFilesToLoad = 0;
-               jarFiles[nbFilesToLoad++] = mainJar;
-               
-               /* Toolboxes jar files */
-               if (helps != null) {
-                       for (int k = 0; k < helps.length; k++) {
-                               File toolboxJarPath = new File(helps[k]);
-
-                               /* Find all Jars */
-                               String[] all = toolboxJarPath.list(new FilenameFilter() {
-                                       public boolean accept(File pathname, String filename) {
-                                               return filename.endsWith(jarExtension);
-                                       }
-                               });
-
-                               // For toolboxes JAR files are stored in jar directory
-                               if (all == null || all.length == 0) {
-                                       toolboxJarPath = new File(helps[k] + "/../../jar");
-                                       all = toolboxJarPath.list(new FilenameFilter() {
-                                               public boolean accept(File pathname, String filename) {
-                                                       return filename.endsWith(jarExtension);
-                                               }
-                                       });
-                               }
-
-                               /* Get the default language help and the current language help */
-                               int defaultHelpIndex = -1;
-                               int localeHelpIndex = -1;
-                                               if (all != null) {
-                                                       for (int fileIndex = 0; fileIndex < all.length; fileIndex++) {
-                                                               if (all[fileIndex].indexOf(defaultLanguage) != -1) {
-                                                                       defaultHelpIndex = fileIndex;
-                                                               }
-                                                               if (all[fileIndex].indexOf(language) != -1) {
-                                                                       localeHelpIndex = fileIndex;
-                                                               }
-                                                       }
-                                                       
-                                                       /* Add the toolbox help file */
-                                                       if (localeHelpIndex != -1) {
-                                                               jarFiles[nbFilesToLoad++] =  new File(toolboxJarPath + File.separator + all[localeHelpIndex]);
-                                                       } else if (defaultHelpIndex != -1) {
-                                                               jarFiles[nbFilesToLoad++] =  new File(toolboxJarPath + File.separator + all[defaultHelpIndex]);
-                                                       } else if ((all != null) && (all.length != 0)) {
-                                                               jarFiles[nbFilesToLoad++] =  new File(toolboxJarPath + File.separator + all[0]); /* First file as default */
-                                                       }
-                                               }
-                       }
-               }
-               this.setModel(new DefaultHelpModel(new HelpSet()));
-               
-               for (int i = 0; i < nbFilesToLoad; ++i) {
-                       URI jarURI = jarFiles[i].toURI();
-
-                       StringBuilder buffer = new StringBuilder("jar:");
-                       buffer.append(jarURI);
-                       buffer.append("!/");
-                       buffer.append(rootName(jarURI));
-                       buffer.append("/jhelpset.hs");
-
-                       URL helpSetURL = null;
-                       try {
-                               helpSetURL = new URL(buffer.toString());
-                       } catch (MalformedURLException cannotHappen) {
-                               cannotHappen.printStackTrace();
-                               continue;
-                       }
-
-                       try {
-                               helpSet = new HelpSet(/*classLoader*/ null, helpSetURL);
-                       } catch (HelpSetException e) {
-                               System.err.println("Could not load file: " + jarFiles[i] + ". Please check its contents, must be a Java Help file.");
-                               System.err.println("Error message: "+e.getLocalizedMessage());
-                               /* Reinit status bar and cursor */
-                               if (ScilabConsole.isExistingConsole() && ScilabConsole.getConsole().getInfoBar() != null) {
-                                       ScilabConsole.getConsole().getInfoBar().setText("");
-                                       ScilabConsole.getConsole().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
-                               }
-                               return;
-                       }
-                       this.getModel().getHelpSet().add(helpSet);
-               }
-               
-               /** Disable Index navigator because no index in Scilab help files */
-               Enumeration navigators = getHelpNavigators();
-               navigators.nextElement(); /* TOC */
-               removeHelpNavigator((JHelpIndexNavigator) navigators.nextElement());
-               
-               /* Reinit status bar and cursor */
-               if (ScilabConsole.isExistingConsole() && ScilabConsole.getConsole().getInfoBar() != null) {
-                       ScilabConsole.getConsole().getInfoBar().setText("");
-                       ScilabConsole.getConsole().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
-               }
-               helpHistory = new DefaultHelpHistoryModel(this);
-       }
-       
-       /**
-        * Display the Help Browser
-        */
-       public void display() {
-               
-       }
-       
-       /**
-        * Display the matching items for a specified keyword
-        * @param keyword the keyword
-        */
-       public void searchKeywork(String keyword) {
-               try {
-                       Enumeration navigators = getHelpNavigators();
-                       if (navigators.hasMoreElements()) {
-                               setCurrentNavigator((JHelpTOCNavigator) navigators.nextElement());
-                       } else {
-                               System.out.println("Scilab help files not loaded. Please check if " 
-                                               + mainJarPath + "*" + jarExtension + " files exist and are Java Help files.");
-                               return;
-                       }
-                       setCurrentID(keyword);
-               } catch (BadIDException e) {
-                       fullTextSearch(keyword);
-               }
-       }
-       
-       /**
-        * Display the matching help pages for a specified keyword
-        * @param keyword the keyword to search
-        */
-       public void fullTextSearch(String keyword) {
-               Enumeration navigators = getHelpNavigators();
-       
-               navigators.nextElement(); // JHelpTOCNavigator
-               //navigators.nextElement();     // JHelpIndexNavigator 
-               JHelpSearchNavigator searchNav = (JHelpSearchNavigator) navigators.nextElement();
-
-               setCurrentNavigator(searchNav);
-       
-               SearchQuery query = searchNav.getSearchEngine().createQuery();
-               query.addSearchListener((BasicSearchNavigatorUI) searchNav.getUI());
-               query.start(keyword, new Locale(currentLanguage));
-       }
-       
-       /**
-        * Close the HelpBrowser
-        */
-       public void close() {
-               
-       }
-
-       
-       /**
-        * Get teh root name of an URI
-        * @param uri the URI
-        * @return the root name
-        */
-       private static String rootName(URI uri) {
-               String path = uri.toString();
-
-               String baseName;
-               int pos = path.lastIndexOf('/');
-               if (pos < 0) {
-                       baseName = path;
-               } else {
-                       baseName = path.substring(pos + 1);
-               }
-               String rootName;
-               pos = baseName.lastIndexOf('.');
-               if (pos < 0) {
-                       rootName = baseName;
-               } else {
-                       rootName = baseName.substring(0, pos);
-               }
-
-               return rootName;
-       }
 
+    private static final long serialVersionUID = 5306766011092074961L;
+
+    private String jarExtension = "_help.jar";
+    private String mainJarPath = System.getenv("SCI") + "/modules/helptools/jar/scilab_";
+    private String defaultLanguage = "en_US";
+    private String currentLanguage = "";
+    private HelpSet helpSet;
+    private URL homePageURL;
+
+    /* We are storing the HelpHistory model to be able to
+     * use the back/forward feature from the jpopupmenu
+     */
+    private static DefaultHelpHistoryModel helpHistory;
+
+    static {
+        SwingHelpUtilities.setContentViewerUI("org.scilab.modules.gui.bridge.helpbrowser.SwingScilabHelpBrowserViewer");
+    }
+
+    /**
+     * Return the History model
+     * @return The DefaultHelpHistoryModel which is called
+     * from the popup menu
+     */
+    public static DefaultHelpHistoryModel getHelpHistory() {
+        return helpHistory;
+    }
+
+    /**
+     * Constructor
+     * @param helps help chapters and directories
+     * @param language Scilab current language
+     */
+    public SwingScilabHelpBrowser(String[] helps, String language) {
+        super();
+
+        /* Send information to the user using status bar and cursor */
+        if (ScilabConsole.isExistingConsole() && ScilabConsole.getConsole().getInfoBar() != null) {
+            ScilabConsole.getConsole().getInfoBar().setText(Messages.gettext("Loading help browser..."));
+            ScilabConsole.getConsole().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+        }
+
+        File[] jarFiles;
+        if (helps != null) {
+            jarFiles = new File[helps.length + 1]; /* +1 because of Scilab main help jar file */
+        } else {
+            jarFiles = new File[1]; /* Scilab main help jar file */
+        }
+
+        /* Main Jar file */
+        File mainJar = new File(mainJarPath + language + jarExtension);
+        currentLanguage = language;
+        if (!mainJar.exists()) {
+            mainJar = new File(mainJarPath + defaultLanguage + jarExtension);
+            currentLanguage = defaultLanguage;
+        }
+
+        if (!mainJar.exists()) {
+            String message = "'" + mainJarPath + defaultLanguage + jarExtension + "' has not been found on the system. "
+                + "" + "Are you sure you built it? The help will not be available.";
+            if (ScilabConsole.isExistingConsole()) {
+                MessageBox messageBox = ScilabMessageBox.createMessageBox();
+                messageBox.setMessage(message);
+                messageBox.setModal(true);
+                messageBox.setIcon("error");
+                messageBox.displayAndWait();
+            } else {
+                System.out.println(message);
+            }
+            return;
+        }
+
+        int nbFilesToLoad = 0;
+        jarFiles[nbFilesToLoad++] = mainJar;
+
+        /* Toolboxes jar files */
+        if (helps != null) {
+            for (int k = 0; k < helps.length; k++) {
+                File toolboxJarPath = new File(helps[k]);
+
+                /* Find all Jars */
+                String[] all = toolboxJarPath.list(new FilenameFilter() {
+                        public boolean accept(File pathname, String filename) {
+                            return filename.endsWith(jarExtension);
+                        }
+                    });
+
+                // For toolboxes JAR files are stored in jar directory
+                if (all == null || all.length == 0) {
+                    toolboxJarPath = new File(helps[k] + "/../../jar");
+                    all = toolboxJarPath.list(new FilenameFilter() {
+                            public boolean accept(File pathname, String filename) {
+                                return filename.endsWith(jarExtension);
+                            }
+                        });
+                }
+
+                /* Get the default language help and the current language help */
+                int defaultHelpIndex = -1;
+                int localeHelpIndex = -1;
+                if (all != null) {
+                    for (int fileIndex = 0; fileIndex < all.length; fileIndex++) {
+                        if (all[fileIndex].indexOf(defaultLanguage) != -1) {
+                            defaultHelpIndex = fileIndex;
+                        }
+                        if (all[fileIndex].indexOf(language) != -1) {
+                            localeHelpIndex = fileIndex;
+                        }
+                    }
+
+                    /* Add the toolbox help file */
+                    if (localeHelpIndex != -1) {
+                        jarFiles[nbFilesToLoad++] =  new File(toolboxJarPath + File.separator + all[localeHelpIndex]);
+                    } else if (defaultHelpIndex != -1) {
+                        jarFiles[nbFilesToLoad++] =  new File(toolboxJarPath + File.separator + all[defaultHelpIndex]);
+                    } else if ((all != null) && (all.length != 0)) {
+                        jarFiles[nbFilesToLoad++] =  new File(toolboxJarPath + File.separator + all[0]); /* First file as default */
+                    }
+                }
+            }
+        }
+        this.setModel(new DefaultHelpModel(new HelpSet()));
+
+        for (int i = 0; i < nbFilesToLoad; ++i) {
+            URI jarURI = jarFiles[i].toURI();
+
+            StringBuilder buffer = new StringBuilder("jar:");
+            buffer.append(jarURI);
+            buffer.append("!/");
+            buffer.append(rootName(jarURI));
+            buffer.append("/jhelpset.hs");
+
+            URL helpSetURL = null;
+            try {
+                helpSetURL = new URL(buffer.toString());
+            } catch (MalformedURLException cannotHappen) {
+                cannotHappen.printStackTrace();
+                continue;
+            }
+
+            try {
+                helpSet = new HelpSet(/*classLoader*/ null, helpSetURL);
+            } catch (HelpSetException e) {
+                System.err.println("Could not load file: " + jarFiles[i] + ". Please check its contents, must be a Java Help file.");
+                System.err.println("Error message: " + e.getLocalizedMessage());
+                /* Reinit status bar and cursor */
+                if (ScilabConsole.isExistingConsole() && ScilabConsole.getConsole().getInfoBar() != null) {
+                    ScilabConsole.getConsole().getInfoBar().setText("");
+                    ScilabConsole.getConsole().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+                }
+                return;
+            }
+            this.getModel().getHelpSet().add(helpSet);
+        }
+
+        /** Disable Index navigator because no index in Scilab help files */
+        Enumeration navigators = getHelpNavigators();
+        while (navigators.hasMoreElements()) {
+            Object nav = navigators.nextElement();
+            if (nav instanceof JHelpIndexNavigator) {
+                removeHelpNavigator((JHelpIndexNavigator) nav);
+                break;
+            }
+        }
+
+        /* Reinit status bar and cursor */
+        if (ScilabConsole.isExistingConsole() && ScilabConsole.getConsole().getInfoBar() != null) {
+            ScilabConsole.getConsole().getInfoBar().setText("");
+            ScilabConsole.getConsole().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+        }
+        helpHistory = new DefaultHelpHistoryModel(this);
+
+        try {
+            homePageURL = new URL(this.getModel().getHelpSet().getHelpSetURL().toString().replace("jhelpset.hs", "ScilabHomePage.html"));
+        } catch (MalformedURLException ex) { }
+    }
+
+    /**
+     * Display the home page
+     */
+    public void displayHomePage() {
+        if (homePageURL != null) {
+            setCurrentURL(homePageURL);
+        }
+    }
+
+    /**
+     * Display the Help Browser
+     */
+    public void display() { }
+
+    /**
+     * Display the matching items for a specified keyword
+     * @param keyword the keyword
+     */
+    public void searchKeywork(String keyword) {
+        Enumeration navigators = getHelpNavigators();
+        if (navigators.hasMoreElements()) {
+            setCurrentNavigator((JHelpTOCNavigator) navigators.nextElement());
+        } else {
+            System.out.println("Scilab help files not loaded. Please check if "
+                               + mainJarPath + "*" + jarExtension + " files exist and are Java Help files.");
+            return;
+        }
+        try {
+            setCurrentID(keyword);
+        } catch (BadIDException e) {
+            fullTextSearch(keyword);
+        }
+    }
+
+    /**
+     * Display the matching help pages for a specified keyword
+     * @param keyword the keyword to search
+     */
+    public void fullTextSearch(String keyword) {
+        Enumeration navigators = getHelpNavigators();
+        while (navigators.hasMoreElements()) {
+            Object nav = navigators.nextElement();
+            if (nav instanceof JHelpSearchNavigator) {
+                JHelpSearchNavigator searchNav = (JHelpSearchNavigator) nav;
+                setCurrentNavigator(searchNav);
+                SearchQuery query = searchNav.getSearchEngine().createQuery();
+                query.addSearchListener((BasicSearchNavigatorUI) searchNav.getUI());
+                query.start(keyword, new Locale(currentLanguage));
+                break;
+            }
+        }
+    }
+
+    /**
+     * Close the HelpBrowser
+     */
+    public void close() { }
+
+    /**
+     * Get teh root name of an URI
+     * @param uri the URI
+     * @return the root name
+     */
+    private static String rootName(URI uri) {
+        String path = uri.toString();
+
+        String baseName;
+        int pos = path.lastIndexOf('/');
+        if (pos < 0) {
+            baseName = path;
+        } else {
+            baseName = path.substring(pos + 1);
+        }
+        String rootName;
+        pos = baseName.lastIndexOf('.');
+        if (pos < 0) {
+            rootName = baseName;
+        } else {
+            rootName = baseName.substring(0, pos);
+        }
+
+        return rootName;
+    }
 }
index 990d686..79ff587 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Sylvestre Ledru
+ * Copyright (C) 2011 - Calixte DENIZET
  *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
@@ -15,21 +16,36 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.io.File;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
 
 import javax.help.DefaultHelpHistoryModel;
 import javax.help.JHelpContentViewer;
+import javax.help.HelpSet;
 import javax.help.plaf.basic.BasicContentViewerUI;
 import javax.swing.JComponent;
 import javax.swing.JMenuItem;
 import javax.swing.JPopupMenu;
+import javax.swing.SwingUtilities;
 import javax.swing.event.HyperlinkEvent;
+import javax.swing.text.BadLocationException;
 import javax.swing.text.DefaultEditorKit;
+import javax.swing.text.Document;
+import javax.swing.text.Element;
 
+import org.scilab.modules.commons.ScilabConstants;
 import org.scilab.modules.gui.console.ScilabConsole;
 import org.scilab.modules.gui.helpbrowser.ScilabHelpBrowser;
+import org.scilab.modules.gui.messagebox.ScilabModalDialog;
+import org.scilab.modules.gui.tab.Tab;
 import org.scilab.modules.gui.utils.WebBrowser;
 import org.scilab.modules.localization.Messages;
 
@@ -38,26 +54,33 @@ import org.scilab.modules.localization.Messages;
  * Through this class, we are adding some features on the javahelp browser
  * We are adding a popup menu on the right click of the mouse
  * In this menu, we are providing:
- *     - Execute in Scilab
+ *  - Execute in Scilab
  *  - Edit in the text editor
  *  - Copy
  *  - Select all
  *  - History
+ *
+ * @author Sylvestre LEDRU
+ * @author Calixte DENIZET
  */
 public class SwingScilabHelpBrowserViewer extends BasicContentViewerUI {
 
-    /**
-     *
-     */
+    private static final String SCILAB_PROTO = "scilab://";
+    private static final String SCI = ScilabConstants.SCI.getPath();
     private static final long serialVersionUID = -2593697956426596790L;
+
     /* This field is a copy of BasicContentViewerUI which is privated.
      * Therefor, I am changing the permission here to make it available
      * to the methods of this object
      */
     private javax.swing.JEditorPane accessibleHtml;
 
+    private JHelpContentViewer x;
+    private List<HelpSet> helpSets;
+
     public SwingScilabHelpBrowserViewer(JHelpContentViewer x) {
         super(x);
+        this.x = x;
     }
 
     public static javax.swing.plaf.ComponentUI createUI(JComponent x) {
@@ -71,15 +94,247 @@ public class SwingScilabHelpBrowserViewer extends BasicContentViewerUI {
         if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
             if (event.getDescription().startsWith("http://")) {
                 WebBrowser.openUrl(event.getURL(), event.getDescription());
+            } else if (event.getDescription().startsWith(SCILAB_PROTO)) {
+                if (helpSets == null) {
+                    initHelpSets(x.getModel().getHelpSet());
+                }
+                URL url = resolvScilabLink(event);
+                if (url != null) {
+                    super.hyperlinkUpdate(new HyperlinkEvent(event.getSource(), event.getEventType(), url, ""));
+                }
+            } else if (event.getDescription().startsWith("file://")) {
+                String url = event.getDescription();
+                url = url.replaceFirst("SCI", SCI);
+                WebBrowser.openUrl(url);
             } else {
-                if (event.getDescription().startsWith("file://")) {
-                    String url = event.getDescription();
-                    url = url.replaceFirst("SCI", System.getenv("SCI"));
-                    WebBrowser.openUrl(url);
-                } else {
-                    super.hyperlinkUpdate(event);
+                super.hyperlinkUpdate(event);
+            }
+        }
+    }
+
+    private void initHelpSets(HelpSet hs) {
+        helpSets = new ArrayList();
+        helpSets.add(hs);
+        for (Enumeration<HelpSet> e = hs.getHelpSets(); e.hasMoreElements();) {
+            helpSets.add(e.nextElement());
+        }
+    }
+
+    /**
+     * Try to find an id
+     * @param id the id to find
+     * @return the URL corresponding to the id
+     */
+    public URL getURLFromID(String id) {
+        URL url = null;
+        try {
+            for (HelpSet hs : helpSets) {
+                javax.help.Map map = hs.getLocalMap();
+                if (map.isValidID(id, hs)) {
+                    url = map.getURLFromID(javax.help.Map.ID.create(id, hs));
+                    if (url != null) {
+                        return url;
+                    }
+                }
+            }
+            url = new URL(helpSets.get(0).getHelpSetURL().toString().replace("jhelpset.hs", "ScilabErrorPage.html"));
+        } catch (MalformedURLException ex) { }
+
+        return url;
+    }
+
+    /**
+     * Try to find an id in a toolbox
+     * @param tbxName the toolbox's name
+     * @param id the id to find
+     * @return the URL corresponding to the id
+     */
+    public URL getURLFromID(String tbxName, String id) {
+        if (tbxName == null) {
+            return getURLFromID(id);
+        }
+        URL url = null;
+        try {
+            for (HelpSet hs : helpSets) {
+                if (hs.getHelpSetURL().toString().replaceAll("\\\\", "/").indexOf("/" + tbxName + "/") !=  -1) {
+                    javax.help.Map map = hs.getLocalMap();
+                    if (map.isValidID(id, hs)) {
+                        url = map.getURLFromID(javax.help.Map.ID.create(id, hs));
+                        if (url != null) {
+                            return url;
+                        }
+                    }
                 }
             }
+            url = new URL(helpSets.get(0).getHelpSetURL().toString().replace("jhelpset.hs", "ScilabErrorPage.html"));
+        } catch (MalformedURLException ex) { }
+
+        return url;
+    }
+
+    /**
+     * Try to transform an address such as scilab://scilab.help/bvode into a conform URL
+     * pointing to the corresponding file in using jar: protocol.
+     * E.g. scilab://scilab.help/bvode will be transform into
+     * jar:file:SCI/modules/helptools/jar/scilab_fr_FR_help.jar!/scilab_fr_FR_help/bvode.html
+     * (where SCI has the good value)
+     * @param address the address to convert
+     * @return the correct address in using jar:// protocol
+     **/
+    public URL resolvScilabLink(HyperlinkEvent event) {
+        int pos = SCILAB_PROTO.length();
+        String addr = event.getDescription();
+        addr = addr.trim().replaceAll("\\\\", "/");
+        addr = addr.substring(pos);
+
+        pos = addr.indexOf("/");
+        String location;
+        String path = "";
+        if (pos != -1) {
+            location = addr.substring(0, pos);
+            if (pos != addr.length()) {
+                path = addr.substring(pos + 1);
+            }
+        } else {
+            return getURLFromID(addr);
+        }
+
+        String[] splitLoc = location.split("\\.");
+        String mainLocation = null;
+        String subLocation = null;
+
+        if (splitLoc.length >= 1) {
+            mainLocation = splitLoc[0];
+        }
+        if (splitLoc.length >= 2) {
+            subLocation = splitLoc[1];
+        }
+
+        if (subLocation.equals("help")) {
+            if (mainLocation.equals("scilab")) {
+                return getURLFromID(path);
+            } else {
+                return getURLFromID(mainLocation, path);
+            }
+        } else if (subLocation.equals("exec")) {
+            if (!mainLocation.equals("scilab")) {
+                exec(getToolboxPath() + "/" + path);
+            } else {
+                exec(SCI + "/modules/" + path);
+            }
+        } else if (subLocation.equals("demos")) {
+            if (!mainLocation.equals("scilab")) {
+                exec(getToolboxPath() + "/demos/" + path + ".sce");
+            } else {
+                exec(SCI + "/modules/" + path + ".sce");
+            }
+        } else if (subLocation.equals("execexample")) {
+            execExample(event.getSourceElement().getParentElement().getParentElement().getParentElement().getElement(0).getElement(0));
+        } else if (subLocation.equals("editexample")) {
+            editExample(event.getSourceElement().getParentElement().getParentElement().getParentElement().getElement(0).getElement(0));
+        }
+
+        return null;
+    }
+
+    /**
+     * @return the path of the toolbox
+     */
+    public String getToolboxPath() {
+        try {
+            URL url = ((JarURLConnection) x.getCurrentURL().openConnection()).getJarFileURL();
+            return new File(url.toURI()).getParentFile().getParent();
+        } catch (Exception e) { }
+
+        return "";
+    }
+
+    /**
+     * Execute the code in example
+     * @param pre the preformatted Element containing Scilab's code
+     */
+    public static void execExample(Element pre) {
+        String code = getCode(pre);
+        ScilabConsole.getConsole().getAsSimpleConsole().sendCommandsToScilab(code, true /* display */, true /* store in history */);
+    }
+
+    /**
+     * Edit the code in example
+     * @param pre the preformatted Element containing Scilab's code
+     */
+    public static void editExample(Element pre) {
+        edit(getCode(pre));
+    }
+
+    /**
+     * Edit the code
+     * @param code the code to edit
+     */
+    private static void edit(String code) {
+        try {
+            /* Dynamic load of the SciNotes class.
+             * This is done to avoid a cyclic dependency on gui <=> scinotes
+             */
+            Class scinotesClass = Class.forName("org.scilab.modules.scinotes.SciNotes");
+            Class[] arguments = new Class[] {String.class};
+            Method method = scinotesClass.getMethod("scinotesWithText", arguments);
+            method.invoke(scinotesClass, new Object[]{code});
+
+        } catch (ClassNotFoundException e) {
+            System.err.println("Could not find SciNotes class");
+            e.printStackTrace();
+        } catch (SecurityException e) {
+            System.err.println("Security error: Could not access to SciNotes class");
+            e.printStackTrace();
+        } catch (NoSuchMethodException e) {
+            System.err.println("Could not access to scinotesWithText method from object SciNotes");
+            e.printStackTrace();
+        } catch (IllegalArgumentException e) {
+            System.err.println("Wrong argument used with scinotesWithText method from object SciNotes");
+            e.printStackTrace();
+        } catch (IllegalAccessException e) {
+            System.err.println("Illegal access with scinotesWithText method from object SciNotes");
+            e.printStackTrace();
+        } catch (InvocationTargetException e) {
+            System.err.println("Error of invocation with scinotesWithText method from object SciNotes");
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * @param pre the preformatted Element containing Scilab's code
+     * @return the code
+     */
+    private static String getCode(Element pre) {
+        int size = pre.getElementCount();
+        Document doc = pre.getDocument();
+        StringBuilder buffer = new StringBuilder();
+        for (int i = 0; i < size; i++) {
+            Element line = pre.getElement(i);
+            int ssize = line.getElementCount();
+            for (int j = 0; j < ssize; j++) {
+                Element content = line.getElement(j);
+                if (content.isLeaf()) {
+                    try {
+                        buffer.append(doc.getText(content.getStartOffset(), content.getEndOffset() - content.getStartOffset()));
+                    } catch (BadLocationException e) { }
+                }
+            }
+        }
+
+        return buffer.toString().trim();
+    }
+
+    /**
+     * Execute a file given by its path
+     * @param the file path
+     */
+    public void exec(String path) {
+        String cmd = "exec('" + path + "', -1)";
+        try {
+            ScilabConsole.getConsole().getAsSimpleConsole().sendCommandsToScilab(cmd, true, false);
+        } catch (NoClassDefFoundError e) {
+            ScilabModalDialog.show((Tab) SwingUtilities.getAncestorOfClass(Tab.class, x), Messages.gettext("Could not find the console nor the InterpreterManagement."));
         }
     }
 
@@ -94,7 +349,6 @@ public class SwingScilabHelpBrowserViewer extends BasicContentViewerUI {
         this.createPopupMenu(c);
     }
 
-
     /**
      * Retrieve the field "html" from BasicContentViewerUI and change
      * permission (it is private by default)
@@ -160,40 +414,11 @@ public class SwingScilabHelpBrowserViewer extends BasicContentViewerUI {
                 if (selection == null) {
                     ScilabHelpBrowser.getHelpBrowser().getInfoBar().setText(Messages.gettext("No text selected"));
                 } else {
-                    try {
-                        /* Dynamic load of the SciNotes class.
-                         * This is done to avoid a cyclic dependency on gui <=> scinotes
-                         */
-                        Class scinotesClass = Class.forName("org.scilab.modules.scinotes.SciNotes");
-                        Class[] arguments = new Class[] {String.class};
-                        Method method = scinotesClass.getMethod("scinotesWithText", arguments);
-                        method.invoke(scinotesClass, new Object[]{selection});
-
-                    } catch (ClassNotFoundException e) {
-                        System.err.println("Could not find SciNotes class");
-                        e.printStackTrace();
-                    } catch (SecurityException e) {
-                        System.err.println("Security error: Could not access to SciNotes class");
-                        e.printStackTrace();
-                    } catch (NoSuchMethodException e) {
-                        System.err.println("Could not access to scinotesWithText method from object SciNotes");
-                        e.printStackTrace();
-                    } catch (IllegalArgumentException e) {
-                        System.err.println("Wrong argument used with scinotesWithText method from object SciNotes");
-                        e.printStackTrace();
-                    } catch (IllegalAccessException e) {
-                        System.err.println("Illegal access with scinotesWithText method from object SciNotes");
-                        e.printStackTrace();
-                    } catch (InvocationTargetException e) {
-                        System.err.println("Error of invocation with scinotesWithText method from object SciNotes");
-                        e.printStackTrace();
-                    }
+                    edit(selection);
                 }
             }
         };
 
-
-
         menuItem = new JMenuItem(Messages.gettext("Edit in the Scilab Text Editor"));
         try {
             Class scinotesClass = Class.forName("org.scilab.modules.scinotes.SciNotes");
index 3aab0dd..b7e28a2 100644 (file)
@@ -1,19 +1,22 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2008 - INRIA - Vincent Couvert
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
 
 package org.scilab.modules.gui.helpbrowser;
 
+import java.io.File;
+
 import javax.swing.SwingUtilities;
 
+import org.scilab.modules.commons.ScilabConstants;
 import org.scilab.modules.localization.Messages;
 import org.scilab.modules.gui.bridge.ScilabBridge;
 import org.scilab.modules.gui.bridge.window.SwingScilabWindow;
@@ -21,6 +24,7 @@ import org.scilab.modules.gui.bridge.tab.SwingScilabTab;
 import org.scilab.modules.gui.console.ScilabConsole;
 import org.scilab.modules.gui.dockable.ScilabDockable;
 import org.scilab.modules.gui.events.callback.ScilabCallBack;
+import org.scilab.modules.gui.bridge.helpbrowser.SwingScilabHelpBrowser;
 import org.scilab.modules.gui.menubar.MenuBar;
 import org.scilab.modules.gui.tab.ScilabTab;
 import org.scilab.modules.gui.tab.Tab;
@@ -39,193 +43,206 @@ import org.scilab.modules.gui.window.Window;
  */
 public class ScilabHelpBrowser extends ScilabDockable implements HelpBrowser {
 
-       private static final String MENUBARXMLFILE = System.getenv("SCI") + "/modules/gui/etc/helpbrowser_menubar.xml";
-
-       private static HelpBrowser instance;
-       
-       private static Tab helpTab;
-       
-       private SimpleHelpBrowser component;
-
-       /**
-        * Constructor
-        * @param helps help chapters and directories
-        * @param language Scilab current language
-        */
-       protected ScilabHelpBrowser(String[] helps, String language) {
-               component = ScilabBridge.createHelpBrowser(helps, language);
-       }
-
-       /**
-        * Creates a Scilab Help Browser
-        * @param helps help chapters and directories
-        * @param language Scilab current language
-        * @return the created Help Browser
-        */
-       public static HelpBrowser createHelpBrowser(String[] helps, String language) {
-               if (instance == null) {
-                       
-                       instance = new ScilabHelpBrowser(helps, language);
-                       
-                       if (ScilabConsole.isExistingConsole() && ScilabConsole.getConsole().getInfoBar() != null) {
-                               if (ScilabConsole.getConsole().getInfoBar().getText().equals(Messages.gettext("Loading help browser..."))) {
-                                       // An error occured
-                                       ScilabConsole.getConsole().getInfoBar().setText("");
-                                       return null;
-                               }
-                       }
-                       
-                       helpTab = ScilabTab.createTab(Messages.gettext("Help Browser"));
-                       helpTab.addMember(instance);
-                        /* Action when the Browser tab is closed */
-                       helpTab.setCallback(ScilabCallBack
-                                       .createCallback("org.scilab.modules.gui.bridge.CallScilabBridge.closeHelpBrowser", ScilabCallBack.JAVA_OUT_OF_XCLICK_AND_XGETMOUSE));
-                       
-                       MenuBar menubar = MenuBarBuilder.buildMenuBar(MENUBARXMLFILE);
-                       helpTab.addMenuBar(menubar);
-
-                       TextBox infobar = ScilabTextBox.createTextBox();
-                       helpTab.addInfoBar(infobar);
-
-                       Window helpWindow = ScilabWindow.createWindow();
-                       helpWindow.addTab(helpTab);
-
-                       /* Set the dimension / position of the help window */
-                       helpWindow.setPosition(ConfigManager.getHelpWindowPosition());
-                       helpWindow.setDims(ConfigManager.getHelpWindowSize());
-
-                       helpWindow.draw();
-
-               } else {
-                        SwingScilabWindow window = (SwingScilabWindow) SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, (SwingScilabTab) helpTab.getAsSimpleTab());
-                        window.setVisible(true);
-                        window.toFront();
-               }
-
-               return instance;
-       }
-
-       /**
-        * Get the Scilab Help Browser
-        * @return the console
-        */
-       public static HelpBrowser getHelpBrowser() {
-               if (instance == null) {
-                       instance = new ScilabHelpBrowser(null, "en_US");
-               }
-               return instance;
-       }
-       
-       /**
-        * Get the Scilab Help Browser (does not create it is not existing)
-        * @return the console
-        */
-       public static HelpBrowser getHelpBrowserWithoutCreation() {
-               return instance;
-       }
-       
-       /**
-        * Display the Help Browser
-        */
-       public void display() {
-               ScilabBridge.display(this);
-       }
-       
-       /**
-        * Display the help page for a specified keyword
-        * @param keyword the keyword
-        */
-       public void searchKeywork(String keyword) {
-               ScilabBridge.searchKeywork(this, keyword);
-       }
-       
-       /**
-        * Display the result of a full-text search for a specified word
-        * @param keyword the keyword
-        */
-       public void fullTextSearch(String keyword) {
-               ScilabBridge.fullTextSearch(this, keyword);
-       }
-
-       /**
-        * Close the HelpBrowser
-        */
-       public void close() {
-               ScilabBridge.close(this);
-               helpTab.close();
-               instance = null;
-       }
-
-
-       /**
-        * Not used
-        */
-       public void draw() {
-               throw new UnsupportedOperationException();
-       }
-
-       /**
-        * Gets this Bridge component object
-        * @return this Bridge component object
-        */
-       public SimpleHelpBrowser getAsSimpleHelpBrowser() {
-               return component;
-       }
-
-       /**
-        * Not used
-        * @return nothing
-        */
-       public Size getDims() {
-               throw new UnsupportedOperationException();
-       }
-
-       /**
-        * Not used
-        * @return nothing
-        */
-       public Position getPosition() {
-               throw new UnsupportedOperationException();
-       }
-
-       /**
-        * Not used
-        * @return nothing
-        */
-       public boolean isVisible() {
-               throw new UnsupportedOperationException();
-       }
-
-       /**
-        * Not used
-        * @param newSize not used
-        */
-       public void setDims(Size newSize) {
-               throw new UnsupportedOperationException();
-       }
-
-       /**
-        * Not used
-        * @param newPosition not used
-        */
-       public void setPosition(Position newPosition) {
-               throw new UnsupportedOperationException();
-       }
-
-       /**
-        * Not used
-        * @param newVisibleState not used
-        */
-       public void setVisible(boolean newVisibleState) {
-               throw new UnsupportedOperationException();
-       }
-       
-       /**
-        * Get associated InfoBar
-        * @return the infobar of the parent tab
-        * @see org.scilab.modules.gui.uielement.ScilabUIElement#getInfoBar()
-        */
-       public TextBox getInfoBar() {
-               return helpTab.getInfoBar();
-       }
+    private static final String SCI = ScilabConstants.SCI.getPath();
+    private static final String MENUBARXMLFILE = SCI + "/modules/gui/etc/helpbrowser_menubar.xml";
+
+    private static HelpBrowser instance;
+
+    private static Tab helpTab;
+
+    private SimpleHelpBrowser component;
+
+    /**
+     * Constructor
+     * @param helps help chapters and directories
+     * @param language Scilab current language
+     */
+    protected ScilabHelpBrowser(String[] helps, String language) {
+        component = ScilabBridge.createHelpBrowser(helps, language);
+    }
+
+    /**
+     * Creates a Scilab Help Browser
+     * @param helps help chapters and directories
+     * @param language Scilab current language
+     * @return the created Help Browser
+     */
+    public static HelpBrowser createHelpBrowser(String[] helps, String language) {
+        if (instance == null) {
+
+            instance = new ScilabHelpBrowser(helps, language);
+
+            if (ScilabConsole.isExistingConsole() && ScilabConsole.getConsole().getInfoBar() != null) {
+                if (ScilabConsole.getConsole().getInfoBar().getText().equals(Messages.gettext("Loading help browser..."))) {
+                    // An error occured
+                    ScilabConsole.getConsole().getInfoBar().setText("");
+                    return null;
+                }
+            }
+
+            helpTab = ScilabTab.createTab(Messages.gettext("Help Browser"));
+            helpTab.addMember(instance);
+            /* Action when the Browser tab is closed */
+            helpTab.setCallback(ScilabCallBack
+                                .createCallback("org.scilab.modules.gui.bridge.CallScilabBridge.closeHelpBrowser", ScilabCallBack.JAVA_OUT_OF_XCLICK_AND_XGETMOUSE));
+
+            MenuBar menubar = MenuBarBuilder.buildMenuBar(MENUBARXMLFILE);
+            helpTab.addMenuBar(menubar);
+
+            TextBox infobar = ScilabTextBox.createTextBox();
+            helpTab.addInfoBar(infobar);
+
+            Window helpWindow = ScilabWindow.createWindow();
+            helpWindow.addTab(helpTab);
+
+            /* Set the dimension / position of the help window */
+            helpWindow.setPosition(ConfigManager.getHelpWindowPosition());
+            helpWindow.setDims(ConfigManager.getHelpWindowSize());
+
+            helpWindow.draw();
+        } else {
+            SwingScilabWindow window = (SwingScilabWindow) SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, (SwingScilabTab) helpTab.getAsSimpleTab());
+            window.setVisible(true);
+            window.toFront();
+        }
+
+        return instance;
+    }
+
+    /**
+     * Display the home page
+     */
+    public static void startHomePage() {
+        if (instance != null) {
+            SwingScilabHelpBrowser browser = (SwingScilabHelpBrowser) ((ScilabHelpBrowser) instance).component;
+            try {
+                browser.displayHomePage();
+            } catch (Exception e) {
+                System.err.println("This error should not occured, please report it at bugzilla.scilab.org\n" + e);
+            }
+        }
+    }
+
+    /**
+     * Get the Scilab Help Browser
+     * @return the console
+     */
+    public static HelpBrowser getHelpBrowser() {
+        if (instance == null) {
+            instance = new ScilabHelpBrowser(null, "en_US");
+        }
+        return instance;
+    }
+
+    /**
+     * Get the Scilab Help Browser (does not create it is not existing)
+     * @return the console
+     */
+    public static HelpBrowser getHelpBrowserWithoutCreation() {
+        return instance;
+    }
+
+    /**
+     * Display the Help Browser
+     */
+    public void display() {
+        ScilabBridge.display(this);
+    }
+
+    /**
+     * Display the help page for a specified keyword
+     * @param keyword the keyword
+     */
+    public void searchKeywork(String keyword) {
+        ScilabBridge.searchKeywork(this, keyword);
+    }
+
+    /**
+     * Display the result of a full-text search for a specified word
+     * @param keyword the keyword
+     */
+    public void fullTextSearch(String keyword) {
+        ScilabBridge.fullTextSearch(this, keyword);
+    }
+
+    /**
+     * Close the HelpBrowser
+     */
+    public void close() {
+        ScilabBridge.close(this);
+        helpTab.close();
+        instance = null;
+    }
+
+    /**
+     * Not used
+     */
+    public void draw() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Gets this Bridge component object
+     * @return this Bridge component object
+     */
+    public SimpleHelpBrowser getAsSimpleHelpBrowser() {
+        return component;
+    }
+
+    /**
+     * Not used
+     * @return nothing
+     */
+    public Size getDims() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Not used
+     * @return nothing
+     */
+    public Position getPosition() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Not used
+     * @return nothing
+     */
+    public boolean isVisible() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Not used
+     * @param newSize not used
+     */
+    public void setDims(Size newSize) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Not used
+     * @param newPosition not used
+     */
+    public void setPosition(Position newPosition) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Not used
+     * @param newVisibleState not used
+     */
+    public void setVisible(boolean newVisibleState) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Get associated InfoBar
+     * @return the infobar of the parent tab
+     * @see org.scilab.modules.gui.uielement.ScilabUIElement#getInfoBar()
+     */
+    public TextBox getInfoBar() {
+        return helpTab.getInfoBar();
+    }
 }
diff --git a/scilab/modules/gui/tests/unit_tests/helpviewer_links.tst b/scilab/modules/gui/tests/unit_tests/helpviewer_links.tst
new file mode 100644 (file)
index 0000000..f3bad4b
--- /dev/null
@@ -0,0 +1,49 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - Calixte DENIZET 
+// 
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at    
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// <-- INTERACTIVE TEST -->
+
+tmpdir = TMPDIR + "/testlinks";
+mkdir(tmpdir);
+tmpdir = tmpdir + "/help";
+mkdir(tmpdir);
+tmpdir = tmpdir + "/en_US";
+mkdir(tmpdir);
+tmpfile = tmpdir + "/mytbxhelp.xml";
+mputl(["<?xml version=""1.0"" encoding=""UTF-8""?>"
+       "<refentry version=""5.0-subset Scilab"""
+       "xmlns=""http://docbook.org/ns/docbook"""
+       "xmlns:html=""http://www.w3.org/1999/xhtml"""
+       "xmlns:db=""http://docbook.org/ns/docbook"">"
+       "<refnamediv xml:id=""mytbx_foo"">"
+       "<refname>Mytbx_foo</refname>"
+       "<refpurpose>calculates foo</refpurpose>"
+       "</refnamediv>"
+       "<refsection>"
+       "<para>Firstly a link on <link type=""scilab"" linkend=""scilab.help/bvode"">bvode</link> in the Scilab Doc</para>"
+       "<para>Secondly a link on <link type=""scilab"" linkend=""mytbx.demos/mytbxdemo"">mytbxdemo</link> </para>"
+       "<para>Thirdly a link on <link type=""scilab"" linkend=""mytbx.exec/macros/fooexec.sce"">macros/fooexec.sce</link> (just an about) </para>"
+       "<para>Fourthly a link on <link type=""scilab"" linkend=""module_lycee.help/enlever"">enlever</link> in module_lycee toolbox (must be loaded before)</para>"
+       "<para>Fifthly a link on <link type=""scilab"" linkend=""scilab.help/invalidlink"">invalid link</link></para>"
+       "</refsection>"
+       "<programlisting role=""example""><![CDATA[" 
+       "plot3d() // should link on plot3d"
+       "]]></programlisting>"
+       "</refentry>"], tmpfile);
+jar = xmltojar(tmpdir, 'mytbx', 'en_US');
+tmpdir = TMPDIR + "/testlinks/demos";
+mkdir(tmpdir);
+tmpfile = tmpdir + "/mytbxdemo.sce";
+mputl("messagebox(""A demo from mytbxdemo.sce"");", tmpfile);
+tmpdir = TMPDIR + "/testlinks/macros";
+mkdir(tmpdir);
+tmpfile = tmpdir + "/fooexec.sce";
+mputl("about;", tmpfile);
+add_help_chapter('mytbx', TMPDIR + "/testlinks/jar")
+help('mytbx_foo')
\ No newline at end of file
index d8ed77a..ebb3a30 100644 (file)
@@ -9,6 +9,10 @@ body {
     background-repeat   : repeat-x;
 }
 
+.para {
+    padding-left: 10px;
+}
+
 .refname {
     color: #ff6c0a;
 }
@@ -137,6 +141,19 @@ ul.toc li {
     text-align: center;
 }
 
+.screen {
+    font-family: monospace;
+    font-size: 100%;
+    background-color:#FFFFFF;
+    border-color:#CCCCCC ;
+    border-style:solid;
+    border-width:2px medium;
+    width:80%;
+    color:#333333;
+    line-height:120%;
+    padding:10px;
+}
+
 /* Top and bottom navigation controls on manual pages --------------------- */
 div.manualnavbar {
     background-color: #E0E0E0;
diff --git a/scilab/modules/helptools/data/pages/ban_en_US.png b/scilab/modules/helptools/data/pages/ban_en_US.png
new file mode 100644 (file)
index 0000000..75d0992
Binary files /dev/null and b/scilab/modules/helptools/data/pages/ban_en_US.png differ
diff --git a/scilab/modules/helptools/data/pages/error.html b/scilab/modules/helptools/data/pages/error.html
new file mode 100644 (file)
index 0000000..2c523e3
--- /dev/null
@@ -0,0 +1,21 @@
+<html><head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <title>Error: Could not find the page</title>
+    <style type="text/css" media="all">
+      @import url("scilab_code.css");
+      @import url("xml_code.css");
+      @import url("c_code.css");
+      @import url("style.css");
+    </style>
+  </head>
+  <body>
+
+    <span class="path"><a href="index.html">Scilab manual</a> &gt;&gt; Error</span>
+
+    <br /><br />
+    <div class="info"></div>
+  <div class="refnamediv"><h1 class="refname">Error</h1>
+    <p class="refpurpose">The requested page could not be found.</p>
+    </div>
+  </body>
+</html>
diff --git a/scilab/modules/helptools/data/pages/homepage-en_US.html b/scilab/modules/helptools/data/pages/homepage-en_US.html
new file mode 100644 (file)
index 0000000..82e49d7
--- /dev/null
@@ -0,0 +1,61 @@
+<html><head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf8">
+    <title>scilab - Main script to start Scilab and miscellaneous
+    tools (GNU/Linux, Unix and Mac OS X)</title>
+    <style type="text/css" media="all">
+      @import url("scilab_code.css");
+      @import url("xml_code.css");
+      @import url("c_code.css");
+      @import url("style.css");
+    </style>
+  </head>
+  <body>
+<div align="center">
+<img src="ban_en_US.png" />
+</div>
+    <div class="manualnavbar" align="center">
+<a href="http://www.scilab.org/" class="ulink">Scilab Home page</a> | <a href="http://help.scilab.org/" class="ulink">Online documentation</a> | <a href="http://wiki.scilab.org/" class="ulink">Wiki</a> | <a href="http://bugzilla.scilab.org/" class="ulink">Bug tracker</a> | <a href="http://forge.scilab.org/" class="ulink">Forge</a> | <a href="http://lists.scilab.org/" class="ulink">Mailing list archives</a> | <a href="http://atoms.scilab.org/" class="ulink">ATOMS</a>
+      <hr />
+    </div>
+
+
+    <span class="path"><a href="index.html">Scilab manual</a> &gt;&gt; Homepage</span>
+
+    <br /><br />
+
+  <div class="refsection"><h3 class="title">What is new in Scilab 5.3.1 ?</h3>
+
+<p class="para">Performance and usuability improvements in the display of long values in the console</p>
+
+<p class="para"><a href="repmat.html">repmat</a> added a missing basic function.</p>
+
+<p class="para">TODO at release time + screenshot</p>
+
+</div>
+<hr width="50%" align="left"/>
+
+  <div class="refsection"><h3 class="title">Documentations and help</h3>
+
+<p class="para">This help is also available only on: <a href="http://help.scilab.org">http://help.scilab.org</a>. It provides some advanced features like comments, favorites, search engine, etc.</p>
+
+<p class="para">If you are new to Scilab, you can have a look to the <a href="scilab_keywords.html">Scilab's keyword help pages</a>.</p>
+
+
+<p class="para">The Scilab consortium provides some <a href="http://www.scilab.org/support/documentation/tutorials">documentations and tutorials</a>.</p>
+<p class="para">Many other documentations are also accessible through the <a href="http://www.scilab.org/support/documentation">Scilab portal</a>.</p>
+
+</div>
+<hr width="50%" align="left"/>
+
+<div class="refsection"><h3 class="title">Other ressources</h3>
+
+<p class="para"><a href="http://www.scilab.org/" class="ulink">Scilab Home page</a> - The hub to the Scilab websites</p>
+<p class="para"><a href="http://wiki.scilab.org/" class="ulink">Wiki</a> - Many documentations, tricks, etc</p>
+<p class="para"><a href="http://bugzilla.scilab.org/" class="ulink">Bug tracker</a> - Report bugs and wishes about Scilab</p>
+<p class="para"><a href="http://forge.scilab.org/" class="ulink">Forge</a> - Browse and publish Scilab modules</p>
+<p class="para"><a href="http://lists.scilab.org/" class="ulink">Mailing list archives</a> - Communicate and exchange with the community</p>
+<p class="para"><a href="http://atoms.scilab.org/" class="ulink">ATOMS</a> - Check packaged Scilab modules</p>
+
+</div>
+  </body>
+</html>
diff --git a/scilab/modules/helptools/demos/about.sce b/scilab/modules/helptools/demos/about.sce
new file mode 100644 (file)
index 0000000..891507c
--- /dev/null
@@ -0,0 +1 @@
+about();
\ No newline at end of file
diff --git a/scilab/modules/helptools/etc/SciDocConf.xml b/scilab/modules/helptools/etc/SciDocConf.xml
new file mode 100644 (file)
index 0000000..d77246a
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+
+<!-- id is used to identify the jar file (JavaHelp only) -->
+<scidoc id="scilab">
+
+  <!-- Version identifier -->
+  <!--version id="Scilab 5.3.0" /-->
+
+  <!-- Path to the CSS file for the doc style -->
+  <css doc="${SCI}/modules/helptools/data/css/style.css" />
+
+  <!-- These files are used to give the structure of a the documentation files -->
+  <templates javahelp="${SCI}/modules/helptools/data/template/template_javahelp.html"
+             html="${SCI}/modules/helptools/data/template/template_html.html"
+             chm="${SCI}/modules/helptools/data/template/template_chm.html"
+             web="${SCI}/modules/helptools/data/template/template_web.html" />
+
+  <!-- Path to the file containing all the Scilab's macros. This file is used with
+       the code parser to guess the kind of the keywords met. -->
+  <macros>
+    <file path="${SCI}/modules/helptools/data/configuration/scilab_macros.txt" />
+  </macros>
+
+  <!-- As above but for built-in functions -->
+  <builtins>
+    <file path="${SCI}/modules/helptools/data/configuration/scilab_primitives.txt" />
+  </builtins>
+
+  <!-- Useful to make link on Scilab's official documentation -->
+  <website url="http://help.scilab.org/docs/5.3.0/" />
+
+</scidoc>
diff --git a/scilab/modules/helptools/help/en_US/howtolinktoolbox.xml b/scilab/modules/helptools/help/en_US/howtolinktoolbox.xml
new file mode 100644 (file)
index 0000000..fe87c91
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ --><!-- This document was created with Syntext Serna Free. -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xml:lang="en" xml:id="how_to_link_toolbox_help">
+  <info>
+    <pubdate>January 2011</pubdate>
+  </info>
+  <refnamediv>
+    <refname>Link toolbox help with Scilab one</refname>
+    <refpurpose>How to make hyperlink in toolbox help pointing to Scilab&apos;s items</refpurpose>
+  </refnamediv>
+  <refsection>
+    <title>Description</title>
+    <para>Since Scilab 5.3.1, the hyperlinks in a toolbox help can be used to point on any help pages or to execute demos in the console.</para>
+    <para>Now you can link a demo <link type="scilab" linkend="scilab.demos/gui/demos/uicontrol_plot3d.dem">Uicontrol demo</link> or execute a script <link type="scilab" linkend="scilab.exec/helptools/demos/about.sce">about.sce</link></para>
+  </refsection>
+  <refsection>
+    <title>Details</title>
+    <itemizedlist>
+      <listitem>To link from two external modules, the syntax is: &lt;link type=&quot;scilab&quot; linkend=&quot;module_name.help/fun_in_module_name&quot;&gt;fun_in_module_name&lt;/link&gt; Usually, the name of the function is the id of the page.</listitem>
+      <listitem>To link from a external module to a Scilab function, the syntax is: &lt;link type=&quot;scilab&quot; linkend=&quot;scilab.help/bvode&quot;&gt;bvode&lt;/link&gt; Usually, the name of the function is the id of the page.</listitem>
+      <listitem>To enable the execution of a script, the syntax is: &lt;link type=&quot;scilab&quot; linkend=&quot;mytoolbox.exec/macros/fooexec.sce&quot;&gt;macros/fooexec.sce&lt;/link&gt; </listitem>
+      <listitem>To enable the execution of a demo, the syntax is: &lt;link type=&quot;scilab&quot; linkend=&quot;mytoolbox.demos/mydemo.dem&quot;&gt;My demo&lt;/link&gt; </listitem>
+    </itemizedlist>
+  </refsection>
+  <refsection>
+    <title>Examples</title>
+    <programlisting role="xml"><![CDATA[
+    <?xml version="1.0" encoding="UTF-8"?>
+    <refentry version="5.0-subset Scilab"
+              xmlns="http://docbook.org/ns/docbook"
+              xmlns:html="http://www.w3.org/1999/xhtml"
+              xmlns:db="http://docbook.org/ns/docbook">
+      <refnamediv xml:id="foo">
+        <refname>Foo</refname>
+        <refpurpose>calculates foo</refpurpose>
+      </refnamediv>
+      <refsection>
+        <!-- Link on Scilab's help -->
+        <para>Firstly a link on <link type="scilab" linkend="scilab.help/bvode">bvode</link> in the Scilab Doc</para>
+        <!-- Link on a demo, foodemo must be in toolbox_path/demos/ -->
+        <para>Secondly a link on <link type="scilab" linkend="mytoolbox.demos/foodemo">My demo</link></para>
+        <!-- the executed macro will be toolbox_path/macros/fooexec.sce -->
+        <para>Thirdly a link on <link type="scilab" linkend="mytoolbox.exec/macros/fooexec.sce">macros/fooexec.sce</link></para>
+        <!-- a link for erroneous links -->
+        <para>Fourthly a link on <link type="scilab" linkend="scilab.help/invalidlink">invalid link</link></para>
+      </refsection>
+
+      <programlisting role="example">
+        plot3d() // should link on plot3d
+      </programlisting>
+    </refentry>
+    ]]>
+    </programlisting>
+  </refsection>
+  <refsection>
+    <title>Authors</title>
+    <para>Calixte Denizet</para>
+  </refsection>
+</refentry>
index 05c1e58..1504263 100644 (file)
@@ -1580,14 +1580,20 @@ function master_section = x2f_tree_to_section( tree , offset )
         // title built with the directory name
         section_title = tree("title_default");
     end
-
+    
+    if (isfield(tree, "xml_id")) then
+        xml_id = tree("xml_id");
+    else
+        xml_id = "section_"+getmd5(strsubst(tree("path"),SCI,""),"string");
+    end
+    
     section_title  = strsubst(section_title,"&"  ,"&amp;");
     section_title  = strsubst(section_title,"""" ,"&quot;");
     section_title  = strsubst(section_title,">"  ,"&gt;");
     section_title  = strsubst(section_title,"<"  ,"&lt;");
 
     master_section = [];
-    master_section = [ master_section ; "<"+section_type+" xml:id=''section_"+getmd5(strsubst(tree("path"),SCI,""),"string")+"''>" ];
+    master_section = [ master_section ; "<"+section_type+" xml:id=''" + xml_id + "''>" ];
     master_section = [ master_section ; "<title>"+section_title+"</title>" ];
 
     // Loop on dir_
index 4c7847a..3c8b7df 100644 (file)
@@ -227,7 +227,7 @@ extern "C"
             {
                 doc->setWorkingLanguage((char *) language.c_str());
                 doc->setExportFormat((char *) exportFormat.c_str());
-
+               doc->setIsToolbox(Rhs == 4);
                 doc->process((char *) masterXML.c_str(), (char *) styleSheet.c_str());
             }
             else
index 1750988..a72c207 100644 (file)
@@ -43,7 +43,7 @@ import java.io.IOException;
 
     private AbstractScilabCodeHandler handler;
 
-    public ScilabLexer(String primFile, String macroFile) {
+    public ScilabLexer(String[] primFile, String[] macroFile) {
        if (commands == null) {
           commands = new HashSet();
           macros = new HashSet();
@@ -52,11 +52,21 @@ import java.io.IOException;
        }
     }
 
+    public ScilabLexer(String primFile, String macroFile) {
+       this(new String[]{primFile}, new String[]{macroFile});
+    }
+
     public ScilabLexer(Set primitives, Set macros) {
        commands = primitives;
        this.macros = macros;
     }
 
+    private void loadNames(String[] files, Set set) {
+       for (int i = 0; i < files.length; i++) {
+          loadNames(files[i], set);
+       }
+    }
+
     private void loadNames(String file, Set set) {
        if (file == null) {
           return;
index 5d1beaf..77e42b8 100644 (file)
@@ -45,12 +45,18 @@ public class CHMDocbookTagConverter extends HTMLDocbookTagConverter {
     /**
      * Constructor
      * @param inName the name of the input stream
+     * @param outName the output directory
      * @param primConf the file containing the primitives of Scilab
      * @param macroConf the file containing the macros of Scilab
-     * @param out the output stream
+     * @param template the template to use
+     * @param version the version
+     * @param imageDir the image directory (relative to outName)
+     * @param isToolbox is true when compile a toolbox' help
+     * @param urlBase the base url for external link
+     * @param language the language to use ('en_US', 'fr_FR', ...)
      */
-    public CHMDocbookTagConverter(String inName, String outName, String primConf, String macroConf, String template, String version, String imageDir, String language) throws IOException, SAXException {
-        super(inName, outName, primConf, macroConf, template, version, imageDir);
+    public CHMDocbookTagConverter(String inName, String outName, String[] primConf, String[] macroConf, String template, String version, String imageDir, boolean isToolbox, String urlBase, String language) throws IOException, SAXException {
+        super(inName, outName, primConf, macroConf, template, version, imageDir, isToolbox, urlBase);
         this.outName = new File(outName).getCanonicalPath() + File.separator;
         this.language = language;
     }
index 639b507..03ce3e4 100644 (file)
@@ -36,6 +36,7 @@ import org.scilab.forge.scidoc.image.MathMLImageConverter;
 import org.scilab.forge.scidoc.image.SVGImageConverter;
 import org.scilab.forge.scidoc.scilab.ScilabLexer;
 import org.scilab.forge.scidoc.scilab.HTMLScilabCodeHandler;
+import org.scilab.forge.scidoc.scilab.AbstractScilabCodeHandler;
 import org.scilab.forge.scidoc.XML.XMLLexer;
 import org.scilab.forge.scidoc.XML.HTMLXMLCodeHandler;
 import org.scilab.forge.scidoc.c.CLexer;
@@ -54,6 +55,8 @@ public class HTMLDocbookTagConverter extends DocbookTagConverter implements Temp
     private int latexCompt;
     private String imageDir;
     private String outName;
+    private String urlBase;
+    private boolean linkToTheWeb;
     private boolean hasExamples;
     private int warnings;
     private int nbFiles;
@@ -79,20 +82,25 @@ public class HTMLDocbookTagConverter extends DocbookTagConverter implements Temp
     protected String refpurpose = "";
     protected String refname = "";
     protected String version;
-
+    protected String appendToProgramListing;
+    protected String prependToProgramListing;
     protected String currentId;
 
     protected String indexFilename = "index" /*UUID.randomUUID().toString()*/ + ".html";
 
     /**
      * Constructor
-     * @param in the input stream
      * @param inName the name of the input stream
+     * @param outName the output directory
      * @param primConf the file containing the primitives of Scilab
      * @param macroConf the file containing the macros of Scilab
-     * @param out the output stream
+     * @param template the template to use
+     * @param version the version
+     * @param imageDir the image directory (relative to outName)
+     * @param isToolbox is true when compile a toolbox' help
+     * @param urlBase the base url for external link
      */
-    public HTMLDocbookTagConverter(String inName, String outName, String primConf, String macroConf, String template, String version, String imageDir) throws IOException, SAXException {
+    public HTMLDocbookTagConverter(String inName, String outName, String[] primConf, String[] macroConf, String template, String version, String imageDir, boolean isToolbox, String urlBase) throws IOException, SAXException {
         super(inName);
 
         this.version = version;
@@ -104,6 +112,27 @@ public class HTMLDocbookTagConverter extends DocbookTagConverter implements Temp
         tree = resolver.getTree();
         mapTreeId = resolver.getMapTreeId();
         scilabLexer = new ScilabLexer(primConf, macroConf);
+        this.urlBase = urlBase;
+        this.linkToTheWeb = urlBase != null && !urlBase.equals("scilab://");
+        if (isToolbox) {// we generate a toolbox's help
+            HTMLScilabCodeHandler.setLinkWriter(new AbstractScilabCodeHandler.LinkWriter() {
+                    public String getLink(String id) {
+                        String link = mapId.get(id);
+                        if (link == null) {
+                            return HTMLDocbookTagConverter.this.urlBase + id;
+                        } else {
+                            return link;
+                        }
+                    }
+                });
+        } else {// we generate Scilab's help
+            HTMLScilabCodeHandler.setLinkWriter(new AbstractScilabCodeHandler.LinkWriter() {
+                    public String getLink(String id) {
+                        return mapId.get(id);
+                    }
+                });
+        }
+
         xmlLexer = new XMLLexer();
         cLexer = new CLexer();
         javaLexer = new JavaLexer();
@@ -445,8 +474,9 @@ public class HTMLDocbookTagConverter extends DocbookTagConverter implements Temp
      * @throws SAXEception if an error is encountered
      */
     public String handleRefentry(Map<String, String> attributes, String contents) throws SAXException {
-        if (currentId == null) {
-            currentId = attributes.get("id");
+        String id = attributes.get("id");
+        if (id != null) {
+            currentId = id;
         }
         String fileName = currentId + ".html";
         createHTMLFile(currentId, fileName, refpurpose, contents);
@@ -710,7 +740,14 @@ public class HTMLDocbookTagConverter extends DocbookTagConverter implements Temp
         String role = attributes.get("role");
         String str;
         if (role == null) {
-            str = encloseContents("div", "programlisting", encloseContents("pre", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname, mapId), contents)));
+                String code = encloseContents("pre", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname), contents));
+                if (prependToProgramListing != null) {
+                    code = prependToProgramListing + code;
+                }
+                if (appendToProgramListing != null) {
+                    code += appendToProgramListing;
+                }
+                str = encloseContents("div", "programlisting", code);
         } else {
             if (role.equals("xml")) {
                 str = encloseContents("div", "programlisting", encloseContents("pre", "xmlcode", xmlLexer.convert(HTMLXMLCodeHandler.getInstance(), contents)));
@@ -719,7 +756,14 @@ public class HTMLDocbookTagConverter extends DocbookTagConverter implements Temp
             } else if (role.equals("java")) {
                 str = encloseContents("div", "programlisting", encloseContents("pre", "ccode", javaLexer.convert(HTMLCCodeHandler.getInstance(), contents)));
             } else {
-                str = encloseContents("div", "programlisting", encloseContents("pre", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname, mapId), contents)));
+                String code = encloseContents("pre", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname), contents));
+                if (prependToProgramListing != null) {
+                    code = prependToProgramListing + code;
+                }
+                if (appendToProgramListing != null) {
+                    code += appendToProgramListing;
+                }
+                str = encloseContents("div", "programlisting", code);
             }
         }
         if (id != null) {
@@ -794,7 +838,13 @@ public class HTMLDocbookTagConverter extends DocbookTagConverter implements Temp
             throw new SAXException("No linkend attribute in tag link");
         }
 
-        String id = mapId.get(link);
+        String type = attributes.get("type");
+        String id;
+        if (type != null && type.equals("scilab")) {
+            id = resolvScilabLink(link);
+        } else {
+            id = mapId.get(link);
+        }
         if (id == null) {
             warnings++;
             System.err.println("Warning (should be fixed): invalid internal link to " + link + " in " + currentFileName + "\nat line " + locator.getLineNumber());
@@ -805,6 +855,34 @@ public class HTMLDocbookTagConverter extends DocbookTagConverter implements Temp
     }
 
     /**
+     * Rewrite a link when its type is "scilab"
+     * @param link the link
+     * @return the modified link with protocol scilab:// for example
+     */
+    protected String resolvScilabLink(String link) {
+        int pos = link.indexOf("/");
+        if (pos == -1) {
+            return null;
+        }
+        String first = link.substring(0, pos);
+        String second = link.substring(pos + 1);
+        String[] toks = first.split("\\.");
+        if (toks == null || toks.length != 2) {
+            return null;
+        }
+
+        if (!linkToTheWeb) {
+            return urlBase + link;
+        } else {
+            if (toks[0].equals("scilab") && toks[1].equals("help")) {
+                return urlBase + second + ".html";
+            } else {
+                return "#";
+            }
+        }
+    }
+
+    /**
      * Handle an ulink
      * @param attributes the tag attributes
      * @param contents the tag contents
index 9244493..f95d175 100644 (file)
@@ -44,12 +44,19 @@ public class JavaHelpDocbookTagConverter extends HTMLDocbookTagConverter {
     /**
      * Constructor
      * @param inName the name of the input stream
+     * @param outName the output directory
      * @param primConf the file containing the primitives of Scilab
      * @param macroConf the file containing the macros of Scilab
-     * @param out the output stream
+     * @param template the template to use
+     * @param version the version
+     * @param imageDir the image directory (relative to outName)
+     * @param isToolbox is true when compile a toolbox' help
+     * @param urlBase the base url for external link
      */
-    public JavaHelpDocbookTagConverter(String inName, String outName, String primConf, String macroConf, String template, String version, String imageDir) throws IOException, SAXException {
-        super(inName, outName, primConf, macroConf, template, version, imageDir);
+    public JavaHelpDocbookTagConverter(String inName, String outName, String[] primConf, String[] macroConf, String template, String version, String imageDir, boolean isToolbox, String urlBase) throws IOException, SAXException {
+        super(inName, outName, primConf, macroConf, template, version, imageDir, isToolbox, urlBase);
+        prependToProgramListing = "<table border=\"0\" width=\"100%\"><tr><td width=\"98%\">";
+        appendToProgramListing = "</td><td valign=\"top\"><a href=\"scilab://scilab.execexample/\"><img src=\"ScilabExecute.png\" border=\"0\"/></a></td><td valign=\"top\"><a href=\"scilab://scilab.editexample/\"><img src=\"ScilabEdit.png\" border=\"0\"/></a></td><td></td></tr></table>";
     }
 
     /**
diff --git a/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/SciDocConfiguration.java b/scilab/modules/helptools/src/java/org/scilab/forge/scidoc/SciDocConfiguration.java
new file mode 100644 (file)
index 0000000..72761d7
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.forge.scidoc;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.File;
+import java.io.IOException;
+import java.util.regex.Matcher;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import org.scilab.modules.commons.ScilabConstants;
+
+/**
+ * @author Calixte Denizet
+ */
+public class SciDocConfiguration {
+
+    private static final String SCIVAR = "\\$\\{SCI\\}";
+    private static final String SCI = ScilabConstants.SCI.getPath();
+    private static final String CONF = SCI + "/modules/helptools/etc/SciDocConf.xml";
+    private static final String VERSION = SCI + "/Version.incl";
+    private static final String ERROR_READ = "Problem to read the file ";
+
+    private Document doc;
+
+    /**
+     * Default constructor
+     * @param filename the configuration file
+     */
+    public SciDocConfiguration() {
+        readDocument(CONF);
+    }
+
+    /**
+     * Read the document
+     * @param filename the configuration file
+     */
+    public void readDocument(String filename) {
+        try {
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            doc = factory.newDocumentBuilder().parse(new File(filename));
+        } catch (ParserConfigurationException e) {
+            System.err.println(ERROR_READ + filename);
+        } catch (SAXException e) {
+            System.err.println(ERROR_READ + filename);
+        } catch (IOException e) {
+            System.err.println(ERROR_READ + filename);
+        }
+    }
+
+    /**
+     * @return the file path
+     */
+    public String getCSS() {
+        String str = ((Element) doc.getDocumentElement().getElementsByTagName("css").item(0)).getAttribute("doc");
+        return str.replaceAll(SCIVAR, Matcher.quoteReplacement(SCI));
+    }
+
+    /**
+     * @param kind should be javahelp, chm, html or web
+     * @return the template file path
+     */
+    public String getTemplate(String kind) {
+        String str = ((Element) doc.getDocumentElement().getElementsByTagName("templates").item(0)).getAttribute(kind);
+        return str.replaceAll(SCIVAR, Matcher.quoteReplacement(SCI));
+    }
+
+    /**
+     * @return the Scilab's doc web url
+     */
+    public String getWebSiteURL() {
+        return ((Element) doc.getDocumentElement().getElementsByTagName("website").item(0)).getAttribute("url");
+    }
+
+    /**
+     * @return the path of the file containing Scilab macros
+     */
+    public String[] getMacros() {
+        return getPathList("macros");
+    }
+
+    /**
+     * @return the path of the file containing Scilab primitives
+     */
+    public String[] getBuiltins() {
+        return getPathList("builtins");
+    }
+
+    /**
+     * @param kind should be "macros" or "builtins"
+     * @return the path of the file containing Scilab macros or built-in function.
+     */
+    private String[] getPathList(String kind) {
+        Element macros = (Element) doc.getDocumentElement().getElementsByTagName(kind).item(0);
+        NodeList pathList = macros.getElementsByTagName("file");
+        String[] paths = new String[pathList.getLength()];
+        for (int i = 0; i < paths.length; i++) {
+            paths[i] = ((Element) pathList.item(i)).getAttribute("path").replaceAll(SCIVAR, Matcher.quoteReplacement(SCI));
+        }
+
+        return paths;
+    }
+
+    /**
+     * @return the version string
+     */
+    public String getVersion() {
+        String str = null;
+        NodeList list = doc.getDocumentElement().getElementsByTagName("version");
+        if (list != null && list.getLength() > 0) {
+            Element el = (Element) list.item(0);
+            if (el != null) {
+                str = el.getAttribute("id");
+            }
+        }
+
+        return getVersion(str);
+    }
+
+    /**
+     * Get the version in Version.incl if ver==null or ver=="".
+     * @param ver the actual version
+     * @return the version in Version.incl
+     */
+    private static String getVersion(String ver) {
+        String ret = "";
+        if (ver == null || ver.isEmpty()) {
+            try {
+                BufferedReader reader = new BufferedReader(new FileReader(VERSION));
+                ret = reader.readLine().split("=")[1];
+                reader.close();
+            } catch (IOException e) {
+                System.err.println(e);
+            }
+        } else {
+            ret = ver;
+        }
+
+        return ret;
+    }
+}
index f2a63af..07edc82 100644 (file)
@@ -34,17 +34,16 @@ import org.scilab.forge.scidoc.external.HTMLSVGHandler;
 public final class SciDocMain {
 
     private static final String SCI = ScilabConstants.SCI.getPath();
-    private static final String VERSION = SCI + "/Version.incl";
 
-    private String input;
     private String outputDirectory;
     private String language;
     private String format;
     private String template;
-    private String sciprim;
-    private String scimacro;
     private String version;
     private String imagedir;
+    private String[] sciprim;
+    private String[] scimacro;
+    private boolean isToolbox;
 
     /**
      * Set the directory where files must be exported
@@ -74,6 +73,13 @@ public final class SciDocMain {
     }
 
     /**
+     * @param isToolbox must be true if we compile a toolbox doc
+     */
+    public void setIsToolbox(boolean isToolbox) {
+        this.isToolbox = isToolbox;
+    }
+
+    /**
      * Defines the export format
      * @param format the format (among the list CHM, HTML, PDF, JH, PS)
      */
@@ -81,95 +87,42 @@ public final class SciDocMain {
         this.format = format;
     }
 
-    public static void main(String[] args) {
-        SciDocMain sciDoc = new SciDocMain();
-        sciDoc.buildDocumentationCommandLine(args);
-    }
-
-    public void buildDocumentationCommandLine(String[] args) {
-        Map<String, String> map = parseCommandLine(args);
-        if (map.containsKey("help")) {
-            System.out.println("Usage scidoc [OPTION]... file");
-            System.out.println("SciDoc is a tool to generate html, chm or javahelp files from DocBook");
-            System.out.println("");
-            System.out.println("-input        Input DocBook file");
-            System.out.println("-output       The output directory");
-            System.out.println("-template     A template file used for the generation");
-            System.out.println("-imagedir     The directory which will contain the generated images");
-            System.out.println("              the path is relative to output");
-            System.out.println("-javahelp     No expected argument, just precise the kind of output");
-            System.out.println("-html         No expected argument, just precise the kind of output (default)");
-            System.out.println("-web          No expected argument, just precise the kind of output");
-            System.out.println("-sciprim      A file containing the list of the Scilab primitives");
-            System.out.println("-scimacro     A file containing the list of the Scilab macros");
-            System.out.println("-version      A string with the version of Scilab");
-            System.out.println("");
-            System.out.println("Report bugs on: <http://bugzilla.scilab.org>");
-            System.out.println("Project page: <http://forge.scilab.org/index.php/p/scidoc>");
-            return;
-        }
-
-        if (!map.containsKey("input")) {
-            System.err.println("No input file");
-            System.err.println("Use the option -help");
-            return;
-        }
-
-        if (!map.containsKey("template")) {
-            System.err.println("No template to generate files");
-            System.err.println("Use the option -help");
-            return;
-        }
-
-        if (!map.containsKey("imagedir")) {
-            System.err.println("No image directory specified");
-            System.err.println("Use the option -help");
-            return;
-        }
-
-        input = map.get("input");
-        outputDirectory = map.get("output");
-        if (outputDirectory == null || outputDirectory.length() == 0) {
-            outputDirectory = ".";
-        }
-        template = map.get("template");
-        sciprim = map.get("sciprim");
-        scimacro = map.get("scimacro");
-        version = map.get("version");
-        imagedir = map.get("imagedir");
-
-                process(input, "");
-    }
-
     /* Stylesheet is useless and just kept to keep the consistency with
      * builddoc V1 */
     public String process(String sourceDoc, String styleSheet)  {
-        template = SCI + "/modules/helptools/data/template/template_" + format.toLowerCase() + ".html";
+        SciDocConfiguration conf = new SciDocConfiguration();
+        template = conf.getTemplate(format.toLowerCase());
         /* TODO: make this file generated at build time of Scilab */
-        sciprim = SCI + "/modules/helptools/data/configuration/scilab_primitives.txt";
-        scimacro = SCI + "/modules/helptools/data/configuration/scilab_macros.txt";
-        version = getVersion(version);
+        sciprim = conf.getBuiltins();
+        scimacro = conf.getMacros();
+        version = conf.getVersion();
         imagedir = ".";//the path must be relative to outputDirectory
 
-
         if (!new File(sourceDoc).isFile()) {
             System.err.println("Could not find master document: " + sourceDoc);
-                        return null;
+            return null;
         }
 
         if (!new File(template).isFile()) {
             System.err.println("Could not find template document: " + template);
-                        return null;
+            return null;
         }
 
         try {
             DocbookTagConverter converter = null;
+            String urlBase = null;
+
             if (format.equalsIgnoreCase("javahelp")) {
-                converter = new JavaHelpDocbookTagConverter(sourceDoc, outputDirectory, sciprim, scimacro, template, version, imagedir);
-            } else if (format.equalsIgnoreCase("html") || format.equalsIgnoreCase("web")) {
-                converter = new HTMLDocbookTagConverter(sourceDoc, outputDirectory, sciprim, scimacro, template, version, imagedir);
-            } else if (format.equalsIgnoreCase("chm")) {
-                converter = new CHMDocbookTagConverter(sourceDoc, outputDirectory, sciprim, scimacro, template, version, imagedir, language);
+                converter = new JavaHelpDocbookTagConverter(sourceDoc, outputDirectory, sciprim, scimacro, template, version, imagedir, isToolbox, "scilab://");
+            } else {
+                if (isToolbox) {
+                    urlBase = conf.getWebSiteURL() + language + "/";
+                }
+                if (format.equalsIgnoreCase("html") || format.equalsIgnoreCase("web")) {
+                    converter = new HTMLDocbookTagConverter(sourceDoc, outputDirectory, sciprim, scimacro, template, version, imagedir, isToolbox, urlBase);
+                } else if (format.equalsIgnoreCase("chm")) {
+                    converter = new CHMDocbookTagConverter(sourceDoc, outputDirectory, sciprim, scimacro, template, version, imagedir, isToolbox, urlBase, language);
+                }
             }
 
             converter.registerExternalXMLHandler(new HTMLMathMLHandler(outputDirectory, imagedir));
@@ -179,8 +132,15 @@ public final class SciDocMain {
             Helpers.copyFile(new File(SCI + "/modules/helptools/data/css/xml_code.css"), new File(outputDirectory + "/xml_code.css"));
             Helpers.copyFile(new File(SCI + "/modules/helptools/data/css/c_code.css"), new File(outputDirectory + "/c_code.css"));
             Helpers.copyFile(new File(SCI + "/modules/helptools/data/css/style.css"), new File(outputDirectory + "/style.css"));
+            Helpers.copyFile(new File(SCI + "/modules/gui/images/icons/media-playback-start.png"), new File(outputDirectory + "/ScilabExecute.png"));
+            Helpers.copyFile(new File(SCI + "/modules/gui/images/icons/accessories-text-editor.png"), new File(outputDirectory + "/ScilabEdit.png"));
             if (format.equalsIgnoreCase("javahelp")) {
-                BuildJavaHelp.buildJavaHelp(outputDirectory, language); // replace en_US by language
+                if (!isToolbox) {
+                    Helpers.copyFile(new File(SCI + "/modules/helptools/data/pages/error.html"), new File(outputDirectory + "/ScilabErrorPage.html"));
+                    Helpers.copyFile(new File(SCI + "/modules/helptools/data/pages/homepage-en_US.html"), new File(outputDirectory + "/ScilabHomePage.html"));
+                    Helpers.copyFile(new File(SCI + "/modules/helptools/data/pages/ban_en_US.png"), new File(outputDirectory + "/ban_en_US.png"));
+                }
+                BuildJavaHelp.buildJavaHelp(outputDirectory, language);
             }
 
         } catch (Exception e) {
@@ -190,65 +150,4 @@ public final class SciDocMain {
 
         return outputDirectory;
     }
-
-    /**
-     * Get the version in Version.incl if ver==null.
-     * @param ver the actual version
-     * @return the version in Version.incl
-     */
-    private static String getVersion(String ver) {
-        String ret = "";
-        if (ver == null) {
-            try {
-                BufferedReader reader = new BufferedReader(new FileReader(VERSION));
-                ret = reader.readLine().split("=")[1];
-                reader.close();
-            } catch (IOException e) { }
-        } else {
-            ret = ver;
-        }
-
-        return ret;
-    }
-
-    /**
-     * Parse the command line
-     * @param args the command line arguments
-     * @return a map argsname-&gt;argsvalue
-     */
-    private static Map<String, String> parseCommandLine(String[] args) {
-        String option = null;
-        boolean in = false;
-        Map<String, String> map = new HashMap();
-        for (int i = 0; i < args.length; i++) {
-            if (args[i].length() >= 2 && args[i].charAt(0) == '-') {
-                if (option != null) {
-                    map.put(option, "");
-                    option = null;
-                    option = args[i];
-                }
-                if (args[i].charAt(1) == '-') {
-                    option = args[i].substring(2);
-                } else {
-                    option = args[i].substring(1);
-                }
-            } else {
-                if (option != null) {
-                    map.put(option, args[i]);
-                    option = null;
-                } else if (!in) {
-                    map.put("input", args[i]);
-                    in = true;
-                } else {
-                    System.err.println("Not an argument " + args[i]);
-                    return null;
-                }
-            }
-        }
-        if (option != null) {
-            map.put(option, "");
-        }
-
-        return map;
-    }
 }
index d264bd6..f014912 100644 (file)
@@ -19,120 +19,140 @@ public abstract class AbstractScilabCodeHandler {
     /**
      * Handle default: when a char sequence is unidentified
      * @param seq the sequence to append
-     */  
+     */
     public void handleDefault(String seq) throws IOException { }
 
     /**
      * Handle operator: '+', '/', '*', ...
      * @param seq the sequence to append
-     */  
+     */
     public void handleOperator(String seq) throws IOException { }
 
     /**
      * Handle open/close: '(', ')', '[', ']', ...
      * @param seq the sequence to append
-     */  
+     */
     public void handleOpenClose(String seq) throws IOException { }
 
     /**
-     * Handle function keywords: 'function' or 'endfunction' 
+     * Handle function keywords: 'function' or 'endfunction'
      * @param seq the sequence to append
-     */  
+     */
     public void handleFKeywords(String seq) throws IOException { }
 
     /**
      * Handle structure keywords: 'if', 'for', ...
      * @param seq the sequence to append
-     */  
+     */
     public void handleSKeywords(String seq) throws IOException { }
 
     /**
      * Handle control keywords: 'abort', 'return', ...
      * @param seq the sequence to append
-     */  
+     */
     public void handleCKeywords(String seq) throws IOException { }
 
     /**
      * Handle contants: '%pi', '%e', ...
      * @param seq the sequence to append
-     */  
+     */
     public void handleConstants(String seq) throws IOException { }
 
     /**
      * Handle command: 'sin', 'cos', ...
      * @param seq the sequence to append
-     */  
+     */
     public void handleCommand(String seq) throws IOException { }
 
     /**
      * Handle macro: 'cosh', 'sinh', ...
      * @param seq the sequence to append
-     */  
+     */
     public void handleMacro(String seq) throws IOException { }
 
     /**
      * Handle function identifier which appears in the code
      * @param seq the sequence to append
-     */  
+     */
     public void handleFunctionId(String seq) throws IOException { }
 
     /**
      * Handle function identifier: 'function identifier(...)'
      * @param seq the sequence to append
-     */  
+     */
     public void handleFunctionIdDecl(String seq) throws IOException { }
 
     /**
      * Handle a valid scilab identifier
      * @param seq the sequence to append
-     */  
+     */
     public void handleId(String seq) throws IOException { }
 
     /**
      * Handle in/out args: 'function [...,out,...]=id(...,in,...)'
      * @param seq the sequence to append
-     */  
+     */
     public void handleInputOutputArgsDecl(String seq) throws IOException { }
 
     /**
      * Handle in/out args which appears in the code
      * @param seq the sequence to append
-     */  
+     */
     public void handleInputOutputArgs(String seq) throws IOException { }
 
     /**
      * Handle number: 123, 123.4, 123e4...
      * @param seq the sequence to append
-     */  
+     */
     public void handleNumber(String seq) throws IOException { }
 
     /**
      * Handle special: '$', ':', '..' (break operator)
      * @param seq the sequence to append
-     */  
+     */
     public void handleSpecial(String seq) throws IOException { }
 
     /**
      * Handle string: "hello world"
      * @param seq the sequence to append
-     */  
+     */
     public void handleString(String seq) throws IOException { }
 
     /**
      * Handle nothing: when no particular formatting is required
      * @param seq the sequence to append
-     */  
+     */
     public void handleNothing(String seq) throws IOException { }
 
     /**
      * Handle field: 'foo.bar'
      * @param seq the sequence to append
-     */  
+     */
     public void handleField(String seq) throws IOException { }
 
     /**
      * Handle comment: '// comments...'
      * @param seq the sequence to append
-     */  
+     */
     public void handleComment(String seq) throws IOException { }
+
+
+    /**
+     * Inner class to have different way to handle links
+     */
+    public static class LinkWriter {
+
+       /**
+        * Default Constructor
+        */
+       public LinkWriter() { }
+       
+        /**
+         * @param id the id
+         * @return the modified link
+         */
+        public String getLink(String id) {
+            return id;
+        }
+    }
 }
index fe76217..d2b3c7e 100644 (file)
@@ -21,20 +21,32 @@ public class HTMLScilabCodeHandler extends AbstractScilabCodeHandler {
 
     private static final int BUFCAPACITY = 8192;
     private static HTMLScilabCodeHandler handler = new HTMLScilabCodeHandler();
+    private static LinkWriter linkWriter = new LinkWriter();
 
     private List<String> undoc = new ArrayList();
 
-    protected Map<String, String> mapId;
     protected String currentCommand;
     protected Appendable buffer;
 
+    /**
+     * Default constructor
+     */
     protected HTMLScilabCodeHandler() {
         buffer = new StringBuilder(BUFCAPACITY);
     }
 
-    public static AbstractScilabCodeHandler getInstance(String currentCommand, Map<String, String> mapId) {
+    /**
+     * @param lw the LinkWriter to use to handle links
+     */
+    public static void setLinkWriter(LinkWriter lw) {
+        handler.linkWriter = lw;
+    }
+
+    /**
+     * @return an instance of HTMLScilabCodeHandler
+     */
+    public static AbstractScilabCodeHandler getInstance(String currentCommand) {
         handler.currentCommand = currentCommand;
-        handler.mapId = mapId;
         ((StringBuilder) handler.buffer).setLength(0);
         return handler;
     }
@@ -111,8 +123,8 @@ public class HTMLScilabCodeHandler extends AbstractScilabCodeHandler {
             buffer.append(seq);
             buffer.append("</span>");
         } else {
-            String link = mapId.get(seq);
-            if (link == null) {
+            String link = linkWriter.getLink(seq);
+            if (link == null) {// the command is not internal
                 buffer.append("<span class=\"scilabcommand\">");
                 buffer.append(seq);
                 buffer.append("</span>");
@@ -122,7 +134,7 @@ public class HTMLScilabCodeHandler extends AbstractScilabCodeHandler {
                 }
             } else {
                 buffer.append("<a class=\"scilabcommand\" href=\"");
-                buffer.append(mapId.get(seq));
+                buffer.append(link);
                 buffer.append("\">");
                 buffer.append(seq);
                 buffer.append("</a>");
@@ -139,7 +151,7 @@ public class HTMLScilabCodeHandler extends AbstractScilabCodeHandler {
             buffer.append(seq);
             buffer.append("</span>");
         } else {
-            String link = mapId.get(seq);
+            String link = linkWriter.getLink(seq);
             if (link == null) {
                 buffer.append("<span class=\"scilabmacro\">");
                 buffer.append(seq);
index c8904c5..40f1cc0 100644 (file)
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.4.3 on 17/11/10 08:08 */
+/* The following code was generated by JFlex 1.4.3 on 22/01/11 19:49 */
 
 //CHECKSTYLE:OFF
 
@@ -21,7 +21,7 @@ import java.io.IOException;
 /**
  * This class is a scanner generated by 
  * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
- * on 17/11/10 08:08 from the specification file
+ * on 22/01/11 19:49 from the specification file
  * <tt>scilab.jflex</tt>
  */
 public final class ScilabLexer {
@@ -93,19 +93,19 @@ public final class ScilabLexer {
     "\1\30\1\1\2\2\1\31\1\32\1\33\1\34\1\35"+
     "\1\36\2\37\1\40\1\37\1\41\1\42\1\43\1\1"+
     "\1\4\1\1\2\44\1\45\2\44\1\37\1\46\1\47"+
-    "\1\37\1\50\1\37\1\51\1\52\2\53\1\54\1\53"+
-    "\1\55\1\52\1\53\1\56\1\57\1\60\1\53\1\61"+
-    "\1\52\1\53\1\62\1\63\1\64\2\53\2\65\1\53"+
-    "\1\17\1\53\2\66\1\52\1\67\1\70\1\71\1\72"+
-    "\1\73\2\74\1\12\1\74\12\12\1\75\4\12\1\7"+
-    "\1\76\1\20\1\7\1\22\1\77\1\100\1\101\1\0"+
-    "\5\12\1\22\2\0\1\102\1\0\1\103\1\104\2\0"+
-    "\1\105\3\0\1\106\1\107\1\0\6\12\1\75\5\12"+
-    "\1\74\10\12\1\22\1\102\1\110\3\12\1\75\1\111"+
-    "\27\12\1\112\1\113\2\12\1\114";
+    "\1\37\1\50\1\37\1\51\1\52\1\53\1\37\1\54"+
+    "\1\52\1\37\1\55\1\56\1\57\1\37\1\60\1\52"+
+    "\1\37\1\61\1\62\1\63\2\37\2\64\1\37\1\17"+
+    "\1\37\2\65\1\52\1\66\1\67\1\70\1\71\1\72"+
+    "\2\73\1\12\1\73\12\12\1\74\4\12\1\7\1\75"+
+    "\1\20\1\7\1\22\1\76\1\77\1\100\1\0\5\12"+
+    "\1\22\2\0\1\101\1\0\1\102\1\103\5\0\1\104"+
+    "\1\105\1\0\6\12\1\74\5\12\1\73\10\12\1\22"+
+    "\1\101\1\106\3\12\1\74\1\107\27\12\1\110\1\111"+
+    "\2\12\1\112";
 
   private static int [] zzUnpackAction() {
-    int [] result = new int[233];
+    int [] result = new int[230];
     int offset = 0;
     offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
     return result;
@@ -195,27 +195,37 @@ public final class ScilabLexer {
     private boolean breakargs;
     private int whitesOnFirstLine;
     private int saveLexState;
-    
+
     private String id;
     private List<String> returnValues = new ArrayList();
     private List<String> argsValues = new ArrayList();
-    private List<String> localFun = new ArrayList();       
-    
+    private List<String> localFun = new ArrayList();
+
     private AbstractScilabCodeHandler handler;
 
-    public ScilabLexer(String primFile, String macroFile) {
+    public ScilabLexer(String[] primFile, String[] macroFile) {
        if (commands == null) {
-                 commands = new HashSet();
-         macros = new HashSet();
+          commands = new HashSet();
+          macros = new HashSet();
           loadNames(primFile, commands);
-                 loadNames(macroFile, macros);
+          loadNames(macroFile, macros);
        }
     }
 
+    public ScilabLexer(String primFile, String macroFile) {
+       this(new String[]{primFile}, new String[]{macroFile});
+    }
+
     public ScilabLexer(Set primitives, Set macros) {
        commands = primitives;
        this.macros = macros;
-    }    
+    }
+
+    private void loadNames(String[] files, Set set) {
+       for (int i = 0; i < files.length; i++) {
+          loadNames(files[i], set);
+       }
+    }
 
     private void loadNames(String file, Set set) {
        if (file == null) {
@@ -226,68 +236,68 @@ public final class ScilabLexer {
           input =  new BufferedReader(new FileReader(file));
           String line = null;
           while ((line = input.readLine()) != null) {
-            set.add(line);
+             set.add(line);
           }
        } catch (IOException e) {
-                 System.err.println(e);
+          System.err.println(e);
        }
        if (input != null) {
           try {
-            input.close();
+             input.close();
           } catch (IOException e) {
-                    System.err.println(e);
+             System.err.println(e);
           }
        }
     }
 
     private String trimEnd(String str) {
         int end = str.length() - 1;
-       int i = end;
+        int i = end;
         for (; i >= 0; i--) {
-          char c = str.charAt(i);      
-          if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
-             break;
-          }
+           char c = str.charAt(i);
+           if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
+              break;
+           }
+        }
+        if (i != end) {
+           return str.substring(0, i + 1);
         }
-       if (i != end) {
-          return str.substring(0, i + 1);
-       }
 
-       return str;
+        return str;
     }
 
     public String convert(AbstractScilabCodeHandler h, String code) {
         Reader reader = new StringReader(trimEnd(code));
-       String str = convert(h, reader, true);
-       try {
-         reader.close();
-       } catch (IOException e) { }
-       
-       return str;
+        String str = convert(h, reader, true);
+        try {
+          reader.close();
+        } catch (IOException e) { }
+
+        return str;
     }
 
     public String convert(AbstractScilabCodeHandler h, Reader code, boolean ret) {
         if (code == null) {
-          return null;
-       } else {
-          handler = h;
-          transposable = false;
+           return null;
+        } else {
+           handler = h;
+           transposable = false;
            breakargs = false;
-           breakstring = false;        
-          whitesOnFirstLine = 0;      
-          localFun.clear();
+           breakstring = false;
+           whitesOnFirstLine = 0;
+           localFun.clear();
            yyreset(code);
-          yybegin(CLEANFIRST);
+           yybegin(CLEANFIRST);
            try {
-              yylex();
-          } catch (IOException e) {
-              return null;
-          }
-          if (ret) {
-              return h.toString();
+               yylex();
+           } catch (IOException e) {
+               return null;
            }
-          return "";
-       }      
+           if (ret) {
+               return h.toString();
+           }
+           return "";
+        }
     }
 
 
@@ -800,14 +810,14 @@ public final class ScilabLexer {
                 case 63: 
                 case 65: 
                 case 67: 
-                case 68: zzIsFinal = true; zzNoLookAhead = true; zzState = 95; break zzForNext;
-                case 1: zzIsFinal = true; zzState = 96; break zzForNext;
-                case 4: zzIsFinal = true; zzNoLookAhead = true; zzState = 97; break zzForNext;
-                case 9: zzIsFinal = true; zzState = 98; break zzForNext;
+                case 68: zzIsFinal = true; zzNoLookAhead = true; zzState = 72; break zzForNext;
+                case 1: zzIsFinal = true; zzState = 87; break zzForNext;
+                case 4: zzIsFinal = true; zzNoLookAhead = true; zzState = 95; break zzForNext;
+                case 9: zzIsFinal = true; zzState = 96; break zzForNext;
                 case 59: 
-                case 62: zzIsFinal = true; zzState = 100; break zzForNext;
-                case 60: zzIsFinal = true; zzState = 101; break zzForNext;
-                default: zzIsFinal = true; zzState = 99; break zzForNext;
+                case 62: zzIsFinal = true; zzState = 98; break zzForNext;
+                case 60: zzIsFinal = true; zzState = 99; break zzForNext;
+                default: zzIsFinal = true; zzState = 97; break zzForNext;
               }
 
             case 10:
@@ -833,17 +843,17 @@ public final class ScilabLexer {
                 case 61: 
                 case 65: 
                 case 67: 
-                case 68: zzIsFinal = true; zzNoLookAhead = true; zzState = 95; break zzForNext;
-                case 1: zzIsFinal = true; zzState = 96; break zzForNext;
-                case 3: zzIsFinal = true; zzNoLookAhead = true; zzState = 102; break zzForNext;
-                case 6: zzIsFinal = true; zzNoLookAhead = true; zzState = 103; break zzForNext;
-                case 34: zzIsFinal = true; zzState = 105; break zzForNext;
-                case 37: zzIsFinal = true; zzNoLookAhead = true; zzState = 106; break zzForNext;
+                case 68: zzIsFinal = true; zzNoLookAhead = true; zzState = 72; break zzForNext;
+                case 1: zzIsFinal = true; zzState = 87; break zzForNext;
+                case 3: zzIsFinal = true; zzNoLookAhead = true; zzState = 100; break zzForNext;
+                case 6: zzIsFinal = true; zzNoLookAhead = true; zzState = 101; break zzForNext;
+                case 34: zzIsFinal = true; zzState = 103; break zzForNext;
+                case 37: zzIsFinal = true; zzNoLookAhead = true; zzState = 104; break zzForNext;
                 case 59: 
-                case 62: zzIsFinal = true; zzState = 107; break zzForNext;
-                case 60: zzIsFinal = true; zzState = 108; break zzForNext;
-                case 63: zzIsFinal = true; zzNoLookAhead = true; zzState = 109; break zzForNext;
-                default: zzIsFinal = true; zzState = 104; break zzForNext;
+                case 62: zzIsFinal = true; zzState = 105; break zzForNext;
+                case 60: zzIsFinal = true; zzState = 106; break zzForNext;
+                case 63: zzIsFinal = true; zzNoLookAhead = true; zzState = 107; break zzForNext;
+                default: zzIsFinal = true; zzState = 102; break zzForNext;
               }
 
             case 11:
@@ -871,50 +881,50 @@ public final class ScilabLexer {
                 case 61: 
                 case 65: 
                 case 67: 
-                case 68: zzIsFinal = true; zzNoLookAhead = true; zzState = 95; break zzForNext;
-                case 1: zzIsFinal = true; zzState = 96; break zzForNext;
+                case 68: zzIsFinal = true; zzNoLookAhead = true; zzState = 72; break zzForNext;
+                case 1: zzIsFinal = true; zzState = 87; break zzForNext;
                 case 59: 
-                case 62: zzIsFinal = true; zzState = 107; break zzForNext;
-                case 63: zzIsFinal = true; zzNoLookAhead = true; zzState = 109; break zzForNext;
-                case 7: zzIsFinal = true; zzNoLookAhead = true; zzState = 110; break zzForNext;
-                case 34: zzIsFinal = true; zzState = 112; break zzForNext;
-                case 60: zzIsFinal = true; zzState = 113; break zzForNext;
-                default: zzIsFinal = true; zzState = 111; break zzForNext;
+                case 62: zzIsFinal = true; zzState = 105; break zzForNext;
+                case 63: zzIsFinal = true; zzNoLookAhead = true; zzState = 107; break zzForNext;
+                case 7: zzIsFinal = true; zzNoLookAhead = true; zzState = 108; break zzForNext;
+                case 34: zzIsFinal = true; zzState = 110; break zzForNext;
+                case 60: zzIsFinal = true; zzState = 111; break zzForNext;
+                default: zzIsFinal = true; zzState = 109; break zzForNext;
               }
 
             case 12:
               switch (zzInput) {
-                case 1: zzIsFinal = true; zzState = 114; break zzForNext;
-                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 115; break zzForNext;
-                case 9: zzIsFinal = true; zzState = 116; break zzForNext;
-                case 59: zzIsFinal = true; zzState = 117; break zzForNext;
-                case 62: zzIsFinal = true; zzState = 118; break zzForNext;
-                default: zzIsFinal = true; zzNoLookAhead = true; zzState = 95; break zzForNext;
+                case 1: zzIsFinal = true; zzState = 112; break zzForNext;
+                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 113; break zzForNext;
+                case 9: zzIsFinal = true; zzState = 114; break zzForNext;
+                case 59: zzIsFinal = true; zzState = 115; break zzForNext;
+                case 62: zzIsFinal = true; zzState = 116; break zzForNext;
+                default: zzIsFinal = true; zzNoLookAhead = true; zzState = 72; break zzForNext;
               }
 
             case 13:
               switch (zzInput) {
                 case 59: zzIsFinal = true; zzNoLookAhead = true; zzState = 49; break zzForNext;
-                case 1: zzIsFinal = true; zzState = 120; break zzForNext;
-                default: zzIsFinal = true; zzNoLookAhead = true; zzState = 119; break zzForNext;
+                case 1: zzIsFinal = true; zzState = 118; break zzForNext;
+                default: zzIsFinal = true; zzNoLookAhead = true; zzState = 117; break zzForNext;
               }
 
             case 14:
               switch (zzInput) {
                 case 1: 
-                case 2: zzIsFinal = true; zzState = 121; break zzForNext;
+                case 2: zzIsFinal = true; zzState = 119; break zzForNext;
                 case 59: 
-                case 62: zzIsFinal = true; zzState = 122; break zzForNext;
-                default: zzIsFinal = true; zzNoLookAhead = true; zzState = 95; break zzForNext;
+                case 62: zzIsFinal = true; zzState = 120; break zzForNext;
+                default: zzIsFinal = true; zzNoLookAhead = true; zzState = 72; break zzForNext;
               }
 
             case 15:
               switch (zzInput) {
                 case 1: 
-                case 2: zzIsFinal = true; zzState = 124; break zzForNext;
+                case 2: zzIsFinal = true; zzState = 122; break zzForNext;
                 case 59: 
-                case 62: zzIsFinal = true; zzState = 125; break zzForNext;
-                default: zzIsFinal = true; zzNoLookAhead = true; zzState = 123; break zzForNext;
+                case 62: zzIsFinal = true; zzState = 123; break zzForNext;
+                default: zzIsFinal = true; zzNoLookAhead = true; zzState = 121; break zzForNext;
               }
 
             case 17:
@@ -926,7 +936,7 @@ public final class ScilabLexer {
             case 21:
               switch (zzInput) {
                 case 34: zzIsFinal = true; zzNoLookAhead = true; zzState = 42; break zzForNext;
-                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 126; break zzForNext;
+                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 124; break zzForNext;
                 default: break zzForAction;
               }
 
@@ -936,11 +946,11 @@ public final class ScilabLexer {
                 case 14: 
                 case 15: 
                 case 16: 
-                case 21: zzIsFinal = true; zzState = 127; break zzForNext;
-                case 17: zzIsFinal = true; zzState = 128; break zzForNext;
-                case 18: zzIsFinal = true; zzState = 129; break zzForNext;
-                case 19: zzIsFinal = true; zzState = 130; break zzForNext;
-                case 20: zzIsFinal = true; zzState = 131; break zzForNext;
+                case 21: zzIsFinal = true; zzState = 125; break zzForNext;
+                case 17: zzIsFinal = true; zzState = 126; break zzForNext;
+                case 18: zzIsFinal = true; zzState = 127; break zzForNext;
+                case 19: zzIsFinal = true; zzState = 128; break zzForNext;
+                case 20: zzIsFinal = true; zzState = 129; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -976,8 +986,8 @@ public final class ScilabLexer {
 
             case 25:
               switch (zzInput) {
-                case 46: zzIsFinal = true; zzState = 132; break zzForNext;
-                case 48: zzIsFinal = true; zzState = 133; break zzForNext;
+                case 46: zzIsFinal = true; zzState = 130; break zzForNext;
+                case 48: zzIsFinal = true; zzState = 131; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1013,7 +1023,7 @@ public final class ScilabLexer {
 
             case 26:
               switch (zzInput) {
-                case 29: zzIsFinal = true; zzState = 134; break zzForNext;
+                case 29: zzIsFinal = true; zzState = 132; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1049,8 +1059,8 @@ public final class ScilabLexer {
 
             case 27:
               switch (zzInput) {
-                case 45: zzIsFinal = true; zzState = 135; break zzForNext;
-                case 56: zzIsFinal = true; zzState = 136; break zzForNext;
+                case 45: zzIsFinal = true; zzState = 133; break zzForNext;
+                case 56: zzIsFinal = true; zzState = 134; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1121,9 +1131,9 @@ public final class ScilabLexer {
 
             case 29:
               switch (zzInput) {
-                case 20: zzIsFinal = true; zzState = 137; break zzForNext;
-                case 49: zzIsFinal = true; zzState = 138; break zzForNext;
-                case 58: zzIsFinal = true; zzState = 139; break zzForNext;
+                case 20: zzIsFinal = true; zzState = 135; break zzForNext;
+                case 49: zzIsFinal = true; zzState = 136; break zzForNext;
+                case 58: zzIsFinal = true; zzState = 137; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1159,7 +1169,7 @@ public final class ScilabLexer {
 
             case 30:
               switch (zzInput) {
-                case 22: zzIsFinal = true; zzState = 140; break zzForNext;
+                case 22: zzIsFinal = true; zzState = 138; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1195,7 +1205,7 @@ public final class ScilabLexer {
 
             case 31:
               switch (zzInput) {
-                case 15: zzIsFinal = true; zzState = 141; break zzForNext;
+                case 15: zzIsFinal = true; zzState = 139; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1231,7 +1241,7 @@ public final class ScilabLexer {
 
             case 32:
               switch (zzInput) {
-                case 17: zzIsFinal = true; zzState = 142; break zzForNext;
+                case 17: zzIsFinal = true; zzState = 140; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1267,7 +1277,7 @@ public final class ScilabLexer {
 
             case 33:
               switch (zzInput) {
-                case 53: zzIsFinal = true; zzState = 143; break zzForNext;
+                case 53: zzIsFinal = true; zzState = 141; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1303,7 +1313,7 @@ public final class ScilabLexer {
 
             case 34:
               switch (zzInput) {
-                case 24: zzIsFinal = true; zzState = 144; break zzForNext;
+                case 24: zzIsFinal = true; zzState = 142; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1339,7 +1349,7 @@ public final class ScilabLexer {
 
             case 35:
               switch (zzInput) {
-                case 23: zzIsFinal = true; zzState = 145; break zzForNext;
+                case 23: zzIsFinal = true; zzState = 143; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1377,24 +1387,24 @@ public final class ScilabLexer {
               switch (zzInput) {
                 case 41: zzIsFinal = true; zzNoLookAhead = true; zzState = 42; break zzForNext;
                 case 9: 
-                case 40: zzIsFinal = true; zzState = 146; break zzForNext;
-                case 10: zzIsFinal = true; zzNoLookAhead = true; zzState = 147; break zzForNext;
-                case 34: zzIsFinal = true; zzState = 148; break zzForNext;
-                case 39: zzIsFinal = true; zzState = 149; break zzForNext;
-                case 65: zzIsFinal = true; zzState = 150; break zzForNext;
+                case 40: zzIsFinal = true; zzState = 144; break zzForNext;
+                case 10: zzIsFinal = true; zzNoLookAhead = true; zzState = 145; break zzForNext;
+                case 34: zzIsFinal = true; zzState = 146; break zzForNext;
+                case 39: zzIsFinal = true; zzState = 147; break zzForNext;
+                case 65: zzIsFinal = true; zzState = 148; break zzForNext;
                 default: break zzForAction;
               }
 
             case 37:
               switch (zzInput) {
-                case 36: zzIsFinal = true; zzNoLookAhead = true; zzState = 151; break zzForNext;
-                case 37: zzIsFinal = true; zzNoLookAhead = true; zzState = 152; break zzForNext;
+                case 36: zzIsFinal = true; zzNoLookAhead = true; zzState = 149; break zzForNext;
+                case 37: zzIsFinal = true; zzNoLookAhead = true; zzState = 150; break zzForNext;
                 default: break zzForAction;
               }
 
             case 38:
               switch (zzInput) {
-                case 37: zzIsFinal = true; zzNoLookAhead = true; zzState = 153; break zzForNext;
+                case 37: zzIsFinal = true; zzNoLookAhead = true; zzState = 151; break zzForNext;
                 default: break zzForAction;
               }
 
@@ -1438,7 +1448,7 @@ public final class ScilabLexer {
                 case 63: 
                 case 64: 
                 case 68: break zzForAction;
-                default: zzState = 154; break zzForNext;
+                default: zzState = 152; break zzForNext;
               }
 
             case 41:
@@ -1449,7 +1459,7 @@ public final class ScilabLexer {
 
             case 43:
               switch (zzInput) {
-                case 17: zzIsFinal = true; zzState = 155; break zzForNext;
+                case 17: zzIsFinal = true; zzState = 153; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1485,7 +1495,7 @@ public final class ScilabLexer {
 
             case 44:
               switch (zzInput) {
-                case 48: zzIsFinal = true; zzState = 156; break zzForNext;
+                case 48: zzIsFinal = true; zzState = 154; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1521,8 +1531,8 @@ public final class ScilabLexer {
 
             case 45:
               switch (zzInput) {
-                case 22: zzIsFinal = true; zzState = 157; break zzForNext;
-                case 45: zzIsFinal = true; zzState = 158; break zzForNext;
+                case 22: zzIsFinal = true; zzState = 155; break zzForNext;
+                case 45: zzIsFinal = true; zzState = 156; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1558,7 +1568,7 @@ public final class ScilabLexer {
 
             case 46:
               switch (zzInput) {
-                case 45: zzIsFinal = true; zzState = 141; break zzForNext;
+                case 45: zzIsFinal = true; zzState = 139; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1594,7 +1604,7 @@ public final class ScilabLexer {
 
             case 47:
               switch (zzInput) {
-                case 46: zzIsFinal = true; zzState = 159; break zzForNext;
+                case 46: zzIsFinal = true; zzState = 157; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1630,7 +1640,7 @@ public final class ScilabLexer {
 
             case 48:
               switch (zzInput) {
-                case 56: zzIsFinal = true; zzState = 139; break zzForNext;
+                case 56: zzIsFinal = true; zzState = 137; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -1702,19 +1712,19 @@ public final class ScilabLexer {
             case 53:
               switch (zzInput) {
                 case 65: zzIsFinal = true; break zzForNext;
-                case 34: zzIsFinal = true; zzState = 150; break zzForNext;
+                case 34: zzIsFinal = true; zzState = 148; break zzForNext;
                 case 17: 
                 case 30: 
                 case 32: 
-                case 52: zzIsFinal = true; zzState = 160; break zzForNext;
+                case 52: zzIsFinal = true; zzState = 158; break zzForNext;
                 default: break zzForAction;
               }
 
             case 55:
               switch (zzInput) {
                 case 10: 
-                case 11: zzState = 161; break zzForNext;
-                case 34: zzState = 162; break zzForNext;
+                case 11: zzState = 159; break zzForNext;
+                case 34: zzState = 160; break zzForNext;
                 case 1: 
                 case 2: 
                 case 35: 
@@ -1746,7 +1756,7 @@ public final class ScilabLexer {
 
             case 59:
               switch (zzInput) {
-                case 34: zzIsFinal = true; zzState = 163; break zzForNext;
+                case 34: zzIsFinal = true; zzState = 161; break zzForNext;
                 case 1: 
                 case 2: 
                 case 10: 
@@ -1862,7 +1872,7 @@ public final class ScilabLexer {
               switch (zzInput) {
                 case 4: zzIsFinal = true; zzNoLookAhead = true; zzState = 76; break zzForNext;
                 case 59: 
-                case 62: zzState = 164; break zzForNext;
+                case 62: zzState = 162; break zzForNext;
                 default: break zzForAction;
               }
 
@@ -1870,7 +1880,7 @@ public final class ScilabLexer {
               switch (zzInput) {
                 case 4: zzIsFinal = true; zzNoLookAhead = true; zzState = 76; break zzForNext;
                 case 59: 
-                case 62: zzState = 164; break zzForNext;
+                case 62: zzState = 162; break zzForNext;
                 default: break zzForAction;
               }
 
@@ -1897,7 +1907,7 @@ public final class ScilabLexer {
 
             case 81:
               switch (zzInput) {
-                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 126; break zzForNext;
+                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 124; break zzForNext;
                 case 1: 
                 case 2: 
                 case 35: 
@@ -1918,13 +1928,13 @@ public final class ScilabLexer {
 
             case 85:
               switch (zzInput) {
-                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 126; break zzForNext;
+                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 124; break zzForNext;
                 default: break zzForAction;
               }
 
             case 86:
               switch (zzInput) {
-                case 34: zzIsFinal = true; zzState = 165; break zzForNext;
+                case 34: zzIsFinal = true; zzState = 163; break zzForNext;
                 default: break zzForAction;
               }
 
@@ -2006,31 +2016,25 @@ public final class ScilabLexer {
 
             case 92:
               switch (zzInput) {
-                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 166; break zzForNext;
+                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 164; break zzForNext;
                 default: break zzForAction;
               }
 
             case 94:
               switch (zzInput) {
-                case 9: zzState = 167; break zzForNext;
+                case 9: zzState = 165; break zzForNext;
                 case 59: 
-                case 62: zzState = 168; break zzForNext;
+                case 62: zzState = 166; break zzForNext;
                 default: break zzForAction;
               }
 
             case 96:
               switch (zzInput) {
-                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 95; break zzForNext;
+                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 76; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 98:
-              switch (zzInput) {
-                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 169; break zzForNext;
-                default: break zzForAction;
-              }
-
-            case 99:
+            case 97:
               switch (zzInput) {
                 case 0: 
                 case 1: 
@@ -2065,15 +2069,15 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; break zzForNext;
               }
 
-            case 100:
+            case 98:
               switch (zzInput) {
-                case 9: zzState = 170; break zzForNext;
+                case 9: zzState = 167; break zzForNext;
                 case 59: 
-                case 62: zzState = 171; break zzForNext;
+                case 62: zzState = 168; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 101:
+            case 99:
               switch (zzInput) {
                 case 0: 
                 case 1: 
@@ -2105,10 +2109,10 @@ public final class ScilabLexer {
                 case 63: 
                 case 67: 
                 case 68: break zzForAction;
-                default: zzIsFinal = true; zzState = 99; break zzForNext;
+                default: zzIsFinal = true; zzState = 97; break zzForNext;
               }
 
-            case 104:
+            case 102:
               switch (zzInput) {
                 case 0: 
                 case 1: 
@@ -2143,20 +2147,20 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; break zzForNext;
               }
 
-            case 105:
+            case 103:
               switch (zzInput) {
-                case 34: zzState = 172; break zzForNext;
+                case 34: zzState = 169; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 107:
+            case 105:
               switch (zzInput) {
                 case 59: 
                 case 62: zzIsFinal = true; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 108:
+            case 106:
               switch (zzInput) {
                 case 0: 
                 case 1: 
@@ -2188,10 +2192,10 @@ public final class ScilabLexer {
                 case 63: 
                 case 67: 
                 case 68: break zzForAction;
-                default: zzIsFinal = true; zzState = 104; break zzForNext;
+                default: zzIsFinal = true; zzState = 102; break zzForNext;
               }
 
-            case 111:
+            case 109:
               switch (zzInput) {
                 case 0: 
                 case 1: 
@@ -2226,13 +2230,13 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; break zzForNext;
               }
 
-            case 112:
+            case 110:
               switch (zzInput) {
-                case 34: zzIsFinal = true; zzState = 173; break zzForNext;
+                case 34: zzIsFinal = true; zzState = 170; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 113:
+            case 111:
               switch (zzInput) {
                 case 0: 
                 case 1: 
@@ -2264,76 +2268,76 @@ public final class ScilabLexer {
                 case 63: 
                 case 67: 
                 case 68: break zzForAction;
-                default: zzIsFinal = true; zzState = 111; break zzForNext;
+                default: zzIsFinal = true; zzState = 109; break zzForNext;
               }
 
-            case 114:
+            case 112:
               switch (zzInput) {
-                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 115; break zzForNext;
+                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 113; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 116:
+            case 114:
               switch (zzInput) {
-                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 174; break zzForNext;
+                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 171; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 117:
+            case 115:
               switch (zzInput) {
-                case 1: zzIsFinal = true; zzState = 114; break zzForNext;
-                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 115; break zzForNext;
+                case 1: zzIsFinal = true; zzState = 112; break zzForNext;
+                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 113; break zzForNext;
                 case 59: 
-                case 62: zzState = 175; break zzForNext;
+                case 62: zzState = 172; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 118:
+            case 116:
               switch (zzInput) {
-                case 1: zzIsFinal = true; zzState = 114; break zzForNext;
-                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 115; break zzForNext;
+                case 1: zzIsFinal = true; zzState = 112; break zzForNext;
+                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 113; break zzForNext;
                 case 59: 
-                case 62: zzState = 175; break zzForNext;
+                case 62: zzState = 172; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 120:
+            case 118:
               switch (zzInput) {
-                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 119; break zzForNext;
+                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 117; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 121:
+            case 119:
               switch (zzInput) {
                 case 1: 
                 case 2: zzIsFinal = true; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 122:
+            case 120:
               switch (zzInput) {
                 case 1: 
-                case 2: zzIsFinal = true; zzState = 121; break zzForNext;
+                case 2: zzIsFinal = true; zzState = 119; break zzForNext;
                 case 59: 
                 case 62: zzIsFinal = true; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 124:
+            case 122:
               switch (zzInput) {
                 case 1: 
                 case 2: zzIsFinal = true; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 125:
+            case 123:
               switch (zzInput) {
                 case 59: 
                 case 62: zzIsFinal = true; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 127:
+            case 125:
               switch (zzInput) {
                 case 0: 
                 case 1: 
@@ -2368,9 +2372,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 128:
+            case 126:
               switch (zzInput) {
-                case 18: zzIsFinal = true; zzState = 176; break zzForNext;
+                case 18: zzIsFinal = true; zzState = 173; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2404,9 +2408,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 129:
+            case 127:
               switch (zzInput) {
-                case 19: zzIsFinal = true; zzState = 127; break zzForNext;
+                case 19: zzIsFinal = true; zzState = 125; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2440,9 +2444,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 130:
+            case 128:
               switch (zzInput) {
-                case 20: zzIsFinal = true; zzState = 177; break zzForNext;
+                case 20: zzIsFinal = true; zzState = 174; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2476,9 +2480,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 131:
+            case 129:
               switch (zzInput) {
-                case 22: zzIsFinal = true; zzState = 178; break zzForNext;
+                case 22: zzIsFinal = true; zzState = 175; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2512,9 +2516,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 132:
+            case 130:
               switch (zzInput) {
-                case 50: zzIsFinal = true; zzState = 141; break zzForNext;
+                case 50: zzIsFinal = true; zzState = 139; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2548,9 +2552,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 133:
+            case 131:
               switch (zzInput) {
-                case 17: zzIsFinal = true; zzState = 179; break zzForNext;
+                case 17: zzIsFinal = true; zzState = 176; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2584,9 +2588,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 134:
+            case 132:
               switch (zzInput) {
-                case 31: zzIsFinal = true; zzState = 180; break zzForNext;
+                case 31: zzIsFinal = true; zzState = 177; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2620,9 +2624,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 135:
+            case 133:
               switch (zzInput) {
-                case 46: zzIsFinal = true; zzState = 141; break zzForNext;
+                case 46: zzIsFinal = true; zzState = 139; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2656,9 +2660,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 136:
+            case 134:
               switch (zzInput) {
-                case 20: zzIsFinal = true; zzState = 181; break zzForNext;
+                case 20: zzIsFinal = true; zzState = 178; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2692,9 +2696,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 137:
+            case 135:
               switch (zzInput) {
-                case 52: zzIsFinal = true; zzState = 182; break zzForNext;
+                case 52: zzIsFinal = true; zzState = 179; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2728,9 +2732,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 138:
+            case 136:
               switch (zzInput) {
-                case 21: zzIsFinal = true; zzState = 183; break zzForNext;
+                case 21: zzIsFinal = true; zzState = 180; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2764,9 +2768,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 139:
+            case 137:
               switch (zzInput) {
-                case 19: zzIsFinal = true; zzState = 184; break zzForNext;
+                case 19: zzIsFinal = true; zzState = 181; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2800,9 +2804,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 140:
+            case 138:
               switch (zzInput) {
-                case 56: zzIsFinal = true; zzState = 185; break zzForNext;
+                case 56: zzIsFinal = true; zzState = 182; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2836,7 +2840,7 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 141:
+            case 139:
               switch (zzInput) {
                 case 0: 
                 case 1: 
@@ -2871,9 +2875,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 142:
+            case 140:
               switch (zzInput) {
-                case 49: zzIsFinal = true; zzState = 186; break zzForNext;
+                case 49: zzIsFinal = true; zzState = 183; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2907,9 +2911,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 143:
+            case 141:
               switch (zzInput) {
-                case 45: zzIsFinal = true; zzState = 187; break zzForNext;
+                case 45: zzIsFinal = true; zzState = 184; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2943,9 +2947,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 144:
+            case 142:
               switch (zzInput) {
-                case 25: zzIsFinal = true; zzState = 188; break zzForNext;
+                case 25: zzIsFinal = true; zzState = 185; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -2979,9 +2983,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 145:
+            case 143:
               switch (zzInput) {
-                case 24: zzIsFinal = true; zzState = 189; break zzForNext;
+                case 24: zzIsFinal = true; zzState = 186; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3015,36 +3019,36 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 146:
+            case 144:
               switch (zzInput) {
                 case 34: zzIsFinal = true; zzNoLookAhead = true; zzState = 42; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 148:
+            case 146:
               switch (zzInput) {
                 case 34: zzIsFinal = true; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 149:
+            case 147:
               switch (zzInput) {
                 case 34: 
                 case 39: zzIsFinal = true; zzNoLookAhead = true; zzState = 42; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 150:
+            case 148:
               switch (zzInput) {
                 case 65: zzIsFinal = true; break zzForNext;
                 case 17: 
                 case 30: 
                 case 32: 
-                case 52: zzIsFinal = true; zzState = 160; break zzForNext;
+                case 52: zzIsFinal = true; zzState = 158; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 154:
+            case 152:
               switch (zzInput) {
                 case 67: zzIsFinal = true; zzNoLookAhead = true; zzState = 16; break zzForNext;
                 case 0: 
@@ -3081,10 +3085,10 @@ public final class ScilabLexer {
                 default: break zzForNext;
               }
 
-            case 155:
+            case 153:
               switch (zzInput) {
-                case 13: zzIsFinal = true; zzState = 190; break zzForNext;
-                case 21: zzIsFinal = true; zzState = 191; break zzForNext;
+                case 13: zzIsFinal = true; zzState = 187; break zzForNext;
+                case 21: zzIsFinal = true; zzState = 188; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3118,9 +3122,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 156:
+            case 154:
               switch (zzInput) {
-                case 19: zzIsFinal = true; zzState = 192; break zzForNext;
+                case 19: zzIsFinal = true; zzState = 189; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3154,10 +3158,10 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 157:
+            case 155:
               switch (zzInput) {
-                case 13: zzIsFinal = true; zzState = 193; break zzForNext;
-                case 21: zzIsFinal = true; zzState = 194; break zzForNext;
+                case 13: zzIsFinal = true; zzState = 190; break zzForNext;
+                case 21: zzIsFinal = true; zzState = 191; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3191,9 +3195,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 158:
+            case 156:
               switch (zzInput) {
-                case 20: zzIsFinal = true; zzState = 195; break zzForNext;
+                case 20: zzIsFinal = true; zzState = 192; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3227,9 +3231,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 159:
+            case 157:
               switch (zzInput) {
-                case 17: zzIsFinal = true; zzState = 196; break zzForNext;
+                case 17: zzIsFinal = true; zzState = 193; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3263,21 +3267,21 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 160:
+            case 158:
               switch (zzInput) {
                 case 42: 
-                case 65: zzIsFinal = true; zzState = 197; break zzForNext;
+                case 65: zzIsFinal = true; zzState = 194; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 161:
+            case 159:
               switch (zzInput) {
                 case 10: 
                 case 11: zzIsFinal = true; zzState = 55; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 162:
+            case 160:
               switch (zzInput) {
                 case 1: 
                 case 2: 
@@ -3291,15 +3295,15 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 55; break zzForNext;
               }
 
-            case 163:
+            case 161:
               switch (zzInput) {
                 case 34: zzIsFinal = true; break zzForNext;
                 case 59: 
-                case 62: zzIsFinal = true; zzState = 198; break zzForNext;
+                case 62: zzIsFinal = true; zzState = 195; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 164:
+            case 162:
               switch (zzInput) {
                 case 4: zzIsFinal = true; zzNoLookAhead = true; zzState = 76; break zzForNext;
                 case 59: 
@@ -3307,64 +3311,64 @@ public final class ScilabLexer {
                 default: break zzForAction;
               }
 
-            case 165:
+            case 163:
               switch (zzInput) {
                 case 34: zzIsFinal = true; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 167:
+            case 165:
               switch (zzInput) {
-                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 166; break zzForNext;
+                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 164; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 168:
+            case 166:
               switch (zzInput) {
-                case 9: zzState = 167; break zzForNext;
+                case 9: zzState = 165; break zzForNext;
                 case 59: 
                 case 62: break zzForNext;
                 default: break zzForAction;
               }
 
-            case 170:
+            case 167:
               switch (zzInput) {
-                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 169; break zzForNext;
+                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 76; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 171:
+            case 168:
               switch (zzInput) {
-                case 9: zzState = 170; break zzForNext;
+                case 9: zzState = 167; break zzForNext;
                 case 59: 
                 case 62: break zzForNext;
                 default: break zzForAction;
               }
 
-            case 172:
+            case 169:
               switch (zzInput) {
-                case 34: zzIsFinal = true; zzNoLookAhead = true; zzState = 199; break zzForNext;
+                case 34: zzIsFinal = true; zzNoLookAhead = true; zzState = 196; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 173:
+            case 170:
               switch (zzInput) {
                 case 34: zzIsFinal = true; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 175:
+            case 172:
               switch (zzInput) {
-                case 1: zzIsFinal = true; zzState = 114; break zzForNext;
-                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 115; break zzForNext;
+                case 1: zzIsFinal = true; zzState = 112; break zzForNext;
+                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 113; break zzForNext;
                 case 59: 
                 case 62: break zzForNext;
                 default: break zzForAction;
               }
 
-            case 176:
+            case 173:
               switch (zzInput) {
-                case 21: zzIsFinal = true; zzState = 127; break zzForNext;
+                case 21: zzIsFinal = true; zzState = 125; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3398,9 +3402,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 177:
+            case 174:
               switch (zzInput) {
-                case 15: zzIsFinal = true; zzState = 127; break zzForNext;
+                case 15: zzIsFinal = true; zzState = 125; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3434,9 +3438,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 178:
+            case 175:
               switch (zzInput) {
-                case 20: zzIsFinal = true; zzState = 127; break zzForNext;
+                case 20: zzIsFinal = true; zzState = 125; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3470,9 +3474,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 179:
+            case 176:
               switch (zzInput) {
-                case 20: zzIsFinal = true; zzState = 141; break zzForNext;
+                case 20: zzIsFinal = true; zzState = 139; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3506,9 +3510,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 180:
+            case 177:
               switch (zzInput) {
-                case 32: zzIsFinal = true; zzState = 200; break zzForNext;
+                case 32: zzIsFinal = true; zzState = 197; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3542,9 +3546,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 181:
+            case 178:
               switch (zzInput) {
-                case 51: zzIsFinal = true; zzState = 201; break zzForNext;
+                case 51: zzIsFinal = true; zzState = 198; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3578,9 +3582,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 182:
+            case 179:
               switch (zzInput) {
-                case 15: zzIsFinal = true; zzState = 202; break zzForNext;
+                case 15: zzIsFinal = true; zzState = 199; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3614,9 +3618,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 183:
+            case 180:
               switch (zzInput) {
-                case 17: zzIsFinal = true; zzState = 203; break zzForNext;
+                case 17: zzIsFinal = true; zzState = 200; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3650,9 +3654,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 184:
+            case 181:
               switch (zzInput) {
-                case 13: zzIsFinal = true; zzState = 204; break zzForNext;
+                case 13: zzIsFinal = true; zzState = 201; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3686,9 +3690,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 185:
+            case 182:
               switch (zzInput) {
-                case 21: zzIsFinal = true; zzState = 205; break zzForNext;
+                case 21: zzIsFinal = true; zzState = 202; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3722,9 +3726,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 186:
+            case 183:
               switch (zzInput) {
-                case 17: zzIsFinal = true; zzState = 206; break zzForNext;
+                case 17: zzIsFinal = true; zzState = 203; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3758,9 +3762,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 187:
+            case 184:
               switch (zzInput) {
-                case 46: zzIsFinal = true; zzState = 184; break zzForNext;
+                case 46: zzIsFinal = true; zzState = 181; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3794,9 +3798,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 188:
+            case 185:
               switch (zzInput) {
-                case 27: zzIsFinal = true; zzState = 207; break zzForNext;
+                case 27: zzIsFinal = true; zzState = 204; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3830,9 +3834,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 189:
+            case 186:
               switch (zzInput) {
-                case 25: zzIsFinal = true; zzState = 127; break zzForNext;
+                case 25: zzIsFinal = true; zzState = 125; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3866,9 +3870,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 190:
+            case 187:
               switch (zzInput) {
-                case 56: zzIsFinal = true; zzState = 208; break zzForNext;
+                case 56: zzIsFinal = true; zzState = 205; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3902,9 +3906,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 191:
+            case 188:
               switch (zzInput) {
-                case 56: zzIsFinal = true; zzState = 209; break zzForNext;
+                case 56: zzIsFinal = true; zzState = 206; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3938,9 +3942,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 192:
+            case 189:
               switch (zzInput) {
-                case 49: zzIsFinal = true; zzState = 194; break zzForNext;
+                case 49: zzIsFinal = true; zzState = 191; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -3974,9 +3978,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 193:
+            case 190:
               switch (zzInput) {
-                case 51: zzIsFinal = true; zzState = 210; break zzForNext;
+                case 51: zzIsFinal = true; zzState = 207; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4010,9 +4014,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 194:
+            case 191:
               switch (zzInput) {
-                case 17: zzIsFinal = true; zzState = 141; break zzForNext;
+                case 17: zzIsFinal = true; zzState = 139; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4046,9 +4050,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 195:
+            case 192:
               switch (zzInput) {
-                case 13: zzIsFinal = true; zzState = 211; break zzForNext;
+                case 13: zzIsFinal = true; zzState = 208; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4082,9 +4086,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 196:
+            case 193:
               switch (zzInput) {
-                case 22: zzIsFinal = true; zzState = 212; break zzForNext;
+                case 22: zzIsFinal = true; zzState = 209; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4118,22 +4122,22 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 197:
+            case 194:
               switch (zzInput) {
                 case 65: zzIsFinal = true; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 198:
+            case 195:
               switch (zzInput) {
                 case 59: 
                 case 62: zzIsFinal = true; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 200:
+            case 197:
               switch (zzInput) {
-                case 25: zzIsFinal = true; zzState = 213; break zzForNext;
+                case 25: zzIsFinal = true; zzState = 210; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4167,9 +4171,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 201:
+            case 198:
               switch (zzInput) {
-                case 13: zzIsFinal = true; zzState = 214; break zzForNext;
+                case 13: zzIsFinal = true; zzState = 211; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4203,9 +4207,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 202:
+            case 199:
               switch (zzInput) {
-                case 56: zzIsFinal = true; zzState = 215; break zzForNext;
+                case 56: zzIsFinal = true; zzState = 212; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4239,7 +4243,7 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 203:
+            case 200:
               switch (zzInput) {
                 case 19: zzIsFinal = true; zzState = 31; break zzForNext;
                 case 0: 
@@ -4275,7 +4279,7 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 204:
+            case 201:
               switch (zzInput) {
                 case 0: 
                 case 1: 
@@ -4310,9 +4314,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 205:
+            case 202:
               switch (zzInput) {
-                case 17: zzIsFinal = true; zzState = 204; break zzForNext;
+                case 17: zzIsFinal = true; zzState = 201; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4346,9 +4350,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 206:
+            case 203:
               switch (zzInput) {
-                case 51: zzIsFinal = true; zzState = 216; break zzForNext;
+                case 51: zzIsFinal = true; zzState = 213; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4382,9 +4386,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 207:
+            case 204:
               switch (zzInput) {
-                case 28: zzIsFinal = true; zzState = 217; break zzForNext;
+                case 28: zzIsFinal = true; zzState = 214; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4418,9 +4422,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 208:
+            case 205:
               switch (zzInput) {
-                case 46: zzIsFinal = true; zzState = 218; break zzForNext;
+                case 46: zzIsFinal = true; zzState = 215; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4454,9 +4458,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 209:
+            case 206:
               switch (zzInput) {
-                case 57: zzIsFinal = true; zzState = 205; break zzForNext;
+                case 57: zzIsFinal = true; zzState = 202; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4490,9 +4494,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 210:
+            case 207:
               switch (zzInput) {
-                case 48: zzIsFinal = true; zzState = 141; break zzForNext;
+                case 48: zzIsFinal = true; zzState = 139; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4526,9 +4530,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 211:
+            case 208:
               switch (zzInput) {
-                case 19: zzIsFinal = true; zzState = 219; break zzForNext;
+                case 19: zzIsFinal = true; zzState = 216; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4562,9 +4566,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 212:
+            case 209:
               switch (zzInput) {
-                case 54: zzIsFinal = true; zzState = 204; break zzForNext;
+                case 54: zzIsFinal = true; zzState = 201; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4598,9 +4602,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 213:
+            case 210:
               switch (zzInput) {
-                case 33: zzIsFinal = true; zzState = 127; break zzForNext;
+                case 33: zzIsFinal = true; zzState = 125; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4634,9 +4638,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 214:
+            case 211:
               switch (zzInput) {
-                case 19: zzIsFinal = true; zzState = 220; break zzForNext;
+                case 19: zzIsFinal = true; zzState = 217; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4670,9 +4674,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 215:
+            case 212:
               switch (zzInput) {
-                case 20: zzIsFinal = true; zzState = 221; break zzForNext;
+                case 20: zzIsFinal = true; zzState = 218; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4706,9 +4710,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 216:
+            case 213:
               switch (zzInput) {
-                case 13: zzIsFinal = true; zzState = 141; break zzForNext;
+                case 13: zzIsFinal = true; zzState = 139; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4742,9 +4746,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 217:
+            case 214:
               switch (zzInput) {
-                case 29: zzIsFinal = true; zzState = 222; break zzForNext;
+                case 29: zzIsFinal = true; zzState = 219; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4778,9 +4782,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 218:
+            case 215:
               switch (zzInput) {
-                case 20: zzIsFinal = true; zzState = 204; break zzForNext;
+                case 20: zzIsFinal = true; zzState = 201; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4814,9 +4818,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 219:
+            case 216:
               switch (zzInput) {
-                case 20: zzIsFinal = true; zzState = 223; break zzForNext;
+                case 20: zzIsFinal = true; zzState = 220; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4850,9 +4854,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 220:
+            case 217:
               switch (zzInput) {
-                case 45: zzIsFinal = true; zzState = 224; break zzForNext;
+                case 45: zzIsFinal = true; zzState = 221; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4886,9 +4890,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 221:
+            case 218:
               switch (zzInput) {
-                case 51: zzIsFinal = true; zzState = 225; break zzForNext;
+                case 51: zzIsFinal = true; zzState = 222; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4922,9 +4926,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 222:
+            case 219:
               switch (zzInput) {
-                case 30: zzIsFinal = true; zzState = 127; break zzForNext;
+                case 30: zzIsFinal = true; zzState = 125; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4958,9 +4962,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 223:
+            case 220:
               switch (zzInput) {
-                case 56: zzIsFinal = true; zzState = 205; break zzForNext;
+                case 56: zzIsFinal = true; zzState = 202; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -4994,9 +4998,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 224:
+            case 221:
               switch (zzInput) {
-                case 20: zzIsFinal = true; zzState = 226; break zzForNext;
+                case 20: zzIsFinal = true; zzState = 223; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -5030,9 +5034,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 225:
+            case 222:
               switch (zzInput) {
-                case 13: zzIsFinal = true; zzState = 227; break zzForNext;
+                case 13: zzIsFinal = true; zzState = 224; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -5066,11 +5070,11 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 226:
+            case 223:
               switch (zzInput) {
-                case 3: zzIsFinal = true; zzNoLookAhead = true; zzState = 228; break zzForNext;
+                case 3: zzIsFinal = true; zzNoLookAhead = true; zzState = 225; break zzForNext;
                 case 59: 
-                case 62: zzIsFinal = true; zzState = 229; break zzForNext;
+                case 62: zzIsFinal = true; zzState = 226; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -5101,9 +5105,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 227:
+            case 224:
               switch (zzInput) {
-                case 19: zzIsFinal = true; zzState = 230; break zzForNext;
+                case 19: zzIsFinal = true; zzState = 227; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -5137,16 +5141,16 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 229:
+            case 226:
               switch (zzInput) {
                 case 59: 
                 case 62: zzIsFinal = true; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 230:
+            case 227:
               switch (zzInput) {
-                case 45: zzIsFinal = true; zzState = 231; break zzForNext;
+                case 45: zzIsFinal = true; zzState = 228; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -5180,9 +5184,9 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 231:
+            case 228:
               switch (zzInput) {
-                case 20: zzIsFinal = true; zzState = 232; break zzForNext;
+                case 20: zzIsFinal = true; zzState = 229; break zzForNext;
                 case 0: 
                 case 1: 
                 case 2: 
@@ -5216,7 +5220,7 @@ public final class ScilabLexer {
                 default: zzIsFinal = true; zzState = 28; break zzForNext;
               }
 
-            case 232:
+            case 229:
               switch (zzInput) {
                 case 0: 
                 case 1: 
@@ -5270,434 +5274,424 @@ public final class ScilabLexer {
       zzMarkedPos = zzMarkedPosL;
 
       switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
-        case 50: 
+        case 49: 
           { handler.handleDefault(", ");
           }
-        case 77: break;
+        case 75: break;
         case 2: 
           { handler.handleComment(yytext());
           }
-        case 78: break;
-        case 51: 
-          { handler.handleOpenClose(")");
-                                  yybegin(YYINITIAL);
-          }
-        case 79: break;
-        case 57: 
+        case 76: break;
+        case 8: 
+          { if (transposable) {
+                                       handler.handleOperator("&#0039;");
+                                   } else {
+                                       beginString = zzStartRead;
+                                       yybegin(QSTRING);
+                                       handler.handleString("&#0039;");
+                                   }
+          }
+        case 77: break;
+        case 56: 
           { handler.handleNothing("\n");
           }
-        case 80: break;
-        case 64: 
+        case 78: break;
+        case 9: 
           { transposable = false;
-                                  handler.handleOperator("&#0060;=");
+                                   beginString = zzStartRead;
+                                   yybegin(QSTRING);
+                                   handler.handleString("&#0034;");
+          }
+        case 79: break;
+        case 63: 
+          { transposable = false;
+                                   handler.handleOperator("&#0060;=");
+          }
+        case 80: break;
+        case 50: 
+          { handler.handleOpenClose(")");
+                                   yybegin(YYINITIAL);
           }
         case 81: break;
-        case 66: 
-          { yypushback(yylength());
-                                   yybegin(BREAKSTRING);
-                                   transposable = false;
-                                  handler.handleString(yytext());
+        case 68: 
+          { handler.handleSpecial(yytext());
+                                   yybegin(BREAKINARGS);
           }
         case 82: break;
-        case 60: 
-          { transposable = true;
-                                  handler.handleConstants(yytext());
-          }
-        case 83: break;
         case 36: 
           { handler.handleDefault(yytext());
           }
+        case 83: break;
+        case 44: 
+          { id = yytext();
+                                   localFun.add(id);
+                                   handler.handleFunctionIdDecl(id);
+          }
         case 84: break;
-        case 28: 
-          { handler.handleComment("&#0060;");
+        case 62: 
+          { transposable = false;
+                                   handler.handleOperator("&#0060;&#0062;");
           }
         case 85: break;
-        case 30: 
-          { handler.handleComment("&#0038;");
+        case 65: 
+          { yypushback(yylength());
+                                   yybegin(BREAKSTRING);
+                                   transposable = false;
+                                   handler.handleString(yytext());
           }
         case 86: break;
-        case 1: 
-          { handler.handleString(yytext());
+        case 28: 
+          { handler.handleComment("&#0060;");
           }
         case 87: break;
-        case 25: 
-          { if (breakstring) {
-                                    saveLexState = QSTRING;
-                                    breakstring = false;
-                                  } else if (breakargs) {
-                                    saveLexState = WHITESEOL;
-                                    breakargs = false;
-                                  } else {
-                                    saveLexState = YYINITIAL;
-                                  }
-                                  handler.handleNothing("\n");
-                                  yybegin(CLEAN);
+        case 30: 
+          { handler.handleComment("&#0038;");
           }
         case 88: break;
-        case 59: 
-          { transposable = false;
-                                   yypushback(2);
-                                   yybegin(COMMENT);
+        case 1: 
+          { handler.handleString(yytext());
           }
         case 89: break;
-        case 67: 
-          { breakstring = true;
-                                  handler.handleSpecial(yytext());
+        case 37: 
+          { if (breakstring) {
+                                      breakstring = false;
+                                      saveLexState = QSTRING;
+                                   } else {
+                                      saveLexState = YYINITIAL;
+                                   }
+                                   handler.handleNothing("\n");
+                                   yybegin(CLEAN);
           }
         case 90: break;
         case 74: 
           { transposable = false;
-                                  handler.handleFKeywords("function");
-                                  handler.handleNothing(" ");
-                                  handler.handleOpenClose("[");
-                                   yybegin(RETS);
+                                   returnValues.clear();
+                                   argsValues.clear();
+                                   handler.handleFKeywords("endfunction");
           }
         case 91: break;
-        case 48: 
-          { id = yytext();
-                                   returnValues.add(id);
-                                  handler.handleInputOutputArgsDecl(id);
+        case 22: 
+          { transposable = false;
+                                   handler.handleString("&#0060;");
           }
         case 92: break;
-        case 49: 
-          { handler.handleOperator("=");
+        case 41: 
+          { returnValues.add(id);
+                                   handler.handleInputOutputArgsDecl(id);
+                                   handler.handleOperator("=");
                                    yybegin(FUNNAME);
           }
         case 93: break;
-        case 56: 
-          { yypushback(1);
-                                  yybegin(saveLexState);
+        case 58: 
+          { transposable = false;
+                                   yypushback(2);
+                                   yybegin(COMMENT);
           }
         case 94: break;
-        case 46: 
-          { handler.handleOpenClose("[");
+        case 16: 
+          { transposable = false;
+                                   handler.handleSpecial(yytext());
           }
         case 95: break;
-        case 12: 
+        case 73: 
           { transposable = false;
-                                  handler.handleOperator("&#0060;");
+                                   handler.handleFKeywords("function");
+                                   handler.handleNothing(" ");
+                                   yybegin(FUNCTION);
           }
         case 96: break;
-        case 14: 
+        case 24: 
           { transposable = false;
-                                  handler.handleOperator("&#0038;");
+                                   handler.handleString("&#0038;");
           }
         case 97: break;
-        case 47: 
-          { handler.handleOpenClose("]");
+        case 48: 
+          { handler.handleOperator("=");
+                                   yybegin(FUNNAME);
           }
         case 98: break;
-        case 65: 
-          { transposable = false;
-                                  handler.handleOperator("&#0062;=");
+        case 10: 
+          { transposable = true;
+                                   String str = yytext();
+                                   if (commands.contains(str)) {
+                                       yybegin(COMMANDS);
+                                       handler.handleCommand(str);
+                                   } else if (macros.contains(str)) {
+                                       yybegin(COMMANDS);
+                                       handler.handleMacro(str);
+                                   } else if (localFun.contains(str)) {
+                                        yybegin(COMMANDS);
+                                        handler.handleFunctionId(str);
+                                   } else {
+                                       if (returnValues.contains(str) || argsValues.contains(str)) {
+                                           handler.handleInputOutputArgs(str);
+                                       }  else {
+                                           handler.handleId(str);
+                                       }
+                                   }
           }
         case 99: break;
-        case 71: 
-          { breakargs = true;
-                                   yypushback(2);
-                                   yybegin(COMMENT);
+        case 45: 
+          { handler.handleOpenClose("[");
           }
         case 100: break;
-        case 21: 
-          { transposable = false;
-                                   yybegin(YYINITIAL);
-                                  handler.handleString("&#0034;");
+        case 34: 
+          { yybegin(COMMANDSWHITE);
+                                   handler.handleNothing(" ");
           }
         case 101: break;
-        case 9: 
+        case 72: 
           { transposable = false;
-                                   beginString = zzStartRead;
-                                   yybegin(QSTRING);
-                                  handler.handleString("&#0034;");
+                                   handler.handleFKeywords("function");
+                                   handler.handleNothing(" ");
+                                   handler.handleOpenClose("[");
+                                   yybegin(RETS);
           }
         case 102: break;
-        case 63: 
-          { transposable = false;
-                                  handler.handleOperator("&#0060;&#0062;");
+        case 66: 
+          { breakstring = true;
+                                   handler.handleSpecial(yytext());
           }
         case 103: break;
-        case 72: 
-          { handler.handleNothing("...");
+        case 46: 
+          { handler.handleOpenClose("]");
           }
         case 104: break;
-        case 44: 
-          { handler.handleOpenClose("(");
-                                   yybegin(ARGS);
+        case 12: 
+          { transposable = false;
+                                   handler.handleOperator("&#0060;");
           }
         case 105: break;
-        case 52: 
-          { id = yytext();
-                                   argsValues.add(id);
-                                  handler.handleInputOutputArgsDecl(id);
+        case 14: 
+          { transposable = false;
+                                   handler.handleOperator("&#0038;");
           }
         case 106: break;
-        case 20: 
-          { transposable = false;
-                                   yybegin(YYINITIAL);
-                                  handler.handleString("&#0039;");
+        case 69: 
+          { breakargs = true;
+                                   yypushback(2);
+                                   yybegin(COMMENT);
           }
         case 107: break;
-        case 5: 
+        case 64: 
           { transposable = false;
-                                  handler.handleOpenClose(yytext());
+                                   handler.handleOperator("&#0062;=");
           }
         case 108: break;
-        case 34: 
-          { yybegin(COMMANDSWHITE);
-                                  handler.handleNothing(" ");
+        case 21: 
+          { transposable = false;
+                                   yybegin(YYINITIAL);
+                                   handler.handleString("&#0034;");
           }
         case 109: break;
-        case 3: 
-          { transposable = false;
-                                  handler.handleDefault(yytext());
+        case 18: 
+          { transposable = true;
+                                   handler.handleNumber(yytext());
           }
         case 110: break;
-        case 45: 
-          { id = yytext();
-                                  localFun.add(id);
-                                  handler.handleFunctionIdDecl(id);
+        case 70: 
+          { handler.handleNothing("...");
           }
         case 111: break;
-        case 62: 
-          { transposable = false;
-                                  handler.handleOperator(".&#0039;");
+        case 43: 
+          { handler.handleOpenClose("(");
+                                   yybegin(ARGS);
           }
         case 112: break;
-        case 32: 
-          { handler.handleField(yytext());
+        case 7: 
+          { transposable = false;
+                                   handler.handleOperator(yytext());
           }
         case 113: break;
-        case 75: 
+        case 20: 
           { transposable = false;
-                                  handler.handleFKeywords("function");
-                                  handler.handleNothing(" ");
-                                   yybegin(FUNCTION);
+                                   yybegin(YYINITIAL);
+                                   handler.handleString("&#0039;");
           }
         case 114: break;
-        case 55: 
-          { whitesOnFirstLine = yylength();
-                                  yybegin(YYINITIAL);
+        case 57: 
+          { int len = yylength() - whitesOnFirstLine;
+                                   if (len > 0) {
+                                      yypushback(len);
+                                   }
+                                   yybegin(saveLexState);
           }
         case 115: break;
-        case 17: 
-          { handler.handleNothing("    ");
+        case 32: 
+          { handler.handleField(yytext());
           }
         case 116: break;
-        case 37: 
-          { if (breakstring) {
-                                     breakstring = false;
-                                     saveLexState = QSTRING;
-                                  } else {
-                                     saveLexState = YYINITIAL;
-                                  }
-                                  handler.handleNothing("\n");
-                                  yybegin(CLEAN);
+        case 5: 
+          { transposable = false;
+                                   handler.handleOpenClose(yytext());
           }
         case 117: break;
-        case 41: 
-          { returnValues.add(id);
-                                  handler.handleInputOutputArgsDecl(id);
-                                  handler.handleOperator("=");
-                                   yybegin(FUNNAME);
+        case 61: 
+          { transposable = false;
+                                   handler.handleOperator(".&#0039;");
           }
         case 118: break;
-        case 15: 
-          { handler.handleNothing(" ");
+        case 17: 
+          { handler.handleNothing("    ");
           }
         case 119: break;
-        case 23: 
-          { transposable = false;
-                                  handler.handleString("&#0062;");
+        case 4: 
+          { handler.handleNothing("\n");
+                                   saveLexState = YYINITIAL;
+                                   yybegin(CLEAN);
           }
         case 120: break;
-        case 40: 
-          { localFun.add(id);
-                                  handler.handleFunctionIdDecl(id);
-                                  handler.handleOpenClose("(");
-                                   yybegin(ARGS);
+        case 51: 
+          { id = yytext();
+                                   argsValues.add(id);
+                                   handler.handleInputOutputArgsDecl(id);
           }
         case 121: break;
+        case 15: 
+          { handler.handleNothing(" ");
+          }
+        case 122: break;
+        case 6: 
+          { transposable = true;
+                                   handler.handleOpenClose(yytext());
+          }
+        case 123: break;
         case 31: 
           { yypushback(1);
                                    yybegin(YYINITIAL);
           }
-        case 122: break;
+        case 124: break;
         case 38: 
           { handler.handleOpenClose("[");
                                    yybegin(RETS);
           }
-        case 123: break;
-        case 69: 
-          { yypushback(yylength());
-                                  yybegin(YYINITIAL);
-          }
-        case 124: break;
-        case 43: 
-          { yypushback(1);
-                                  yybegin(YYINITIAL);
-          }
         case 125: break;
-        case 33: 
-          { yypushback(yylength());
-                                   yybegin(YYINITIAL);
+        case 25: 
+          { if (breakstring) {
+                                     saveLexState = QSTRING;
+                                     breakstring = false;
+                                   } else if (breakargs) {
+                                     saveLexState = WHITESEOL;
+                                     breakargs = false;
+                                   } else {
+                                     saveLexState = YYINITIAL;
+                                   }
+                                   handler.handleNothing("\n");
+                                   yybegin(CLEAN);
           }
         case 126: break;
         case 35: 
           { yybegin(COMMANDSWHITE);
-                                  handler.handleNothing("    ");
+                                   handler.handleNothing("    ");
           }
         case 127: break;
-        case 53: 
-          { handler.handleNothing("\n");
-                                  saveLexState = WHITESEOL;
-                                  yybegin(CLEAN);
+        case 55: 
+          { yypushback(1);
+                                   yybegin(saveLexState);
           }
         case 128: break;
-        case 61: 
-          { transposable = false;
-                                  handler.handleSKeywords(yytext());
+        case 33: 
+          { yypushback(yylength());
+                                   yybegin(YYINITIAL);
           }
         case 129: break;
-        case 29: 
-          { handler.handleComment("&#0062;");
+        case 67: 
+          { localFun.add(id);
+                                   handler.handleFunctionIdDecl(id);
+                                   yypushback(yylength());
+                                   yybegin(YYINITIAL);
           }
         case 130: break;
-        case 54: 
-          { yypushback(1);
-                                  yybegin(ARGS);
+        case 52: 
+          { handler.handleNothing("\n");
+                                   saveLexState = WHITESEOL;
+                                   yybegin(CLEAN);
           }
         case 131: break;
-        case 70: 
-          { handler.handleSpecial(yytext());
-                                  yybegin(BREAKINARGS);
+        case 47: 
+          { id = yytext();
+                                   returnValues.add(id);
+                                   handler.handleInputOutputArgsDecl(id);
           }
         case 132: break;
-        case 76: 
-          { transposable = false;
-                                  returnValues.clear();
-                                  argsValues.clear();
-                                  handler.handleFKeywords("endfunction");
+        case 59: 
+          { transposable = true;
+                                   handler.handleConstants(yytext());
           }
         case 133: break;
-        case 7: 
-          { transposable = false;
-                                  handler.handleOperator(yytext());
+        case 53: 
+          { yypushback(1);
+                                   yybegin(ARGS);
           }
         case 134: break;
-        case 18: 
-          { transposable = true;
-                                  handler.handleNumber(yytext());
+        case 29: 
+          { handler.handleComment("&#0062;");
           }
         case 135: break;
-        case 68: 
-          { localFun.add(id);
-                                  handler.handleFunctionIdDecl(id);
-                                  yypushback(yylength());
-                                  yybegin(YYINITIAL);
+        case 60: 
+          { transposable = false;
+                                   handler.handleSKeywords(yytext());
           }
         case 136: break;
-        case 19: 
-          { return;
+        case 3: 
+          { transposable = false;
+                                   handler.handleDefault(yytext());
           }
         case 137: break;
-        case 39: 
-          { id = yytext();
-                                   yybegin(TYPEID);
+        case 11: 
+          { transposable = false;
+                                   yybegin(FIELD);
+                                   handler.handleOperator(yytext());
           }
         case 138: break;
-        case 10: 
-          { transposable = true;
-                                   String str = yytext();
-                                  if (commands.contains(str)) {
-                                      yybegin(COMMANDS);
-                                      handler.handleCommand(str);
-                                   } else if (macros.contains(str)) {
-                                       yybegin(COMMANDS);
-                                      handler.handleMacro(str);
-                                   } else if (localFun.contains(str)) {
-                                       yybegin(COMMANDS);
-                                       handler.handleFunctionId(str);
-                                   } else {
-                                       if (returnValues.contains(str) || argsValues.contains(str)) {
-                                          handler.handleInputOutputArgs(str);
-                                       }  else {
-                                          handler.handleId(str);
-                                      }
-                                   }
+        case 19: 
+          { return;
           }
         case 139: break;
-        case 73: 
+        case 23: 
           { transposable = false;
-                                  handler.handleCKeywords(yytext());
+                                   handler.handleString("&#0062;");
           }
         case 140: break;
-        case 4: 
-          { handler.handleNothing("\n");
-                                  saveLexState = YYINITIAL;
-                                  yybegin(CLEAN);
+        case 39: 
+          { id = yytext();
+                                   yybegin(TYPEID);
           }
         case 141: break;
-        case 27: 
-          { handler.handleComment("&#0034;");
+        case 54: 
+          { whitesOnFirstLine = yylength();
+                                   yybegin(YYINITIAL);
           }
         case 142: break;
-        case 13: 
-          { transposable = false;
-                                  handler.handleOperator("&#0062;");
+        case 27: 
+          { handler.handleComment("&#0034;");
           }
         case 143: break;
-        case 6: 
-          { transposable = true;
-                                  handler.handleOpenClose(yytext());
+        case 71: 
+          { transposable = false;
+                                   handler.handleCKeywords(yytext());
           }
         case 144: break;
-        case 58: 
-          { int len = yylength() - whitesOnFirstLine;
-                                  if (len > 0) {
-                                     yypushback(len); 
-                                  }
-                                  yybegin(saveLexState);
+        case 40: 
+          { localFun.add(id);
+                                   handler.handleFunctionIdDecl(id);
+                                   handler.handleOpenClose("(");
+                                   yybegin(ARGS);
           }
         case 145: break;
-        case 22: 
-          { transposable = false;
-                                  handler.handleString("&#0060;");
-          }
-        case 146: break;
-        case 8: 
-          { if (transposable) {
-                                      handler.handleOperator("&#0039;");
-                                   } else {
-                                       beginString = zzStartRead;
-                                       yybegin(QSTRING);
-                                      handler.handleString("&#0039;");
-                                   }
-          }
-        case 147: break;
-        case 11: 
-          { transposable = false;
-                                   yybegin(FIELD);
-                                  handler.handleOperator(yytext());
-          }
-        case 148: break;
         case 26: 
           { handler.handleComment("&#0039;");
           }
-        case 149: break;
-        case 16: 
-          { transposable = false;
-                                  handler.handleSpecial(yytext());
-          }
-        case 150: break;
-        case 24: 
+        case 146: break;
+        case 13: 
           { transposable = false;
-                                  handler.handleString("&#0038;");
+                                   handler.handleOperator("&#0062;");
           }
-        case 151: break;
+        case 147: break;
         case 42: 
           { 
           }
-        case 152: break;
+        case 148: break;
         default: 
           if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
             zzAtEOF = true;
index 7aec798..00d4327 100644 (file)
@@ -32,148 +32,149 @@ import org.scilab.forge.scidoc.scilab.ScilabLexer;
 
 public class ScilabSourceBrowser extends HTMLScilabCodeHandler {
 
-    private static final String entete = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n          \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"{$lang}\" lang=\"{$lang}\">\n  <head{$profile}>\n    <title><!--<title>--> <!--<subtitle>--></title>\n    <style type=\"text/css\" media=\"all\">\n      @import url(\"site.css\");\n      @import url(\"css/scilab_code.css\");\n      @import url(\"css/style.css\");\n    </style>\n    <!--[if IE]><![endif]><![endif]-->\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n   <!-- <link rel=\"shortcut icon\" href=\"{$_SERVER['STATIC_ROOT']}/favicon.ico\" />{$link}\n     $canonical\n    <script type=\"text/javascript\" src=\"{$_SERVER['STATIC_ROOT']}/userprefs.js\"></script>{$base}{$meta}{$moreheadtags}\n        -->\n  </head>\n  <body>";
+    private static final String entete = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n          \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"{$lang}\" lang=\"{$lang}\">\n  <head{$profile}>\n    <title><!--<title>--> <!--<subtitle>--></title>\n    <style type=\"text/css\" media=\"all\">\n      @import url(\"site.css\");\n      @import url(\"css/scilab_code.css\");\n      @import url(\"css/style.css\");\n    </style>\n    <!--[if IE]><![endif]><![endif]-->\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n    <!-- <link rel=\"shortcut icon\" href=\"{$_SERVER['STATIC_ROOT']}/favicon.ico\" />{$link}\n     $canonical\n    <script type=\"text/javascript\" src=\"{$_SERVER['STATIC_ROOT']}/userprefs.js\"></script>{$base}{$meta}{$moreheadtags}\n        -->\n  </head>\n  <body>";
 
     private List<String> files;
     private Map<String, Set<String>> macroUsage = new HashMap();
     private ScilabLexer scilabLexer;
     private String outputDirectory;
+    private Map<String, String> mapId;
 
     public static void main(String[] args) {
-       ScilabSourceBrowser b = new ScilabSourceBrowser(args[0], args[1], args[2], args[3]);
-       b.generateSource();
+        ScilabSourceBrowser b = new ScilabSourceBrowser(args[0], args[1], args[2], args[3]);
+        b.generateSource();
     }
 
     public ScilabSourceBrowser(String paths, String primFile, String macroFile, String outputDirectory) {
-       super();
-       this.outputDirectory = outputDirectory;
-       scilabLexer = new ScilabLexer(primFile, macroFile);
-       generateMapId(paths);
+        super();
+        this.outputDirectory = outputDirectory;
+        scilabLexer = new ScilabLexer(primFile, macroFile);
+        generateMapId(paths);
     }
 
     public void generateSource() {
-       new FirstPass().getMacroUsage();
-       for (String file : files) {
-           try {
-               File f = new File(file);
-               System.out.println(f);
-               Reader input = new BufferedReader(new FileReader(f));
-               currentCommand = f.getName().split("\\.")[0];
-               buffer = new FileWriter(outputDirectory + File.separator + currentCommand + ".html");
-               buffer.append(entete);
-               buffer.append("<div style=\"code\"><pre>");
-               scilabLexer.convert(this, input, false);
-               buffer.append("</pre></div>\n</body>\n</html>");
-               ((Writer) buffer).flush();
-               ((Writer) buffer).close();
-               input.close();
-           } catch (IOException e) {
-               e.printStackTrace();
-           }
-       }
+        new FirstPass().getMacroUsage();
+        for (String file : files) {
+            try {
+                File f = new File(file);
+                System.out.println(f);
+                Reader input = new BufferedReader(new FileReader(f));
+                currentCommand = f.getName().split("\\.")[0];
+                buffer = new FileWriter(outputDirectory + File.separator + currentCommand + ".html");
+                buffer.append(entete);
+                buffer.append("<div style=\"code\"><pre>");
+                scilabLexer.convert(this, input, false);
+                buffer.append("</pre></div>\n</body>\n</html>");
+                ((Writer) buffer).flush();
+                ((Writer) buffer).close();
+                input.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
     }
 
     /**
      * {@inheritDoc}
-     */  
+     */
     public void handleCommand(String seq) throws IOException {
-       buffer.append("<span class=\"command\">");
-       buffer.append(seq);
-       buffer.append("</span>");
+        buffer.append("<span class=\"command\">");
+        buffer.append(seq);
+        buffer.append("</span>");
     }
 
     /**
      * {@inheritDoc}
-     */  
+     */
     public void handleFunctionId(String seq) throws IOException {
-       buffer.append("<a href=\"#");
-       buffer.append(seq);
-       buffer.append("\"><span class=\"functionid\">");
-       buffer.append(seq);
-       buffer.append("</span></a>");
+        buffer.append("<a href=\"#");
+        buffer.append(seq);
+        buffer.append("\"><span class=\"functionid\">");
+        buffer.append(seq);
+        buffer.append("</span></a>");
     }
 
     /**
      * {@inheritDoc}
-     */  
+     */
     public void handleFunctionIdDecl(String seq) throws IOException {
-       buffer.append("<a name=\"");
-       buffer.append(seq);
-       buffer.append("\"></a><span class=\"functionid\">");
-       buffer.append(seq);
-       buffer.append("</span>");
+        buffer.append("<a name=\"");
+        buffer.append(seq);
+        buffer.append("\"></a><span class=\"functionid\">");
+        buffer.append(seq);
+        buffer.append("</span>");
     }
 
     /**
      * {@inheritDoc}
-     */  
+     */
     public void handleInputOutputArgs(String seq) throws IOException {
-       buffer.append("<a href=\"#");
-       buffer.append(seq);
-       buffer.append("\"><span class=\"inputoutputargs\">");
-       buffer.append(seq);
-       buffer.append("</span></a>");
+        buffer.append("<a href=\"#");
+        buffer.append(seq);
+        buffer.append("\"><span class=\"inputoutputargs\">");
+        buffer.append(seq);
+        buffer.append("</span></a>");
     }
 
     /**
      * {@inheritDoc}
-     */  
+     */
     public void handleInputOutputArgsDecl(String seq) throws IOException {
-       buffer.append("<a name=\"");
-       buffer.append(seq);
-       buffer.append("\"></a><span class=\"inputoutputargs\">");
-       buffer.append(seq);
-       buffer.append("</span>");
+        buffer.append("<a name=\"");
+        buffer.append(seq);
+        buffer.append("\"></a><span class=\"inputoutputargs\">");
+        buffer.append(seq);
+        buffer.append("</span>");
     }
 
     private void generateMapId(String filename) {
-       BufferedReader input = null;
-       files = new ArrayList();
-       mapId = new HashMap();
-       try {
-           input =  new BufferedReader(new FileReader(filename));
-           String line = null;
-           while ((line = input.readLine()) != null) {
-               files.add(line);
-               String name = new File(line).getName().split("\\.")[0];
-               mapId.put(name, name + ".html");
-           }
-       } catch (IOException e) {
-           System.err.println(e);
-       }
-       if (input != null) {
-           try {
-               input.close();
-           } catch (IOException e) {
-               System.err.println(e);
-           }
-       }
+        BufferedReader input = null;
+        files = new ArrayList();
+        mapId = new HashMap();
+        try {
+            input =  new BufferedReader(new FileReader(filename));
+            String line = null;
+            while ((line = input.readLine()) != null) {
+                files.add(line);
+                String name = new File(line).getName().split("\\.")[0];
+                mapId.put(name, name + ".html");
+            }
+        } catch (IOException e) {
+            System.err.println(e);
+        }
+        if (input != null) {
+            try {
+                input.close();
+            } catch (IOException e) {
+                System.err.println(e);
+            }
+        }
     }
 
     class FirstPass extends AbstractScilabCodeHandler {
-       
-       FirstPass() { }
-       
-       void getMacroUsage() {
-           for (String file : files) {
-               try {
-                   File f = new File(file);
-                   Reader input = new BufferedReader(new FileReader(f));
-                   currentCommand = f.getName().split("\\.")[0];
-                   scilabLexer.convert(this, input, false);
-               } catch (IOException e) {
-                   e.printStackTrace();
-               }
-           }
-       }
-
-       public void handleMacro(String macro) throws IOException {
-           Set<String> set = macroUsage.get(macro);
-           if (set == null) {
-               set = new HashSet();
-               macroUsage.put(macro, set);
-           }           
-           set.add(currentCommand);
-       }
+
+        FirstPass() { }
+
+        void getMacroUsage() {
+            for (String file : files) {
+                try {
+                    File f = new File(file);
+                    Reader input = new BufferedReader(new FileReader(f));
+                    currentCommand = f.getName().split("\\.")[0];
+                    scilabLexer.convert(this, input, false);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+
+        public void handleMacro(String macro) throws IOException {
+            Set<String> set = macroUsage.get(macro);
+            if (set == null) {
+                set = new HashSet();
+                macroUsage.put(macro, set);
+            }
+            set.add(currentCommand);
+        }
     }
-}
\ No newline at end of file
+}
index 1d53453..0342d33 100644 (file)
@@ -3,19 +3,23 @@
 
     <method name="buildDocumentation" returnType="void">
       <param type="String" name="type" />
-       </method>
+    </method>
 
     <method name="setOutputDirectory" returnType="boolean">
       <param type="String" name="directory" />
-       </method>
+    </method>
 
-       <method name="setWorkingLanguage" returnType="void">
+    <method name="setWorkingLanguage" returnType="void">
       <param type="String" name="language" />
-       </method>
+    </method>
 
-       <method name="setExportFormat" returnType="void">
+    <method name="setExportFormat" returnType="void">
       <param type="String" name="format" />
-       </method>
+    </method>
+
+    <method name="setIsToolbox" returnType="void">
+      <param type="boolean" name="isToolbox" />
+    </method>
 
     <method name="process" returnType="String">
       <param type="String" name="sourceDoc" />
index 53ef397..fe3bf5f 100644 (file)
@@ -108,6 +108,7 @@ voidbuildDocumentationjstringID=NULL;
 jbooleansetOutputDirectoryjstringID=NULL; 
 voidsetWorkingLanguagejstringID=NULL; 
 voidsetExportFormatjstringID=NULL; 
+voidsetIsToolboxjbooleanID=NULL; 
 jstringprocessjstringjstringID=NULL; 
 
 
@@ -135,6 +136,7 @@ throw GiwsException::JniObjectCreationException(curEnv, this->className());
 jbooleansetOutputDirectoryjstringID=NULL; 
 voidsetWorkingLanguagejstringID=NULL; 
 voidsetExportFormatjstringID=NULL; 
+voidsetIsToolboxjbooleanID=NULL; 
 jstringprocessjstringjstringID=NULL; 
 
 
@@ -229,6 +231,24 @@ throw GiwsException::JniCallMethodException(curEnv);
 }
 }
 
+void SciDocMain::setIsToolbox (bool isToolbox){
+
+JNIEnv * curEnv = getCurrentEnv();
+
+if (voidsetIsToolboxjbooleanID==NULL) { /* Use the cache */
+ voidsetIsToolboxjbooleanID = curEnv->GetMethodID(this->instanceClass, "setIsToolbox", "(Z)V" ) ;
+if (voidsetIsToolboxjbooleanID == NULL) {
+throw GiwsException::JniMethodNotFoundException(curEnv, "setIsToolbox");
+}
+}
+jboolean isToolbox_ = (static_cast<bool>(isToolbox) ? JNI_TRUE : JNI_FALSE);
+
+                         curEnv->CallVoidMethod( this->instance, voidsetIsToolboxjbooleanID ,isToolbox_);
+                        if (curEnv->ExceptionCheck()) {
+throw GiwsException::JniCallMethodException(curEnv);
+}
+}
+
 char * SciDocMain::process (char * sourceDoc, char * styleSheet){
 
 JNIEnv * curEnv = getCurrentEnv();
index 9b7cf93..71f5881 100644 (file)
@@ -68,6 +68,7 @@ jmethodID voidbuildDocumentationjstringID; // cache method id
 jmethodID jbooleansetOutputDirectoryjstringID; // cache method id
 jmethodID voidsetWorkingLanguagejstringID; // cache method id
 jmethodID voidsetExportFormatjstringID; // cache method id
+jmethodID voidsetIsToolboxjbooleanID; // cache method id
 jmethodID jstringprocessjstringjstringID; // cache method id
 
 
@@ -133,6 +134,8 @@ void setWorkingLanguage(char * language);
 
 void setExportFormat(char * format);
 
+void setIsToolbox(bool isToolbox);
+
 char * process(char * sourceDoc, char * styleSheet);