JavaScript is a widely used and known language and I've found that
with few changes an Harbour source can be "digested" by IDEs like
Eclipse or NetBeans as a JavaScript source and that these changes can
also "fix" some "ambiguities" of the actual language.
Moreover I think this "alternative" syntax would increase the
acceptance of Harbour to new developers that use C, C++, C#, Php, etc.
Please understand me I'm not suggesting to use the new syntax in
Harbour codebase and everything need to be optional, I only want to
understand if the pp can be used and how and where changes to the
compiler are needed.

1) {} to enclose function's body. This valid code:

function test( a )

if a == 1
   return .t.
else
   return .f.
endif

using -w gives: warning: W0007  Function 'TEST' does not end with
RETURN statement, so it would be good to have:

function test( a ) {
if a == 1
   return .t.
else
   return .f.
endif
}

the rule could be: "if after the function there is an open curly brace
there must be a close brace at the end and at least one return inside"

2) ";" as statement separator. This is a valid code:

function test( a ) ; outstd( "Hello World" ) ; return nil

but not if I simply "reform" the code:

function test( a ) ;
outstd( "Hello World" ) ;
return nil

the rule could be: ";" is the statement separator but is optional if
it is followed by a <newline>
( HB_PP_MULTILINE_STRING could be changed to "\" <newline> )

3) "=" vs "==" vs ":="

Viktor took some time to change <> to !( == ) and = to := so it could
be that = is always assignment and == is always equal
( clearly activated via a compiler switch ) so we could have:

function test( a )
   var a = 1;

instead of

function test( a )
   local a := 1

in classes we already use VAR for "local" members.

These changes are enough to get a correctly outlined source with the
syntax highlighted.

Comments?

best regards,
Lorenzo
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to