home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
p2demo21.exe
/
PEL
/
AWK.PEL
< prev
next >
Wrap
Text File
|
1995-01-04
|
8KB
|
188 lines
# $Header: P:\source\wmacros\awk.pev 1.3 04 Jan 1995 16:57:20 PFHJXM0 $
## $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: awk.pel $: Awk specific functions
function setup_awk_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 = "awk"
language_template[ "(" ] = "( `expression-1` )"
language_template[ "/*" ] = "/*\n** `comment-1`\n*/"
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 __pel()
#{
#}
function __awk()
{
electric_symbol.open_comment = "#"
electric_symbol.middle_comment = "#"
electric_symbol.end_comment = "#"
}
global function add_awk_type()
{
add_type("awk", "Thompson Tools Awk Compiler", "awk", "4 7", "1 77",
"{ } [ ] ( )", "\\",
default_buffer_flags, 0, 1, "()[];:,='", 1);
}
global function load_factory_awk_syntax()
{
local type = "awk";
set_factory_categories( type );
add_syntax_item(type, BLOCK, "/* */", CATEGORY_COMMENT);
add_syntax_item(type, LINE, "\" \"", 0x10000 + CATEGORY_LITERAL);
add_syntax_item(type, KEYWORD, "break", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "case", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "continue", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "do", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "else", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "for", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "function", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "goto", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "if", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "return", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "switch", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "typedef", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "while", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "{", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "}", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "static", CATEGORY_TYPE);
set_escape_character(type, "\\")
set_style_delimiters(type, ".();,=:")
set_case_sensitive(type, 0)
}
global function add_pel_type()
{
add_type("pel", "PEL Compiler", "awk", "4 7", "1 77", "{ } [ ] ( )", "\\",
default_buffer_flags, 0, 1, "()[];:,='", 1);
}
global function load_factory_pel_syntax()
{
local type = "pel";
set_factory_categories( type );
add_syntax_item(type, LINE, "\" \"", 0x010000 + CATEGORY_LITERAL);
add_syntax_item(type, LINE, "#", CATEGORY_COMMENT);
add_syntax_item(type, KEYWORD, "break", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "delete", CATEGORY_RESERVED)
add_syntax_item(type, KEYWORD, "do", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "else", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "for", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "function", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "global", CATEGORY_TYPE);
add_syntax_item(type, KEYWORD, "if", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "local", CATEGORY_TYPE);
add_syntax_item(type, KEYWORD, "return", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "while", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "{", CATEGORY_RESERVED);
add_syntax_item(type, KEYWORD, "}", CATEGORY_RESERVED);
set_style_delimiters(type, "()[];:,=");
set_escape_character(type, "\\");
}