% Prolog mode with syntax highlighting and indentation. % Put something like this into your .jedrc: % % add_mode_for_extension ("prolog", "pl"); % autoload ("prolog_mode","/home/sax/lib/public_html/download/prolog.sl"); % % If you don't like the ending "pl" because you're also frequently % using the perl mode, replace it with "pro". Then you'll may come % in conflict with the IDL mode instead :-) % % Indentation is based on matching against the end of lines so this is % where you will want your delimiters. % % $Log:$ % % Author: Andre Rognes % % Based on a prolog mode by: Detlef Sax Copyright (c) 1999, Detlef Sax % % Copyright (c) 2003, Andre Rognes % All rights reserved. % % This program is free software; you can redistribute it and/or modify it % under the terms of the GNU General Public License as published by the Free % Software Foundation; either version 2 of the License, or (at your option) % any later version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or % FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for % more details. % % You should have received a copy of the GNU General Public License along % with this program; if not, write to the Free Software Foundation, Inc., 675 % Mass Ave, Cambridge, MA 02139, USA. message ("Reading Prolog Syntax_table"); $1 = "Prolog"; !if (keymap_p ($1)) make_keymap ($1); % definekey ("indent_line", "\t", $1); create_syntax_table ("Prolog"); define_syntax ("%", "", '%', "Prolog"); % comments define_syntax ("/*", "*/", '%', "Prolog"); % comments define_syntax ("([{", ")]}", '(', "Prolog");% delimiters define_syntax ('"', '"', "Prolog"); % Prolog strings define_syntax ('\'', '\'', "Prolog"); % Prolog atoms or 0'x: No! define_syntax ('\\', '\\', "Prolog"); define_syntax ("a-zA-Z0-9_", 'w', "Prolog"); % words define_syntax ("-+0-9", '0', "Prolog"); % Numbers define_syntax (".!", ',', "Prolog"); % W.t.h are punctuations ?: define_syntax (",;:^*/<>=-+@\\", '+', "Prolog"); % operators and keywords1 set_syntax_flags ("Prolog", 0); % ISO And Commonly Used Prolog Predicates % Type 0 keywords () = define_keywords_n ("Prolog","nlop",2,0); () = define_keywords_n ("Prolog","arggetnthputseetabvar",3,0); () = define_keywords_n ("Prolog","atomcallfailhaltnameonceopenreadseensorttelltoldtrue",4,0); () = define_keywords_n ("Prolog","bagofcatchclosefloatsetofthrowwrite",5,0); () = define_keywords_n ("Prolog","appendatomicclauselengthmembernonvarnumberpublicrepeatseeingwriteq",6,0); () = define_keywords_n ("Prolog","abolishassertaassertzconsultdisplaydynamicfindallfunctorincludeintegerlistingretractreversetelling",7,0); () = define_keywords_n ("Prolog","callablecompoundget_byteget_charget_codeput_charput_codesub_atom",8,0); () = define_keywords_n ("Prolog","char_codecopy_termmemberchkmultifilepeek_bytepeek_charpeek_coderead_termset_input",9,0); () = define_keywords_n ("Prolog","atom_charsatom_codescurrent_opset_outputwrite_term",10,0); () = define_keywords_n ("Prolog","atom_concatatom_length",11,0); () = define_keywords_n ("Prolog","flush_outputnumber_charsnumber_codes",12,0); () = define_keywords_n ("Prolog","current_inputdiscontiguousensure_loaded",13,0); () = define_keywords_n ("Prolog","current_outputinitialization",14,0); () = define_keywords_n ("Prolog","char_conversionset_prolog_flagstream_propertywrite_canonical",15,0); () = define_keywords_n ("Prolog","at_end_of_stream",16,0); () = define_keywords_n ("Prolog","current_predicate",17,0); () = define_keywords_n ("Prolog","current_prolog_flagset_stream_position",19,0); () = define_keywords_n ("Prolog","current_char_conversionunify_with_occurs_check",23,0); % ISO Prolog Arithmetic Functions. % Type 1 keywords () = define_keywords_n ("Prolog","is",2,1); () = define_keywords_n ("Prolog","abscosexplogmodremrndsin",3,1); () = define_keywords_n ("Prolog","atansignsqrt",4,1); () = define_keywords_n ("Prolog","floatfloorround",5,1); () = define_keywords_n ("Prolog","ceiling",7,1); () = define_keywords_n ("Prolog","truncate",8,1); () = define_keywords_n ("Prolog","float_integer_part",18,1); () = define_keywords_n ("Prolog","float_fractional_part",21,1); define lp_reset_point () { push_mark (); bskip_white (); if (bolp ()) { skip_white (); pop_mark_0 (); } else pop_mark_1 (); } define lp_column_line_arr(lines) { variable i,str,col; col = 0; foreach (lines) { str = (); str = strcompress(str," \t\f\r\n"); if (str == ".") continue; % the initial . if (string_match(str,"^%",1)) continue; %this line is a comment if (string_match(str,":-$",1)) col += TAB; if (string_match(str,"-->$",1)) col += TAB; %also covers ---> if (string_match(str,"($",1)) col += TAB; if (string_match(str,")$",1)) col -= TAB; if (string_match(str,"{$",1)) col += TAB; if (string_match(str,"}$",1)) col -= TAB; if (string_match(str,"\\\[$",1)) col += TAB; if (string_match(str,"\\\]$",1)) col -= TAB; } return col; } define lp_column() { variable val,str,lines; bol(); push_spot(); push_mark(); if (re_bsearch("\\\.[ \t\f\r]*$") == 0) bob(); str = bufsubstr(); lines = strchop(str,'\n',0); pop_mark_0(); pop_spot(); return lp_column_line_arr(lines); } define lp_indent_line () { variable col; push_spot (); col = lp_column(); bol_skip_white (); bol_trim (); whitespace (col); pop_spot (); lp_reset_point(); } define prolog_mode () { variable mode = "Prolog"; set_mode (mode, 0x4); set_buffer_hook("indent_hook","lp_indent_line"); use_keymap (mode); use_syntax_table (mode); mode_set_mode_info (mode, "fold_info", "%{{{\r%}}}\r\r"); run_mode_hooks("prolog_mode_hook"); }