Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [imp-dev] Key word with hyphen

This really is a show-stopper for me. Using older versions of IMP, I had both a Minus '-' as a terminal in the grammar and a hyphenated keyword ("top-level") in the lexicon. I cannot get this to work with the latest version of IMP. No matter what I have tried, the '-' splits the character stream into separate tokens.
For exaple, if I create a new project with the leg grammar and then add a new type keyword, "aa-bb", dumpTokens shows that "aa" is identified as an identifier, '-'  as a Minus, and "bb" as an identifier. Is there some way to have "-" as an terminal of the grammar and still use it as a character in a keyword? If so, how?
 
Andy Crapo
GE Research


From: Crapo, Andrew (GE, Research)
Sent: Tuesday, September 08, 2009 4:01 PM
To: 'IMP Developers List'
Subject: RE: [imp-dev] Key word with hyphen

The image just showed a sentence in the language:
 
    Rock is a top-level class.
 
with a red underline starting with the hyphen and going to the end of the line. The popup error says "{0} unexpected token(s) ignored: "ERROR_TOKEN"".
 
Looking at what happens, it checks "top" to see if it is a keyword, then encounters the hyphen which is unexpected, then checks "level" to see if it is a keyword.
 
Thanks,
Andy


From: imp-dev-bounces@xxxxxxxxxxx [mailto:imp-dev-bounces@xxxxxxxxxxx] On Behalf Of Robert M. Fuhrer
Sent: Tuesday, September 08, 2009 3:12 PM
To: IMP Developers List
Subject: Re: [imp-dev] Key word with hyphen

Hi Andy,

For some reason I can't access the image of the error in your message. [I think your attempt to attach it failed - the picture has the name "No AttachName".) Can you try again?

On Sep 8, 2009, at 1:44 PM, Crapo, Andrew (GE, Research) wrote:

I'm upgrading from a very old version of IMP (about the time you became an Eclipse incubator project) to the latest version. I can't seem to get a keyword with a hyphen to work--worked in old version.

In KWLexer.gi:

%Export

    toplevel

%End

%Terminals
    a    b    c    d    e    f    g    h    i    j    k    l    m
    n    o    p    q    r    s    t    u    v    w    x    y    z
    A    B    C    D    E    F    G    H    I    J    K    L    M
    N    O    P    Q    R    S    T    U    V    W    X    Y    Z
    Hyphen ::= '-'
%End

%Rules
    Keyword ::= …..

              | t o p Hyphen l e v e l   /.$setResult($_toplevel);./
              ….
%End

%Headers
    /.
        static {
            tokenKind['-'] = SADLKWLexersym.Char_Hyphen;  // Map the hyphen character
        }
    ./
%End

Result is a error at the hyphen:
Picture (Device Independent Bitmap)
I've also tried it with

             tokenKind['-'] = SADLKWLexersym.Char_Hyphen;

Which is what worked in the old version.


Andrew Crapo
Information Scientist
GE Global Research

T +1 518 387 5729
F +1 518 387 6104
D *833 5729
E crapo@xxxxxxxxxxxxxxx
www.research.ge.com

One Research Circle
Niskayuna, NY 12309 USA
General Electric Company

GE imagination at work

_______________________________________________
imp-dev mailing list
imp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/imp-dev

--
Cheers,
  - Bob
-------------------------------------------------
Robert M. Fuhrer
Research Staff Member
Programming Technologies Dept.
IBM T.J. Watson Research Center

IMP Project Lead (http://www.eclipse.org/imp)
X10: Productivity for High-Performance Parallel Programming (http://x10.sf.net)


Back to the top