Skip to content

Commit

Permalink
changed "scanf" keyword to "skip"
Browse files Browse the repository at this point in the history
  • Loading branch information
dahu committed Jun 23, 2012
1 parent 0e4e953 commit aa417f2
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 33 deletions.
16 changes: 15 additions & 1 deletion autoload/efmc.vim
Expand Up @@ -10,7 +10,7 @@ let s:keywords = {
\ 'message' : '%m', \ 'message' : '%m',
\ 'rest' : '%r', \ 'rest' : '%r',
\ 'pointer' : '%p', \ 'pointer' : '%p',
\ 'scanf' : '%*', \ 'skip' : '%*',
\ 'string' : '%s', \ 'string' : '%s',
\} \}


Expand All @@ -24,3 +24,17 @@ func! efmc#keyword(elems)
return '' return ''
endif endif
endfunc endfunc

func! efmc#regex(elems)
return efmc#efm_escape(join(map(a:elems[1], 'v:val[1]'), ''))
endfunc

func! efmc#skip(elems)
"echom "keyword: " . string(a:elems)
return s:keywords['skip'] . a:elems[2]
endfunc

" stub this for now
func! efmc#efm_escape(string)
return escape(a:string, '\')
endfunc
8 changes: 6 additions & 2 deletions autoload/efmcg.vimpeg
Expand Up @@ -9,11 +9,15 @@


efm ::= efmline+ efm ::= efmline+
efmline ::= efmset | comment efmline ::= efmset | comment
efmset ::= (whitespace* ( keyword | string | regex))+ eol efmset ::= (whitespace* ( skip | keyword | string | regex))+ eol
regex ::= '/' ( '\\\\' | '\\/' | !'/' '.' )* '/' regex ::= '/' ( '\\\\' | '\\/' | !'/' '.' )* '/' -> #regex
string ::= "'" ( "'" "'"+ | !"'" '.' )* "'" string ::= "'" ( "'" "'"+ | !"'" '.' )* "'"
skip ::= 'skip' whitespace* regex -> #skip
keyword ::= '\a\+' -> #keyword keyword ::= '\a\+' -> #keyword
comment ::= '#.*' eol comment ::= '#.*' eol
whitespace ::= ( '\s' | eol ) whitespace ::= ( '\s' | eol )
eol ::= '\n' eol ::= '\n'
eof ::= '\_$' eof ::= '\_$'

; [ [[], '{'], [[...], ' '], [[...], '}'] ]

2 changes: 1 addition & 1 deletion test/simple_test_driver
Expand Up @@ -8,7 +8,7 @@ runtime autoload/efmc.vim
let testname = expand('<sfile>:p:t:r') let testname = expand('<sfile>:p:t:r')
let testexpr = matchstr(testname, '^test_\d\+_\zs[^_]\+') let testexpr = matchstr(testname, '^test_\d\+_\zs[^_]\+')
exe "edit " . testname . '.in' exe "edit " . testname . '.in'
exe "%s/.*/\\=string(g:efmc#parser.GetSym(testexpr).match(submatch(0))['value'])/" exe "%s/.*/\\=g:efmc#parser.GetSym(testexpr).match(submatch(0))['value']/"
exe "write " . testname . ".out" exe "write " . testname . ".out"
quit! quit!
" vim: set ft=vim: " vim: set ft=vim:
1 change: 0 additions & 1 deletion test/test_01_keyword_1.in
Expand Up @@ -7,5 +7,4 @@ number
message message
rest rest
pointer pointer
scanf
string string
6 changes: 0 additions & 6 deletions test/test_01_keyword_1.msgout

This file was deleted.

21 changes: 10 additions & 11 deletions test/test_01_keyword_1.ok
@@ -1,11 +1,10 @@
'%f' %f
'%l' %l
'%c' %c
'%v' %v
'%t' %t
'%n' %n
'%m' %m
'%r' %r
'%p' %p
'%*' %s
'%s'
11 changes: 0 additions & 11 deletions test/test_01_keyword_1.out

This file was deleted.

1 change: 1 addition & 0 deletions test/test_02_skip_1.in
@@ -0,0 +1 @@
skip /[ ]/
1 change: 1 addition & 0 deletions test/test_02_skip_1.ok
@@ -0,0 +1 @@
%*[ ]
1 change: 1 addition & 0 deletions test/test_02_skip_1.vim

0 comments on commit aa417f2

Please sign in to comment.