ObjectWeb Consortium
Search ObjectWeb Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | enhydra List | Febuary 1999 Index

<--  Date Index  --> <--  Thread Index  -->

Enhydra: PATCH: Enhydra Build On Windows, NT, Linux


Good news!

  The Enhydra source tree would not build on Windows and NT
with jdk 1.1.6 and 1.1.7... the problem was with JavaCC,
which is used to build the Enhydra Jolt compiler, which is
used to build the Enhydra apps in the tree. There were
reports of this same problem on Linux also.

  We discovered a work-around for this problem! The attached
file replaces 
com/lutris/appserver/server/jolt/parser/JoltParser.jjt

  You only need this new file if you are trying to build the
entire Enhydra tree, and it fails with the error message
"Can't find class com/lutris/appserver/server/jolt/joltc/
JoltCompile". 
   If you are compiling your application with the runtime install
of Enhydra you do not need this "patch".

  This fix should eliminate most of the problems people have
been having building Enhydra.

Andy John
/*-----------------------------------------------------------------------------
 * Enhydra Java Application Server
 * Copyright 1997-1999 Lutris Technologies, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes Enhydra software developed by Lutris
 *      Technologies, Inc. and its contributors.
 * 4. Neither the name of Lutris Technologies nor the names of its 
contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY LUTRIS TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL LUTRIS TECHNOLOGIES OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 
*-----------------------------------------------------------------------------
 * $Id: JoltParser.jjt,v 1.10 1999/02/27 08:30:00 andy Exp $
 
*-----------------------------------------------------------------------------
 */

options {
    MULTI=true;
    IGNORE_CASE=true;
    VISITOR=true;
    JAVA_UNICODE_ESCAPE=true;
}

PARSER_BEGIN(JoltParser)
package com.lutris.appserver.server.jolt.parser;

/**
 * This parser uses JJTree and JavaCC to generate the Java class.
 *
 * There are multiple lexical states:
 * DEFAULT      html sections and jolt tag parsed contents
 * IN_UNPARSED  jolt tag unparsed contents              <jolt>...</jolt>
 * IN_JOLT_TAG  inside jolt tags (parsed contents)      <jolt ... >
 * IN_U_JOLT_TAG inside jolt tags (unparsed contents)   <jolt ... >
 * IN_JOLT_FIELD between the jolt field and end jolt field tags (@ ... @)
 * IN_ARG_NAME  the left hand side of the equal sign    ... =
 * IN_U_ARG_NAME the left hand side of the equal sign   ... =
 * IN_ARG_VALUE the right hand side of the equal sign   = ...
 * IN_U_ARG_VALUE the right hand side of the equal sign = ...
 *
 * The reason for all of the _U states is that we don't want the token
 * manager finding tokens and changing states inside of unparsed jolt
 * contents.  Because of this we end up with some almost identical Nodes
 * for the parsed and unparsed contents states.
 *
 * When used as a standalone application the first and only
 * argument is the file to be parsed.
 * If no argument is passed System.in is parsed by default.
 *
 * Otherwise you can instantiate the JoltParser, call Start(),
 * and then use a Visitor on the node tree as is done in main().
 *
 * Known limitations:
 * Jolt fields are recognized as tokens inside of comments
 *   within html sections.
 * Jolt end tags are recognized as the end of a javadef
 *   section even if they are inside of a java comment.
 *
 * @author Shawn McMurdo
 * @version $Revision: 1.10 $
 */
public class JoltParser {

    private static String PARSER_NAME = "Lutris Jolt Parser";

    /**
     * The main entry point into the standalone parser.
     *
     * @param args
     *          The commandline arguments.
     */
    public static void main(String args[]) {
        JoltParser joltParser;

        if (args.length == 0) {
            joltParser = new JoltParser(System.in);
        } else if (args.length == 1) {
            try {
                joltParser =
                        new JoltParser(new java.io.FileInputStream(args[0]));
            } catch (java.io.FileNotFoundException e) {
                System.err.println(PARSER_NAME + ": Could not find file: " +
                        args[0]);
                return;
            }
        } else {
            usage();
            return;
        }

        try {
            // Parse the file.
            ASTStart startNode = joltParser.Start();

            // Use a visitor to traverse the tree printing each node.
            JoltParserVisitor visitor = new JoltDumpVisitor();
            startNode.jjtAccept(visitor, null);

            System.out.println(PARSER_NAME + ": Completed successfully.");
        } catch (Exception e) {
            System.out.println(PARSER_NAME + ": Encountered an error.");
            System.out.println(e.getMessage());
        }
    }

