Lines Matching refs:a

52     call ErlangIndentLog(a:s)
63 " Calculate the new virtual column after the given segment of a line.
81 let line = a:line[a:first_index : a:last_index]
84 let last_index = a:last_index - a:first_index
85 let vcol = a:vcol
101 let vcol = (vcol / a:tabstop + (next_i - i)) * a:tabstop
130 let linelen = strlen(a:line) " The length of the line
135 if a:string_continuation
136 let i = matchend(a:line, '^\%([^"\\]\|\\.\)*"', 0)
141 let vcol = s:CalcVCol(a:line, 0, i - 1, 0, a:tabstop)
144 elseif a:atom_continuation
145 let i = matchend(a:line, "^\\%([^'\\\\]\\|\\\\.\\)*'", 0)
150 let vcol = s:CalcVCol(a:line, 0, i - 1, 0, a:tabstop)
160 if a:line[i] ==# ' '
161 let next_i = matchend(a:line, ' *', i + 1)
164 elseif a:line[i] ==# "\t"
165 let next_i = matchend(a:line, '\t*', i + 1)
168 let next_vcol = (vcol / a:tabstop + (next_i - i)) * a:tabstop
171 elseif a:line[i] ==# '%'
175 elseif a:line[i] ==# '"'
176 let next_i = matchend(a:line, '\%([^"\\]\|\\.\)*"', i + 1)
180 let next_vcol = s:CalcVCol(a:line, i, next_i - 1, vcol, a:tabstop)
185 elseif a:line[i] ==# "'"
186 let next_i = matchend(a:line, "\\%([^'\\\\]\\|\\\\.\\)*'", i + 1)
190 let next_vcol = s:CalcVCol(a:line, i, next_i - 1, vcol, a:tabstop)
195 elseif a:line[i] =~# '[a-zA-Z_@0-9]'
196 let next_i = matchend(a:line,
199 call add(indtokens, [a:line[(i):(next_i - 1)], vcol, i])
201 " Character token: $<char> (as in: $a)
202 elseif a:line[i] ==# '$'
207 elseif a:line[i] ==# '.'
211 if i + 1 ==# linelen || a:line[i + 1] =~# '[[:blank:]%]'
223 elseif a:line[i] ==# '='
227 call add(indtokens, [a:line[i], vcol, i])
232 \ index(['=:=', '=/='], a:line[i : i + 1]) != -1
233 call add(indtokens, [a:line[i : i + 1], vcol, i])
240 \ a:line[i : i + 1]) != -1
241 call add(indtokens, [a:line[i : i + 1], vcol, i])
246 call add(indtokens, [a:line[i], vcol, i])
268 while i < len(a:indtokens)
269 if a:indtokens[i][2] ==# a:col
271 elseif a:indtokens[i][2] > a:col
272 return [0, s:IndentError('No token at col ' . a:col . ', ' .
273 \'indtokens = ' . string(a:indtokens),
278 return [0, s:IndentError('No token at col ' . a:col . ', ' .
279 \'indtokens = ' . string(a:indtokens),
287 " Push a token onto the parser's stack.
292 call s:Log(' Stack Push: "' . a:token . '" into ' . string(a:stack))
293 call insert(a:stack, a:token)
297 " Pop a token from the parser's stack.
304 let head = remove(a:stack, 0)
305 call s:Log(' Stack Pop: "' . head . '" from ' . string(a:stack))
319 " Clear the Erlang token cache if we have a different file or the file has
347 call s:Log('Tokenizing starts from line ' . a:lnum)
348 if a:direction ==# 'up'
349 let lnum = prevnonblank(a:lnum)
350 else " a:direction ==# 'down'
351 let lnum = nextnonblank(a:lnum)
384 " As a helper function for PrevIndToken and NextIndToken, the FindIndToken
398 let lnum = a:lnum
400 let lnum += (a:dir ==# 'up' ? -1 : 1)
401 let [lnum, indtokens] = s:TokenizeLine(lnum, a:dir)
406 " We found a non-empty line. If we were moving up, we return the last
408 let i = (a:dir ==# 'up' ? len(indtokens) - 1 : 0)
424 call s:Log(' PrevIndToken called: lnum=' . a:lnum . ', i =' . a:i)
426 " If the current line has a previous token, return that
427 if a:i > 0
428 return [s:all_tokens[a:lnum][a:i - 1], a:lnum, a:i - 1]
430 return s:FindIndToken(a:lnum, 'up')
444 call s:Log(' NextIndToken called: lnum=' . a:lnum . ', i =' . a:i)
446 " If the current line has a next token, return that
447 if len(s:all_tokens[a:lnum]) > a:i + 1
448 return [s:all_tokens[a:lnum][a:i + 1], a:lnum, a:i + 1]
450 return s:FindIndToken(a:lnum, 'down')
458 " This function is called when the parser encounters a syntax error.
460 " If we encounter a syntax error, we return
470 call s:Log('Indent error: ' . a:msg . ' -> return')
471 call s:Log(' Token = ' . a:token . ', ' .
472 \' stack = ' . string(a:stack))
489 call s:Log(' Unexpected token ' . a:token . ', stack = ' .
490 \string(a:stack) . ' -> return')
499 " Return whether the given line starts with a string continuation.
506 " "This is a % IsLineStringContinuation = false
511 return synIDattr(synID(a:lnum, 1, 0), 'name') =~# '^erlangString'
529 let syn_name = synIDattr(synID(a:lnum, 1, 0), 'name')
539 " `lnum`) is standalone or part of a try-catch block, based on the preceding
547 call s:Log(' IsCatchStandalone called: lnum=' . a:lnum . ', i=' . a:i)
548 let [prev_indtoken, _, _] = s:PrevIndToken(a:lnum, a:i)
550 " If we hit the beginning of the file, it is not a catch in a try block
559 elseif prev_token =~# '[a-z]'
591 " This function is called when a begin-type element ('begin', 'case',
605 if empty(a:stack)
606 if a:stored_vcol ==# -1
607 call s:Log(' "' . a:token . '" directly precedes LTI -> return')
608 return [1, a:curr_vcol + a:sw]
610 call s:Log(' "' . a:token .
612 return [1, a:stored_vcol]
620 " This function is called when a begin-type element ('begin', 'case', '[',
639 let [ret, res] = s:BeginElementFoundIfEmpty(a:stack, a:token, a:curr_vcol,
640 \a:stored_vcol, a:sw)
643 if a:stack[0] ==# a:end_token
644 call s:Log(' "' . a:token . '" pops "' . a:end_token . '"')
645 call s:Pop(a:stack)
646 if !empty(a:stack) && a:stack[0] ==# 'align_to_begin_element'
647 call s:Pop(a:stack)
648 if empty(a:stack)
649 return [1, a:curr_vcol]
651 return [1, s:UnexpectedToken(a:token, a:stack)]
657 return [1, s:UnexpectedToken(a:token, a:stack)]
662 " This function is called when we hit the beginning of a file or an
680 if !empty(a:stack) && a:stack[0] ==# 'when'
682 call s:Pop(a:stack)
683 if empty(a:stack)
684 call s:Log(' Stack is ["when"], so LTI is in a guard -> return')
685 return [1, a:stored_vcol + shiftwidth() + 2]
687 return [1, s:UnexpectedToken(a:token, a:stack)]
689 elseif !empty(a:stack) && a:stack[0] ==# '->'
691 call s:Pop(a:stack)
692 if empty(a:stack)
694 return [1, a:stored_vcol + shiftwidth()]
695 elseif a:stack[0] ==# ';'
696 call s:Pop(a:stack)
698 if !empty(a:stack)
699 return [1, s:UnexpectedToken(a:token, a:stack)]
702 if a:lnum ==# 0
707 let lnum = a:lnum
708 let i = a:i
711 " Are we after a "-spec func() ...;" clause?
724 call s:Log(' Stack is ["->", ";"], so LTI is in a "-spec" ' .
732 call s:Log(' Stack is ["->", ";"], so LTI is in a function head ' .
734 return [1, a:stored_vcol]
737 return [1, s:UnexpectedToken(a:token, a:stack)]
748 call cursor(a:lnum, a:curr_col + 1)
750 \searchpairpos(a:start, a:middle, a:end, 'bW',
760 \ a:lnum, a:curr_col,
762 \ '\<fun\>\%(\s\|\n\|%.*$\|[A-Z_@][a-zA-Z_@]*\)*(',
781 let res = s:ErlangCalcIndent2(a:lnum, a:stack)
788 let lnum = a:lnum
792 let stack = a:stack
836 if token =~# '[a-zA-Z_@#]' ||
886 " stack = [] => LTI is a condition
887 " stack = ['->'] => LTI is a branch
888 " stack = ['->', ';'] => LTI is a condition
889 " stack = ['when'] => LTI is a guard
891 call s:Log(' LTI is in a condition after ' .
895 call s:Log(' LTI is in a branch after ' .
899 call s:Log(' LTI is in a guard after ' .
908 " stack = [] => LTI is a condition
909 " stack = ['->'] => LTI is a branch
910 " stack = ['->', ';'] => LTI is a condition
911 " stack = ['when'] => LTI is in a guard
924 " a catch/after/end, we didn't modify it.
935 call s:Log(' LTI is in a condition; matching ' .
942 call s:Log(' LTI is in a condition; matching ' .
948 call s:Log(' LTI is in a branch; matching ' .
953 call s:Log(' LTI is in a guard; matching ' .
970 " The "fun" is followed by a variable, so we might have a named fun:
972 " whether this is a function definition ("fun()") or just a function
982 " stack = [] => LTI is a condition
983 " stack = ['->'] => LTI is a branch
984 " stack = ['->', ';'] => LTI is a condition
985 " stack = ['when'] => LTI is in a guard
987 call s:Log(' LTI is in a condition; matching "fun" found')
990 call s:Log(' LTI is in a condition; matching "fun" found')
994 call s:Log(' LTI is in a branch; matching "fun" found')
998 call s:Log(' LTI is in a guard; matching "fun" found')
1007 " Pass: we have a function reference (e.g. "fun f/0")
1039 " We found the opening pair for a closing paren that
1182 " We have to escape '[', because this string will be interpreted as a
1222 " - If the stack top is an '->' or a 'when', then we
1227 " if the stack already has a catch/after/end, we don't
1241 " stack = [';'] -> LTI is either a branch or in a guard
1242 " stack = ['->'] -> LTI is a condition
1243 " stack = ['->', ';'] -> LTI is a branch
1250 " - If the stack top is a 'when', then we should keep
1251 " that, because this signifies that LTI is a in a guard.
1254 " if the stack already has a catch/after/end, we don't
1290 " - If the stack top is an '->' or a 'when', then we
1295 " if the stack already has a catch/after/end, we don't
1319 " if the stack already has a catch/after/end, we don't
1352 endwhile " iteration on tokens in a line
1393 " If the previous line also starts with a comment, then return the same
1395 " don't care that the current line is a comment.
1408 " If the line has a special beginning, but not a standalone catch
1465 echo "Line: " . a:line
1466 let indtokens = s:GetTokensFromLine(a:line, 0, 0, &tabstop)