2000-07-28 06:30 UTC+0800 Ron Pinkas <ron@profit-master.com>
+ doc/simplex.txt
+ Added 1st draft of SimpLex documentation.
* source/compiler/simplex.c
+ Added overidable macro STREAM_EXCEPTION()
* source/compiler/harbour.l
* Modified to return every \n to correct line numbers reporting.
/* Note: removed note about . after \n, I beleive it was needed to avoid conflict with $ which is no longer used,
and should be avoided, due to few other side effects. */
source/compiler/harbour.slx
* Standadized un-terminated strings messages.
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
2000-07-28 06:30 UTC+0800 Ron Pinkas <ron@profit-master.com>
|
||||
+ doc/simplex.txt
|
||||
+ Added 1st draft of SimpLex documentation.
|
||||
|
||||
* source/compiler/simplex.c
|
||||
+ Added overidable macro STREAM_EXCEPTION()
|
||||
|
||||
* source/compiler/harbour.l
|
||||
* Modified to return every \n to correct line numbers reporting.
|
||||
/* Note: removed note about . after \n, I beleive it was needed to avoid conflict with $ which is no longer used,
|
||||
and should be avoided, due to few other side effects. */
|
||||
|
||||
source/compiler/harbour.slx
|
||||
* Standadized un-terminated strings messages.
|
||||
|
||||
2000-07-28 00:18 UTC+0500 April White <awhite@user.rose.com>
|
||||
|
||||
* include/hbapi.h
|
||||
|
||||
21
harbour/doc/simplex.txt
Normal file
21
harbour/doc/simplex.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
Overview:
|
||||
SimpLex uses high-level definitions, which for many programmers might be more readable, than equivalent Flex definitions. SimpLex Language Definitions are divided into 6 main sections:
|
||||
|
||||
1. Delimiters. There are 3 kinds of Lexical Delimiters"
|
||||
a. Ignorable. Typical example of such delimiters is "white space", i.e. space and tab.
|
||||
b. Returnable. Typical examples of such delimiters are commas, parenthesis, and math operators.
|
||||
c. Appendables. While I don't have any examples in mind, I suspect there might be a need for such delimiters. This kind of delimiters should be appended to the preceding token, in effect making such delimiter a terminator character.
|
||||
|
||||
2. Streams. These are also referred to as "pairs". Stream or Pair, as the name may suggest, is any sequence (or stream) of characters, enclosed within a STARTing character and an ENDing character (the pair). Typical example of such lexical element is a LITERAL string, i.e. "Hello World".
|
||||
|
||||
3. Self Contained Words. These are a specific set of reserved words, which do NOT require ANY delimiters. These words might be viewed as a form of Meta Delimiters. These words will be extracted from the input stream, regardless of any preceding, or succeeding characters. Typical example of such tokens are the dBase' .AND. .OR. .NOT. logical operators, the C language inline assignment operators += *= etc., as well as pre and post increment/decrement operators -- and ++. The unique attribute of such elements is the fact that these elements do NOT require preceding or succeeding delimiters.
|
||||
|
||||
4. Keywords. These are specific set of reserved words, which have lexical significance in the defined language, when appearing as the FIRST token in a given source line.
|
||||
|
||||
5. Words. These are specific set of reserved words, which have lexical significance in the defined language, when appearing ANYWHERE in a given source line.
|
||||
|
||||
6. Rules. There are 2 kinds of rules:
|
||||
|
||||
a. Reduction Rules. This kind of rules defines the translation of a 1 or more tokens into 1 or more other tokens (or custom actions).
|
||||
b. Pass Through (Left Associate). This kind of rules directs the Lexer to accept such token[s] as a valid form, and may also be used to eliminate a possible association with the next input. Typical example is a rule that associates the dBase '[' character with a preceding identifier name, to "defuse" its usage as a string delimiter, i.e. MyArray[1] as opposed to [Hello World].
|
||||
|
||||
@@ -342,12 +342,10 @@ Separator {SpaceTab}
|
||||
|
||||
{SpaceTab} ;
|
||||
|
||||
\n. { /* "." after "\n" is important so we skip empty lines, until begining of non empty next line - don't remove!!! */
|
||||
\n {
|
||||
hb_comp_iState = LOOKUP;
|
||||
iIndexSets = 0;
|
||||
|
||||
yyless( 1 );
|
||||
|
||||
if( ! hb_comp_bQuiet && ( hb_comp_iLine % 100 ) == 0 )
|
||||
{
|
||||
printf( "\r%i", hb_comp_iLine );
|
||||
|
||||
@@ -50,6 +50,12 @@
|
||||
#undef YY_BUF_SIZE
|
||||
#define YY_BUF_SIZE HB_PP_STR_SIZE
|
||||
|
||||
#undef STREAM_EXCEPTION
|
||||
#define STREAM_EXCEPTION( sPair, cChar ) \
|
||||
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_STRING_TERMINATOR, sPair, NULL ); \
|
||||
aiReturn[ iReturn++ ] = '\n'; \
|
||||
aiReturn[ iReturn++ ] = LITERAL;
|
||||
|
||||
static int iTexts = 0;
|
||||
static char * aTexts[1024];
|
||||
static int iIdentifier = 0;
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
#define STOP_IF_ONE_OF_THESE(x) x,
|
||||
#define AND_IGNORE_DELIMITERS(x) x,
|
||||
#define AS_PAIR_TOKEN(x) x }
|
||||
#define STREAM_EXCEPTION( sPair, chrPair) \
|
||||
if( chrPair ) \
|
||||
printf( "Exception: %c for stream at: \"%s\"\n", chrPair, sPair ); \
|
||||
else \
|
||||
printf( "Exception: <EOF> for stream at: \"%s\"\n", chrPair, sPair ); \
|
||||
|
||||
/* Pairs. */
|
||||
static char sPair[ 2048 ];
|
||||
@@ -962,7 +967,7 @@ int yylex( void )
|
||||
{
|
||||
sPair[ iPairLen ] = '\0';
|
||||
|
||||
printf( "Exception: %c for Pair: at \"%s\"\n", chrPair, sPair );
|
||||
STREAM_EXCEPTION( sPair, chrPair);
|
||||
|
||||
/* Resetting. */
|
||||
cTerm = 0;
|
||||
@@ -1005,7 +1010,7 @@ int yylex( void )
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
DEBUG_INFO( printf( "Exception: <EOF> for Pair: at \"%s\"\n", sPair ) );
|
||||
STREAM_EXCEPTION( sPair, NULL );
|
||||
|
||||
/* Resetting. */
|
||||
cTerm = 0;
|
||||
|
||||
Reference in New Issue
Block a user