diff --git a/regexes.txt b/regexes.txt new file mode 100644 index 0000000..4b4a208 --- /dev/null +++ b/regexes.txt @@ -0,0 +1,48 @@ + +/* A */ => // A + + %s/\/\* \(.*\) \*\//\/\/ \1/gc + +A; [// B] => A [// B] + + %s/;[ \t]*\( \\/ .*\)\?$/\1/gc + +type [*]name => name [*]type + + %s/\(\%(\%(const\|unsigned\) \)\?\%(yaml_[a-z_]*_t\|\\|\\|\\)\) \(\**\)\([a-z_]\+\)/\3 \2\1/gc + +if (A) return B => if A { return B } + + %s/if (\(.*\)) return \([^ ]\+\)$/if \1 { return \2 }/gc + +if (A) { => if A { + + %s/if (\(.*\)) {$/if \1 {/gc + +if (A)\n{\n => if A {\n + + %s/\([ \t\/]*\)\(else\|if\)\( \)(\([^{]\+\))\n[ \t\/]*{$/\1\2\3\4 {/gc + +if (A)\nB => if A {\nB\n} + + %s/^\([ \t]*\/\/\)\?\( *\)if (\(.*\))\n\(.*\)/\1\2if \3 {^M\4^M\1\2}/gc + +if (A\nB) { => if A\nB { + + %s/\(if\|for\) (\(\_[^{]\+\)) {/\1 \2 {/gc + +}\nelse\n{ => } else { + + %s/^\([ \t\/]*\)}\([ \t\/\n]*\)\n\1else\(\n\1\| \){/\1} else {/gc + +}\nelse if => } else if + + %s/^\([ \t\/]*\)}\([ \t\/\n]*\)\n\1else if/\1} else if/gc + +//static int\nyaml_*)\n//{ => //func yaml_*) bool { + + %s/^\/\/\(static int\|YAML_DECLARE(int)\)\n\/\/\(yaml_\([^{]\+\n\?\)\+)\)\n\/\/{/\/\/func \2 bool {/gc + +IS_X_AT => is_x + + %s/IS_BLANKZ_AT(parser.buffer, \([0-9]\))/is_blankz(parser.buffer, parser.buffer_pos+\1)/ diff --git a/yaml_h.go b/yaml_h.go index 1e95b96..eb8931c 100644 --- a/yaml_h.go +++ b/yaml_h.go @@ -196,6 +196,10 @@ type yaml_token_t struct { // The token data. + // [Go] These structs should all be flattened onto the outer + // struct, as many of them are naturally shared among the various + // token types. This will reduce the impact of the lack of a union. + // The stream start (for yaml_STREAM_START_TOKEN). stream_start struct { encoding yaml_encoding_t // The stream encoding.