[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-423-gb5e52e0

Xavier Oswald xoswald at debian.org
Thu Aug 20 19:40:41 UTC 2009


The following commit has been merged in the master branch:
commit b5e52e07b59f58dc314f2944d147a2c46cdc857b
Author: Xavier Oswald <xoswald at debian.org>
Date:   Thu Aug 20 21:40:00 2009 +0200

    Update vim coloration and indentation

diff --git a/editor/vim/indent/lisaac.vim b/editor/vim/indent/lisaac.vim
index 4116ef2..c5c46c6 100644
--- a/editor/vim/indent/lisaac.vim
+++ b/editor/vim/indent/lisaac.vim
@@ -1,13 +1,13 @@
 " Vim indent file
 " Language: Lisaac
-" Maintainer: Xavier Oswald <x.oswald at free.fr>
+" Maintainer: Xavier Oswald <xoswald at debian.org>
 " Contributors: Matthieu Herrmann <matthieu.herrmann at laposte.net>
-" $Date: 2007/08/21 21:33:52 
+" $Date: 2009/05/19 21:33:52 
 " $Revision: 1.0 
 " URL: http://isaacproject.u-strasbg.fr/
 
 " TODO:
-"  * test if there is '[' or '{' in comments
+" - Improve string indent and if there are {, ( .... inside
 
 " Only load this indent file when no other was loaded.
 if exists("b:did_indent")
@@ -27,6 +27,7 @@ setlocal tabstop=2     " tab spacing
 setlocal softtabstop=2 " 2 spaces when pressing <tab> unify
 setlocal shiftwidth=2  " unify
 
+
 " Only define the function once.
 if exists("*GetLisaacIndent")
 	finish
@@ -41,34 +42,56 @@ function GetLisaacIndent()
 	let pline = getline(pnum)
 
 	" At the start of the file use zero indent.
-	if lnum == 0
-		return 0 
-	endif
+"	if lnum == 0
+"		return 0 
+"	endif
+	
+	"""""""""""""""""
+	" NO INDENT     "
+	"""""""""""""""""
+
+	" Whole line String 
+  if linec =~ '^.\s*\\.*\\\s*$' || linec =~ '^\s*\\.*\"'
+    return ind
+  endif
+	
+	" && and ||
+  if line =~ '^.*&&\s*$' || line =~ '^.*||\s*$' "|| line =~ '^\s*{.*}.*'
+    return ind
+  endif
+	
 
 	"""""""""""""""""
 	" INDENT PART   "
 	"""""""""""""""""
-	
+
+	if line =~ '^.*($'
+		let ind = ind + &sw
+		return ind
+	endif
+
 	" Add a 'shiftwidth' after lines that start with a Section word
 	if line =~ '^\s*Section'
 		let ind = ind + &sw
 		return ind
 	endif
 
-	" Add a 'shiftwidth' after a "(" and no ")" 
-	if line =~ '^.*(' && line !~ '^.*(.*).*'  
+	" Add a 'shiftwidth' after a "(" and no ")" and not in a string
+	if line =~ '^.*(' && line !~ '^.*(.*).*'  && line !~ '^.*\".*(.*\".*'
 		let ind = ind + &sw
 		return ind
 	endif
 
-	" Add a 'shiftwidth' after a "{" and no "}"
-	if line =~ '^.*{' && line !~ '^.*{.*}.*'  
+	" Add a 'shiftwidth' after a "{" and no "}" and not in a string
+	" .....{ OR ......{ code;
+	" No invariant (contract)
+	if line =~ '^.*{\s*$' || line =~'^.*{.*' && line !~ '^.*\".*{.*\".*' && line !~ '^.*\\.*{.*\".*'	&& line !~ '^.*?\s*{' && line !~ '^\s*{.*}.*'
 		let ind = ind + &sw
 		return ind
 	endif
 	
-	" Add a 'shiftwidth' after a "[" and no "]"
-	if line =~ '^.*\[' && line !~ '^.*\[ .* \].*'  
+	" Add a 'shiftwidth' after a "[" and no "]" and not in a string 
+	if line =~ '^.\s[' && line !~ '^.*\[ .* \].*'
 		let ind = ind + &sw
 		return ind
 	endif
@@ -77,30 +100,45 @@ function GetLisaacIndent()
 	" UNINDENT PART "
 	"""""""""""""""""
 
+	" Unindent end block and end string
+  if linec =~ '^\s*};\s*$'
+		let ind = ind - &sw 
+    return ind
+  endif
+  if linec =~ '^\s*);\s*$' || linec =~ '^\s*).*'
+		let ind = ind - &sw 
+    return ind
+  endif
+
 	" Unindent Sections :
 	if linec =~ '^\s*Section'
 		let ind = ind - &sw
 		return 0
 	endif
 
-	" Unindent for ")"
-	if linec =~ '^.*)' && linec !~ '^.*(.*).*'  
+	" Unindent for ")" and not in a string
+	if linec =~ '^.*)' && linec !~ '^.*(.*).*' && linec !~ '^.*\".*).*\".*'
 		let ind = ind - &sw	
 		return ind
 	endif
-
-	" Unindent for "}"
-	if linec =~ '^.*}' && linec !~ '^.*{.*}.*'  
+	
+	" Unindent for "}" and not in a sting
+	"if linec =~ '^.*}.*' && linec !~ '^.*{.*}.*'  
+	if linec =~ '^.*}.*' && linec !~ '^.*{.*'  && linec !~ '^.*\".*}.*\".*'
 		let ind = ind - &sw
 		return ind
 	endif
-
-	" Unindent for "]"
-	if linec =~ '^.*\]' && linec !~ '^.*\[ .* \] .*'  
+	if linec =~ '^\s*}.*' 
 		let ind = ind - &sw
 		return ind
 	endif
 
+	" Unindent for "]" and not in a string
+	if linec =~ '^\s*]' && linec !~ '^.*\[ .* \] .*' 
+		let ind = ind - &sw
+		return ind
+	endif
+	
 return ind
 
 endfunction	
diff --git a/editor/vim/syntax/lisaac.vim b/editor/vim/syntax/lisaac.vim
index b41ca29..94edaf5 100644
--- a/editor/vim/syntax/lisaac.vim
+++ b/editor/vim/syntax/lisaac.vim
@@ -1,13 +1,10 @@
 " Vim syntax file
 " Language:     Lisaac
-" Maintainer:   Xavier Oswald <x.oswald at free.fr>
+" Maintainer:   Xavier Oswald <xoswald at debian.org>
 " URL:          http://isaacproject.u-strasbg.fr/
-" Last Change:  2007 May 07
+" Last Change:  2008 November 06 
 " Filenames:    *.li
 
-" TODO: - Fix the bug when a String begin by \[a-z]
-"       - Fix the String if there are a \" inside the String
-
 " Quit when a syntax file was already loaded
 if !exists("main_syntax")
   if version < 600
@@ -19,108 +16,100 @@ if !exists("main_syntax")
   let main_syntax='li'
 endif
 
-" don't use standard HiLink, it will not work with included syntax files
-if version < 508
-  command! -nargs=+ HiLink hi link <args>
-else
-  command! -nargs=+ HiLink hi def link <args>
-endif
 
-"+--------------------+
 " keyword definitions
-"+--------------------+
+" ===================
 syn keyword liFunction            while while_do if else when elseif then self by to do or downto if_true if_false shrink
-syn keyword liKey                 Section Header Insert Inherit Public Private Mapping Interrupt Right Left Self Old Expanded Strict
-syn keyword liTODO                TODO FIXME not_yet_implemented die_with_code
-
-"+-------------------+
-" Support for String
-"+-------------------+
-syn match   liStringSpecial       contained "\\[a-z]"
-syn match   liString              "\".*\\" contains=liStringSpecial
-syn match   liString              "\\.*\\" contains=liStringSpecial
-syn match   liString              "\\.*\"" contains=liStringSpecial
-syn match   liString              "\".*\"" contains=liStringSpecial
-
-"+----------+
+syn keyword liKey                 Parallel Section Header Insert Inherit Public Private Mapping Interrupt Right Left Self Old Expanded Strict 
+syn keyword liSpecial             TODO FIXME DEBUG NOTE not_yet_implemented die_with_code BSBS XOXO JBJB
+
+" Support for String and Char
+" ===========================
+syn match   liStringSpecial       "^\s*\\" 
+syn match   liStringSpecial       "\\$" 
+syn match   liStringSpecial       "\\." 
+syn region  liString              start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=liStringSpecial
+
 " Operators 
-"+----------+
-syn match   liOperator            "<\|>\|*\|/=\|=\|&&\||\|!\|?\|-?\|+?"
+" =========
+syn match   liOperatorAffect      "<-\|:=\|?=\|->"
+syn match   liOperatorCmp         "<\|>\|*\|/=\|=\|&&\||\|!\|?\|-?\|+?"
 syn match   liOperator            "+\|-\|*\|/"
 
-"+-------------------+
-" Quoted expressions
-"+-------------------+
+" Quoted expression
+" =================
 syn match   liExternalExpr        "`[^`\n]*`"
-syn match   liQuotedExpr          "'[^'\n]*'"
+syn region  liQuotedExpr          start=+'+  skip=+\\\\\|\\'+  end=+'+  contains=liStringSpecial
 
-"+---------+
-" Others ;) 
-"+---------+
+" Others 
+" ======
 syn match   liPrototype           "[A-Z][A-Z0-9_]*"
 syn match   liKey                 "Result\(_[0-9]*\)\="
 syn match   liSlot                "^\(\s\|\t\|[(]\)*\(+\|-\)\D"
 syn match   liBlock               "{\|}"
 syn match   liElement             "\(\[\|\]\)"
-syn match   liAssignment          "<-\|:=\|?=\|->"
 syn match   liSymbolDeclaration   "(\|)"
 syn match   liContrat             "^\(\s\|\t\)*\[\(\s\|\t\)*\(\.\.\.\)\=\|\]"
 syn match   liFunction            "\.\w*"
+syn keyword liBoolean             TRUE FALSE BOOLEAN
 
-"+-----------------------------------------------------------------+
 " Support for decimal, real, binary, Hexadecimal and octal numbers
-"+-----------------------------------------------------------------+
+" ================================================================
 " hexa
-syn match   liNumber "\<\(\d\|[ABCDEF]\)\(_\|\d\|[ABCDEF]\)*[hH]\=\>"
+syn match   liNumberHexa    "\<\(\d\|[ABCDEF]\)\(_\|\d\|[ABCDEF]\)*[hH]\=\>"
 
 " binary
-syn match   liNumber "\<[01]\(\(_\|[01]*\)[01]\)*[bB]\=\>"
+syn match   liNumberBinary  "\<[01]\(\(_\|[01]*\)[01]\)*[bB]\=\>"
 
 " decimal, binary, octal
-syn match   liNumber "\<\d\(\(_\|\d*\)\d\)*[dDbBoO]\=\>"
+syn match   liNumberDecimal "\<\d\(\(_\|\d*\)\d\)*[dDbBoO]\=\>"
 
 " real 
-syn match   liNumber "\<\d\(\(_\|\d*\)\d\)*\.\d*\(E-\=\)\=\(\(_\|\d*\)\d\)*[fF]\=\>"
-"syn match   liNumber "-\=\<\(_\|\d\)*\.\(_\|\d\)*\(E-\=\)\=[fF]\=\>"
+syn match   liNumberFloat   "\<\d\(\(_\|\d*\)\d\)*\.\d*\(E-\=\)\=\(\(_\|\d*\)\d\)*[fF]\=\>"
 
-"+---------+
 " Comments 
-"+---------+
-syn region  liLinesComment        start="/\*" end="\*/" contains=liTODO
+" ========
+syn region  liLinesComment        start="/\*" end="\*/" contains=liSpecial
 syn match   liQuotedExprInComment contained "`[^']*'" 
-syn match   liHiddenComment       "//.*" contains=liQuotedExprInComment,liTODO 
+syn match   liHiddenComment       "//.*" contains=liQuotedExprInComment,liSpecial 
 
-"+-------------------------+
-" The default highlighting
-" Coloration
-"+-------------------------+
+" The default highlighting Coloration
+" ===================================
 if version >= 508 || !exists("did_li_syn_inits")
   if version < 508
     let did_li_syn_inits = 1
+    command -nargs=+ HiLink hi link <args>
+  else
+    command -nargs=+ HiLink hi def link <args>
   endif
-  HiLink liLinesComment         Comment
-  HiLink liHiddenComment        Comment
+  HiLink liNumberHexa           Number
+  HiLink liNumberDecimal        Number
+  HiLink liNumberBinary         Number
+  HiLink liNumberFloat          Float
+  HiLink liFunction             Function
+  HiLink liBoolean              Type 
+  HiLink liKey                  Label 
+  HiLink liString               String
+  HiLink liStringSpecial        SpecialChar
+  HiLink liSpecial              Todo
+  HiLink liOperatorAffect       Delimiter 
+  HiLink liOperatorCmp          Delimiter
+  HiLink liOperator             Delimiter
   HiLink liExternalExpr         Define
+  HiLink liQuotedExpr           Special 
   HiLink liPrototype            Type
-  HiLink liKey                  Statement 
   HiLink liSlot                 Keyword 
+  HiLink liBlock                Conditional
+  HiLink liElement              keyword
   HiLink liSymbolDeclaration    Keyword
-  HiLink liBlock                Keyword
   HiLink liContrat              keyword
-  HiLink liElement              keyword
-  HiLink liAssignment           Delimiter
-  HiLink liOperator             Delimiter
-  HiLink liQuotedExprInComment  SpecialChar 
-  HiLink liQuotedExpr           Special 
-  HiLink liStringSpecial        SpecialChar
-  HiLink liString               String
   HiLink liNumber               Number 
-  HiLink liFunction             Function 
-  HiLink liTODO                 Todo
+  HiLink liLinesComment         Comment
+  HiLink liHiddenComment        Comment
+  HiLink liQuotedExprInComment  SpecialChar 
+  delcommand HiLink
 endif
 
-delcommand HiLink
-
 let b:current_syntax = "li"
 
 if main_syntax == 'li'

-- 
Lisaac compiler



More information about the Lisaac-commits mailing list