Lines Matching refs:token

68 "   vcol: integer -- the virtual column of the first character of the token
122 " indtoken = [token, vcol, col]
123 " token = string (examples: 'begin', '<quoted_atom>', '}')
124 " vcol = integer (the virtual column of the first character of the token;
174 " String token: "..."
184 " Quoted atom token: '...'
194 " Keyword or atom or variable token or number
201 " Character token: $<char> (as in: $a)
206 " Dot token: .
212 " End of clause token: . (as in: f() -> ok.)
217 " - Dot token in float: . (as in: 3.14)
218 " - Dot token in record: . (as in: #myrec.myfield)
272 return [0, s:IndentError('No token at col ' . a:col . ', ' .
278 return [0, s:IndentError('No token at col ' . a:col . ', ' .
287 " Push a token onto the parser's stack.
289 " stack: [token]
290 " token: string
291 function! s:Push(stack, token) argument
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.
299 " stack: [token]
300 " token: string
302 " token: string -- the removed element
312 " The Erlang token cache: an `lnum -> indtokens` dictionary that stores the
319 " Clear the Erlang token cache if we have a different file or the file has
385 " function finds the first line with at least one token in the given
395 " -- the content, lnum and token index of the next (or previous)
407 " token of this line. Otherwise we return the first token if this line.
415 " Find the token that directly precedes the given token.
417 " lnum: integer -- the line of the given token
418 " i: the index of the given token within line `lnum`
420 " result = [] -- the result is an empty list if the given token is the first
421 " token of the file
426 " If the current line has a previous token, return that
435 " Find the token that directly succeeds the given token.
437 " lnum: integer -- the line of the given token
438 " i: the index of the given token within line `lnum`
440 " result = [] -- the result is an empty list if the given token is the last
441 " token of the file
446 " If the current line has a next token, return that
465 " token: string
466 " stack: [token]
469 function! s:IndentError(msg, token, stack) argument
471 call s:Log(' Token = ' . a:token . ', ' .
477 " This function is called when the parser encounters an unexpected token,
480 " If we encounter an unexpected token, we return
484 " token: string
485 " stack: [token]
488 function! s:UnexpectedToken(token, stack) argument
489 call s:Log(' Unexpected token ' . a:token . ', stack = ' .
538 " Return whether the 'catch' token (which should be the `i`th token in line
540 " token.
594 " stack: [token]
595 " token: string
604 function! s:BeginElementFoundIfEmpty(stack, token, curr_vcol, stored_vcol, sw) argument
607 call s:Log(' "' . a:token . '" directly precedes LTI -> return')
610 call s:Log(' "' . a:token .
611 \'" token (whose expression includes LTI) found -> return')
624 " stack: [token]
625 " token: string
628 " end_token: end token that belongs to the begin element found (e.g. if the
629 " begin element is 'begin', the end token is 'end')
636 function! s:BeginElementFound(stack, token, curr_vcol, stored_vcol, end_token, sw) argument
639 let [ret, res] = s:BeginElementFoundIfEmpty(a:stack, a:token, a:curr_vcol,
644 call s:Log(' "' . a:token . '" pops "' . a:end_token . '"')
651 return [1, s:UnexpectedToken(a:token, a:stack)]
657 return [1, s:UnexpectedToken(a:token, a:stack)]
663 " end-of-clause token -- i.e. when we found the beginning of the current
669 " stack: [token]
670 " token: string
674 " i: the index of the "end of clause" token within its own line
679 function! s:BeginningOfClauseFound(stack, token, stored_vcol, lnum, i) argument
687 return [1, s:UnexpectedToken(a:token, a:stack)]
699 return [1, s:UnexpectedToken(a:token, a:stack)]
737 return [1, s:UnexpectedToken(a:token, a:stack)]
775 " stack: [token] -- initial stack
789 let stored_vcol = -1 " Virtual column of the first character of the token that
815 let [token, curr_vcol, curr_col] = indtokens[i]
816 call s:Log(' Analyzing the following token: ' . string(indtokens[i]))
819 return s:IndentError('Stack too long', token, stack)
822 if token ==# '<end_of_clause>'
823 let [ret, res] = s:BeginningOfClauseFound(stack, token, stored_vcol,
836 if token =~# '[a-zA-Z_@#]' ||
837 \ token ==# '<string>' || token ==# '<string_start>' ||
838 \ token ==# '<quoted_atom>' || token ==# '<quoted_atom_start>'
839 call s:Log(' previous token found: curr_vcol + plus = ' .
844 elseif token ==# 'begin'
845 let [ret, res] = s:BeginElementFound(stack, token, curr_vcol,
860 elseif (index(['of', 'receive', 'after', 'if'], token) != -1 ||
861 \ (token ==# 'catch' && !s:IsCatchStandalone(lnum, i))) &&
903 return s:UnexpectedToken(token, stack)
906 elseif index(['case', 'if', 'try', 'receive'], token) != -1
914 elseif (token ==# 'case' && stack[0] ==# 'of') ||
915 \ (token ==# 'if') ||
916 \ (token ==# 'try' && (stack[0] ==# 'of' ||
919 \ (token ==# 'receive')
927 " there is at most one of/catch/after/end token in the
929 if token ==# 'case' || token ==# 'try' ||
930 \ (token ==# 'receive' && stack[0] ==# 'after')
961 let [ret, res] = s:BeginElementFound(stack, token, curr_vcol,
965 elseif token ==# 'fun'
971 " "fun Fun() -> ok end". Thus we take the next token to decide
1003 let [ret, res] = s:BeginElementFound(stack, token, curr_vcol,
1010 elseif token ==# '['
1012 let [ret, res] = s:BeginElementFound(stack, token, curr_vcol,
1016 elseif token ==# '<<'
1018 let [ret, res] = s:BeginElementFound(stack, token, curr_vcol,
1022 elseif token ==# '(' || token ==# '{'
1024 let end_token = (token ==# '(' ? ')' :
1025 \token ==# '{' ? '}' : 'error')
1031 call s:Log(' "' . token . '" pops "' . end_token . '"')
1044 return s:UnexpectedToken(token, stack)
1072 call s:Log(' "' . token .
1073 \'" token found at end of line -> find previous token')
1095 call s:Log(' "' . token . '" token (whose closing token ' .
1116 call s:Log(' "' . token .
1117 \'" token (which directly precedes LTI) found -> return')
1138 call s:Log(' "' . token .
1139 \'" token (whose block contains LTI) found -> return')
1144 elseif index(['end', ')', ']', '}', '>>'], token) != -1
1148 " just push the token onto the stack and keep parsing.
1152 call s:Push(stack, token)
1155 elseif token ==# '>>'
1156 call s:Push(stack, token)
1158 elseif token ==# 'end'
1162 return s:IndentError('Matching token for "end" not found',
1163 \token, stack)
1173 let [token, curr_vcol, curr_col] = indtokens[i]
1178 else " token is one of the following: ')', ']', '}'
1180 call s:Push(stack, token)
1184 let open_paren = (token ==# ')' ? '(' :
1185 \token ==# ']' ? '\[' :
1189 \open_paren, '', token)
1192 return s:IndentError('Matching token not found',
1193 \token, stack)
1203 let [token, curr_vcol, curr_col] = indtokens[i]
1212 elseif token ==# ';'
1229 " there will be at most one of/catch/after/end token in
1232 return s:UnexpectedToken(token, stack)
1235 elseif token ==# '->'
1256 " there will be at most one of/catch/after/end token in
1259 return s:UnexpectedToken(token, stack)
1262 elseif token ==# 'when'
1277 let [ret, res] = s:BeginElementFoundIfEmpty(stack, token, curr_vcol,
1284 call s:Push(stack, token)
1297 " there will be at most one of/catch/after/end token in
1300 return s:UnexpectedToken(token, stack)
1303 elseif token ==# 'of' || token ==# 'after' ||
1304 \ (token ==# 'catch' && !s:IsCatchStandalone(lnum, i))
1306 if token ==# 'after'
1309 let [ret, res] = s:BeginElementFoundIfEmpty(stack, token, curr_vcol,
1315 call s:Push(stack, token)
1321 " there will be at most one of/catch/after/end token in
1324 return s:UnexpectedToken(token, stack)
1327 elseif token ==# '||' && empty(stack) && !last_token_of_line
1333 call s:Log(' Misc token, stack unchanged = ' . string(stack))
1340 call s:Log(' Misc token when the stack is empty or has "->" ' .
1420 return s:IndentError('Matching token for "end" not found',
1429 let [token, curr_vcol, curr_col] = indtokens[i]