GithubHelp home page GithubHelp logo

Comments (3)

tyru avatar tyru commented on July 23, 2024

sorry, I translated Japanese to English (I forgot about this repository's rule)

from vim-vimlparser.

mattn avatar mattn commented on July 23, 2024

StringReader.buf should have buffer which have same length of the source. So leading \ should be contained in AST. However, we doesn't have the token for the \. ex: s:TOKEN_JOINBACKSLASH ? i.e. this will be breaking compatibility.
I have an idea to avoid breaking compatibility. But workaround.

diff --git a/autoload/vimlparser.vim b/autoload/vimlparser.vim
index 431f340..1dc02a9 100644
--- a/autoload/vimlparser.vim
+++ b/autoload/vimlparser.vim
@@ -234,6 +234,10 @@ function! s:iswordc1(c)
   return a:c =~# '^[A-Za-z_]$'
 endfunction
 
+function! s:iswhite(c)
+  return a:c =~# '^[ \t]$' || a:c == ''
+endfunction
+
 function! s:iswhite(c)
   return a:c =~# '^[ \t]$'
 endfunction
@@ -1071,6 +1075,8 @@ function! s:VimLParser.parse_trail()
   elseif c ==# '"'
     call self.parse_comment()
     call self.reader.get()
+  elseif c ==# ''
+    call self.reader.get()
   else
     throw s:Err(printf('E488: Trailing characters: %s', c), self.reader.getpos())
   endif
@@ -3780,10 +3786,11 @@ function! s:StringReader.__init__(lines)
           if c == '\'
             let skip = s:FALSE
           endif
+          call add(self.buf, '')
         else
           call add(self.buf, c)
-          call add(self.pos, [lnum + 2, col + 1])
         endif
+        call add(self.pos, [lnum + 2, col + 1])
         let col += len(c)
       endfor
       let lnum += 1

This add leading \ into AST as empty character, and skip them while traversing. How about this?

from vim-vimlparser.

mattn avatar mattn commented on July 23, 2024

vim-vimparser parse characters in source. So the offset should be unicode-based index. So you must get the code pointed from pos and endpos like below.

return join(map(split(join(a:src, "\n"), '\zs'), 'v:val[pos.i : endpos.i]'), '')

from vim-vimlparser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.