Moved the parseAST magics to evals.nim

Added string interpolation helper routines in parserutils

Added a proof-of-concept string interpolation user-land macros (currently, only as a test case):
  the interpolated expression could either be transformed to
  concat("literal string ", $(interpolated), " end") or
  "literal string $1 end" % [$(interpolated)]

Added a very initial definition of Optional[T] generic type

A new overload of ParseIdent was added in hope to get around the fact that the 
old one doesn't work correctly in macros, but the problem persists.
This commit is contained in:
Zahary Karadjov 2011-09-07 22:05:21 +03:00
commit dbcca9b3b9
6 changed files with 216 additions and 40 deletions

View file

@ -710,7 +710,7 @@ proc `&` * (x, y: string): string {.
proc `&` * (x: char, y: string): string {.
magic: "ConStrStr", noSideEffect, merge.}
## is the `concatenation operator`. It concatenates `x` and `y`.
# implementation note: These must all have the same magic value "ConStrStr" so
# that the merge optimization works properly.
@ -895,7 +895,12 @@ type # these work for most platforms:
PFloat64* = ptr Float64 ## an alias for ``ptr float64``
PInt64* = ptr Int64 ## an alias for ``ptr int64``
PInt32* = ptr Int32 ## an alias for ``ptr int32``
type TOptional*[T] = object
case hasValue* : bool
of true: value*: T
of false: nil
proc toFloat*(i: int): float {.
magic: "ToFloat", noSideEffect, importc: "toFloat".}
## converts an integer `i` into a ``float``. If the conversion