fb-doc  0.4.0
FreeBASIC documentation tool
fbdoc_emit_syntax.bas File Reference

Emitter for repairing the Doxygen listing files. More...

#include "fbdoc_emit_syntax.bi"
#include "fbdoc_options.bi"
#include "fbdoc_version.bi"
#include "fbdoc_doxyfile.bi"
Include dependency graph for fbdoc_emit_syntax.bas:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define GET_WORD_TYPE()
 check a word in source code More...
 

Functions

FUNCTION_AS_STRING html_specials (BYVAL_AS_UBYTE_PTR T, BYVAL_AS_INTEGER A, BYVAL_AS_INTEGER L)
 Replace special characters for HTML output. More...
 
FUNCTION_AS_STRING tex_specials (BYVAL_AS_UBYTE_PTR T, BYVAL_AS_INTEGER A, BYVAL_AS_INTEGER L)
 Replace special characters for LaTeX output. More...
 
FUNCTION_AS_STRING xml_specials (BYVAL_AS_UBYTE_PTR T, BYVAL_AS_INTEGER A, BYVAL_AS_INTEGER L)
 Replace special characters for XML output. More...
 
FUNCTION_AS_STRING html_eol (BYVAL_AS_RepData_PTR Symb, BYREF_AS_INTEGER Nr)
 Generate end of line code for HTML output. More...
 
FUNCTION_AS_STRING tex_eol (BYVAL_AS_RepData_PTR Symb, BYREF_AS_INTEGER Nr)
 Generate end of line code for LaTeX output. More...
 
FUNCTION_AS_STRING xml_eol (BYVAL_AS_RepData_PTR Symb, BYREF_AS_INTEGER Nr)
 Generate end of line code for XML output. More...
 
SUB_CDECL synt_init (BYVAL_AS_Parser_PTR P)
 Emitter to be called per file before parsing starts. More...
 
SUB_CDECL synt_exit (BYVAL_AS_Parser_PTR P)
 Emitter to be called after parsing of a file. More...
 
SUB_CDECL synt_incl (BYVAL_AS_Parser_PTR P)
 Emitter to generate an include statement. More...
 
SUB_CDECL synt_func (BYVAL_AS_Parser_PTR P)
 Emitter to generate a function name. More...
 
SUB init_syntax (BYVAL_AS_EmitterIF_PTR Emi)
 Initialize the SyntaxHighlighting EmitterIF. More...
 

Detailed Description

Emitter for repairing the Doxygen listing files.

This file contains the emitter SyntaxHighlighting, used as default emitter in mode --syntax-mode (-s) to generate accurate source code listings for Doxygen back-end.

This emitter replaces the code section in the original Doxygen output files, originally containing the C-like intermediate formate (used as Doxygen input). The code section gets replaced by real FB source code in accurate syntax highlighting. Also links get transfered from the old Doxygen output to the new context. This works for Html, LaTeX and XML output.

In mode --syntax-mode (-s) fb-doc doesn't operate on single FB source input files. Instead it parses some tags in the Doxygen configuration file Doxyfile and operates on the specified paths / files (in a similar way as Doxygen did).

Definition in file fbdoc_emit_syntax.bas.

Macro Definition Documentation

#define GET_WORD_TYPE ( )
Value:
/* (multi line FreeBASIC #MACRO)
VAR word = MID(*T, start + 1, size)
VAR res = IIF(Symbols, Symbols->rep(word), cast(zstring ptr, SADD(word))) ' !!! CAST is a workaround, to be replaced when fbc types OK again
IF res = SADD(word) THEN ' no symbol, check keyword & preprocessor
word = UCASE(word)
res = word_type(word)
typ = IIF(res, ASC(*res), FB_CODE)
SELECT CASE AS CONST OPT->CaseMode ' reformat letter cases, if required
CASE OPT->CASE_LOWER : MID(*T, start + 1, size) = LCASE(word)
CASE OPT->CASE_MIXED : MID(*T, start + 1, size) = MID(*res, 2, size)
CASE OPT->CASE_UPPER : MID(*T, start + 1, size) = word
END SELECT
ELSE
typ = CAST(INTEGER, res) ' start of replacement string
END IF
#ENDMACRO */

check a word in source code

This macro is used for single source reasons. It reads the current word from the input buffer and checks if it matches

  1. an entry in the container Highlighter::Symbols (links read from orig. file),
  2. the FB keyword list

The result is in the typ variable:

  1. = keyword,
  2. = keywordtype,
  3. = preprocessor,
  4. or greater = link (type gets a ZSTRING PTR to the context)

Definition at line 1102 of file fbdoc_emit_syntax.bas.

Function Documentation

FUNCTION_AS_STRING html_specials ( BYVAL_AS_UBYTE_PTR  T,
BYVAL_AS_INTEGER  A,
BYVAL_AS_INTEGER  L 
)

Replace special characters for HTML output.

Parameters
TThe Buffer to read from
AStart position (zero based)
LLength of substring
Returns
A string with replaced special characters

The function is used as Highlighter::special_chars() function. It extracts a substring from the input buffer. Special characters are replaced by their HTML equivalents.

Definition at line 81 of file fbdoc_emit_syntax.bas.

Here is the caller graph for this function:

FUNCTION_AS_STRING tex_specials ( BYVAL_AS_UBYTE_PTR  T,
BYVAL_AS_INTEGER  A,
BYVAL_AS_INTEGER  L 
)

Replace special characters for LaTeX output.

Parameters
TThe Buffer to read from
AStart position (zero based)
LLength of substring
Returns
A string with replaced special characters

The function is used as Highlighter::special_chars() function. It extracts a substring from the input buffer. Special characters are replaced by their LaTeX equivalents.

Definition at line 107 of file fbdoc_emit_syntax.bas.

Here is the caller graph for this function:

FUNCTION_AS_STRING xml_specials ( BYVAL_AS_UBYTE_PTR  T,
BYVAL_AS_INTEGER  A,
BYVAL_AS_INTEGER  L 
)

Replace special characters for XML output.

Parameters
TThe Buffer to read from
AStart position (zero based)
LLength of substring
Returns
A string with replaced special characters

The function is used as Highlighter::special_chars() function. It extracts a substring from the input buffer. Special characters are replaced by their XML equivalents.

Definition at line 135 of file fbdoc_emit_syntax.bas.

Here is the caller graph for this function:

FUNCTION_AS_STRING html_eol ( BYVAL_AS_RepData_PTR  Symb,
BYREF_AS_INTEGER  Nr 
)

Generate end of line code for HTML output.

Parameters
SymbSymbol table for cross-referencing
NrLine number
Returns
A string to end the current line and start a new one

The function is used as Highlighter::eol() function. It generates code to end the current line and start a new one with the next line number. The number counter gets increased and returned as a BYREF parameter. Special line numbers are

  • 1: the first line (emit no line end but the line start)
  • 0: the last line (emit the line end but no line start)

Definition at line 167 of file fbdoc_emit_syntax.bas.

Here is the caller graph for this function:

FUNCTION_AS_STRING tex_eol ( BYVAL_AS_RepData_PTR  Symb,
BYREF_AS_INTEGER  Nr 
)

Generate end of line code for LaTeX output.

Parameters
SymbSymbol table for cross-referencing
NrLine number
Returns
A string to end the current line and start a new one

The function is used as Highlighter::eol() function. It generates code to end the current line and start a new one with the next line number. The number counter gets increased and returned as a BYREF parameter. Special line no. are

  • 1: the first line (emit no line end but the line start)
  • 0: the last line (emit the line end but no line start)

Definition at line 197 of file fbdoc_emit_syntax.bas.

Here is the caller graph for this function:

FUNCTION_AS_STRING xml_eol ( BYVAL_AS_RepData_PTR  Symb,
BYREF_AS_INTEGER  Nr 
)

Generate end of line code for XML output.

Parameters
SymbSymbol table for cross-referencing
NrLine number
Returns
A string to end the current line and start a new one

The function is used as Highlighter::eol() function. It generates code to end the current line and start a new one with the next line number. The number counter gets increased and returned as a BYREF parameter. Special line numbers are

  • 1: the first line (emit no line end but the line start)
  • 0: the last line (emit the line end but no line start)

Definition at line 223 of file fbdoc_emit_syntax.bas.

Here is the caller graph for this function:

SUB_CDECL synt_init ( BYVAL_AS_Parser_PTR  P)

Emitter to be called per file before parsing starts.

Parameters
Pthe parser calling this emitter

This emitter gets called before the parser starts its parsing process. It initializes the FB source code emission.

Definition at line 1392 of file fbdoc_emit_syntax.bas.

Here is the caller graph for this function:

SUB_CDECL synt_exit ( BYVAL_AS_Parser_PTR  P)

Emitter to be called after parsing of a file.

Parameters
Pthe parser calling this emitter

This emitter gets called after the parser ends its parsing process. It sends the rest of the FB source code to the output stream.

Definition at line 1415 of file fbdoc_emit_syntax.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

SUB_CDECL synt_incl ( BYVAL_AS_Parser_PTR  P)

Emitter to generate an include statement.

Parameters
Pthe parser calling this emitter

This emitter operates on include statements. It extracts the file name and checks the Highlighter::Symbols table for a matching link. If there is no link, nothing is done.

In case of a matching link the source code gets emitted up to the link.

File names need special handling because the string literals don't get checked for linkage.

Definition at line 1440 of file fbdoc_emit_syntax.bas.

Here is the caller graph for this function:

SUB_CDECL synt_func ( BYVAL_AS_Parser_PTR  P)

Emitter to generate a function name.

Parameters
Pthe parser calling this emitter

This emitter operates on SUB, FUNCTION, PROPERTY, OPERATOR, CONSTRUCTOR andDESTRUCTOR` definitions (function body, not declaration). It extracts the function name and checks the Highlighter::Symbols table for a matching link. If there is no link, nothing is done.

In case of a matching link the source code gets emitted up to the link.

Funktion names need special handling because they vary between intermediate format and FB source (:: vs. .).

Definition at line 1477 of file fbdoc_emit_syntax.bas.

Here is the caller graph for this function:

SUB init_syntax ( BYVAL_AS_EmitterIF_PTR  Emi)

Initialize the SyntaxHighlighting EmitterIF.

Parameters
EmiThe EmitterIF to initialize

FIXME

Since
0.4.0

Definition at line 1519 of file fbdoc_emit_syntax.bas.

Here is the call graph for this function:

Here is the caller graph for this function: