Hi Philippe, Sorry for replying so late, i was away. Yes this is what i did: in the symbol lookup table the identifier are always inserted lowercased. For what i need this seems to be doing the job nicely, not sure though if it's a right thing to do or if i'll have problems with this later on. For now it seems to be fine. Ovidiu From: Philippe Charles [mailto:pgc1@xxxxxxxx] Sent: Wednesday, March 30, 2011 3:11 PM To: pinosh Cc: 'IMP Developers List' Subject: Re: [imp-dev] Case-insensitiv lexer - lpg Hi Ovidiu, Basically, a sequence of alphabetic characters will always be classified as an identifier. Disregarding case for identifiers is a semantic issue. You need to implement a lookup table (symbol table) that folds identifiers before doing the table search. On Mar 29, 2011, at 9:37 AM, pinosh wrote:
Thanks for the super fast reply. I tried this but it doesn't seem to work. The editor still allows me to declare like Ex: int a; int A; it considers those different Anywhere else you think i should point my attention to? From: imp-dev-bounces@xxxxxxxxxxx [mailto:imp-dev-bounces@xxxxxxxxxxx] On Behalf Of Robert M. Fuhrer Sent: Tuesday, March 29, 2011 5:07 PM To: IMP Developers List Cc: Philippe G. Charles Subject: Re: [imp-dev] Case-insensitiv lexer - lpg I'm cc'ing Philippe Charles, the main author of LPG, in case he has something to add. I think you need to use a modified copy of the LexerBasicMapF.gi include file to effect the case-folding you're looking for. Specifically, to fold everything to lower-case, find the letter-related entries in the tokenKind[] array that look like: $sym_type.$prefix$A$suffix$, // 065 0x41 $sym_type.$prefix$B$suffix$, // 066 0x42 $sym_type.$prefix$C$suffix$, // 067 0x43 and replace them with their lower-case equivalents: $sym_type.$prefix$a$suffix$, // 097 0x61 $sym_type.$prefix$b$suffix$, // 098 0x62 $sym_type.$prefix$c$suffix$, // 099 0x63 I haven't actually tried this myself, but I believe it should work. On Mar 29, 2011, at 9:26 AM, Ovidiu Diac wrote: I'm currently working on an ide for a Java-like scripting language. The problem i have is that this script is supposed to be case-insensitive. I managed to make the keywords case-insensitive by using the KWLexerFoldedCaseMapF.gi include in KWLexer but i don't know what to do about identifiers. - i'm using the lpg parser Any help is much appreciated. -- Cheers, -- Bob -------------------------------- Robert M. Fuhrer Research Staff Member Programming Technologies Dept. IBM T.J. Watson Research Center
IMP Team Lead (http://www.eclipse.org/imp) X10: Productivity for High-Performance Parallel Programming (http://x10-lang.org) |