Archived

This forum has been archived. Please start a new discussion on GitHub.

Slice compilers unable to parse demo .ice files?

I'm trying to evaluate ICE for possible use in an upcoming project, comparing it with .NET Remoting and various CORBA ORBs. ICE docs are impressive, and the features seem right, particularly AMD support in multiple languages. Now that I'm getting down to trying out the tools and hopefully writing a demo client/server pair, I'm flummoxed by what seems like the most basic thing.

I downloaded Ice-3.0.0-VC71.msi (also previously tried 2.1.2 and 2.1.1), and executed it. I let it install to the default C:\Ice-3.0.0\ and used the Complete install option, rather than Custom. This is on WinXP SP2.

Now I want to create Java and C# proxy & skeleton code corresponding to a simple Slice interface. I tried my own .ice file, but got unhelpful "syntax error" messages. Now I'm just trying to compile one of the simple demo .ice files.

I assumed the compilers (slice2java, slice2cs) would work on the command-line out of the box, but since they don't seem to (at least for me), I've tried setting ICE_HOME, PATH and even JAVA_HOME variables as recommended somewhere, and also tried building the provided demo projects in Visual Studio 7.1 (for C#) and ant (for Java). The results are always the same: "syntax error" messages without other information (such as line numbers).

Seems like I've got something configured wrong, or some dependency is missing, but I'm out of ideas as to what.

Anyone know this one? Any advice?

Seems like the parser is unhappy with something at the beginning of the file. The debug output below shows it recognizing various tokens properly, but the initial syntax error (due to token $undefined?) seems to have thrown everything off. Also, longer, more complex demo .ice files may result in similar "syntax error" messages in the beginning, followed by more informative errors that specify the file and line number and identify particular issues. In other words, the parser seems to "recover", but does so mid-scope, so it doesn't recognize valid slice code, complaining (for example) that interfaces in a module are declared at global scope.

Here's a demo .ice file I've tried:
C:\> type C:\Ice-3.0.0\demoj\book\printer\Printer.ice
// **********************************************************************
//
// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

#ifndef SIMPLE_ICE
#define SIMPLE_ICE

module Demo
{

    interface Printer
    {
        void printString(string s);
    };

};

#endif


And here's me trying to compile it to java:
C:\> c:\Ice-3.0.0\bin\slice2java.exe C:\Ice-3.0.0\demoj\book\printer\Printer.ice
syntax error
syntax error
syntax error


Same result with java2cs.exe and java2cpp.exe.
Here's the same, with debug output enabled:
C:\> c:\Ice-3.0.0\bin\slice2java.exe -d C:\Ice-3.0.0\demoj\book\printer\Printer.ice
Starting parse
Entering state 0
Reading a token: Next token is token $undefined ()
syntax error
Shifting token error ()
Entering state 1
Next token is token $undefined ()
Error: discarding token $undefined ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ICE_INTEGER_LITERAL ()
Error: discarding token ICE_INTEGER_LITERAL ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ICE_STRING_LITERAL ()
Error: discarding token ICE_STRING_LITERAL ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ICE_MODULE ()
Error: discarding token ICE_MODULE ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ICE_IDENTIFIER ()
Error: discarding token ICE_IDENTIFIER ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token '{' ()
Error: discarding token '{' ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ICE_INTERFACE ()
Error: discarding token ICE_INTERFACE ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ICE_IDENTIFIER ()
Error: discarding token ICE_IDENTIFIER ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token '{' ()
Error: discarding token '{' ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ICE_VOID ()
Error: discarding token ICE_VOID ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ICE_IDENT_OP ()
Error: discarding token ICE_IDENT_OP ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ICE_STRING ()
Error: discarding token ICE_STRING ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ICE_IDENTIFIER ()
Error: discarding token ICE_IDENTIFIER ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ')' ()
Error: discarding token ')' ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ';' ()
Shifting token ';' ()
Entering state 8
Reducing stack by rule 9 (line 153), -> @3
Stack now 0 1 8
Entering state 33
Reading a token: Next token is token '}' ()
Reducing stack by rule 12 (line 162), -> definitions
Stack now 0 1 8 33
Entering state 67
Reducing stack by rule 10 (line 152), error ';' @3 definitions -> definitions
Stack now 0
Entering state 7
Reducing stack by rule 1 (line 102), definitions -> start
Stack now 0
Entering state 4
Next token is token '}' ()
syntax error
Error: popping nterm start ()
Stack now 0
Shifting token error ()
Entering state 1
Next token is token '}' ()
Error: discarding token '}' ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ';' ()
Shifting token ';' ()
Entering state 8
Reducing stack by rule 9 (line 153), -> @3
Stack now 0 1 8
Entering state 33
Reading a token: Next token is token '}' ()
Reducing stack by rule 12 (line 162), -> definitions
Stack now 0 1 8 33
Entering state 67
Reducing stack by rule 10 (line 152), error ';' @3 definitions -> definitions
Stack now 0
Entering state 7
Reducing stack by rule 1 (line 102), definitions -> start
Stack now 0
Entering state 4
Next token is token '}' ()
syntax error
Error: popping nterm start ()
Stack now 0
Shifting token error ()
Entering state 1
Next token is token '}' ()
Error: discarding token '}' ()
Error: popping token error ()
Stack now 0
Shifting token error ()
Entering state 1
Reading a token: Next token is token ';' ()
Shifting token ';' ()
Entering state 8
Reducing stack by rule 9 (line 153), -> @3
Stack now 0 1 8
Entering state 33
Reading a token: Now at end of input.
Reducing stack by rule 12 (line 162), -> definitions
Stack now 0 1 8 33
Entering state 67
Reducing stack by rule 10 (line 152), error ';' @3 definitions -> definitions
Stack now 0
Entering state 7
Reducing stack by rule 1 (line 102), definitions -> start
Stack now 0
Entering state 4
Now at end of input.

Comments

  • mes
    mes California
    Hi Dave,

    Welcome to the forum.

    Can you show us the output of running this command:

    c:\Ice-3.0.0\bin\icecpp C:\Ice-3.0.0\demoj\book\printer\Printer.ice

    Thanks,
    - Mark
  • Thanks for your reply. Here's the invocation and output:
    C:\> c:\Ice-3.0.0\bin\icecpp C:\Ice-3.0.0\demoj\book\printer\Printer.ice
    # 1 "C:\\Ice-3.0.0\\demoj\\book\\printer\\Printer.ice"
    
    
    
    
    
    
    
    
    
    
    
    
    module Demo
    {
    
        interface Printer
        {
            void printString(string s);
        };
    
    };
    
    
    
    C:\>
    
  • benoit
    benoit Rennes, France
    Could you try to compile the output of the preprocessor and see if it works?

    Try the following commands:
    C:\> cd C:\Ice-3.0.0\demoj\book\printer
    C:\Ice-3.0.0\demoj\book\printer> C:\Ice-3.0.0\bin\icecpp.exe Printer.ice > Test.ice
    C:\Ice-3.0.0\demoj\book\printer> C:\Ice-3.0.0\bin\slice2java.exe Test.ice
    If this works, this would indicate that somehow slice2java isn't using the right preprocessor. If this doesn't work, something is wrong with the preprocessor output (for some reasons the first character '#' isn't recognized), if this is the case, could you zip the Printer.ice and Test.ice files and post them here so that we can have a look at it?

    Thanks,
    Benoit.
  • Doesn't that feed the preprocessor output through the preprocessor again? Is that what you wanted? Anyway, here are the results. The preprocessor redirect to file follows the initial dump to stdout. I also ran the compile command again but with debug output at the end.

    The good news is I installed the same Ice 3.0 .msi package on my home machine and the slice2* compilers work fine there. The bad news is, I don't need Ice at home... But it does suggest the office machine experiencing the problem perhaps has the wrong version of some supporting file, or is configured differently. I will look into determining which DLLs and child process EXEs the compilers load and see if they look reasonable.
    C:\Ice-3.0.0\demoj\book\printer> c:\Ice-3.0.0\bin\icecpp.exe Printer.ice
    # 1 "Printer.ice"
    
    
    
    
    
    
    
    
    
    
    
    
    module Demo
    {
    
        interface Printer
        {
            void printString(string s);
        };
    
    };
    
    
    
    C:\Ice-3.0.0\demoj\book\printer> c:\Ice-3.0.0\bin\icecpp.exe Printer.ice > Test.ice
    
    C:\Ice-3.0.0\demoj\book\printer> c:\Ice-3.0.0\bin\slice2java.exe Test.ice
    syntax error
    Printer.ice:19: syntax error
    Printer.ice:21: syntax error
    
    C:\Ice-3.0.0\demoj\book\printer> c:\Ice-3.0.0\bin\slice2java.exe -d Test.ice
    Starting parse
    Entering state 0
    Reading a token: Next token is token $undefined ()
    syntax error
    Shifting token error ()
    Entering state 1
    Next token is token $undefined ()
    Error: discarding token $undefined ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ICE_INTEGER_LITERAL ()
    Error: discarding token ICE_INTEGER_LITERAL ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ICE_STRING_LITERAL ()
    Error: discarding token ICE_STRING_LITERAL ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ICE_MODULE ()
    Error: discarding token ICE_MODULE ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ICE_IDENTIFIER ()
    Error: discarding token ICE_IDENTIFIER ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token '{' ()
    Error: discarding token '{' ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ICE_INTERFACE ()
    Error: discarding token ICE_INTERFACE ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ICE_IDENTIFIER ()
    Error: discarding token ICE_IDENTIFIER ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token '{' ()
    Error: discarding token '{' ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ICE_VOID ()
    Error: discarding token ICE_VOID ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ICE_IDENT_OP ()
    Error: discarding token ICE_IDENT_OP ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ICE_STRING ()
    Error: discarding token ICE_STRING ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ICE_IDENTIFIER ()
    Error: discarding token ICE_IDENTIFIER ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ')' ()
    Error: discarding token ')' ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ';' ()
    Shifting token ';' ()
    Entering state 8
    Reducing stack by rule 9 (line 153), -> @3
    Stack now 0 1 8
    Entering state 33
    Reading a token: Next token is token '}' ()
    Reducing stack by rule 12 (line 162), -> definitions
    Stack now 0 1 8 33
    Entering state 67
    Reducing stack by rule 10 (line 152), error ';' @3 definitions -> definitions
    Stack now 0
    Entering state 7
    Reducing stack by rule 1 (line 102), definitions -> start
    Stack now 0
    Entering state 4
    Next token is token '}' ()
    Printer.ice:19: syntax error
    Error: popping nterm start ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Next token is token '}' ()
    Error: discarding token '}' ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ';' ()
    Shifting token ';' ()
    Entering state 8
    Reducing stack by rule 9 (line 153), -> @3
    Stack now 0 1 8
    Entering state 33
    Reading a token: Next token is token '}' ()
    Reducing stack by rule 12 (line 162), -> definitions
    Stack now 0 1 8 33
    Entering state 67
    Reducing stack by rule 10 (line 152), error ';' @3 definitions -> definitions
    Stack now 0
    Entering state 7
    Reducing stack by rule 1 (line 102), definitions -> start
    Stack now 0
    Entering state 4
    Next token is token '}' ()
    Printer.ice:21: syntax error
    Error: popping nterm start ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Next token is token '}' ()
    Error: discarding token '}' ()
    Error: popping token error ()
    Stack now 0
    Shifting token error ()
    Entering state 1
    Reading a token: Next token is token ';' ()
    Shifting token ';' ()
    Entering state 8
    Reducing stack by rule 9 (line 153), -> @3
    Stack now 0 1 8
    Entering state 33
    Reading a token: Now at end of input.
    Reducing stack by rule 12 (line 162), -> definitions
    Stack now 0 1 8 33
    Entering state 67
    Reducing stack by rule 10 (line 152), error ';' @3 definitions -> definitions
    Stack now 0
    Entering state 7
    Reducing stack by rule 1 (line 102), definitions -> start
    Stack now 0
    Entering state 4
    Now at end of input.
    
    C:\Ice-3.0.0\demoj\book\printer>
    
  • benoit
    benoit Rennes, France
    Oops, you're right this will go through the preprocess again :) A better test would be to run the slice2java compiler with the -E option, to just run the preprocessor and see if the output is the same as the one from icecpp.exe:
    C:\Ice-3.0.0\bin\slice2java.exe -E C:\Ice-3.0.0\demoj\book\Printer.ice > Test.ice

    Could you try this and zip Printer.ice and Test.ice in a zip file and attach the ZIP file to this post (or attach both files)? It's possible that there's some characters which aren't printed when you cut/paste the output, so it's better to attach the files with your post.

    Thanks,
    Benoit.
  • Sorry I neglected to zip and attach the files as per originally requested.

    I've now found and fixed the problem. Sorry to have wasted your time, and many thanks for trying to help me!

    Sysinternals' filemon utility showed slice2java.exe spawning cmd.exe, and that spawning icecpp.exe (because slice2java.exe uses the _popen function in the C runtime DLL rather than the CreateProcess API directly). It also showed the intermediate cmd.exe writing a single byte to the pipe slice2java reads and (only) icecpp.exe is supposed to write to. Very strange. It writes it before spawning icecpp.exe.

    With the debugger, I see this byte show up at the front of the slice2java's read buffer, and its value is 0x0C (form-feed).

    I suspected some sort of compatibility mode was causing cmd.exe to write the formfeed char, so I went looking in the registry for settings related to cmd.exe. Turns out, I have this registry key defined to setup my cmd-prompts' windows' prompt string and do a 'cls' command to wipe the initial gunk displayed by cmd.exe.
    [HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
    "AutoRun"="prompt $M$P$_$G && cls"
    

    This AutoRun command executes even if cmd.exe is run in the background rather than in interactive mode, and that 'cls' command presumably issues the form-feed character to the process's stdout stream. Removing that command from the registry value cleared up the problem with slice2java.
  • benoit
    benoit Rennes, France
    Great investigation :) And thanks for the letting us know about what the problem was! This might be useful for other users in the future!

    Benoit.
  • How to compile slice defination in windows
    benoit wrote: »
    Great investigation :) And thanks for the letting us know about what the problem was! This might be useful for other users in the future!

    Benoit.
    Hi
    creating our C++ application is to compile our Slice definition to
    generate C++ proxies and skeletons. for compiling this slice defination in windows whats is the process means any commands...example my slice defination is stored as first.ice , once its compiled it needs to be generate c++ source files first.h and first .cpp. and also help me out in to start a new ice project which template in visual studio 2005 version is need to be used means win32 or General one.
    Thansk in advance
    venkatesh
    Ge Healthcare
  • You can use a custom build step with Visual Studio to run the slice2cpp compiler. Have a look at the demos that ship with Ice for C++ for some example Visual Studio projects.

    Cheers,

    Michi.
  • Thanks for your reply michi , when i compile by using custom build i am getting this error
    error PRJ0019: A tool returned an error code from "Performing Custom Build Step".. can u help me out.
  • bernard
    bernard Jupiter, FL
    Hi Venkatesh,

    Could you copy & paste your custom build step?

    Thanks,
    Bernard
  • Hi
    i wrote a the following text in a file
    module Demo
    {
    interface priter
    {

    void prinstring(string s);

    };
    };
    and saved as printer.ice
    and added this fiel as Resource file generated in Vc++ general Empty project.

    and make the custom build general properties as

    command line : ..\..\..\bin\slice2cpp.exe printer.ice

    Description :Performing Custom Build Step.

    Outputs : printer.cpp, printer.h.

    Additional dependencies :..\..\..\bin\slice2cpp.exe;..\..\..\lib\sliced.lib;
    may be i made mistakes in creating new project in visual studio please let me know my mistakes.
    Regards
    Venkatesh
  • bernard
    bernard Jupiter, FL
    Hi Venkatesh,

    In the demo build system, we use ..\..\.. to locate the root directory of the Ice installation.

    If you created your project in another directory, you need to locate slice2cpp through some other ways.

    I would recommend to simply add the Ice bin directory to your PATH (or to Options > Projects and Solutions > VC++ Directories > Executable files in Visual Studio) and remove these dependencies. The custom build step becomes:

    command line : slice2cpp.exe printer.ice

    Description :Performing Custom Build Step.

    Outputs : printer.cpp, printer.h.

    Additional dependencies :

    The dependencies on slice2cpp.exe and sliceD.lib are only useful if you change slice2cpp and/or the Slice library, and want the .ice files to rebuild then...this is quite unusual.

    Best regards,
    Bernard
  • Hi Bernard


    Thank you now i am able to run slice defination..

    Regards
    Venkatesh