Ignore:
Timestamp:
2013-12-07T20:50:29+01:00 (11 years ago)
Author:
donvip
Message:

[josm_openinghours] remove generated code from SVN, use JOSM's JavaCC

Location:
applications/editors/josm/plugins/OpeningHoursEditor
Files:
3 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/OpeningHoursEditor/build.xml

    r29854 r30112  
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    66    <property name="plugin.main.version" value="6162"/>
    7     <!--
    8       ************************************************
    9       ** should not be necessary to change the following properties
    10      -->
    11     <property name="josm" location="../../core/dist/josm-custom.jar"/>
    12     <property name="plugin.build.dir" value="build"/>
    13     <property name="plugin.src.dir" value="src"/>
    14     <!-- this is the directory where the plugin jar is copied to -->
    15     <property name="plugin.dist.dir" value="../../dist"/>
    16     <property name="ant.build.javac.target" value="1.6"/>
    17     <property name="plugin.jar" value="${plugin.dist.dir}/${ant.project.name}.jar"/>
    18     <!--
     7       
     8    <property name="plugin.author" value="Falko Thomale"/>
     9    <property name="plugin.class" value="org.openstreetmap.josm.plugins.ohe.OhePlugin"/>
     10    <property name="plugin.description" value="extended options for editing opening_hours"/>
     11    <property name="plugin.icon" value="images/opening_hours.png"/>
     12    <property name="plugin.link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/OpeningHoursEditor"/>
     13
     14    <!-- ** include targets that all plugins have in common ** -->
     15    <import file="../build-common.xml"/>
     16       
     17    <property name="javacc.home" location="../../core/tools"/>
     18        <property name="parser.dir" location="${plugin.src.dir}/org/openstreetmap/josm/plugins/ohe/parser"/>
     19       
     20    <target name="javacc" depends="init" unless="javacc.notRequired">
     21        <exec append="false" executable="java" failifexecutionfails="true">
     22            <arg value="-cp"/>
     23            <arg value="${javacc.home}/javacc.jar"/>
     24            <arg value="javacc"/>
     25            <arg value="-JDK_VERSION=1.6"/>
     26            <arg value="-GRAMMAR_ENCODING=UTF-8"/>
     27            <arg value="-UNICODE_INPUT"/>
     28            <arg value="-OUTPUT_DIRECTORY=${parser.dir}"/>
     29            <arg value="${parser.dir}/OpeningTimeCompiler.jj"/>
     30        </exec>
     31    </target>
     32
     33        <!--
    1934    **********************************************************
    20     ** javacc-otc - compiles OpeningTimeCompiler
    21     **
    22     ** can be changed see http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-moz.htm#tth_sEc2.5
     35    ** compile - compiles the source tree
    2336    **********************************************************
    2437    -->
    25     <target name="javacc-otc">
    26         <echo message="compiling OpeningTimeCompiler with javacc ... "/>
    27         <exec executable="javacc" dir="src/org/openstreetmap/josm/plugins/ohe/parser/">
    28             <arg value="OpeningTimeCompiler.jj"/>
    29         </exec>
    30     </target>
    31     <!--
    32     **********************************************************
    33     ** init - initializes the build
    34     **********************************************************
    35     -->
    36     <target name="init">
    37         <mkdir dir="${plugin.build.dir}"/>
    38     </target>
    39     <!--
    40     **********************************************************
    41     ** compile - complies the source tree
    42     **********************************************************
    43     -->
    44     <target name="compile" depends="init">
    45         <echo message="compiling sources for  ${plugin.jar} ... "/>
    46         <javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}">
     38    <target name="compile" depends="init, javacc">
     39        <echo message="compiling sources for ${plugin.jar} ... "/>
     40        <javac srcdir="src" debug="true" destdir="${plugin.build.dir}" includeAntRuntime="false" encoding="UTF-8">
     41            <classpath>
     42                <pathelement path="${plugin.build.dir}"/>
     43                <pathelement location="${josm}"/>
     44            </classpath>
    4745            <compilerarg value="-Xlint:deprecation"/>
    4846            <compilerarg value="-Xlint:unchecked"/>
    4947        </javac>
    5048    </target>
    51     <!--
    52     **********************************************************
    53     ** dist - creates the plugin jar
    54     **********************************************************
    55     -->
    56     <target name="dist" depends="compile,revision">
    57         <echo message="creating ${ant.project.name}.jar ... "/>
    58         <copy todir="${plugin.build.dir}/images">
    59             <fileset dir="images"/>
    60         </copy>
    61         <copy todir="${plugin.build.dir}/data">
    62             <fileset dir="data"/>
    63         </copy>
    64         <copy todir="${plugin.build.dir}">
    65             <fileset dir=".">
    66                 <include name="README"/>
    67                 <include name="LICENSE"/>
    68             </fileset>
    69         </copy>
    70         <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}">
    71             <!--
    72         ************************************************
    73         ** configure these properties. Most of them will be copied to the plugins
    74         ** manifest file. Property values will also show up in the list available
    75         ** plugins: http://josm.openstreetmap.de/wiki/Plugins.
    76         **
    77         ************************************************
    78     -->
    79             <manifest>
    80                 <attribute name="Author" value="Falko Thomale"/>
    81                 <attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.ohe.OhePlugin"/>
    82                 <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
    83                 <attribute name="Plugin-Description" value="extended options for editing opening_hours"/>
    84                 <attribute name="Plugin-Icon" value="images/opening_hours.png"/>
    85                 <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/OpeningHoursEditor"/>
    86                 <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
    87                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
    88             </manifest>
    89         </jar>
    90     </target>
    91     <!--
    92     **********************************************************
    93     ** revision - extracts the current revision number for the
    94     **    file build.number and stores it in the XML property
    95     **    version.*
    96     **********************************************************
    97     -->
    98     <target name="revision">
    99         <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
    100             <env key="LANG" value="C"/>
    101             <arg value="info"/>
    102             <arg value="--xml"/>
    103             <arg value="."/>
    104         </exec>
    105         <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
    106         <delete file="REVISION"/>
    107     </target>
    108     <!--
    109     **********************************************************
    110     ** clean - clean up the build environment
    111     **********************************************************
    112     -->
    113     <target name="clean">
    114         <delete dir="${plugin.build.dir}"/>
    115         <delete file="${plugin.jar}"/>
    116     </target>
    117     <!--
    118     **********************************************************
    119     ** install - install the plugin in your local JOSM installation
    120     **********************************************************
    121     -->
    122     <target name="install" depends="dist">
    123         <property environment="env"/>
    124         <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins">
    125             <and>
    126                 <os family="windows"/>
    127             </and>
    128         </condition>
    129         <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
    130     </target>
    131     <!--
    132     ************************** Publishing the plugin ***********************************
    133     -->
    134     <!--
    135         ** extracts the JOSM release for the JOSM version in ../core and saves it in the
    136         ** property ${coreversion.info.entry.revision}
    137         **
    138         -->
    139     <target name="core-info">
    140         <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
    141             <env key="LANG" value="C"/>
    142             <arg value="info"/>
    143             <arg value="--xml"/>
    144             <arg value="../../core"/>
    145         </exec>
    146         <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>
    147         <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
    148         <echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>
    149         <delete file="core.info.xml"/>
    150     </target>
    151     <!--
    152         ** commits the source tree for this plugin
    153         -->
    154     <target name="commit-current">
    155         <echo>Commiting the plugin source with message '${commit.message}' ...</echo>
    156         <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
    157             <env key="LANG" value="C"/>
    158             <arg value="commit"/>
    159             <arg value="-m '${commit.message}'"/>
    160             <arg value="."/>
    161         </exec>
    162     </target>
    163     <!--
    164         ** updates (svn up) the source tree for this plugin
    165         -->
    166     <target name="update-current">
    167         <echo>Updating plugin source ...</echo>
    168         <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
    169             <env key="LANG" value="C"/>
    170             <arg value="up"/>
    171             <arg value="."/>
    172         </exec>
    173         <echo>Updating ${plugin.jar} ...</echo>
    174         <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
    175             <env key="LANG" value="C"/>
    176             <arg value="up"/>
    177             <arg value="../dist/${plugin.jar}"/>
    178         </exec>
    179     </target>
    180     <!--
    181         ** commits the plugin.jar
    182         -->
    183     <target name="commit-dist">
    184         <echo>
    185     ***** Properties of published ${plugin.jar} *****
    186     Commit message    : '${commit.message}'                   
    187     Plugin-Mainversion: ${plugin.main.version}
    188     JOSM build version: ${coreversion.info.entry.revision}
    189     Plugin-Version    : ${version.entry.commit.revision}
    190     ***** / Properties of published ${plugin.jar} *****                   
    191                        
    192     Now commiting ${plugin.jar} ...
    193     </echo>
    194         <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
    195             <env key="LANG" value="C"/>
    196             <arg value="-m '${commit.message}'"/>
    197             <arg value="commit"/>
    198             <arg value="${plugin.jar}"/>
    199         </exec>
    200     </target>
    201     <!-- ** make sure svn is present as a command line tool ** -->
    202     <target name="ensure-svn-present">
    203         <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">
    204             <env key="LANG" value="C"/>
    205             <arg value="--version"/>
    206         </exec>
    207         <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">
    208             <!-- return code not set at all? Most likely svn isn't installed -->
    209             <condition>
    210                 <not>
    211                     <isset property="svn.exit.code"/>
    212                 </not>
    213             </condition>
    214         </fail>
    215         <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">
    216             <!-- error code from SVN? Most likely svn is not what we are looking on this system -->
    217             <condition>
    218                 <isfailure code="${svn.exit.code}"/>
    219             </condition>
    220         </fail>
    221     </target>
    222     <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
    223     </target>
     49
    22450</project>
  • applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/parser/OpeningTimeCompiler.jj

    r22751 r30112  
    99timespan ::= [ dayspanlist " " ] daytimespanlist
    1010
    11 daytimespanlist ::=     daytimespan [ "," daytimespanlist ]
     11daytimespanlist ::= daytimespan [ "," daytimespanlist ]
    1212daytimespan ::= off | ( daytime ( openend |  [ "-" daytime ]) )
    13 daytime ::=     (DIGIT DIGIT ":" DIGIT DIGIT )
     13daytime ::= (DIGIT DIGIT ":" DIGIT DIGIT )
    1414openend ::= PLUS
    1515off ::= OFF
    1616
    17 dayspanlist ::= dayspan [ "," dayspanlist ]
    18 dayspan ::=     WEEKDAY [ "-" WEEKDAY ]
     17dayspanlist ::= dayspan [ "," dayspanlist ]
     18dayspan ::= WEEKDAY [ "-" WEEKDAY ]
    1919*/
    2020
     
    7777  {
    7878    if (time.size() == 0) {
    79                 ArrayList<DaySpan> daySpans = new ArrayList<DaySpan>();
    80         daySpans.add(new DaySpan(0,6));
    81                 ArrayList<DaytimeSpan> timeSpans = new ArrayList<DaytimeSpan>();
    82         timeSpans.add(new DaytimeSpan(0, 24 * 60));
    83         time.add(new DateTime(daySpans, timeSpans));
    84         }
    85        
     79          ArrayList<DaySpan> daySpans = new ArrayList<DaySpan>();
     80        daySpans.add(new DaySpan(0,6));
     81          ArrayList<DaytimeSpan> timeSpans = new ArrayList<DaytimeSpan>();
     82        timeSpans.add(new DaytimeSpan(0, 24 * 60));
     83        time.add(new DateTime(daySpans, timeSpans));
     84    }
     85       
    8686    return time;
    8787  }
     
    9999    list.add(first);
    100100    if(second != null)
    101         list.addAll(second);
     101        list.addAll(second);
    102102    return list;
    103103  }
     
    128128    list.add(first);
    129129    if(second != null)
    130         list.addAll(second);
     130        list.addAll(second);
    131131    return list;
    132132  }
     
    144144  {
    145145    if (end < 0)
    146         end = start;
     146        end = start;
    147147    else if(end < start)
    148         throw new SyntaxException(null, usedTokens.lastElement().beginColumn - 1, usedTokens.lastElement().endColumn + 1);
     148        throw new SyntaxException(null, usedTokens.lastElement().beginColumn - 1, usedTokens.lastElement().endColumn + 1);
    149149   
    150150    return new DaytimeSpan(start, end);
     
    167167
    168168    if (hour > 24)
    169         throw new SyntaxException(null, th1.beginColumn - 1, th0.endColumn + 1);
     169        throw new SyntaxException(null, th1.beginColumn - 1, th0.endColumn + 1);
    170170    if (minute >= 60 || (hour == 24 && minute != 0))
    171         throw new SyntaxException(null, tm1.beginColumn - 1, tm0.endColumn + 1);
     171        throw new SyntaxException(null, tm1.beginColumn - 1, tm0.endColumn + 1);
    172172
    173173    return hour * 60 + minute;
     
    235235  {
    236236    if(end < 0)
    237         end = start;
     237        end = start;
    238238    else if(end < start)
    239         throw new SyntaxException(null, usedTokens.lastElement().beginColumn - 1, usedTokens.lastElement().endColumn + 1);
     239        throw new SyntaxException(null, usedTokens.lastElement().beginColumn - 1, usedTokens.lastElement().endColumn + 1);
    240240   
    241241    return new DaySpan(start, end);
     
    253253    for (int i = 0; i < WEEKDAYS.length; ++i)
    254254      if (WEEKDAYS[i].equals(t.image))
    255         return i;
    256        
     255        return i;
     256       
    257257    throw new SyntaxException(null, t.beginColumn - 1, t.endColumn + 1);
    258258  }
Note: See TracChangeset for help on using the changeset viewer.