fixed pango/pangoutils new wrappers
This commit is contained in:
parent
eba9af04f7
commit
40ea1d0330
759 changed files with 803 additions and 755 deletions
0
lib/copying.txt
Normal file → Executable file
0
lib/copying.txt
Normal file → Executable file
0
lib/cycle.h
Normal file → Executable file
0
lib/cycle.h
Normal file → Executable file
0
lib/devel/urls.nim
Normal file → Executable file
0
lib/devel/urls.nim
Normal file → Executable file
0
lib/ecmas/dom.nim
Normal file → Executable file
0
lib/ecmas/dom.nim
Normal file → Executable file
0
lib/impure/db_mysql.nim
Normal file → Executable file
0
lib/impure/db_mysql.nim
Normal file → Executable file
0
lib/impure/db_postgres.nim
Normal file → Executable file
0
lib/impure/db_postgres.nim
Normal file → Executable file
0
lib/impure/db_sqlite.nim
Normal file → Executable file
0
lib/impure/db_sqlite.nim
Normal file → Executable file
0
lib/impure/dialogs.nim
Normal file → Executable file
0
lib/impure/dialogs.nim
Normal file → Executable file
0
lib/impure/graphics.nim
Normal file → Executable file
0
lib/impure/graphics.nim
Normal file → Executable file
0
lib/impure/web.nim
Normal file → Executable file
0
lib/impure/web.nim
Normal file → Executable file
0
lib/impure/zipfiles.nim
Normal file → Executable file
0
lib/impure/zipfiles.nim
Normal file → Executable file
0
lib/lgpl.txt
Normal file → Executable file
0
lib/lgpl.txt
Normal file → Executable file
0
lib/newwrap/cairo/cairo.nim
Normal file → Executable file
0
lib/newwrap/cairo/cairo.nim
Normal file → Executable file
0
lib/newwrap/cairo/cairoft.nim
Normal file → Executable file
0
lib/newwrap/cairo/cairoft.nim
Normal file → Executable file
0
lib/newwrap/cairo/cairowin32.nim
Normal file → Executable file
0
lib/newwrap/cairo/cairowin32.nim
Normal file → Executable file
0
lib/newwrap/cairo/cairoxlib.nim
Normal file → Executable file
0
lib/newwrap/cairo/cairoxlib.nim
Normal file → Executable file
0
lib/newwrap/gtk/atk.nim
Normal file → Executable file
0
lib/newwrap/gtk/atk.nim
Normal file → Executable file
0
lib/newwrap/gtk/gdk2.nim
Normal file → Executable file
0
lib/newwrap/gtk/gdk2.nim
Normal file → Executable file
0
lib/newwrap/gtk/gdk2pixbuf.nim
Normal file → Executable file
0
lib/newwrap/gtk/gdk2pixbuf.nim
Normal file → Executable file
0
lib/newwrap/gtk/gdkglext.nim
Normal file → Executable file
0
lib/newwrap/gtk/gdkglext.nim
Normal file → Executable file
0
lib/newwrap/gtk/glib2.nim
Normal file → Executable file
0
lib/newwrap/gtk/glib2.nim
Normal file → Executable file
0
lib/newwrap/gtk/gtk2.nim
Normal file → Executable file
0
lib/newwrap/gtk/gtk2.nim
Normal file → Executable file
0
lib/newwrap/gtk/gtkglext.nim
Normal file → Executable file
0
lib/newwrap/gtk/gtkglext.nim
Normal file → Executable file
0
lib/newwrap/gtk/gtkhtml.nim
Normal file → Executable file
0
lib/newwrap/gtk/gtkhtml.nim
Normal file → Executable file
0
lib/newwrap/gtk/libglade2.nim
Normal file → Executable file
0
lib/newwrap/gtk/libglade2.nim
Normal file → Executable file
1357
lib/newwrap/gtk/pango.nim
Normal file → Executable file
1357
lib/newwrap/gtk/pango.nim
Normal file → Executable file
File diff suppressed because it is too large
Load diff
69
lib/newwrap/gtk/pangoutils.nim
Normal file → Executable file
69
lib/newwrap/gtk/pangoutils.nim
Normal file → Executable file
|
|
@ -2,44 +2,41 @@
|
|||
import
|
||||
glib2, pango
|
||||
|
||||
type
|
||||
pint32* = ptr int32
|
||||
|
||||
proc pango_split_file_list*(str: cstring): PPchar{.cdecl, dynlib: pangolib,
|
||||
proc split_file_list*(str: cstring): PPchar{.cdecl, dynlib: lib,
|
||||
importc: "pango_split_file_list".}
|
||||
proc pango_trim_string*(str: cstring): cstring{.cdecl, dynlib: pangolib,
|
||||
proc trim_string*(str: cstring): cstring{.cdecl, dynlib: lib,
|
||||
importc: "pango_trim_string".}
|
||||
proc pango_read_line*(stream: TFile, str: PGString): gint{.cdecl,
|
||||
dynlib: pangolib, importc: "pango_read_line".}
|
||||
proc pango_skip_space*(pos: PPchar): gboolean{.cdecl, dynlib: pangolib,
|
||||
proc read_line*(stream: TFile, str: PGString): gint{.cdecl, dynlib: lib,
|
||||
importc: "pango_read_line".}
|
||||
proc skip_space*(pos: PPchar): gboolean{.cdecl, dynlib: lib,
|
||||
importc: "pango_skip_space".}
|
||||
proc pango_scan_word*(pos: PPchar, OutStr: PGString): gboolean{.cdecl,
|
||||
dynlib: pangolib, importc: "pango_scan_word".}
|
||||
proc pango_scan_string*(pos: PPchar, OutStr: PGString): gboolean{.cdecl,
|
||||
dynlib: pangolib, importc: "pango_scan_string".}
|
||||
proc pango_scan_int*(pos: PPchar, OutInt: pint32): gboolean{.cdecl,
|
||||
dynlib: pangolib, importc: "pango_scan_int".}
|
||||
proc pango_config_key_get(key: cstring): cstring{.cdecl, dynlib: pangolib,
|
||||
proc scan_word*(pos: PPchar, OutStr: PGString): gboolean{.cdecl, dynlib: lib,
|
||||
importc: "pango_scan_word".}
|
||||
proc scan_string*(pos: PPchar, OutStr: PGString): gboolean{.cdecl, dynlib: lib,
|
||||
importc: "pango_scan_string".}
|
||||
proc scan_int*(pos: PPchar, OutInt: ptr int32): gboolean{.cdecl, dynlib: lib,
|
||||
importc: "pango_scan_int".}
|
||||
proc config_key_get*(key: cstring): cstring{.cdecl, dynlib: lib,
|
||||
importc: "pango_config_key_get".}
|
||||
proc pango_lookup_aliases(fontname: cstring, families: PPPchar,
|
||||
n_families: pint32){.cdecl, dynlib: pangolib,
|
||||
importc: "pango_lookup_aliases".}
|
||||
proc pango_parse_style*(str: cstring, style: PStyle, warn: gboolean): gboolean{.
|
||||
cdecl, dynlib: pangolib, importc: "pango_parse_style".}
|
||||
proc pango_parse_variant*(str: cstring, variant: PVariant, warn: gboolean): gboolean{.
|
||||
cdecl, dynlib: pangolib, importc: "pango_parse_variant".}
|
||||
proc pango_parse_weight*(str: cstring, weight: PWeight, warn: gboolean): gboolean{.
|
||||
cdecl, dynlib: pangolib, importc: "pango_parse_weight".}
|
||||
proc pango_parse_stretch*(str: cstring, stretch: PStretch, warn: gboolean): gboolean{.
|
||||
cdecl, dynlib: pangolib, importc: "pango_parse_stretch".}
|
||||
proc pango_get_sysconf_subdirectory(): cstring{.cdecl, dynlib: pangolib,
|
||||
proc lookup_aliases*(fontname: cstring, families: PPPchar, n_families: ptr int32){.
|
||||
cdecl, dynlib: lib, importc: "pango_lookup_aliases".}
|
||||
proc parse_style*(str: cstring, style: PStyle, warn: gboolean): gboolean{.cdecl,
|
||||
dynlib: lib, importc: "pango_parse_style".}
|
||||
proc parse_variant*(str: cstring, variant: PVariant, warn: gboolean): gboolean{.
|
||||
cdecl, dynlib: lib, importc: "pango_parse_variant".}
|
||||
proc parse_weight*(str: cstring, weight: PWeight, warn: gboolean): gboolean{.
|
||||
cdecl, dynlib: lib, importc: "pango_parse_weight".}
|
||||
proc parse_stretch*(str: cstring, stretch: PStretch, warn: gboolean): gboolean{.
|
||||
cdecl, dynlib: lib, importc: "pango_parse_stretch".}
|
||||
proc get_sysconf_subdirectory*(): cstring{.cdecl, dynlib: lib,
|
||||
importc: "pango_get_sysconf_subdirectory".}
|
||||
proc pango_get_lib_subdirectory(): cstring{.cdecl, dynlib: pangolib,
|
||||
importc: "pango_get_lib_subdirectory".}
|
||||
proc pango_log2vis_get_embedding_levels*(str: Pgunichar, len: int32,
|
||||
pbase_dir: PDirection, embedding_level_list: Pguint8): gboolean{.cdecl,
|
||||
dynlib: pangolib, importc: "pango_log2vis_get_embedding_levels".}
|
||||
proc pango_get_mirror_char*(ch: gunichar, mirrored_ch: Pgunichar): gboolean{.
|
||||
cdecl, dynlib: pangolib, importc: "pango_get_mirror_char".}
|
||||
proc pango_language_get_sample_string*(language: PLanguage): cstring{.cdecl,
|
||||
dynlib: pangolib, importc: "pango_language_get_sample_string".}
|
||||
proc get_lib_subdirectory*(): cstring{.cdecl, dynlib: lib,
|
||||
importc: "pango_get_lib_subdirectory".}
|
||||
proc log2vis_get_embedding_levels*(str: Pgunichar, len: int32,
|
||||
pbase_dir: PDirection,
|
||||
embedding_level_list: Pguint8): gboolean{.
|
||||
cdecl, dynlib: lib, importc: "pango_log2vis_get_embedding_levels".}
|
||||
proc get_mirror_char*(ch: gunichar, mirrored_ch: Pgunichar): gboolean{.cdecl,
|
||||
dynlib: lib, importc: "pango_get_mirror_char".}
|
||||
proc language_get_sample_string*(language: PLanguage): cstring{.cdecl,
|
||||
dynlib: lib, importc: "pango_language_get_sample_string".}
|
||||
|
|
|
|||
0
lib/newwrap/libcurl.nim
Normal file → Executable file
0
lib/newwrap/libcurl.nim
Normal file → Executable file
0
lib/newwrap/lua/lauxlib.nim
Normal file → Executable file
0
lib/newwrap/lua/lauxlib.nim
Normal file → Executable file
0
lib/newwrap/lua/lua.nim
Normal file → Executable file
0
lib/newwrap/lua/lua.nim
Normal file → Executable file
0
lib/newwrap/lua/lualib.nim
Normal file → Executable file
0
lib/newwrap/lua/lualib.nim
Normal file → Executable file
0
lib/newwrap/mysql.nim
Normal file → Executable file
0
lib/newwrap/mysql.nim
Normal file → Executable file
0
lib/newwrap/opengl/gl.nim
Normal file → Executable file
0
lib/newwrap/opengl/gl.nim
Normal file → Executable file
0
lib/newwrap/opengl/glext.nim
Normal file → Executable file
0
lib/newwrap/opengl/glext.nim
Normal file → Executable file
0
lib/newwrap/opengl/glu.nim
Normal file → Executable file
0
lib/newwrap/opengl/glu.nim
Normal file → Executable file
0
lib/newwrap/opengl/glut.nim
Normal file → Executable file
0
lib/newwrap/opengl/glut.nim
Normal file → Executable file
0
lib/newwrap/opengl/glx.nim
Normal file → Executable file
0
lib/newwrap/opengl/glx.nim
Normal file → Executable file
0
lib/newwrap/opengl/wingl.nim
Normal file → Executable file
0
lib/newwrap/opengl/wingl.nim
Normal file → Executable file
0
lib/newwrap/pcre/pcre.nim
Normal file → Executable file
0
lib/newwrap/pcre/pcre.nim
Normal file → Executable file
0
lib/newwrap/postgres.nim
Normal file → Executable file
0
lib/newwrap/postgres.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl_gfx.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl_gfx.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl_image.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl_image.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl_mixer.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl_mixer.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl_mixer_nosmpeg.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl_mixer_nosmpeg.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl_net.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl_net.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl_ttf.nim
Normal file → Executable file
0
lib/newwrap/sdl/sdl_ttf.nim
Normal file → Executable file
0
lib/newwrap/sdl/smpeg.nim
Normal file → Executable file
0
lib/newwrap/sdl/smpeg.nim
Normal file → Executable file
0
lib/newwrap/sqlite3.nim
Normal file → Executable file
0
lib/newwrap/sqlite3.nim
Normal file → Executable file
0
lib/newwrap/tcl.nim
Normal file → Executable file
0
lib/newwrap/tcl.nim
Normal file → Executable file
0
lib/nimbase.h
Normal file → Executable file
0
lib/nimbase.h
Normal file → Executable file
0
lib/posix/posix.nim
Normal file → Executable file
0
lib/posix/posix.nim
Normal file → Executable file
0
lib/pure/browsers.nim
Normal file → Executable file
0
lib/pure/browsers.nim
Normal file → Executable file
0
lib/pure/cgi.nim
Normal file → Executable file
0
lib/pure/cgi.nim
Normal file → Executable file
0
lib/pure/colors.nim
Normal file → Executable file
0
lib/pure/colors.nim
Normal file → Executable file
0
lib/pure/complex.nim
Normal file → Executable file
0
lib/pure/complex.nim
Normal file → Executable file
0
lib/pure/dynlib.nim
Normal file → Executable file
0
lib/pure/dynlib.nim
Normal file → Executable file
0
lib/pure/hashes.nim
Normal file → Executable file
0
lib/pure/hashes.nim
Normal file → Executable file
0
lib/pure/hashtabs.nim
Normal file → Executable file
0
lib/pure/hashtabs.nim
Normal file → Executable file
0
lib/pure/htmlparser.nim
Normal file → Executable file
0
lib/pure/htmlparser.nim
Normal file → Executable file
0
lib/pure/httpclient.nim
Normal file → Executable file
0
lib/pure/httpclient.nim
Normal file → Executable file
0
lib/pure/httpserver.nim
Normal file → Executable file
0
lib/pure/httpserver.nim
Normal file → Executable file
0
lib/pure/lexbase.nim
Normal file → Executable file
0
lib/pure/lexbase.nim
Normal file → Executable file
0
lib/pure/logging.nim
Normal file → Executable file
0
lib/pure/logging.nim
Normal file → Executable file
0
lib/pure/macros.nim
Normal file → Executable file
0
lib/pure/macros.nim
Normal file → Executable file
0
lib/pure/math.nim
Normal file → Executable file
0
lib/pure/math.nim
Normal file → Executable file
0
lib/pure/md5.nim
Normal file → Executable file
0
lib/pure/md5.nim
Normal file → Executable file
0
lib/pure/os.nim
Normal file → Executable file
0
lib/pure/os.nim
Normal file → Executable file
0
lib/pure/osproc.nim
Normal file → Executable file
0
lib/pure/osproc.nim
Normal file → Executable file
0
lib/pure/parsecfg.nim
Normal file → Executable file
0
lib/pure/parsecfg.nim
Normal file → Executable file
0
lib/pure/parsecsv.nim
Normal file → Executable file
0
lib/pure/parsecsv.nim
Normal file → Executable file
0
lib/pure/parseopt.nim
Normal file → Executable file
0
lib/pure/parseopt.nim
Normal file → Executable file
0
lib/pure/parsesql.nim
Normal file → Executable file
0
lib/pure/parsesql.nim
Normal file → Executable file
0
lib/pure/parseurl.nim
Normal file → Executable file
0
lib/pure/parseurl.nim
Normal file → Executable file
0
lib/pure/parseutils.nim
Normal file → Executable file
0
lib/pure/parseutils.nim
Normal file → Executable file
0
lib/pure/parsexml.nim
Normal file → Executable file
0
lib/pure/parsexml.nim
Normal file → Executable file
109
lib/pure/pegs.nim
Normal file → Executable file
109
lib/pure/pegs.nim
Normal file → Executable file
|
|
@ -26,6 +26,8 @@ when useUnicode:
|
|||
|
||||
const
|
||||
InlineThreshold = 5 ## number of leaves; -1 to disable inlining
|
||||
MaxSubpatterns* = 10 ## defines the maximum number of subpatterns that
|
||||
## can be captured. More subpatterns cannot be captured!
|
||||
|
||||
type
|
||||
TPegKind = enum
|
||||
|
|
@ -50,17 +52,20 @@ type
|
|||
pkAndPredicate, ## &a --> Internal DSL: &a
|
||||
pkNotPredicate, ## !a --> Internal DSL: !a
|
||||
pkCapture, ## {a} --> Internal DSL: capture(a)
|
||||
pkBackRef, ## $i --> Internal DSL: backref(i)
|
||||
pkBackRefIgnoreCase,
|
||||
pkBackRefIgnoreStyle,
|
||||
pkSearch, ## @a --> Internal DSL: @a
|
||||
pkRule, ## a <- b
|
||||
pkList ## a, b
|
||||
TNonTerminalFlag = enum
|
||||
ntDeclared, ntUsed
|
||||
TNonTerminal {.final.} = object ## represents a non terminal symbol
|
||||
name: string ## the name of the symbol
|
||||
line: int ## the line the symbol has been declared/used in
|
||||
col: int ## the column the symbol has been declared/used in
|
||||
flags: set[TNonTerminalFlag] ## the nonterminal's flags
|
||||
rule: TNode ## the rule that the symbol refers to
|
||||
name: string ## the name of the symbol
|
||||
line: int ## line the symbol has been declared/used in
|
||||
col: int ## column the symbol has been declared/used in
|
||||
flags: set[TNonTerminalFlag] ## the nonterminal's flags
|
||||
rule: TNode ## the rule that the symbol refers to
|
||||
TNode {.final.} = object
|
||||
case kind: TPegKind
|
||||
of pkEmpty, pkAny, pkAnyRune, pkGreedyAny, pkNewLine: nil
|
||||
|
|
@ -68,6 +73,7 @@ type
|
|||
of pkChar, pkGreedyRepChar: ch: char
|
||||
of pkCharChoice, pkGreedyRepSet: charChoice: ref set[char]
|
||||
of pkNonTerminal: nt: PNonTerminal
|
||||
of pkBackRef..pkBackRefIgnoreStyle: index: range[1..MaxSubpatterns]
|
||||
else: sons: seq[TNode]
|
||||
PNonTerminal* = ref TNonTerminal
|
||||
|
||||
|
|
@ -224,6 +230,24 @@ proc capture*(a: TPeg): TPeg =
|
|||
result.kind = pkCapture
|
||||
result.sons = @[a]
|
||||
|
||||
proc backref*(index: range[1..MaxSubPatterns]): TPeg =
|
||||
## constructs a back reference of the given `index`. `index` starts counting
|
||||
## from 1.
|
||||
result.kind = pkBackRef
|
||||
result.index = index-1
|
||||
|
||||
proc backrefIgnoreCase*(index: range[1..MaxSubPatterns]): TPeg =
|
||||
## constructs a back reference of the given `index`. `index` starts counting
|
||||
## from 1. Ignores case for matching.
|
||||
result.kind = pkBackRefIgnoreCase
|
||||
result.index = index-1
|
||||
|
||||
proc backrefIgnoreStyle*(index: range[1..MaxSubPatterns]): TPeg =
|
||||
## constructs a back reference of the given `index`. `index` starts counting
|
||||
## from 1. Ignores style for matching.
|
||||
result.kind = pkBackRefIgnoreStyle
|
||||
result.index = index-1
|
||||
|
||||
proc spaceCost(n: TPeg): int =
|
||||
case n.kind
|
||||
of pkEmpty: nil
|
||||
|
|
@ -285,10 +309,6 @@ template natural*: expr =
|
|||
## same as ``\d+``
|
||||
+digits
|
||||
|
||||
const
|
||||
MaxSubpatterns* = 10 ## defines the maximum number of subpatterns that
|
||||
## can be captured. More subpatterns cannot be captured!
|
||||
|
||||
# ------------------------- debugging -----------------------------------------
|
||||
|
||||
proc esc(c: char, reserved = {'\0'..'\255'}): string =
|
||||
|
|
@ -394,6 +414,15 @@ proc toStrAux(r: TPeg, res: var string) =
|
|||
add(res, '{')
|
||||
toStrAux(r.sons[0], res)
|
||||
add(res, '}')
|
||||
of pkBackRef:
|
||||
add(res, '$')
|
||||
add(res, $r.index)
|
||||
of pkBackRefIgnoreCase:
|
||||
add(res, "i$")
|
||||
add(res, $r.index)
|
||||
of pkBackRefIgnoreStyle:
|
||||
add(res, "y$")
|
||||
add(res, $r.index)
|
||||
of pkRule:
|
||||
toStrAux(r.sons[0], res)
|
||||
add(res, " <- ")
|
||||
|
|
@ -559,6 +588,18 @@ proc m(s: string, p: TPeg, start: int, c: var TMatchClosure): int =
|
|||
#else: silently ignore the capture
|
||||
else:
|
||||
c.ml = idx
|
||||
of pkBackRef:
|
||||
if p.index >= c.ml: return -1
|
||||
var (a, b) = c.matches[p.index]
|
||||
result = m(s, term(s.copy(a, b)), start, c)
|
||||
of pkBackRefIgnoreCase:
|
||||
if p.index >= c.ml: return -1
|
||||
var (a, b) = c.matches[p.index]
|
||||
result = m(s, termIgnoreCase(s.copy(a, b)), start, c)
|
||||
of pkBackRefIgnoreStyle:
|
||||
if p.index >= c.ml: return -1
|
||||
var (a, b) = c.matches[p.index]
|
||||
result = m(s, termIgnoreStyle(s.copy(a, b)), start, c)
|
||||
of pkRule, pkList: assert false
|
||||
|
||||
proc match*(s: string, pattern: TPeg, matches: var openarray[string],
|
||||
|
|
@ -784,13 +825,15 @@ type
|
|||
tkOption, ## '?'
|
||||
tkAt, ## '@'
|
||||
tkBuiltin, ## \identifier
|
||||
tkEscaped ## \\
|
||||
tkEscaped, ## \\
|
||||
tkDollar ## '$'
|
||||
|
||||
TToken {.final.} = object ## a token
|
||||
kind: TTokKind ## the type of the token
|
||||
modifier: TModifier
|
||||
literal: string ## the parsed (string) literal
|
||||
charset: set[char] ## if kind == tkCharSet
|
||||
index: int ## if kind == tkDollar
|
||||
|
||||
TPegLexer = object ## the lexer object.
|
||||
bufpos: int ## the current position within the buffer
|
||||
|
|
@ -804,7 +847,7 @@ const
|
|||
tokKindToStr: array[TTokKind, string] = [
|
||||
"invalid", "[EOF]", ".", "_", "identifier", "string literal",
|
||||
"character set", "(", ")", "{", "}", "<-", "/", "*", "+", "&", "!", "?",
|
||||
"@", "built-in", "escaped"
|
||||
"@", "built-in", "escaped", "$"
|
||||
]
|
||||
|
||||
proc HandleCR(L: var TPegLexer, pos: int): int =
|
||||
|
|
@ -945,6 +988,19 @@ proc getString(c: var TPegLexer, tok: var TToken) =
|
|||
Inc(pos)
|
||||
c.bufpos = pos
|
||||
|
||||
proc getDollar(c: var TPegLexer, tok: var TToken) =
|
||||
var pos = c.bufPos + 1
|
||||
var buf = c.buf
|
||||
if buf[pos] in {'0'..'9'}:
|
||||
tok.kind = tkDollar
|
||||
tok.index = 0
|
||||
while buf[pos] in {'0'..'9'}:
|
||||
tok.index = tok.index * 10 + ord(buf[pos]) - ord('0')
|
||||
inc(pos)
|
||||
else:
|
||||
tok.kind = tkInvalid
|
||||
c.bufpos = pos
|
||||
|
||||
proc getCharSet(c: var TPegLexer, tok: var TToken) =
|
||||
tok.kind = tkCharSet
|
||||
tok.charset = {}
|
||||
|
|
@ -1050,19 +1106,23 @@ proc getTok(c: var TPegLexer, tok: var TToken) =
|
|||
of '\\':
|
||||
getBuiltin(c, tok)
|
||||
of '\'', '"': getString(c, tok)
|
||||
of '$': getDollar(c, tok)
|
||||
of '\0':
|
||||
tok.kind = tkEof
|
||||
tok.literal = "[EOF]"
|
||||
of 'a'..'z', 'A'..'Z', '\128'..'\255':
|
||||
getSymbol(c, tok)
|
||||
if c.buf[c.bufpos] in {'\'', '"'}:
|
||||
if c.buf[c.bufpos] in {'\'', '"', '$'}:
|
||||
case tok.literal
|
||||
of "i": tok.modifier = modIgnoreCase
|
||||
of "y": tok.modifier = modIgnoreStyle
|
||||
of "v": tok.modifier = modVerbatim
|
||||
else: nil
|
||||
setLen(tok.literal, 0)
|
||||
getString(c, tok)
|
||||
if c.buf[c.bufpos] == '$':
|
||||
getDollar(c, tok)
|
||||
else:
|
||||
getString(c, tok)
|
||||
if tok.modifier == modNone: tok.kind = tkInvalid
|
||||
of '+':
|
||||
tok.kind = tkPlus
|
||||
|
|
@ -1117,8 +1177,7 @@ type
|
|||
tok: TToken
|
||||
nonterms: seq[PNonTerminal]
|
||||
modifier: TModifier
|
||||
|
||||
proc getTok(p: var TPegParser) = getTok(p, p.tok)
|
||||
captures: int
|
||||
|
||||
proc pegError(p: TPegParser, msg: string, line = -1, col = -1) =
|
||||
var e: ref EInvalidPeg
|
||||
|
|
@ -1126,6 +1185,10 @@ proc pegError(p: TPegParser, msg: string, line = -1, col = -1) =
|
|||
e.msg = errorStr(p, msg, line, col)
|
||||
raise e
|
||||
|
||||
proc getTok(p: var TPegParser) =
|
||||
getTok(p, p.tok)
|
||||
if p.tok.kind == tkInvalid: pegError(p, "invalid token")
|
||||
|
||||
proc eat(p: var TPegParser, kind: TTokKind) =
|
||||
if p.tok.kind == kind: getTok(p)
|
||||
else: pegError(p, tokKindToStr[kind] & " expected")
|
||||
|
|
@ -1146,6 +1209,12 @@ proc modifiedTerm(s: string, m: TModifier): TPeg =
|
|||
of modIgnoreCase: result = termIgnoreCase(s)
|
||||
of modIgnoreStyle: result = termIgnoreStyle(s)
|
||||
|
||||
proc modifiedBackref(s: int, m: TModifier): TPeg =
|
||||
case m
|
||||
of modNone, modVerbatim: result = backRef(s)
|
||||
of modIgnoreCase: result = backRefIgnoreCase(s)
|
||||
of modIgnoreStyle: result = backRefIgnoreStyle(s)
|
||||
|
||||
proc primary(p: var TPegParser): TPeg =
|
||||
case p.tok.kind
|
||||
of tkAmp:
|
||||
|
|
@ -1185,6 +1254,7 @@ proc primary(p: var TPegParser): TPeg =
|
|||
getTok(p)
|
||||
result = capture(parseExpr(p))
|
||||
eat(p, tkCurlyRi)
|
||||
inc(p.captures)
|
||||
of tkAny:
|
||||
result = any()
|
||||
getTok(p)
|
||||
|
|
@ -1206,6 +1276,13 @@ proc primary(p: var TPegParser): TPeg =
|
|||
of tkEscaped:
|
||||
result = term(p.tok.literal[0])
|
||||
getTok(p)
|
||||
of tkDollar:
|
||||
var m = p.tok.modifier
|
||||
if m == modNone: m = p.modifier
|
||||
result = modifiedBackRef(p.tok.index, m)
|
||||
if p.tok.index < 0 or p.tok.index > p.captures:
|
||||
pegError(p, "invalid back reference index: " & $p.tok.index)
|
||||
getTok(p)
|
||||
else:
|
||||
pegError(p, "expression expected, but found: " & p.tok.literal)
|
||||
getTok(p) # we must consume a token here to prevent endless loops!
|
||||
|
|
@ -1227,7 +1304,7 @@ proc seqExpr(p: var TPegParser): TPeg =
|
|||
while true:
|
||||
case p.tok.kind
|
||||
of tkAmp, tkNot, tkAt, tkStringLit, tkCharset, tkParLe, tkCurlyLe,
|
||||
tkAny, tkAnyRune, tkBuiltin, tkEscaped:
|
||||
tkAny, tkAnyRune, tkBuiltin, tkEscaped, tkDollar:
|
||||
result = sequence(result, primary(p))
|
||||
of tkIdentifier:
|
||||
if not arrowIsNextTok(p):
|
||||
|
|
|
|||
0
lib/pure/re.nim
Normal file → Executable file
0
lib/pure/re.nim
Normal file → Executable file
0
lib/pure/regexprs.nim
Normal file → Executable file
0
lib/pure/regexprs.nim
Normal file → Executable file
0
lib/pure/ropes.nim
Normal file → Executable file
0
lib/pure/ropes.nim
Normal file → Executable file
0
lib/pure/sockets.nim
Normal file → Executable file
0
lib/pure/sockets.nim
Normal file → Executable file
0
lib/pure/streams.nim
Normal file → Executable file
0
lib/pure/streams.nim
Normal file → Executable file
0
lib/pure/strtabs.nim
Normal file → Executable file
0
lib/pure/strtabs.nim
Normal file → Executable file
0
lib/pure/strutils.nim
Normal file → Executable file
0
lib/pure/strutils.nim
Normal file → Executable file
0
lib/pure/terminal.nim
Normal file → Executable file
0
lib/pure/terminal.nim
Normal file → Executable file
0
lib/pure/times.nim
Normal file → Executable file
0
lib/pure/times.nim
Normal file → Executable file
0
lib/pure/unicode.nim
Normal file → Executable file
0
lib/pure/unicode.nim
Normal file → Executable file
0
lib/pure/unidecode/gen.py
Normal file → Executable file
0
lib/pure/unidecode/gen.py
Normal file → Executable file
0
lib/pure/unidecode/unidecode.dat
Normal file → Executable file
0
lib/pure/unidecode/unidecode.dat
Normal file → Executable file
0
lib/pure/unidecode/unidecode.nim
Normal file → Executable file
0
lib/pure/unidecode/unidecode.nim
Normal file → Executable file
0
lib/pure/variants.nim
Normal file → Executable file
0
lib/pure/variants.nim
Normal file → Executable file
0
lib/pure/xmldom.nim
Normal file → Executable file
0
lib/pure/xmldom.nim
Normal file → Executable file
0
lib/pure/xmldomparser.nim
Normal file → Executable file
0
lib/pure/xmldomparser.nim
Normal file → Executable file
0
lib/pure/xmlgen.nim
Normal file → Executable file
0
lib/pure/xmlgen.nim
Normal file → Executable file
0
lib/pure/xmlparser.nim
Normal file → Executable file
0
lib/pure/xmlparser.nim
Normal file → Executable file
0
lib/pure/xmltree.nim
Normal file → Executable file
0
lib/pure/xmltree.nim
Normal file → Executable file
0
lib/pure/yamllexer.nim
Normal file → Executable file
0
lib/pure/yamllexer.nim
Normal file → Executable file
0
lib/system.nim
Normal file → Executable file
0
lib/system.nim
Normal file → Executable file
0
lib/system/alloc.nim
Normal file → Executable file
0
lib/system/alloc.nim
Normal file → Executable file
0
lib/system/ansi_c.nim
Normal file → Executable file
0
lib/system/ansi_c.nim
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue