fbdoc  1.0.1
FreeBASIC documentation tool
Parser Class Reference

The parser. More...

Collaboration diagram for Parser:

Public Types

enum  ParserTokens {
  MSG_STOP = -1 , MSG_ERROR , TOK_EOS , TOK_BRCLO ,
  TOK_COMMA , TOK_KLOPN , TOK_KLCLO , TOK_DOT ,
  TOK_MEOP , TOK_3DOT , TOK_QUOTE , TOK_LATTE ,
  TOK_BROPN , TOK_EQUAL , TOK_ABST , TOK_ALIA ,
  TOK_AS , TOK_BYRE , TOK_BYVA , TOK_CAST ,
  TOK_CDEC , TOK_CLAS , TOK_COMM , TOK_CONS ,
  TOK_DECL , TOK_DEFI , TOK_DIM , TOK_END ,
  TOK_ENUM , TOK_EXDS , TOK_EMAC , TOK_EXRN ,
  TOK_EXPO , TOK_INCL , TOK_LIB , TOK_MACR ,
  TOK_WITH , TOK_NAMS , TOK_ONCE , TOK_OVER ,
  TOK_PASC , TOK_PRIV , TOK_PROT , TOK_RDIM ,
  TOK_PTR , TOK_PEEK , TOK_PUBL , TOK_SCOP ,
  TOK_SHAR , TOK_PRES , TOK_STAT , TOK_STCL ,
  TOK_TYPE , TOK_UNIO , TOK_VAR , TOK_VIRT ,
  TOK_FUNC , TOK_FILD , TOK_OPER , TOK_PROP ,
  TOK_SUB , TOK_CTOR , TOK_DTOR , TOK_BYTE ,
  TOK_DOUB , TOK_INT , TOK_LONG , TOK_LINT ,
  TOK_STRI , TOK_SHOR , TOK_SING , TOK_UBYT ,
  TOK_ULNG , TOK_ULIN , TOK_UINT , TOK_USHO ,
  TOK_WSTR , TOK_ZSTR , TOK_ANY , TOK_WORD ,
  TOK_COMSL , TOK_COMML
}
 The tokens used by the parser. More...
 

Public Member Functions

 Parser (BYVAL_AS_EmitterIF_PTR)
 The constructor. More...
 
Filehandlers

Filehandlers are used to load some FreeBASIC source code input in to the buffer Parser::Buf from different input channels (may be the STDIN pipe, a single file or all files in a folder). Afterwards the source code gets parsed and translated output created by the emitter gets returned.

SUB File_ (BYREF_AS_STRING, BYVAL_AS_INTEGER)
 Read a buffer from a file and parse. More...
 
SUB StdIn ()
 Read a buffer from pipe STDIN and parse. More...
 
SUB Include (BYVAL_AS_STRING)
 Start a new parser to #INCLUDE a file. More...
 
SUB writeOut (BYREF_AS_STRING)
 Write a piece of output (for external emitters only) More...
 
Properties to extract original source code

Properties are used to extract original text from the input buffer at a certain position. This is the current position of the parser, or the position of the given parameter.

PROPERTY_AS_LONG_PTR CurTok ()
 The current token. More...
 
PROPERTY_AS_STRING BitIni ()
 The initialization of a bitfield. More...
 
PROPERTY_AS_STRING SubStr ()
 Context of current token. More...
 
PROPERTY_AS_STRING SubStr (BYVAL_AS_LONG_PTR)
 Context of current token at position T. More...
 
Parsers for lists and blocks

External demuxers are called from emitter-handlers when they sit on a list of statments, ie. in an ENUM block or in a DIM statement with more than one variable.

SUB parseListNam (BYVAL_AS_EmitFunc)
 Evaluate a list of names. More...
 
SUB parseListNamTyp (BYVAL_AS_EmitFunc)
 Evaluate a list of declarations. More...
 
SUB parseListPara (BYVAL_AS_EmitFunc)
 Evaluate a parameter list. More...
 
SUB parseBlockEnum (BYVAL_AS_EmitFunc)
 Evaluate the context of an ENUM block. More...
 
SUB parseBlockTyUn (BYVAL_AS_EmitFunc)
 Evaluate the context of a block. More...
 

Public Attributes

Parser STRINGs

STRING variables to exchange data with th emitters.

STRING InPath = ""
 path of current of input file (option –tree (-t)) More...
 
STRING Fnam
 the name of the input file More...
 
STRING Buf
 the input buffer More...
 
STRING ErrMsg
 an error message More...
 
STRING Tok
 the token list (binaries) More...
 
STRING BlockNam
 the name of a block (ENUM, UNION, TYPE) More...
 
Parser token pointers

Pointers to the token list, used to specify the result of the parsing process. The tokens specify the construct in progress and they are used by the emitters to create their output.