    /**
     * Prints a usage message.
     */
    public static void usage() {
        System.err.println(PARSER_NAME);
        System.err.println("usage: java JoltParser < yourfile.jhtml");
        System.err.println("or     java JoltParser yourfile.jhtml");
    }

    /**
     * Strips surrounding single and double quotes from argvalues.
     *
     * @param argvalue
     *          The string to dequote.
     * @return The dequoted argvalue String.
     */
    public static String dequote(String argvalue) {
        if ((argvalue != null) &&
                ((argvalue.startsWith("'") && argvalue.endsWith("'")) ||
                (argvalue.startsWith("\"") && argvalue.endsWith("\"")))) {

            return argvalue.substring(1, argvalue.length() - 1);
        } else {
            return argvalue;
        }
    }
}

PARSER_END(JoltParser)

/* DEFAULT */
TOKEN :
{
    <JOLTSTART: "<jolt"> : IN_JOLT_TAG
|   <JOLTFIELDSTART: "(@"> : IN_JOLT_FIELD
}

<DEFAULT, IN_UNPARSED>
TOKEN :
{
    <JOLTEND: "</jolt>"> : DEFAULT
|   <HTMLCHAR: ~[]>
}

<IN_JOLT_TAG, IN_U_JOLT_TAG, IN_JOLT_FIELD, IN_ARG_NAME, IN_U_ARG_NAME>
SKIP :
{
  " "
| "\t"
| "\n"
| "\r"
}

<IN_JOLT_FIELD, IN_JOLT_FIELD_DEFAULT>
TOKEN :
{
    <JOLTFIELDEND: "@)"> : DEFAULT
}

<IN_JOLT_FIELD>
TOKEN :
{
    <ENCODINGSTART: "(">
|   <ENCODINGEND: ")">
|   <DEFAULTSTART: ":"> : IN_JOLT_FIELD_DEFAULT
}

<IN_JOLT_FIELD_DEFAULT>
TOKEN :
{
    <SQ: "'">
|   <DQ: "\"">
|   <WS: " " | "\t" | "\r" | "\n">
|   <CH: ~["'", "\"", " ", "\t", "\r", "\n"]>
}

<IN_JOLT_TAG, IN_U_JOLT_TAG>
TOKEN :
{
    <EQ: "=">
|   <FIELD: "field">
|   <BOOLEANCONDITIONAL: <IFEQ> | <IFNEQ>>
|   <#IFEQ: "ifeq">
|   <#IFNEQ: "ifneq">
|   <DEFINEDCONDITIONAL: <IFDEF> | <IFNDEF>>
|   <#IFDEF: "ifdef">
|   <#IFNDEF: "ifndef">
|   <METHODCONDITIONAL: <IFCALL> | <IFNCALL>>
|   <#IFCALL: "ifcall">
|   <#IFNCALL: "ifncall">
}

<IN_JOLT_TAG>
TOKEN :
{
    <TAGEND: ">"> : DEFAULT
|   <ARGDOT: "arg."> : IN_ARG_NAME
|   <VALUE: "value"> : IN_ARG_NAME
|   <JAVADEF: "javadef"> : IN_U_JOLT_TAG
|   <HTMLDEF: "htmldef">
|   <ANYCALL: <CALL> | <JAVACALL> | <HTMLCALL>> : IN_U_JOLT_TAG
|   <#CALL: "call">
|   <#JAVACALL: "javacall">
|   <#HTMLCALL: "htmlcall">
|   <HTML: "html">
|   <JAVAIMPORT: "javaimport"> : IN_U_JOLT_TAG
|   <INCLUDE: "include"> : IN_U_ARG_NAME
|   <SOURCE: "source"> : IN_U_ARG_NAME
|   <JAVACATCH: "javacatch"> : IN_U_JOLT_TAG
|   <JAVAFINALLY: "javafinally"> : IN_U_JOLT_TAG
}

<IN_U_JOLT_TAG>
TOKEN :
{
    <U_TAGEND: ">"> : IN_UNPARSED
|   <U_ARGDOT: "arg."> : IN_U_ARG_NAME
|   <U_VALUE: "value"> : IN_U_ARG_NAME
}

