!PARSER()

!PARSER()

Top  Previous  Next

 

The !PARSER() subroutine parses a command line.

 

 

Format

 

CALL !PARSER(key, type, string, keyword {, voc.rec , quote.char}})

 

where

 

keyidentifies the operation to be performed:

0

PARSER$RESET

Prepares to parse the data in string.

1

PARSER$GET.TOKEN

Returns the next token from the data.

2

PARSER$GET.REST

Returns all remaining tokens as a single string.

3

PARSER$EXPAND

Inserts string before the remaining tokens.

4

PARSER$LOOK.AHEAD

Previews the next token.

5

PARSER$MFILE

Like PARSER$GET.TOKEN but allows multifile syntax.

 

typeis the returned token type:

0

PARSER$END

End of data reached.

1

PARSER$TOKEN

A token has been returned in string.

2

PARSER$STRING

A quoted string. The quotes are removed in string.

3

PARSER$COMMA

A comma has been found.

4

PARSER$LBR

A left bracket has been found.

5

PARSER$RBR

A right bracket has been found.

 

stringis the returned token string. For key values 0 and 3, this is the string passed into the parser.

 

keywordis the returned token keyword number as defined in the VOC and in the SYSCOM PARSER.H record. This is negative if the token is not a VOC keyword. This argument is ignored for key values 0 and 3.

 

voc.recis an optional argument, returned as the VOC record when string corresponds to a VOC key.

 

quote.charis and optional argument, returned as the quoting character for PARSER$STRING type items.

 

 

The !PARSER() subroutine can be used to parse the elements of a command line.

 

 

Example

 

CALL !PARSER(PARSER$RESET, 0, @SENTENCE, 0)

CALL !PARSER(PARSER$GET.TOKEN, TOKEN.TYPE, STRING, KEYWORD) ;* Verb

LOOP

  CALL !PARSER(PARSER$GET.TOKEN, TOKEN.TYPE, STRING, KEYWORD)

UNTIL TOKEN.TYPE = PARSER$END

  …process token…

REPEAT