Created
July 10, 2015 16:01
-
-
Save dgellow/cfaa2106f6ffee46e3a8 to your computer and use it in GitHub Desktop.
Some regexp to find every Nim proc in a file with the given type as first parameter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function nim-procbyfirst { | |
TYPE_FIRST_ARG=$1 | |
FILE=$2 | |
cat "${FILE}" | | |
grep -P "^\s*proc\s*(?:\`.+\`|\w+)\*(\[.+\])?\(\w+:\s${TYPE_FIRST_ARG=}" | | |
grep -oh -P '(?<=proc\s)(?:\`.+\`|\w+).+' | |
} | |
# Exemple (system.nim is a local file): | |
# $ nim-procbyfirst string system.nim | |
# len*(x: string): int {.magic: "LengthStr", noSideEffect.} | |
# compileOption*(option: string): bool {. | |
# copy*(s: string, first = 0): string {. | |
# copy*(s: string, first, last: int): string {. | |
# substr*(s: string, first = 0): string {. | |
# substr*(s: string, first, last: int): string {. | |
# getRefcount*(x: string): int {.importc: "getRefcount", noSideEffect.} | |
# isNil*(x: string): bool {.noSideEffect, magic: "IsNil".} | |
# GC_ref*(x: string) {.magic: "GCref", benign.} | |
# GC_unref*(x: string) {.magic: "GCunref", benign.} | |
# open*(filename: string, | |
# readFile*(filename: string): TaintedString {.tags: [ReadIOEffect], benign.} | |
# quit*(errormsg: string, errorcode = QuitFailure) {.noReturn.} = | |
# `[]`*(s: string, x: Slice[int]): string {.inline.} = | |
# slurp*(filename: string): string {.magic: "Slurp".} | |
# staticRead*(filename: string): string {.magic: "Slurp".} | |
# gorge*(command: string, input = ""): string {. | |
# staticExec*(command: string, input = ""): string {. | |
# raiseAssert*(msg: string) {.noinline.} = | |
# failedAssertImpl*(msg: string) {.raises: [], tags: [].} = | |
# xlen*(x: string): int {.magic: "XLenStr", noSideEffect.} = discard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment