summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <andreas@andreas-desktop>2009-11-16 08:38:31 +0100
committerAndreas Rumpf <andreas@andreas-desktop>2009-11-16 08:38:31 +0100
commit3710309d39f65718ab5990d53a977acb241432a9 (patch)
tree572893ca9aa111e3356a3892a4ba6729c12c6c65
parent281609c358b139d55461af842ce29f39f01b2441 (diff)
downloadNim-3710309d39f65718ab5990d53a977acb241432a9.tar.gz
nimrod compiles again
-rwxr-xr-xdoc/manual.txt7
-rwxr-xr-xlib/pure/strutils.nim3
-rwxr-xr-xnim/pbraces.pas9
-rwxr-xr-xnim/transf.pas6
-rwxr-xr-xtests/tromans.nim19
5 files changed, 28 insertions, 16 deletions
diff --git a/doc/manual.txt b/doc/manual.txt
index a203b75e0..647ce2774 100755
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -2276,7 +2276,7 @@ top-level symbols that are marked with an asterisk (``*``) are exported.
 
 The algorithm for compiling modules is:
 
-- Compile the whole module as usual, following import statements recursively
+- compile the whole module as usual, following import statements recursively
 - if there is a cycle only import the already parsed symbols (that are
   exported); if an unknown identifier occurs then abort
 
@@ -2408,6 +2408,11 @@ time only. No code will be generated for it. Compile time procs are useful
 as helpers for macros.
 
 
+noReturn pragma
+---------------
+The `noreturn`:idx: pragma is used to mark a proc that it never returns. 
+
+
 error pragma
 ------------
 The `error`:idx: pragma is used to make the compiler output an error message
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim
index d17c48740..a07b8a9f7 100755
--- a/lib/pure/strutils.nim
+++ b/lib/pure/strutils.nim
@@ -9,7 +9,6 @@
 
 ## This module contains various string utility routines.
 ## See the module `regexprs` for regular expression support.
-## All the routines here are avaiable for the EMCAScript target too!
 
 {.deadCodeElim: on.}
 
@@ -27,7 +26,7 @@ template newException(exceptn, message: expr): expr =
 
 
 type
-  TCharSet* = set[char] # for compability with Nim
+  TCharSet* = set[char] # for compatibility with Nim
 
 const
   Whitespace* = {' ', '\t', '\v', '\r', '\l', '\f'}
diff --git a/nim/pbraces.pas b/nim/pbraces.pas
index 2e10c50f2..d1cb84096 100755
--- a/nim/pbraces.pas
+++ b/nim/pbraces.pas
@@ -1376,9 +1376,9 @@ begin
         // type alias:
         
       end;
-      tkEnum:
-      tkObject:
-      tkTuple:
+      tkEnum: begin end;
+      tkObject: begin end;
+      tkTuple: begin end;
       else break;
     end
   end
@@ -1401,7 +1401,8 @@ begin
     tkTemplate:  result := parseRoutine(p, nkTemplateDef);
     tkConverter: result := parseRoutine(p, nkConverterDef);
     tkType, tkEnum, tkObject, tkTuple:      
-      result := parseTypeAlias(p, nkTypeSection, parseTypeDef);
+      result := nil;
+      //result := parseTypeAlias(p, nkTypeSection, parseTypeDef);
     tkConst:     result := parseConstSection(p);
     tkWhen:      result := parseIfOrWhen(p, nkWhenStmt);
     tkVar:       result := parseSection(p, nkVarSection, parseVariable);
diff --git a/nim/transf.pas b/nim/transf.pas
index 192d76a84..a0f07d51d 100755
--- a/nim/transf.pas
+++ b/nim/transf.pas
@@ -916,6 +916,12 @@ begin
       result := transformAddrDeref(c, n, nkAddr, nkHiddenAddr);
     nkHiddenStdConv, nkHiddenSubConv, nkConv:
       result := transformConv(c, n);
+    nkDiscardStmt: begin
+      for i := 0 to sonsLen(n)-1 do
+        result.sons[i] := transform(c, n.sons[i]);
+      if isConstExpr(result.sons[0]) then
+        result := newNode(nkCommentStmt)
+    end;
     nkCommentStmt, nkTemplateDef: exit;
     nkConstSection: exit; // do not replace ``const c = 3`` with ``const 3 = 3``
     else begin
diff --git a/tests/tromans.nim b/tests/tromans.nim
index 89e3deba8..12deca1ea 100755
--- a/tests/tromans.nim
+++ b/tests/tromans.nim
@@ -1,5 +1,5 @@
 import
-  math, strutils
+  strutils
 
 ## Convert an integer to a Roman numeral
 # See http://en.wikipedia.org/wiki/Roman_numerals for reference
@@ -15,7 +15,7 @@ proc raiseInvalidValue(msg: string) {.noreturn.} =
 # --> No. Why introduce additional state into such a simple and nice
 # interface? State is evil. :D
 
-proc ConvertRomanToDecimal(romanVal: string): int =
+proc RomanToDecimal(romanVal: string): int =
   result = 0
   var prevVal = 0
   for i in countdown(romanVal.len - 1, 0):
@@ -36,7 +36,7 @@ proc ConvertRomanToDecimal(romanVal: string): int =
       dec(result, val)
     prevVal = val
 
-proc ConvertDecimalToRoman(decValParam: int): string =
+proc DecimalToRoman(decValParam: int): string =
   # Apparently numbers cannot be above 4000
   # Well, they can be (using overbar or parenthesis notation)
   # but I see little interest (beside coding challenge) in coding them as
@@ -55,10 +55,11 @@ proc ConvertDecimalToRoman(decValParam: int): string =
       dec(decVal, val)
       result.add(key)
 
-randomize()
-for i in 1 .. 10:
-  var rnd = 1 + random(3990)
-  var roman = ConvertDecimalToRoman(rnd)
-  var decimal = ConvertRomanToDecimal(roman)
-  echo("$# => $# => $#" % [ $rnd, roman, $decimal ])
+for i in 1..100:
+  if RomanToDecimal(DecimalToRoman(i)) != i: quit "BUG"
+
+for i in items([1238, 1777, 3830, 2401, 379, 33, 940, 3973]):
+  if RomanToDecimal(DecimalToRoman(i)) != i: quit "BUG"
+ 
+echo "success" #OUT success
 
a id='n94' href='#n94'>94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

































                                                                             
                                                  


























                                                                            





                                                                       





                                                                              
                                                                         

                               
                                 

           
                                                      


                               
 








                                                                                     
 
                                               
           




                                                                                     

           








                                                                         
aerc-templates(7)

# NAME

aerc-templates - template file specification for *aerc*(1)

# SYNOPSIS

aerc uses the go "text/template" package for the template parsing
which supports basic go lang operations.

# MESSAGE DATA

The following data can be used in templates. Though they are not all
available always.

*Addresses*
	An array of mail.Address. That can be used to add sender or recipient
	names to the template.

	- From: List of senders.
	- To: List of To recipients. Not always Available.
	- Cc: List of Cc recipients. Not always Available.
	- Bcc: List of Cc recipients. Not always Available.
	- OriginalFrom: List of senders of the original message.
	  Available for quoted reply and forward.

	Example:

	Get the name of the first sender.
	```
	{{(index .From 0).Name}}
	```

	Get the email address of the first sender.
	```
	{{(index .From 0).Address}}
	```

*Date and Time*
	The date and time information is always available and can be easily
	formated.

	- Date: Date and Time information when the compose window is opened.
	- OriginalDate: Date and Time when the original message of received.
	  Available for quoted reply and forward.

	The _dateFormat_ function can be used to format the date and time.

	Example:

	Format the date to go's time package format options.
	```
	{{dateFormat .Date "Mon Jan 2 15:04:05 -0700 MST 2006"}}
	```

*Subject*
	The subject of the email is available for quoted reply and forward.

	Example:
	{{.Subject}}

*MIME Type*
	MIME Type is available for quoted reply.

	- OriginalMIMEType: MIME type info of quoted mail part. Usually
	  "text/plain" or "text/html".

*Original Message*
	When using quoted reply or forward, the original message is available.
	It can be used using two functions that are available to templates.

	Example:

	_wrap_ function can be used to wrap the original text to a number
	of characters per line.
	```
	{{wrap 72 .OriginalText}}
	```

	_quote_ function prepends each line with "> ".
	```
	{{quote .OriginalText}}
	```

	_exec_ function execute external command to process message.
	```
	{{exec `/usr/local/share/aerc/filters/html`}}
	```

	All of the above can be chained together if needed, for example.
	```
	{{exec `/usr/local/share/aerc/filters/html` .OriginalText | wrap 72 | quote}}
	```

	Automatic HTML parsing can be achieved.
	```
	{{if eq .OriginalMIMEType "text/html"}}
	{{exec `/usr/local/share/aerc/filters/html` .OriginalText | wrap 72 | quote}}
	{{else}}
	{{wrap 72 .OriginalText | quote}}
	{{end}}
	```

# SEE ALSO

*aerc*(1) *aerc-config*(5)

# AUTHORS

Maintained by Drew DeVault <sir@cmpwn.com>, who is assisted by other open
source contributors. For more information about aerc development, see
https://git.sr.ht/~sircmpwn/aerc.