Four main tokens specify the kind of the construct:

  • StaTok: the start of the current construct
  • NamTok - subtokens: DimTok, IniTok (may be zero in parameter lists)
  • TypTok - subtokens: ShaTok, PtrTok, Co1Tok, Co2Tok (is zero for VAR, may be zero for CONST)
  • FunTok - subtokens: ParTok, AliTok, DivTok, By_Tok (is zero for variables)

Other tokens are only valid if the main token is not zero.

LONG_PTR StaTok
 the pre-parsed token More...
 
LONG_PTR NamTok
 the name token of the construct More...
 
LONG_PTR DimTok
 the token of the left parenthesis of a dimension More...
 
LONG_PTR IniTok
 the start character of an initializer ('=') More...
 
LONG_PTR BitTok
 the start character of a bitfiled declaration (':') More...
 
LONG_PTR TypTok
 the token of the type keyword More...
 
LONG_PTR ShaTok
 the token of the SHARED keyword More...
 
LONG_PTR PtrTok
 the token of the first PTR keyword More...
 
LONG_PTR Co1Tok
 the token of the first CONST keyword (if any) More...
 
LONG_PTR Co2Tok
 the token of the second CONST keyword (if any) More...
 
LONG_PTR FunTok
 type of the pre-parsed token More...
 
LONG_PTR CalTok
 the token of the calling convention keyword (if any) More...
 
LONG_PTR AliTok
 the token of the ALIAS keyword (if any) More...
 
LONG_PTR As_Tok
 the token of the AS keyword (if no SUB) More...
 
LONG_PTR ParTok
 the token of the left parenthesis of a parameter list More...
 
LONG_PTR By_Tok
 the token of the declaration specifier (BYVAL / BYREF) More...
 
LONG_PTR DivTok
 the token of different purposes like the STATIC keyword in a member function declaration (if any) or the LIB keyword in a normal declaration More...
 
LONG_PTR Tk1
 the first token in a statment More...
 
LONG_PTR EndTok
 the last token in the list More...
 
LONG_PTR UserTok
 a token for customised usage in emitter-handlers More...
 
Parser counters, integers and pointers

Diverse variables used on different events. They inform the emitters about the state of the parser.

LONG Po
 the current position in the input buffer Parser::Buf More...
 
LONG Fin
 the last position in the input buffer Parser::Buf More...
 
LONG PtrCount
 the number of PTR keywords More...
 
LONG SrcBgn
 start position to export FB source More...
 
LONG LineNo
 the current line in the input buffer Parser::Buf More...
 
LONG LevelCount
 the level in nested blocks (one based) More...
 
LONG InTree
 flag to indicate if to follow source tree #INCLUDEs More...
 
LONG ListCount
 the current entry in a list (zero based) More...
 

Private Types

enum  EoS_Modi { TO_END_BLOCK , TO_END , TO_EOL , TO_COLON }
 The modi for end of statement searching. More...
 

Private Member Functions

Internal parsers