<IN_ARG_NAME>
TOKEN :
{
    <ARGEQ: "="> : IN_ARG_VALUE
}

<IN_U_ARG_NAME>
TOKEN :
{
    <U_ARGEQ: "="> : IN_U_ARG_VALUE
}

<IN_ARG_VALUE>
TOKEN :
{
    <ARGVALUE: "'" ( ~["'"] )* "'"
        |   "\"" ( ~["\""] )* "\""
        | ( ~[">", "\"", "'", " ", "\t", "\n", "\r"] )+
    > : IN_JOLT_TAG
}

<IN_U_ARG_VALUE>
TOKEN :
{
    <U_ARGVALUE: "'" ( ~["'"] )* "'"
        |   "\"" ( ~["\""] )* "\""
        | ( ~[">", "\"", "'", " ", "\t", "\n", "\r"] )+
    > : IN_U_JOLT_TAG
}

/* XXX The breaking of LETTER range definitions on the unicode */
/* XXX characters \u018e and \u0258 is to avoid a bug in JDK 1.1.7 and 1.2 */
<IN_JOLT_TAG, IN_U_JOLT_TAG, IN_JOLT_FIELD, IN_ARG_NAME, IN_U_ARG_NAME>
TOKEN :
{
    <DOT: ".">
|   <QUOTE: <SQUOTE> | <DQUOTE>>
|   <#SQUOTE: "'">
|   <#DQUOTE: "\"">
|   <IDENTIFIER: <LETTER> (<LETTER> | <DIGIT>)*>
|   <#LETTER:
        [
            "\u0024",
            "\u0041"-"\u005a",
            "\u005f",
            "\u0061"-"\u007a",
            "\u00c0"-"\u00d6",
            "\u00d8"-"\u00f6",
            "\u00f8"-"\u00ff",
            "\u0100"-"\u018d",
            "\u018e",
            "\u018f"-"\u0257",
            "\u0258",
            "\u0259"-"\u1fff",
            "\u3040"-"\u318f",
            "\u3300"-"\u337f",
            "\u3400"-"\u3d2d",
            "\u4e00"-"\u9fff",
            "\uf900"-"\ufaff"
        ]
    >
|   <#DIGIT:
        [
            "\u0030"-"\u0039",
            "\u0660"-"\u0669",
            "\u06f0"-"\u06f9",
            "\u0966"-"\u096f",
            "\u09e6"-"\u09ef",
            "\u0a66"-"\u0a6f",
            "\u0ae6"-"\u0aef",
            "\u0b66"-"\u0b6f",
            "\u0be7"-"\u0bef",
            "\u0c66"-"\u0c6f",
            "\u0ce6"-"\u0cef",
            "\u0d66"-"\u0d6f",
            "\u0e50"-"\u0e59",
            "\u0ed0"-"\u0ed9",
            "\u1040"-"\u1049"
        ]
    >
}

ASTStart Start() : {}
{
    (JoltSection() | JoltField() | HtmlSection() )* <EOF>
    { return jjtThis; }
}

String Identifier() #void :
{
    String s = null;
    Token t;
}
{
    (<QUOTE>)?
    t=<IDENTIFIER>
    {
        s = t.image;
    }
    (<QUOTE>)?
    {
        return s;
    }
}

String Name() #void :
{
    String s = null;
    String r = null;
    Token t = null;
}
{
    (<QUOTE>)?
    (LOOKAHEAD(2)
    s=FullName()
    {
        r = s;
    }
    | t=<IDENTIFIER>
    {
        r = t.image;
    }
    )
    (<QUOTE>)?
    {
        return r;
    }
}

String FullName() #void :
{
    StringBuffer s = new StringBuffer();
    Token t;
    Token tt;
}
{
    t=<IDENTIFIER>
    {
        s.append(t.image);
    }
    (<DOT> tt=<IDENTIFIER>
        {
            s.append("." + tt.image);
        }
    )+
    {
        return s.toString();
    }
}

void JoltSection() #void : {}
{
    <JOLTSTART>
    (   Javadef()
    |   Htmldef()
    |   AnyCall()
    |   JoltHtml()
    |   JavaImport()
    |   Include()
    |   Source()
    |   JavaCatch()
    |   JavaFinally()
    )
}

