Book a Demo

Author Topic: Code parser chokes on keyword rom  (Read 9467 times)

kalpak

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Code parser chokes on keyword rom
« on: December 04, 2009, 01:44:25 pm »
I opened an embedded C file in the source editor and it generated a parse error on the keyword rom.
What is the work around for that?

Wowbagger

  • EA User
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile
Re: Code parser chokes on keyword rom
« Reply #1 on: December 05, 2009, 04:31:26 am »
It would be nice if you gave us the offending code to look at.

"rom" isn't really a C keyword. Your compiler may treat it as one, but that doesn't make it a keyword. EA is likely throwing an error because the C code you submit ISN'T valid C, but is in reality a bowdlerized dialect - but without seeing a sample of the code it is hard to tell.

kalpak

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Code parser chokes on keyword rom
« Reply #2 on: December 05, 2009, 02:26:11 pm »
Embedded C is full of such additional keywords, and of course there are dialects.
One compiler may need the word rom and another may need code for putting the variable in code (flash) memory.
EA claims it can also be used for embedded applications, so there should be a way of handling dialects.
Here is one of the code snippets that caused this problem. It is working code from Microchip.
Code: [Select]
/*###############################################################################
;# TITLE   "LCD Display"      
;#                         
;#      Program         :External LCD
;#      Version         :1.0      
;#      Revision Date   :6/9/03         
;#      Author          :Naveen Raj
;#                                                      
;# Program demonstrates use of External LCD Module
;# general purpose library module.*/
/*###############################################################################*/


#include "xlcd.h"
#define XLCDCursorOnBlinkOn()        XLCDCommand(0x0F)      //the user may refer the LCD data sheet
#define XLCDCursorOnBlinkOff()       XLCDCommand(0x0E)      //and generate commands like this
#define XLCDDisplayOnCursorOff()     XLCDCommand(0x0C)
#define XLCDDisplayOff()             XLCDCommand(0x08)
#define XLCDCursorMoveLeft()         XLCDCommand(0x10)
#define XLCDCursorMoveRight()        XLCDCommand(0x14)
#define XLCDDisplayMoveLeft()        XLCDCommand(0x18)
#define XLCDDisplayMoveRight()       XLCDCommand(0x1C)
rom const unsigned char aaa[]="Hello";
ram const unsigned char bbb[]="Microchip";

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: Code parser chokes on keyword rom
« Reply #3 on: December 05, 2009, 04:05:32 pm »
Bowdlerized? Just wait until someone tries to reverse engineer code written in Neuron C!

I have had similar problems with embedded C code, vintage 1989 (still out there alive and kicking), originally compiled with a non-standard C compiler. I was able to get EA to parse & import the source code by defining the offending "slang" as C pre-processor macros. EA won't understand the meaning of the term and won't do any macro expansion, but it may at least import the code. You might want to try it (Settings->Preprocessor Macros...) and see if it works.

Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


kalpak

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Code parser chokes on keyword rom
« Reply #4 on: December 05, 2009, 05:07:10 pm »
Actually, bowdlerized means exactly opposite. For example, ANSI C is the bowdlerized version of embedded C.
Thanks, for the hint, but the version I have downloaded is 7.5, build 850 and it does not seem to have any preproccessor setting for C, only for C++.
BTW, It also chokes on ram.
I tried by adding rom as datatype in the settings -> code datatypes , but that did not work either.

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: Code parser chokes on keyword rom
« Reply #5 on: December 06, 2009, 06:21:00 am »
The C++ options work for C as well (at least they did when I tried it)...

The real solution, of course, is for Sparx to make it possible to customize the code templates for export AND import.

Cheers,
Fred Woolsey
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Code parser chokes on keyword rom
« Reply #6 on: December 06, 2009, 08:18:04 am »
You might like to try to modify the following file

C:\Program Files\Sparx Systems\EA\Config\csSyntax.txt

This begins with a section #Keywords where you could add ram and rom

This might work
Models are great!
Correct models are even greater!

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: Code parser chokes on keyword rom
« Reply #7 on: December 06, 2009, 09:04:55 am »
Cheers Phil! I didn't know about that.

After checking out my install of EA (7.5.850), however, I think kalpak would need to modify the file cppSyntax.properties. Also, there is a help file CodeEditorConfig.pdf (and .rtf) in the same directory.

Fred Woolsey
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code parser chokes on keyword rom
« Reply #8 on: December 07, 2009, 08:52:00 am »
The keywords listed in the files mentioned are for syntax highlighting only.

Sparx Systems can't support every dialect of C, but if you send us a support request I am confident we can get you going very quickly with at least this extension.

PS. I disagree that ANSI C is bowdlerized embedded C.  That would imply that ANSI C is derived from embedded C.

kalpak

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Code parser chokes on keyword rom
« Reply #9 on: December 07, 2009, 02:42:46 pm »
Oh, so that is why suggestion give by Phil and Fred would not work, I was still getting the parser error.
I can send you a list of these keywords, but like I said earlier, there is a subtle difference between compilers, and I do use quite a few, depending on the processor family. So how are you going to support embedded system design?
Let me clarify about my principal needs. I am looking for a software
  • That takes me from generating the requirements doc to the UML design
  • Helps in resource management (upto Gantt charts)
  • Extracts / exports the above info in a common format so that my client does not need to learn EA
  • Reverse engineer the code so that I can track if the code written follows the design


fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: Code parser chokes on keyword rom
« Reply #10 on: December 07, 2009, 03:31:53 pm »
Simon,

I agree that it is unrealistic to expect Sparx to support every C dialect, but what if both import & export parsing were fully customizable? The use of external syntax grammar files rather than hard-coded EBNF (or equivalent) would permit this; then users could do their own customization. Perhaps in EA 8.0?

Cheers,
Fred Woolsey

PS: ANSI C is bowdlerized K+R C.  ;)
« Last Edit: December 07, 2009, 03:33:00 pm by fwoolz »
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.