Functions for evaluating a construct in the FreeBASIC source code after a relevant keyword was found in the pre-parsering process. After the fine-parsing process the matching emitter-handler gets called. (Or the function EmitterIF::Error_() in case of a syntax problem. It's up to the emitter if and where the user sees the error message.)

SUB pre_parse ()
 Pre-parse all FB source code, search relevant constructs. More...
 
PROPERTY_AS_STRING USubStr ()
 Check current token position, extract word if string type. More...
 
FUNCTION_AS_INTEGER getToken ()
 Check word at current parser position. More...
 
FUNCTION_AS_INTEGER tokenize (BYVAL_AS_EoS_Modi)
 Parse a relevant construct, create a token list. More...
 
FUNCTION_AS_INTEGER Errr (BYREF_AS_STRING)
 Emit an error message. More...
 
FUNCTION_AS_INTEGER demuxNam (BYVAL_AS_INTEGER, BYVAL_AS_INTEGER)
 Evaluate a name, dimension and initializer in the token list. More...
 
FUNCTION_AS_INTEGER demuxTyp (BYVAL_AS_INTEGER)
 Evaluate a type declaration in the token list. More...
 
FUNCTION_AS_INTEGER demuxDecl ()
 Evaluate a function declaration in the token list. More...
 
FUNCTION_AS_INTEGER skipOverColon ()
 Move to the end of statement and one step beyond. More...
 
FUNCTION_AS_INTEGER skipOverBrclo ()
 Move to the matching right parenthesis and one step beyond. More...
 
FUNCTION_AS_INTEGER skipOverComma ()
 Move to the next comma and one step beyond. More...
 
FUNCTION_AS_INTEGER VAR_ ()
 Evaluate a variable declaration. More...
 
FUNCTION_AS_INTEGER TYPE_ ()
 Evaluate a TYPE or CLASS statement. More...
 
FUNCTION_AS_INTEGER ENUM_ ()
 Evaluate an ENUM block. More...
 
FUNCTION_AS_INTEGER UNION_ ()
 Evaluate a UNION block. More...
 
FUNCTION_AS_INTEGER FUNCTION_ ()
 Evaluate a function. More...
 
FUNCTION_AS_INTEGER DECLARE_ ()
 Evaluate a forward declaration. More...
 
FUNCTION_AS_INTEGER INCLUDE_ ()
 Evaluate an #INCLUDE line. More...
 
FUNCTION_AS_INTEGER DEFINE_ ()
 Evaluate a #DEFINE declaration. More...
 
FUNCTION_AS_INTEGER MACRO_ ()
 Evaluate a #MACRO declaration. More...
 

Private Attributes

Internal values

Variables used in pre-parsing process.

LONG ToLast
 the type of the token before the current one More...
 
LONG_PTR Tk
 the current token of the parser More...
 
LONG_PTR A
 start of a word in pre-parsing More...
 
LONG_PTR L
 length of a word in pre-parsing More...
 
EmitterIF_PTR Emit
 the emitter interface More...
 

Detailed Description

The parser.

Class to handle FreeBASIC source code. A Parser allways work on exactly one input stream, comming from a file or from STDIN. The Parser does

  • read the source from an input channel (see StdIn(), File_())
  • call function EmitterIF::Init_() before parsing
  • pre-parse the source for relavant code fractions (see pre_parse()) and call the comments emitter-handler on the way.
  • fine-scan any relavant code fractions (see tokenize()) and call the matching emitter-handler for this code (done by the private functions ie. like DEFINE_(), FUNCTION_(), VAR_(), ...)
  • provide functions to extract elements form the source (like SubStr(), CurTok(), BitIni(), ...)
  • call matching emitter functions to generaate the output stream
  • call function EmitterIF::Exit_() after parsing

When fbdoc follows the source tree (option –tree (-t)), the function EmitterIF::Incl_() creates a new Parser for each file.

Definition at line 46 of file fbdoc_parser.bi.

Member Enumeration Documentation

◆ ParserTokens

The tokens used by the parser.

Enumerators used to classify the type of a token found in the FreeBASIC source code. Most of them are used in equal / not equal checks, but a few are used with greater or smaller operators. Those are marked as labeled enumerators. Don't change the order (without adapting the source code).

Enumerator
MSG_STOP 

end of file / token list reached

MSG_ERROR 

create error message, continue parsing (labeled enumerator)

TOK_EOS 

end of statement (either new line or ":", labeled enumerator)

TOK_BRCLO 

right parenthesis

TOK_COMMA 

a comma (labeled enumerator)

TOK_KLOPN 

left other bracket

TOK_KLCLO 

right other bracket

TOK_DOT 

a dot

TOK_MEOP 

the pointer to memory access operator "->"

TOK_3DOT 

three dots

TOK_QUOTE 

a string constant (including quotes)

TOK_LATTE 

the '#' character

TOK_BROPN 

left parenthesis (labeled enumerator)

TOK_EQUAL 

the '=' character

TOK_ABST 

the ABSTRACT keyword (labeled enumerator)

TOK_ALIA 

the ALIAS keyword

TOK_AS 

the AS keyword

TOK_BYRE 

the BYREF keyword

TOK_BYVA 

the BYVAL keyword

TOK_CAST 

the CAST keyword

TOK_CDEC 

the CDECL keyword

TOK_CLAS 

the CLASS keyword

TOK_COMM 

the COMMON keyword

TOK_CONS 

the CONST keyword

TOK_DECL 

the DECLARE keyword

TOK_DEFI 

the #DEFINE keyword

TOK_DIM 

the DIM keyword

TOK_END 

the END keyword

TOK_ENUM 

the ENUM keyword

TOK_EXDS 

the EXTENDS keyword

TOK_EMAC 

the #ENDMACRO keyword

TOK_EXRN 

the EXTERN keyword

TOK_EXPO 

the EXPORT keyword

TOK_INCL 

the #INCLUDE keyword

TOK_LIB 

the LIB keyword

TOK_MACR 

the #MACRO keyword

TOK_WITH 

the WITH keyword

TOK_NAMS 

the NAMESPACE keyword

TOK_ONCE 

the ONCE keyword

TOK_OVER 

the OVERLOAD keyword

TOK_PASC 

the PASCAL keyword

TOK_PRIV 

the PRIVATE keyword

TOK_PROT 

the PROTECTED keyword

TOK_RDIM 

the REDIM keyword

TOK_PTR 

the PTR or POINTER keyword

TOK_PEEK 

the PEEK keyword

TOK_PUBL 

the PUBLIC keyword

TOK_SCOP 

the SCOPE keyword

TOK_SHAR 

the SHARED keyword

TOK_PRES 

the PRESERVE keyword

TOK_STAT 

the STATIC keyword

TOK_STCL 

the STDCALL keyword

TOK_TYPE 

the TYPE keyword

TOK_UNIO 

the UNION keyword

TOK_VAR 

the VAR keyword

TOK_VIRT 

the VIRTUAL keyword

TOK_FUNC 

the FUNCTION keyword

TOK_FILD 

the FIELD keyword

TOK_OPER 

the OPERATOR keyword

TOK_PROP 

the PROPERTY keyword

TOK_SUB 

the SUB keyword

TOK_CTOR 

the CONSTRUCTOR keyword

TOK_DTOR 

the DESTRUCTOR keyword

TOK_BYTE 

the BYTE data type (labeled enumerator)

TOK_DOUB 

the DOUBLE data type

TOK_INT 

the INTEGER data type

TOK_LONG 

the LONG data type

TOK_LINT 

the LONGINT data type

TOK_STRI 

the STRING data type

TOK_SHOR 

the SHORT data type

TOK_SING 

the SINGLE data type

TOK_UBYT 

the UBYTE data type

TOK_ULNG 

the ULONG data type

TOK_ULIN 

the ULONGINT data type

TOK_UINT 

the UINTEGER data type

TOK_USHO 

the USHORT data type

TOK_WSTR 

the ZSTRING data type

TOK_ZSTR 

the ZSTRING data type

TOK_ANY 

the ANY keyword

TOK_WORD 

a word (labeled enumerator)

TOK_COMSL 

line end comment (single line, labeled enumerator)

TOK_COMML 

multi line comment

Definition at line 58 of file fbdoc_parser.bi.

◆ EoS_Modi

enum Parser::EoS_Modi
private

The modi for end of statement searching.

Enumerators used in internal in the parser to specify where to stop to tokenize the input buffer

Enumerator
TO_END_BLOCK 

tokenize to the end of the structure

TO_END 

stop at the end of the token list

TO_EOL 

stop at the next line end

TO_COLON 

stop at the next line end or colon

Definition at line 280 of file fbdoc_parser.bi.

Constructor & Destructor Documentation

◆ Parser()

Parser::Parser ( BYVAL_AS_EmitterIF_PTR  Em)

The constructor.

Parameters
EmA pointer to the emitter interface to use

Initialize the start values. We get the pointer to the EmitterIF to use and we create a short token list (just two entries) for usage inside the parser. This token list is static and it doesn't change its adress (unlike the list Parser::Tok that may shift when growing).

Definition at line 23 of file fbdoc_parser.bas.

Member Function Documentation

◆ File_()

SUB Parser::File_ ( BYREF_AS_STRING  File,
BYVAL_AS_INTEGER  Tree 
)

Read a buffer from a file and parse.

Parameters
FileThe name of the file to translate
TreeIf to follow source tree #INCLUDE
Returns
The translated code (if any)

Read a file in to input buffer. Start detailed parsing on each relevant construct. Otherwise skip the current line. Export comments on the way. Do nothing if file doesn't exist or isn't readable.

Definition at line 1077 of file fbdoc_parser.bas.

◆ StdIn()

SUB Parser::StdIn ( )

Read a buffer from pipe STDIN and parse.

Returns
The translated code (or an informal text)

Get all characters from STDIN. Start the parsing process. If there is no input (an empty line) then call function EmitterIF::Empty_(). (Useful for generating file templates in mode –geany-mode (-g).)

Definition at line 1103 of file fbdoc_parser.bas.

Here is the caller graph for this function:

◆ Include()

SUB Parser::Include ( BYVAL_AS_STRING  N)

Start a new parser to #INCLUDE a file.

Parameters
NThe (path, if any, and) file name

This procedure is used by the emitter handlers for #INCLUDE statements. It checks if the file has been done already or can get opened. If one of these fails a message gets sent to STDERR and the file gets skipped.

Otherwise a new parser gets started to operate on that file.

Definition at line 1228 of file fbdoc_parser.bas.

Here is the caller graph for this function:

◆ writeOut()

SUB Parser::writeOut ( BYREF_AS_STRING  T)

Write a piece of output (for external emitters only)

Parameters
TThe text to write

External emitters cannot use the streams opened in the main program directly. They have to send text to this procedure to use the standard output stream.

Definition at line 1143 of file fbdoc_parser.bas.

◆ CurTok()

PROPERTY_AS_LONG_PTR Parser::CurTok ( )

The current token.

Returns
The token the parser currently stopping at

This property returns the parser token (where the parser currently stops).

Definition at line 1155 of file fbdoc_parser.bas.

◆ BitIni()

PROPERTY_AS_STRING Parser::BitIni ( )

The initialization of a bitfield.

Returns
The bitfield initialization

This property returns the initialization of a bitfield in a TYPE / UNION block. The size of the bitfield may either be an integer number or a macro (= TOK_WORD).

Definition at line 1167 of file fbdoc_parser.bas.

◆ SubStr() [1/2]

PROPERTY_AS_STRING Parser::SubStr ( )

Context of current token.

Returns
The context of the current token

This property returns the context of the current token from the input buffer.

Definition at line 1186 of file fbdoc_parser.bas.

Here is the caller graph for this function:

◆ SubStr() [2/2]

PROPERTY_AS_STRING Parser::SubStr ( BYVAL_AS_LONG_PTR  T)

Context of current token at position T.

Parameters
TThe token to read
Returns
The context of the token T

This property returns the context of the token at position T from the input buffer.

Definition at line 1199 of file fbdoc_parser.bas.

◆ parseListNam()

SUB Parser::parseListNam ( BYVAL_AS_EmitFunc  Export_)

Evaluate a list of names.

Parameters
Export_The function to call on each find

Scan the token list for variable declarations and call the emitter for each find (ie. for constructs like DIM AS BYTE Nam1, Nam2(5) = {0,1,2,3,4,5}, Nam3, ...).

Definition at line 304 of file fbdoc_parser.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseListNamTyp()

SUB Parser::parseListNamTyp ( BYVAL_AS_EmitFunc  Export_)

Evaluate a list of declarations.

Parameters
Export_The function to call on each find

Scan the token list for variable declarations and call the emitter for each find (ie. for constructs like DIM Nam1 AS BYTE, Nam2(5) AS UBYTE = {0,1,2,3,4,5}, Nam3 AS STRING, ...).

Definition at line 323 of file fbdoc_parser.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseListPara()

SUB Parser::parseListPara ( BYVAL_AS_EmitFunc  Export_)

Evaluate a parameter list.

Parameters
Export_The function to call on each find

Scan the token list for a parameter list. Evaluate declaration specifiers (BYVAL / BYREF) and handle ellipsis, parameters without name, initializers and empty lists.

Definition at line 466 of file fbdoc_parser.bas.

Here is the call graph for this function:

◆ parseBlockEnum()

SUB Parser::parseBlockEnum ( BYVAL_AS_EmitFunc  Export_)

Evaluate the context of an ENUM block.

Parameters
Export_The function to call on each find

The emitter calls us to evaluate statements inside an ENUM block. So we stop after finding a statement and call the emitter handler one-by-one.

Definition at line 342 of file fbdoc_parser.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseBlockTyUn()

SUB Parser::parseBlockTyUn ( BYVAL_AS_EmitFunc  Export_)

Evaluate the context of a block.

Parameters
Export_The function to call on each find

The emitter calls us to evaluate constructs inside a block (TYPE / UNION). So we stop after finding a statement and call the emitter handler one-by-one.

Definition at line 370 of file fbdoc_parser.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pre_parse()

SUB Parser::pre_parse ( )
private

Pre-parse all FB source code, search relevant constructs.

Search the input buffer for a relevant construct. Start detailed parsing on each relevant construct. Otherways skip the current line. Export comments on the way.

Definition at line 1011 of file fbdoc_parser.bas.

◆ USubStr()

PROPERTY_AS_STRING Parser::USubStr ( )
private

Check current token position, extract word if string type.

Returns
The current word in upper case

This property returns the context of the current parser position in the input buffer in upper case characters.

Definition at line 1212 of file fbdoc_parser.bas.

Here is the caller graph for this function:

◆ getToken()

FUNCTION_AS_INTEGER Parser::getToken ( )
private

Check word at current parser position.

Returns
: The token for the word at current position

This function checks the word at the current parser position. In case of a keyword the matching token gets returned. Otherwise Parser::TOK_WORD gets returned.

Definition at line 776 of file fbdoc_parser.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tokenize()

FUNCTION_AS_INTEGER Parser::tokenize ( BYVAL_AS_EoS_Modi  Stop_)
private

Parse a relevant construct, create a token list.

Parameters
Stop_The condition where to end parsing
Returns
The length of the token list in byte (at least 8)

Start at the current position of the input buffer to check each character. Sort the input in to a token list. The token list contains three values in each entry: the type of the input, its start and its length.

The end of this process gets specified by the Stop_ parameter. It's one of the EoS_Modi enumerators.

Definition at line 926 of file fbdoc_parser.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Errr()

FUNCTION_AS_INTEGER Parser::Errr ( BYREF_AS_STRING  E)
private

Emit an error message.

Parameters
EThe reason for the error message
Returns
MSG_ERROR (and MSG_STOP at end of file)

Create an error message and call the error function of the emitter. It depends on the emitter if and where the error gets shown.

Definition at line 728 of file fbdoc_parser.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ demuxNam()

FUNCTION_AS_INTEGER Parser::demuxNam ( BYVAL_AS_INTEGER  MinTk = TOK_WORD,
BYVAL_AS_INTEGER  DeclMod = 0 
)
private

Evaluate a name, dimension and initializer in the token list.

Parameters
MinTkThe token to start at
DeclModThe modus (normal or declaration)
Returns
The (doubled) number of steps gone in the token list (or MSG_ERROR on error and MSG_STOP on the end of the token list)

Check the token list for a declaration of a name, starting at the current token (ie. behind a VAR keyword). Also checking for parenthesis to specify a dimension and the equal '=' character of an initializer. After execution the current position is at the next token after the equal character, or behind the closing parenthesis, or the name. An error is returned if there is no word at the current position.

Definition at line 114 of file fbdoc_parser.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ demuxTyp()

FUNCTION_AS_INTEGER Parser::demuxTyp ( BYVAL_AS_INTEGER  DeclMod = 0)
private

Evaluate a type declaration in the token list.

Parameters
DeclModThe modus (normal or declaration)
Returns
The (doubled) number of steps gone in the token list (or MSG_ERROR on error and MSG_STOP on the end of the token list)

Check the token list for a type declaration. Starting at the AS statement we read the name of the type and all following 'PTR' statements. The type may be a SUB, FUNCTION, PROPERTY, ... After execution the current position is at the next token behind the last PTR, or at the type name, or at the closing parenthesis. An error is returned if there is no word at the current position, or the token list doesn't start with 'AS', or the next token isn't a word.

Definition at line 212 of file fbdoc_parser.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ demuxDecl()

FUNCTION_AS_INTEGER Parser::demuxDecl ( )
private

Evaluate a function declaration in the token list.

Returns
The the result of demuxTyp() (or MSG_ERROR on error and MSG_STOP on the end of the token list)

Pre-check the token list for a declaration of a function, starting at the token behind the DECLARE statement. When OK, use demuxTyp() to evaluate the type of the declaration.

Definition at line 170 of file fbdoc_parser.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ skipOverColon()

FUNCTION_AS_INTEGER Parser::skipOverColon ( )
private

Move to the end of statement and one step beyond.

Returns
The (doubled) number of steps gone in the token list (or MSG_ERROR on error and MSG_STOP on the end of the token list)

Step through the token list and search for the end of the current statement. Then walk one step beyond, if not end of token list.

Definition at line 90 of file fbdoc_parser.bas.

Here is the caller graph for this function:

◆ skipOverBrclo()

FUNCTION_AS_INTEGER Parser::skipOverBrclo ( )
private

Move to the matching right parenthesis and one step beyond.

Returns
The (doubled) number of steps gone in the token list (or MSG_ERROR on error and MSG_STOP on the end of the token list)

Step through the token list and search for the next right parenthesis, skipping nested pairs of paranethesis. When we find a matching right parenthesis we walk one step beyond. Else we stop at the next colon or line end.

Definition at line 70 of file fbdoc_parser.bas.

Here is the caller graph for this function:

◆ skipOverComma()

FUNCTION_AS_INTEGER Parser::skipOverComma ( )
private

Move to the next comma and one step beyond.

Returns
The (doubled) number of steps gone in the token list (or MSG_ERROR on error and MSG_STOP on the end of the token list)

We step trough the token list and search for the next comma, skipping nested pairs of parenthesis. When we find a comma we walk one step beyond. Otherwise we stop at the next right parenthesis or the next colon or line end.

Definition at line 47 of file fbdoc_parser.bas.

Here is the caller graph for this function:

◆ VAR_()

FUNCTION_AS_INTEGER Parser::VAR_ ( )
private

Evaluate a variable declaration.

Returns
MSG_ERROR (or MSG_STOP on the end of the token list)

The pre-parser found a VAR, DIM, REDIM, CONST, EXTERN, COMMON or STATIC keyword. We tokenize the current line and send the result to the emitter, or we call Errr() on syntax problems.

Definition at line 544 of file fbdoc_parser.bas.

Here is the call graph for this function:

◆ TYPE_()

FUNCTION_AS_INTEGER Parser::TYPE_ ( )
private

Evaluate a TYPE or CLASS statement.

Returns
MSG_ERROR (or MSG_STOP on the end of the token list)

The pre-parser found a TYPE or CLASS keyword. In case of TYPE we tokenize the line and check if it is an alias declaration. In that case we call the emitter for a declaration on that single line. Otherwise we tokenize the complete block and call the emitter for a TYPE block. Or we call Errr() on syntax problems.

Note: the C emitter creates

  • 'typedef Typ Nam' for 'TYPE AS Typ Nam'
  • 'typedef struct Typ Nam' for 'TYPE Nam AS Typ'

Definition at line 506 of file fbdoc_parser.bas.

Here is the call graph for this function:

◆ ENUM_()

FUNCTION_AS_INTEGER Parser::ENUM_ ( )
private

Evaluate an ENUM block.

Returns
MSG_ERROR (or MSG_STOP on the end of the token list)

The pre-parser found an ENUM keyword. We tokenize the context of the complete block and call the emitter, or we call Errr() on syntax problems.

Definition at line 583 of file fbdoc_parser.bas.

Here is the call graph for this function:

◆ UNION_()

FUNCTION_AS_INTEGER Parser::UNION_ ( )
private

Evaluate a UNION block.

Returns
MSG_ERROR (or MSG_STOP on the end of the token list)

The pre-parser found an UNION keyword. We tokenize the context of the complete block and call the emitter, or we call Errr() on syntax problems.

Definition at line 601 of file fbdoc_parser.bas.

Here is the call graph for this function:

◆ FUNCTION_()

FUNCTION_AS_INTEGER Parser::FUNCTION_ ( )
private

Evaluate a function.

Returns
MSG_ERROR (or MSG_STOP on the end of the token list)

The pre-parser found a SUB, FUNCTION, CONSTRUCTOR, DESTRUCTOR, PROPERTY or OPERATOR keyword. We tokenize the complete block, evaluate the name and type and send the result to the emitter, or we call Errr() on syntax problems.

Definition at line 621 of file fbdoc_parser.bas.

Here is the call graph for this function:

◆ DECLARE_()

FUNCTION_AS_INTEGER Parser::DECLARE_ ( )
private

Evaluate a forward declaration.

Returns
MSG_ERROR (or MSG_STOP on the end of the token list)

The pre-parser found a DECLARE keyword. We tokenize the current line and send the result to the emitter, or we call Errr() on syntax problems.

Definition at line 654 of file fbdoc_parser.bas.

Here is the call graph for this function:

◆ INCLUDE_()

FUNCTION_AS_INTEGER Parser::INCLUDE_ ( )
private

Evaluate an #INCLUDE line.

Returns
MSG_ERROR (or MSG_STOP on the end of the token list)

The pre-parser found an #INCLUDE line. We tokenize the line and call the emitter, or we call Errr() handler on syntax problems. It's up to the emitter function to follow the source tree (= create a new parser and load the file).

Definition at line 671 of file fbdoc_parser.bas.

Here is the call graph for this function:

◆ DEFINE_()

FUNCTION_AS_INTEGER Parser::DEFINE_ ( )
private

Evaluate a #DEFINE declaration.

Returns
MSG_ERROR (or MSG_STOP on the end of the token list)

The pre-parser found a #DEFINE line. We tokenize the line and call the emitter, or we call Errr() handler on syntax problems.

Definition at line 706 of file fbdoc_parser.bas.

Here is the call graph for this function:

◆ MACRO_()

FUNCTION_AS_INTEGER Parser::MACRO_ ( )
private

Evaluate a #MACRO declaration.

Returns
MSG_ERROR (or MSG_STOP on the end of the token list)

The pre-parser found a #MACRO block. We tokenize the block and call the emitter, or we call Errr() handler on syntax problems.

Definition at line 687 of file fbdoc_parser.bas.

Here is the call graph for this function:

Member Data Documentation

◆ InPath

STRING Parser::InPath = ""

path of current of input file (option –tree (-t))

Definition at line 155 of file fbdoc_parser.bi.

◆ Fnam

STRING Parser::Fnam

the name of the input file

Definition at line 156 of file fbdoc_parser.bi.

◆ Buf

STRING Parser::Buf

the input buffer

Definition at line 157 of file fbdoc_parser.bi.

◆ ErrMsg

STRING Parser::ErrMsg

an error message

Definition at line 158 of file fbdoc_parser.bi.

◆ Tok

STRING Parser::Tok

the token list (binaries)

Definition at line 159 of file fbdoc_parser.bi.

◆ BlockNam

STRING Parser::BlockNam

the name of a block (ENUM, UNION, TYPE)

Definition at line 160 of file fbdoc_parser.bi.

◆ StaTok

LONG_PTR Parser::StaTok

the pre-parsed token

Definition at line 183 of file fbdoc_parser.bi.

◆ NamTok

LONG_PTR Parser::NamTok

the name token of the construct

Definition at line 184 of file fbdoc_parser.bi.

◆ DimTok

LONG_PTR Parser::DimTok

the token of the left parenthesis of a dimension

Definition at line 185 of file fbdoc_parser.bi.

◆ IniTok

LONG_PTR Parser::IniTok

the start character of an initializer ('=')

Definition at line 186 of file fbdoc_parser.bi.

◆ BitTok

LONG_PTR Parser::BitTok

the start character of a bitfiled declaration (':')

Definition at line 187 of file fbdoc_parser.bi.

◆ TypTok

LONG_PTR Parser::TypTok

the token of the type keyword

Definition at line 188 of file fbdoc_parser.bi.

◆ ShaTok

LONG_PTR Parser::ShaTok

the token of the SHARED keyword

Definition at line 189 of file fbdoc_parser.bi.

◆ PtrTok

LONG_PTR Parser::PtrTok

the token of the first PTR keyword

Definition at line 190 of file fbdoc_parser.bi.

◆ Co1Tok

LONG_PTR Parser::Co1Tok

the token of the first CONST keyword (if any)

Definition at line 191 of file fbdoc_parser.bi.

◆ Co2Tok

LONG_PTR Parser::Co2Tok

the token of the second CONST keyword (if any)

Definition at line 192 of file fbdoc_parser.bi.

◆ FunTok

LONG_PTR Parser::FunTok

type of the pre-parsed token

Definition at line 193 of file fbdoc_parser.bi.

◆ CalTok

LONG_PTR Parser::CalTok

the token of the calling convention keyword (if any)

Definition at line 194 of file fbdoc_parser.bi.

◆ AliTok

LONG_PTR Parser::AliTok

the token of the ALIAS keyword (if any)

Definition at line 195 of file fbdoc_parser.bi.

◆ As_Tok

LONG_PTR Parser::As_Tok

the token of the AS keyword (if no SUB)

Definition at line 196 of file fbdoc_parser.bi.

◆ ParTok

LONG_PTR Parser::ParTok

the token of the left parenthesis of a parameter list

Definition at line 197 of file fbdoc_parser.bi.

◆ By_Tok

LONG_PTR Parser::By_Tok

the token of the declaration specifier (BYVAL / BYREF)

Definition at line 198 of file fbdoc_parser.bi.

◆ DivTok

LONG_PTR Parser::DivTok

the token of different purposes like the STATIC keyword in a member function declaration (if any) or the LIB keyword in a normal declaration

Definition at line 199 of file fbdoc_parser.bi.

◆ Tk1

LONG_PTR Parser::Tk1

the first token in a statment

Definition at line 200 of file fbdoc_parser.bi.

◆ EndTok

LONG_PTR Parser::EndTok

the last token in the list

Definition at line 201 of file fbdoc_parser.bi.

◆ UserTok

LONG_PTR Parser::UserTok

a token for customised usage in emitter-handlers

Definition at line 202 of file fbdoc_parser.bi.

◆ Po

LONG Parser::Po

the current position in the input buffer Parser::Buf

Definition at line 214 of file fbdoc_parser.bi.

◆ Fin

LONG Parser::Fin

the last position in the input buffer Parser::Buf

Definition at line 215 of file fbdoc_parser.bi.

◆ PtrCount

LONG Parser::PtrCount

the number of PTR keywords

Definition at line 216 of file fbdoc_parser.bi.

◆ SrcBgn

LONG Parser::SrcBgn

start position to export FB source

Definition at line 217 of file fbdoc_parser.bi.

◆ LineNo

LONG Parser::LineNo

the current line in the input buffer Parser::Buf

Definition at line 218 of file fbdoc_parser.bi.

◆ LevelCount

LONG Parser::LevelCount

the level in nested blocks (one based)

Definition at line 219 of file fbdoc_parser.bi.

◆ InTree

LONG Parser::InTree

flag to indicate if to follow source tree #INCLUDEs

Definition at line 220 of file fbdoc_parser.bi.

◆ ListCount

LONG Parser::ListCount

the current entry in a list (zero based)

Definition at line 221 of file fbdoc_parser.bi.

◆ ToLast

LONG Parser::ToLast
private

the type of the token before the current one

Definition at line 294 of file fbdoc_parser.bi.

◆ Tk

LONG_PTR Parser::Tk
private

the current token of the parser

Definition at line 297 of file fbdoc_parser.bi.

◆ A

LONG_PTR Parser::A
private

start of a word in pre-parsing

Definition at line 298 of file fbdoc_parser.bi.

◆ L

LONG_PTR Parser::L
private

length of a word in pre-parsing

Definition at line 299 of file fbdoc_parser.bi.

◆ Emit

EmitterIF_PTR Parser::Emit
private

the emitter interface

Definition at line 301 of file fbdoc_parser.bi.


The documentation for this class was generated from the following files: