home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
p2demo21.exe
/
PEL
/
C.PEL
< prev
next >
Wrap
Text File
|
1995-04-04
|
32KB
|
978 lines
# $Header: P:\source\wmacros\c.pev 1.14 04 Apr 1995 09:28:24 WALKER $
## $Tabs:4 7$
##############################################################################
#
# Compuware Corporation
# 31440 Northwestern Highway
# Farmington Hills, Michigan 48334-2564
#
# This source code listing contains information that is
# proprietary to Compuware Corporation and may not be copied
# duplicated, translated, transmitted, stored, retrieved
# or in any manner or by any method conveyed or disclosed
# to a third party or parties without express written
# permission from Compuware Corporation.
#
#
##############################################################################
#### $Workfile: c.pel $: C support functions
local make_extra_files = 0
# This is a list of lines to skip when doing ctags processing
# this list should be configurable in the future
local skipList
local function ctags_init_skiplist()
{
local counter = 0
skipList[++counter] = "#include"
skipList[++counter] = "declare"
skipList[++counter] = "public:"
skipList[++counter] = "private:"
skipList[++counter] = "protected:"
return counter;
}
global function do_c_routines(dhTemp, allBuffers)
{
local found_routine = 0
local i
local found_array[]
local temp[]
local fun_name
process_background( DISABLE_FOREGROUND )
# Since the format of C-like files vary from person to person, we have to
# come up with a better way of finding functions in a file. The easiest
# way to do that is to just use the ctags_add function of the ctags_make.
# By doing this, we are assured that we will find all available functions,
# that is, assuming the ctags_make finds all functions
found_array = ctags_add(0)
for (i in found_array)
{
split( found_array[i], temp, SUBSEP )
current_line = temp[2]
if ( allBuffers )
fun_name = buffer_filename " : " temp[2] " : " temp[1]
else
fun_name = temp[2] " : " temp[1]
add_item_to_list( dhTemp, fun_name, \
buffer_filename, current_line, 0, -1 )
found_routine = 1
}
process_background( END_BACKGROUND )
return found_routine
}
############################### C tags support ############################
# temp array used to store symbols during ctags_make
local tagsArray
local classArray
#local miscArray
local definesArray
local headerArray
local IDD_TAGS_PROGRESS = 1629
local IDB_TAGS_STOP = 1630
local IDT_TAGS_FILES_PROCESSED = 1631
local IDT_TAGS_TAGS_PROCESSED = 1632
local IDT_TAGS_CURRENT_FILE = 1633
local IDT_TAGS_PERCENT = 1634
local tags_temp_buffer
local tags_extensions = "*.c *.h *.cpp *.hpp *.cxx *.hxx"
local tags_file = "ctags.tag"
local tags_buffer
local tags_make_successful
local tags_remake_all = FALSE
global function ctags_make_background()
{
local j
local source_file
local wildcard
local filespecs[]
local file_count
local full_spec
tags_make_successful = FALSE
split( tags_extensions, filespecs )
making_tags_dialog()
set_tags_files_processed( 0 )
set_tags_tags_processed( 0 )
set_tags_message( "Building " tags_file " - Please wait..." )
# scan the source files for "interesting" symbols
for ( j in filespecs )
{
wildcard = buildpath( filespecs[ j ] )
if ( (source_file = findfirst( wildcard )) )
{
do
{
full_spec = buildpath( getcwd() source_file )
source_file = tolower( path_path( wildcard ) source_file )
set_tags_current_file( source_file )
if ( !tags_remake_all &&
filetime(source_file) == get_timestamp(full_spec) )
continue
# open the buffer as a system buffer
current_buffer = tags_temp_buffer = create_buffer( "",
source_file,
BUFFER_SYSTEM +
BUFFER_NO_UNDO )
# build the tags array
ctags_add( 1 )
# DWM--combine these two lines to fool the compiler
# into generating only one debug_step for both
# operations. If the user breaks out of the make it
# is important that the tags_temp_buffer be null if
# the buffer has been deleted.
delete_buffer(); tags_temp_buffer = 0
ctags_support( tagsArray, tags_buffer, tags_file, source_file )
file_count++
set_tags_files_processed( file_count )
update_timestamp( source_file )
} while (( source_file = findnext()))
}
}
tags_make_successful = TRUE
}
local function ctags_setup( file_extensions, output_tags_file )
{
local success = FALSE
tags_extensions = file_extensions
tags_file = output_tags_file
# If the tag file has been deleted,
# remake all of the tags.
if ( filemode(tags_file) == -1 )
tags_remake_all = TRUE
else
tags_remake_all = FALSE
# create a system buffer for the tags info
tags_buffer = create_buffer( tags_file, tags_file, BUFFER_SYSTEM + BUFFER_NO_UNDO )
if ( tags_buffer )
{
init_timestamp( path_path(tags_file) path_fname(tags_file) ".dat" )
success = TRUE
}
else
warning( "invalid tags filename " tags_file )
return success
}
local function ctags_cleanup( outFileName )
{
local response
current_window = current_window
cleanup_timestamp()
current_buffer = tags_buffer
# only write it if it has been updated
if ( and(buffer_flags, BUFFER_MODIFIED) )
{
if ( !tags_make_successful )
{
response = confirm( "Save tags file " tags_file "? [yn]", "yYnN" )
if ( tolower(response) == "y" )
write_buffer()
}
else
write_buffer()
}
# If the background process did not
# clean up after itself, do so now.
if ( tags_temp_buffer )
delete_buffer( tags_temp_buffer )
if ( tags_dlg )
delete_tags_dialog()
set_tags_message( outFileName " complete." )
set_tags_percent( outFileName )
# save the new tags file
current_buffer = tags_buffer
delete_buffer( tags_buffer )
}
## ctags_make() - builds a "ctags.tag" data file for all obvious functions,
# structure definitions, and #defined macros. You will be
# prompted for a list of C source files to process.
#
global function ctags_make( file_extensions, output_tags_file )
{
local priorBuffer = current_buffer
if ( argcount() < 2 )
{
warning( "ctags_make syntax: ctags_make( files_extensions, tags_file )" )
return FALSE
}
if ( ctags_setup(file_extensions, output_tags_file) )
{
process_background( DISABLE_FOREGROUND, function_id("ctags_make_background") )
# save the new tags file
ctags_cleanup( output_tags_file )
}
current_buffer = priorBuffer
return tags_make_successful
}
global function making_tags_callback()
{
local ret = DRC_MSG_PROCESSED
if ( callback_msg == DM_CANCEL || callback_msg == DM_CLOSE )
{
process_background( STOP_BACKGROUND )
}
else if ( callback_msg == DM_CLICK || callback_msg == DM_DOUBLE_CLICK )
{
if ( callback_index == IDB_TAGS_STOP )
{
# set_dialog_window( callback_dialog_handle, DWC_HIDE )
beep()
process_background( STOP_BACKGROUND )
}
}
return ret
}
local tags_dlg = 0
local function set_tags_current_file( file )
{
if ( tags_dlg )
{
set_dialog_item( tags_dlg, IDT_TAGS_CURRENT_FILE, DAC_TEXT, file )
set_tags_percent( 0 )
}
}
local function set_tags_percent( percent )
{
if ( tags_dlg )
set_dialog_item( tags_dlg, IDT_TAGS_PERCENT, DAC_TEXT, "%" percent "" )
}
local function set_tags_files_processed( processed )
{
if ( tags_dlg )
set_dialog_item( tags_dlg, IDT_TAGS_FILES_PROCESSED, DAC_TEXT, processed "" )
}
local function set_tags_tags_processed( processed )
{
if ( tags_dlg )
set_dialog_item( tags_dlg, IDT_TAGS_TAGS_PROCESSED, DAC_TEXT, processed "" )
}
local function increment_tags_processed()
{
local count
if ( tags_dlg )
{
count = query_dialog_item( tags_dlg, IDT_TAGS_TAGS_PROCESSED, DAC_TEXT )
set_dialog_item( tags_dlg, IDT_TAGS_TAGS_PROCESSED, DAC_TEXT, (count + 1) "" )
}
}
local function set_tags_message( msg )
{
if ( tags_dlg )
set_dialog_window( tags_dlg, DWC_STATUSBARTEXT, msg "" )
}
local function delete_tags_dialog()
{
if ( tags_dlg )
{
delete_dialog( tags_dlg )
tags_dlg = 0
}
}
global function making_tags_dialog()
{
tags_dlg = create_mdialog( function_id("making_tags_callback"), mdi_mode == 2 ? -1 : 0, IDD_TAGS_PROGRESS )
set_dialog_window( tags_dlg, DWC_STATUSBAR, TRUE )
begin_dialog( tags_dlg )
}
local function ctags_support( array, buffer_id, outFileName, srcFile )
{
local i, found
# remove obsolete entries for this file
current_buffer = buffer_id
save_position()
goto_buffer_top()
found = 0
# if ( and( status_bar_flags, STB_MESSAGES ) )
set_tags_message( "Removing old entries from " buffer_filename "..." )
while ( search( " " srcFile, SEARCH_FORWARD ))
{
#cvdebug("***removing obsolete source entries")
found = 1
goto_bol()
delete_line()
}
# insert the name, source filename, and
# search pattern into the buffer
restore_position( !found )
# if ( and( status_bar_flags, STB_MESSAGES ) )
set_tags_message( "Adding new entries to " buffer_filename "..." )
for ( i in array )
{
insert_string( i " " srcFile " ^" array[ i ] )
insert_newline()
}
delete array
}
local function add_tag( index, element )
{
tagsArray[ index ] = element
increment_tags_processed()
}
## ctags_add
#
# Extract "interesting symbols" from the current buffer, assuming it
# is C source code. NOTE: This is a "quick and dirty" algorithm - symbols
# can easily be overlooked, or included when they aren't supposed to be.
# No effort is made to deal with #if and #ifdef preprocessor code.
#
# this is also used by the optional routines function
#
global function ctags_add( makingTags, ctags_string, ctags_multiline )
{
local nlines = buffer_last_line
local thisLine = 0
local firstLine = 0
local i = 0;
local currLine = 0
local symbol
local blank
local fname, cname;
local found_prototype;
local oldthisLine, oldLine, secondLine, trimmedThisLine
goto_buffer_top()
if (!makingTags)
delete(tagsArray);
for ( ; current_line < nlines; current_line++ )
{
# idle()
# Skip over blank lines
if ( !current_line_length )
{
# #cvdebug("skipping blank lines line(%d)", current_line)
continue
} #end if current_line
oldthisLine = ""
# read the text of the line
current_column = 1
thisLine = read_buffer()
trimmedThisLine = ltrim( thisLine )
if ( ctags_skip_line( thisLine ) )
{
continue
}
# Skip over obvious procedure bodies
else if ( ctags_skip_proc( thisLine ) )
{
continue
} #end if skip_proc
oldLine = current_line
++current_line
secondLine = read_buffer()
current_line = oldLine
# check for multi-line definitions like the following
#
# void
# foo
# ( int arg1 )
#
if ( match( secondLine, /^[ ]*\([^;]*$/ ) )
{
oldthisLine = thisLine
thisLine = thisLine secondLine
#cvdebug(" thisline changed");
} #end if match
# Preprocessor "#defines"
if ( substr(trimmedThisLine,1,1) == "#" )
{
if ( match( thisLine, /#define[ \t]+/ ))
{
# get text past the "define" keyword
symbol = substr( thisLine, RSTART+RLENGTH )
if ( match( symbol, /[ \t(]+|$/ ))
{
# ..and before the next delimiter
if ( makingTags )
{
add_tag( substr(symbol, 1, RSTART-1), thisLine )
if ( make_extra_files )
definesArray[ substr( symbol, 1, RSTART-1 ) ] = thisLine
} #end if making tags
} #end if match symbol
#cvdebug("matched a define line(%d)", current_line)
# if this is a macro, step over function body
while ( thisLine ~ /\\$/ && current_line != nlines )
{
#cvdebug(" finding end of macro line(%d)", current_line)
current_line++
current_column = 1
thisLine = read_buffer()
} #end while
#cvdebug("skipping after macro found line(%d)", current_line)
continue
} #end if matched thisline
} #end if substr trimmedThisLine
# Structure and class definitions
else if ( match( thisLine, /(enum|struct|class)[ \t]+[a-zA-Z0-9_]+[ \t]*([\{\:\/]|$)/ ) )
{
match( thisLine, /(enum|struct|class)[ \t]+/ )
# get text past the "struct" or "class" keyword
symbol = substr( thisLine, RSTART+RLENGTH )
if ( match( symbol, /[ \t]*([\{\:\/]|$)/ ) > 1 )
{
# ..and before the "{" or ":" or "/"
if ( makingTags )
{
if ( make_extra_files )
headerArray[ substr( symbol, 1, RSTART-1 ) ] = thisLine
add_tag( substr(symbol, 1, RSTART-1), thisLine )
} #end if makingtags
# if we matched a class, find brace and skip over it
# so we can find functions defined w/in class definition
if ( match( thisLine, /class/ ) )
{
search( /\{/, SEARCH_FORWARD )
current_line++
#cvdebug(" jumping pass brace line(%d)", current_line)
continue
} # end if match symbol
} #end if match symbol
} #end else-if match thisLine
# A function definition begins in column one and is followed
# by a parenthesized list not followed by a semi-colon.
# If you use a different convention for function definitions
# you will have to change this.
# A function definition may also be preceeded by types, linkage
# information and extern "C" declarations.
else if ( match( thisLine, /^[^;\/]+\([^;]*$/ ) )
{
# strip off the argument list
symbol = trim( substr( thisLine, 1, index(thisLine,"(") - 1 ))
if (symbol ~ /\"/)
{
if ( !(symbol ~ /extern[ \t]*\"[C|c]\"/ ))
{
# Skip strings
#cvdebug("skipping extern C line(%d)", current_line)
continue
}
}
else if (symbol ~ /[=+-|!%\[\]\}<>.];/ )
{
#cvdebug("skipping expressions line(%d)", current_line)
# Skip assignments and other expressions
# However, references (&) and pointers (*) are OK
continue
}
# get the last keyword before the "("
if ( symbol ~ /[ \t]*::[ \t]*/ )
{
# parse a C++ class::function name.
if ( match( symbol, /[a-zA-Z0-9_~]+$/ ))
{
# strip off the function name
fname = trim( substr( symbol, RSTART ))
symbol = trim( substr( symbol, 1, RSTART - 1 ), " \t:" )
if ( match( symbol, /[a-zA-Z0-9_~]+$/ ))
{
cname = trim( substr( symbol, RSTART ))
symbol = cname "::" fname
}
else
symbol = fname
#cvdebug("matched C++ name line(%d)", current_line)
}
else if ( match( symbol, /[^ \t]+$/ ))
{
# strip off the function name
fname = trim( substr( symbol, RSTART ))
symbol = trim( substr( symbol, 1, RSTART - 1 ), " \t:" )
if ( match( symbol, /[^ \t]+$/ ))
{
cname = trim( substr( symbol, RSTART ))
symbol = cname "::" fname
}
else
symbol = fname
#cvdebug("matched other function line(%d)", current_line)
}
else
{
#cvdebug("just skipping line(%d)", current_line)
continue
}
}
# check for multi-line definitions like the following
#
# void
# foo CALL_CONV
# ( int arg1 )
#
# where CALL_CONV is know to be valid and is passed into
# ctags_make()
#
else if ( match( symbol, "[ ]+" ctags_string "$" ))
{
#cvdebug("match w/ctags string line(%d)", current_line)
#cvdebug(" string before(%s)", symbol )
# remove the offending string
symbol = trim( substr( symbol, 1, RSTART-1 ))
# pull out the function name
if ( match( symbol, /[a-zA-Z0-9_~&*]+$/ ))
symbol = trim( substr( symbol, RSTART ))
#cvdebug(" string after(%s)", symbol )
}
else if ( match( symbol, /[a-zA-Z0-9_~&*=+-><()\[\]]+$/ ))
{
#cvdebug("match multi line 2 line(%d)", current_line)
#cvdebug(" string before(%s)", symbol )
symbol = trim( substr( symbol, RSTART ))
symbol = ltrim( symbol, "*&" )
#cvdebug(" string before(%s)", symbol )
}
else
{
#cvdebug("skipping multi line 1 line(%d)", current_line)
continue
}
if ( symbol == "if" || symbol == "do" ||
symbol == "while" || symbol == "switch" ||
symbol == "for" || symbol == "return" )
{
#cvdebug("skipping if, while line(%d)", current_line)
continue
}
if ( length( symbol ))
{
firstLine = oldthisLine ? oldthisLine : thisLine
# save current line before we go to end of definition
currLine = current_line;
# find the end of the definition
found_prototype = FALSE
while ( thisLine !~ /\{/ && !found_prototype &&
current_line != nlines )
{
if ( thisLine ~ /;/ )
found_prototype = TRUE
#cvdebug(" finding end of definition line(%d)", current_line)
current_line++
current_column = 1
thisLine = read_buffer()
}
if ( found_prototype)
{
#cvdebug(" skipping prototypes line(%d)", current_line)
continue # skip prototypes.
}
if (makingTags)
{
#cvdebug("### Adding(%s) to tags array line(%d)", symbol, current_line)
add_tag( symbol, firstLine )
if ( make_extra_files )
classArray[ symbol ] = firstLine
# Add a second entry in the tags file for the function
# without the class name (as tags_auto will not pick up
# the class name since it is rarely specified when called)
match( symbol, /::/ )
if ( RSTART && RLENGTH )
{
add_tag( substr(symbol, RSTART + RLENGTH), firstLine )
if ( make_extra_files )
classArray[ substr( symbol, RSTART + RLENGTH) ] = firstLine
}
}
else
add_tag( i, symbol SUBSEP currLine )
++i
if ( !makingTags && and( status_bar_flags, STB_MESSAGES ) )
message( "Searching file %s...(%d%%)", \
buffer_filename, current_line * 100 / nlines )
set_tags_percent( current_line * 100 / nlines )
# Skip over the procedure body (if any)
if ( ctags_skip_proc( thisLine ) )
{
continue
}
}
}
#cvdebug("line not processed line(%d)", current_line)
}
return tagsArray;
}
# Utility function used by ctags_add to jump over a line
#
local function ctags_skip_line( thisLine )
{
local skippedOne = FALSE
local trimmedThisLine = ltrim( thisLine )
local maxItems = ctags_init_skiplist()
local i;
# Skip over blank lines
if ( !trimmedThisLine )
{
# #cvdebug("skipping null lines line(%d)", current_line)
skippedOne = TRUE
} #end if trimmedThisLine
# Skip over obvious comment blocks
else if ( substr(trimmedThisLine,1,2) == "//" )
{
# #cvdebug("skipping line comments line(%d)", current_line)
skippedOne = TRUE
} #end if substr
else if ( substr(trimmedThisLine,1,2) == "/*" )
{
# old_line = current_line
search( "*/", SEARCH_FORWARD )
# #cvdebug("skipping comment blocks old(%d) line(%d)",
# old_line, current_line)
skippedOne = TRUE
} #end if substr
# # skip prototypes or statements
# else if ( thisLine ~ /;/ )
# {
# #cvdebug("skipping prototypes in skip line line(%d)", current_line)
# skippedOne = TRUE
# }
else for ( i = 1; i <= maxItems; i++ )
{
if ( (i in skipList ) && trimmedThisLine ~ skipList[ i ] )
{
#cvdebug("skipping line line(%d)", current_line )
skippedOne = TRUE
}
}
return skippedOne
}
# Utility function used by ctags_add to jump over procedure bodies
#
local function ctags_skip_proc( thisLine )
{
local old_col, old_line;
local skippedOne = FALSE
# Skip over the procedure body (if any)
# until read_buffer() expands tabs, we'll have to do a
# search() instead of the much easier goto_pos() and match()
#
# if ( match( thisLine, /\{/ ) && thisLine !~ /\}/ )
if ( thisLine ~ /\{/ && thisLine !~ /\}/ )
{
skippedOne = TRUE
old_line = current_line
old_col = current_column
# search( /\{/, SEARCH_FORWARD + SEARCH_REGEX )
# goto_pos( current_line, RSTART )
search( "{", SEARCH_FORWARD )
goto_matching( "", TRUE )
#cvdebug("skipping procedure bodies RSTART(%d) start(%d,%d) end(%d,%d)", RSTART, old_col, old_line, current_column, current_line)
}
return skippedOne
}
function setup_C_template()
{
local OB, EB, EB2 # open and closed braces
local OC, MC, EC # open, middle, end comment markers
local BLOCK, NBLOCK
OB = electric_symbol.open_brace
EB = electric_symbol.end_brace
EB2 = electric_symbol.end_brace2
OC = electric_symbol.open_comment
MC = electric_symbol.middle_comment
EC = electric_symbol.end_comment
NBLOCK = electric_symbol.new_block
BLOCK = electric_symbol.block
delete( language_template ); # delete last template and start over
ELEC_LANG = "c"
language_template[ "#d" ] = "#define `constant-1`"
language_template[ "#i" ] = "#include <`filename-1`>"
language_template[ "#p" ] = "#pragma `char-sequence-1`"
language_template[ "#u" ] = "#undef `constant-1`"
language_template[ "(" ] = "( `expression-1` )"
language_template[ "/*" ] = "/*\n** `comment-1`\n*/"
language_template[ "/" ] = "/* `comment-1` */"
language_template[ "[" ] = "[ `index-1` ]"
language_template[ "{" ] = BLOCK
language_template[ "_m" ] = "_makepath(@,,,,);"
language_template[ "_s" ] = "_splitpath(@,,,,);"
language_template[ "ac" ] = "access(\"@\",);"
language_template[ "br" ] = "break;\n@"
language_template[ "ca" ] = "case `constant-expr-1`:\n\t`statement-1`\nbreak;\n"
language_template[ "cl" ] = "close(`filename-1`);"
language_template[ "co" ] = "continue;\n@"
language_template[ "do" ] = "do \n" BLOCK " while ( `expr-1` );\n"
language_template[ "fe" ] = "free( `storage-1` );"
language_template[ "fo" ] = "for (`expr-1`;`expr-2`;`expr-3` ) \n" BLOCK OC " end for " EC "\n"
language_template[ "fp" ] = "fprintf(`filename-1`,\"`format-string-1`\",`var-list-1`);"
language_template[ "fr" ] = "fread(`buffer-1`,`size-1`,`count-1`,`stream-1`);"
language_template[ "fs" ] = "fscanf(`filename-1`,\"`format-string-1`\");"
language_template[ "ft" ] = "ftell(`stream-1`);"
language_template[ "fw" ] = "fwrite(`buffer-1`,`size-1`,`count-1`,`stream-1`);"
language_template[ "gc" ] = "getc(`stream-1`);"
language_template[ "gh" ] = "getchar();"
language_template[ "go" ] = "goto `identifier-1`; " OC " `PLEASE EXPLAIN` " EC
language_template[ "gs" ] = "gets(`buffer-1`);"
language_template[ "gw" ] = "getw(`buffer-1`);"
language_template[ "fu" ] = "function `funct-name-1`( `param-list-1` )\n" NBLOCK
language_template[ "if" ] = "if ( `expr-1` ) \n" BLOCK OC " end if " EC "\n"
language_template[ "el" ] = "else \n" BLOCK OC " end else" EC " \n"
language_template[ "ei" ] = "else " language_template["if"]
language_template[ "ie" ] = language_template["if"] "\n" language_template["el"]
language_template[ "ls" ] = "lseek(@,,SEEK_);"
language_template[ "ma" ] = "malloc(`size-1`);"
language_template[ "op" ] = "open(\"@\",,);"
language_template[ "pc" ] = "putc(`int-1`,`stdout-1`);"
language_template[ "ph" ] = "putchar(`int-1`);"
language_template[ "pr" ] = "printf(\"`format-string-1`\", `var-list-1`);"
language_template[ "ps" ] = "puts(\"`string-1`\");"
language_template[ "pw" ] = "putw(@,);"
language_template[ "re" ] = "read(@,,);"
language_template[ "rn" ] = "rename(\"`old-name-1`\", \"`new-name-1`\");"
language_template[ "rt" ] = "return `expr-1`;"
language_template[ "sc" ] = "scanf(`filename-1`, \"`format-string-1`\", `var-list-1`);"
language_template[ "sp" ] = "sprintf(`var-name-1`, \"`format-string-1`\", `var-list-1`);"
language_template[ "ss" ] = "sscanf(`buffer-1`, \"`format-string-1`\", `var-list-1`);"
language_template[ "st" ] = "static `var-name-1`;"
language_template[ "sw" ] = "switch (`expr-1`) \n" OB "\n\tdefault:\n\t`statement-2`\n" EB2 OC " end switch " EC "\n"
language_template[ "ts" ] = "typedef struct \n" BLOCK " `struct-name-1`;\n"
language_template[ "tu" ] = "typedef union \n" BLOCK " `union-name-1`;\n"
language_template[ "ty" ] = "typedef `name-1`"
language_template[ "un" ] = "unlink(\"`filename-1`\");"
language_template[ "vf" ] = "vfprintf(`file-1`,\"`format-string-1`\",`var-list-1`);"
language_template[ "vp" ] = "vprintf(\"`format-string-1`\",`var-list-1`);"
language_template[ "vs" ] = "vsprintf(`buffer-1`,\"`format-string-1`\",`var-list-1`);"
language_template[ "wh" ] = "while (`condition-1`) \n" BLOCK OC " end while " EC "\n"
language_template[ "wr" ] = "write(@,,);"
}
#
# Language-specific macros. The following ("__") macros are called in turn
# whenever a file with the corresponding (".") extension is edited and
# electric is enabled.
#
function __c()
{
electric_symbol.open_comment = "/*"
electric_symbol.middle_comment = "**"
electric_symbol.end_comment = "*/"
}
#function __h() # .h same as .c
#{
# __c()
#}
#
#function __cpp() # C++ same as C
#{
# __c()
#}
#
#function __hpp() # C++ same as C
#{
# __c()
#}
#
#function __cxx() # C++ same as C
#{
# __c()
#}
#
#function __hxx() # C++ same as C
#{
# __c()
#}
global function load_factory_c_syntax()
{
local type = "c";
set_factory_categories(type);
add_syntax_item(type, KEYWORD, "void", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "int", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "long", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "short", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "unsigned", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "float", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "double", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "char", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "struct", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "union", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "class", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "const", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "local", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "global", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "far", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "static", CATEGORY_TYPE)
add_syntax_item(type, KEYWORD, "#if", CATEGORY_DIRECTIVE)
add_syntax_item(type, KEYWORD, "#ifdef", CATEGORY_DIRECTIVE)
add_syntax_item(type, KEYWORD, "#ifndef", CATEGORY_DIRECTIVE)
add_syntax_item(type, KEYWORD, "#endif", CATEGORY_DIRECTIVE)
add_syntax_item(type, KEYWORD, "#else", CATEGORY_DIRECTIVE)
add_syntax_item(type, KEYWORD, "#elif", CATEGORY_DIRECTIVE)
add_syntax_item(type, KEYWORD, "#include", CATEGORY_DIRECTIVE)
add_syntax_item(type, KEYWORD, "#define", CATEGORY_DIRECTIVE)
add_syntax_item(type, KEYWORD, "#undef", CATEGORY_DIRECTIVE)
add_syntax_item(type, KEYWORD, "defined", CATEGORY_DIRECTIVE)
add_syntax_item(type, KEYWORD, "while", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "if", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "else", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "for", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "do", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "continue", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "typedef", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "enum", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "virtual", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "private", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "public", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "protected", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "return", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "switch", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "case", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "break", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "new", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "delete", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "default", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "this", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "extern", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "NULL", CATEGORY_CONSTANT)
add_syntax_item(type, KEYWORD, "{", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "}", CATEGORY_RESERVED)
add_syntax_item(type, BLOCK, "/* */", CATEGORY_COMMENT)
add_syntax_item(type, LINE, "//", CATEGORY_COMMENT)
add_syntax_item(type, LINE, "\" \"", 0x010000 + CATEGORY_LITERAL)
set_style_delimiters(type, "()[];:,=");
set_escape_character(type, "\\");
}