String JoltFieldEncoding() #void :
{
    String e;
}
{
    <ENCODINGSTART> e=Identifier() <ENCODINGEND>
    {
        return e;
    }
}

String SingleQuotedValue() #void :
{
    Token t;
    StringBuffer sb = new StringBuffer();
}
{
    <SQ>
    (
        (t=<DQ> | t=<WS> | t=<CH>)
        {
            sb.append(t.image);
        }
    )*
    <SQ>
    {
        return sb.toString();
    }
}

String DoubleQuotedValue() #void :
{
    Token t;
    StringBuffer sb = new StringBuffer();
}
{
    <DQ>
    (
        (t=<SQ> | t=<WS> | t=<CH>)
        {
            sb.append(t.image);
        }
    )*
    <DQ>
    {
        return sb.toString();
    }
}

String UnQuotedValue() #void :
{
    Token t;
    StringBuffer sb = new StringBuffer();
}
{
    t=<CH>
    {
        sb.append(t.image);
    }
    (LOOKAHEAD(2, {getToken(1).kind != JOLTFIELDEND})
        (t=<SQ> | t=<DQ> | t=<CH>)
        {
            sb.append(t.image);
        }
    )*
    {
        return sb.toString();
    }
}

String JoltFieldDefaultValue() #void :
{
    String v;
}
{
    (
        v=DoubleQuotedValue()
    |   v=SingleQuotedValue()
    |   v=UnQuotedValue()
    )
    {
        return v;
    }
}

String JoltFieldDefault() #void :
{
    String d;
}
{
    <DEFAULTSTART> (<WS>)*
    d=JoltFieldDefaultValue() (<WS>)*
    {
        return d;
    }
}

void JoltField() :
{
    String f = null;
    String e = null;
    String d = null;
    Token st = null;
}
{
    st=<JOLTFIELDSTART> (e=JoltFieldEncoding())? (f=Name())?
    (d=JoltFieldDefault())? <JOLTFIELDEND>
    {
        jjtThis.setBeginLine(st.beginLine);
        if (f == null) {
            jjtThis.setFieldName("#ALL");
        } else {
            jjtThis.setFieldName(f);
        }
        jjtThis.setEncoding(e);
        jjtThis.setDefault(d);
    }
}

void HtmlSection() :
{
    Token t;
    StringBuffer s = new StringBuffer();
    boolean first = true;
}
{
    (LOOKAHEAD(2, {getToken(1).kind != JOLTSTART})
        t=<HTMLCHAR>
        {
            if (first) {
                jjtThis.setBeginLine(t.beginLine);
                first = false;
            }
            s.append(t.image);
        }
    )+
    {
        jjtThis.setContents(s.toString());
    }
}

void JoltContents() :
{
    Token t;
    StringBuffer sb = new StringBuffer();
    boolean first = true;
}
{
    (LOOKAHEAD(2, {getToken(1).kind != JOLTEND})
        t=<HTMLCHAR>
        {
            if (first) {
                jjtThis.setBeginLine(t.beginLine);
                first = false;
            }
            sb.append(t.image);
        }
    )*
    {
        jjtThis.setContents(sb.toString());
    }
}

void JoltParsedContents() : {}
{
    (LOOKAHEAD(2, {getToken(1).kind != JOLTEND})
        (JoltSection() | JoltField() | HtmlSection() )
    )*
}

void Arg() :
{
    String n;
    Token v = null;
}
{
    <ARGDOT> n=Name() <ARGEQ> v=<ARGVALUE>
    {
        jjtThis.setName(n);
        jjtThis.setValue(dequote(v.image));
    }
}

void U_Arg() #Arg :
{
    String n;
    Token v = null;
}
{
    <U_ARGDOT> n=Name() <U_ARGEQ> v=<U_ARGVALUE>
    {
        jjtThis.setName(n);
        jjtThis.setValue(dequote(v.image));
    }
}

void ArgList() : {}
{
    (Arg())+
}

void U_ArgList() #ArgList : {}
{
    (U_Arg())+
}

void Conditional() #void : {}
{
    BooleanConditional()
|   DefinedConditional()
|   MethodConditional()
}

void U_Conditional() #void : {}
{
    U_BooleanConditional()
|   DefinedConditional()
|   U_MethodConditional()
}

void BooleanConditional() :
{
    Token o;
    String f;
    Token v;
}
{
    o=<BOOLEANCONDITIONAL> <FIELD> <EQ> f=Name()
    <VALUE> <ARGEQ> v=<ARGVALUE>
    {
        jjtThis.setOperator(o.image);
        jjtThis.setField(f);
        jjtThis.setValue(dequote(v.image));
    }
}

void U_BooleanConditional() #BooleanConditional :
{
    Token o;
    String f;
    Token v;
}
{
    o=<BOOLEANCONDITIONAL> <FIELD> <EQ> f=Name()
    <U_VALUE> <U_ARGEQ> v=<U_ARGVALUE>
    {
        jjtThis.setOperator(o.image);
        jjtThis.setField(f);
        jjtThis.setValue(dequote(v.image));
    }
}

void DefinedConditional() :
{
    Token o;
    String f;
}
{
    o=<DEFINEDCONDITIONAL> <FIELD> <EQ> f=Name()
    {
        jjtThis.setOperator(o.image);
        jjtThis.setField(f);
    }
}

void MethodConditional() :
{
    Token o;
    String m;
}
{
    o=<METHODCONDITIONAL> <EQ> m=Name() (ArgList())?
    {
        jjtThis.setOperator(o.image);
        jjtThis.setMethodName(m);
    }
}

void U_MethodConditional() #MethodConditional :
{
    Token o;
    String m;
}
{
    o=<METHODCONDITIONAL> <EQ> m=Name() (U_ArgList())?
    {
        jjtThis.setOperator(o.image);
        jjtThis.setMethodName(m);
    }
}

void Javadef() :
{
    Token st = null;
}
{
    st=<JAVADEF> <U_TAGEND> JoltContents() <JOLTEND>
    {
        jjtThis.setBeginLine(st.beginLine);
    }
}

void Htmldef() :
{
    String s;
    Token st = null;
}
{
    st=<HTMLDEF> <EQ> s=Identifier() <TAGEND> JoltParsedContents() <JOLTEND>
    {
        jjtThis.setBeginLine(st.beginLine);
        jjtThis.setMethodName(s);
    }
}

void AnyCall() :
{
    String n;
    Token st = null;
}
{
    st=<ANYCALL> <EQ> n=Name() (U_ArgList())? (U_Conditional())? <U_TAGEND>
    JoltContents() <JOLTEND>
    {
        jjtThis.setBeginLine(st.beginLine);
        jjtThis.setMethodName(n);
    }
}

void JoltHtml() :
{
    Token st = null;
}
{
    st=<HTML> (Conditional())? <TAGEND> JoltParsedContents() <JOLTEND>
    {
        jjtThis.setBeginLine(st.beginLine);
    }
}

void JavaImport() :
{
    Token st = null;
}
{
    st=<JAVAIMPORT> <U_TAGEND> JoltContents() <JOLTEND>
    {
        jjtThis.setBeginLine(st.beginLine);
    }
}

void Include() :
{
    Token f;
    Token st = null;
}
{
    st=<INCLUDE> <U_ARGEQ> f=<U_ARGVALUE> <U_TAGEND> JoltContents() <JOLTEND>
    {
        jjtThis.setBeginLine(st.beginLine);
        jjtThis.setFilename(dequote(f.image));
    }
}

void Source() :
{
    Token f;
    Token st = null;
}
{
    st=<SOURCE> <U_ARGEQ> f=<U_ARGVALUE> <U_TAGEND> JoltContents() <JOLTEND>
    {
        jjtThis.setBeginLine(st.beginLine);
        jjtThis.setFilename(dequote(f.image));
    }
}

void JavaCatch() :
{
    String e;
    Token st = null;
}
{
    st=<JAVACATCH> <EQ> e=Name() <U_TAGEND> JoltContents() <JOLTEND>
    {
        jjtThis.setBeginLine(st.beginLine);
        jjtThis.setException(e);
    }
}

void JavaFinally() :
{
    Token st = null;
}
{
    st=<JAVAFINALLY> <U_TAGEND> JoltContents() <JOLTEND>
    {
        jjtThis.setBeginLine(st.beginLine);
    }
}







<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 1999-2005, ObjectWeb Consortium | contact | webmaster.