emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

DXL mode


From: Vincent Belaïche
Subject: DXL mode
Date: Mon, 14 Feb 2011 23:05:09 +0100

Dear all,

I could not find any edit mode for DXL, if this does not exist, I will
probably create one.

I am wondering what is the best way to start from. DXL is Doors(TM)
eXtension Language. Doors is a data base system used in the industry to
write specifications with easier requirement management.

DXL looks like C to many aspects, and I thought that it may be a good
idea to add one more C dialects to the list in the cc-mode
package. However by some other aspects its syntax can be made quite
different. 

This is why I am seeking guidance on this forum before starting
anything.


Currently I am using the C mode to write DXL code, which obliges me to
write it as much in a C-like manner (for instance I need to end all
statements by a semi-colon), but I would like to get rid of these
constraints, and have some programming mode that would indent correctly
any kind of DXL code.

The main differences from C syntaxe are the following ones:

Predefined types
----------------
you don't have any `float' or `double' or `long int', but there are a
number of predefined types like `bool', `int', `real', `string',
`Array', `Skip', `Link', `Object', etc...

Qualidiers
----------
the only one is `const', and AFAIK it must be always in the first
position:

const int i = 3 // OK
int const i = 3 // not OK

End of statements
-----------------
In DXL statements do not need a tailing semi-colon, an end-of-line is
sufficient. You may have several statements in a line provided that they
are separated by a semi-colon, and statements can also span over several
lines: the DXL interprete detects that an end-of-line does not
terminate a statement if one of the following two conditions is
fulfilled:

+ the line is ended by an empty comment `//', or by a comment with a
  tailing `-' like `// blah blah -'

+ the statement would otherwise contain some incomplete construct
  (e.g. opening bracket that is not closed, or stuff like that)

Ranges
------
there is a range construct like this `FROM : TO by STEP' or `FROM : TO'

Functions
---------
Function calls do not need necessarilly brackets, the 3 following
expression give the same result:

real f0 = sqrt 2 // naked
real f1 = sqrt(2) // à la C
real f3 = (sqrt 2) // à la Lisp

The brackets are needed when there are more than one argument, so you
cannot always write things à-la-Lisp.

Personnally when a function call with a single argument is within an
expression I prefer the à-la-Lisp way to avoid any precedence issues,
but when it is the rightwing of a `=', then I let it naked.

An example why I prefer to do this way is for instance

1: string a="xxx"
2: print length(a) "!" "\n"
3: print (length a) "!\n"
==> 4
==> 3!

On the second row you take the length of `a' concatenated with `"!"', so
it makes `4' which is then stringized and concatenated with `"\n"'. This
is quite confusing if written this way.


Special construct
-----------------
you have this:

for ... in ... do  ... 

and also 

if ... then ...

is possible in addition to

if ... { ... }

in the case that the expression following `if' does not start with a `('

-----------------------------------------------------------------------

I am seeking guidance, based on the preceding information, on whether
I would meet any dead-end issues if I try to add a C dialect to cc-mode
(like awk which also does not always need ending semi-colons), or if it
seems feasible with a reasonable effort.

If adding a dialect to cc-mode is not the good way, then I would rather
re-start from scratch by reworking some simple existing mode, like the
visual-basic-mode which is the one I know best.


VBR,
   Vincent.
  





 














reply via email to

[Prev in Thread] Current Thread [Next in Thread]