emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/kotlin-mode 0786e24d70 142/162: Merge pull request #44 fro


From: ELPA Syncer
Subject: [nongnu] elpa/kotlin-mode 0786e24d70 142/162: Merge pull request #44 from taku0/propertise-multiline-strings
Date: Sat, 29 Jan 2022 08:25:31 -0500 (EST)

branch: elpa/kotlin-mode
commit 0786e24d70435f529f13c929d03002e60f7460d6
Merge: 3062e14ac0 0649b358f2
Author: Gregg Hernandez <greggory.hz@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #44 from taku0/propertise-multiline-strings
    
    Propertize multiline strings
---
 .travis.yml               |   2 +-
 doc/string.png            | Bin 0 -> 28427 bytes
 doc/string.svg            | 237 ++++++++++++++++++++++++++++++
 doc/string_properties.png | Bin 0 -> 60042 bytes
 doc/string_properties.svg | 362 ++++++++++++++++++++++++++++++++++++++++++++++
 kotlin-mode-lexer.el      | 362 ++++++++++++++++++++++++++++++++++++++++++++++
 kotlin-mode.el            |  42 ++----
 test/kotlin-mode-test.el  |   4 +-
 8 files changed, 975 insertions(+), 34 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 9702140d8f..0f43318a8e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -21,7 +21,7 @@ env:
   - EVM_EMACS=emacs-git-snapshot-travis
 script:
   - emacs --version
-  - cask exec ert-runner
+  - cask exec ert-runner -L . -L test
 
 notifications:
   email: false
diff --git a/doc/string.png b/doc/string.png
new file mode 100644
index 0000000000..b8bcc77c67
Binary files /dev/null and b/doc/string.png differ
diff --git a/doc/string.svg b/doc/string.svg
new file mode 100644
index 0000000000..d789f0a361
--- /dev/null
+++ b/doc/string.svg
@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="584"
+   height="144"
+   viewBox="0 0 584 144.00001"
+   version="1.1"
+   id="svg8"
+   inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+   sodipodi:docname="string.svg"
+   inkscape:export-xdpi="192"
+   inkscape:export-ydpi="192">
+  <defs
+     id="defs2">
+    <marker
+       inkscape:stockid="Arrow1Mend"
+       orient="auto"
+       refY="0"
+       refX="0"
+       id="marker6705"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         inkscape:connector-curvature="0"
+         id="path6703"
+         d="M 0,0 5,-5 -12.5,0 5,5 Z"
+         
style="fill:#ff8000;fill-opacity:1;fill-rule:evenodd;stroke:#ff8000;stroke-width:1.00000003pt;stroke-opacity:1"
+         transform="matrix(-0.4,0,0,-0.4,-4,0)" />
+    </marker>
+    <marker
+       inkscape:isstock="true"
+       style="overflow:visible"
+       id="marker13385"
+       refX="0"
+       refY="0"
+       orient="auto"
+       inkscape:stockid="Arrow1Mend">
+      <path
+         transform="matrix(-0.4,0,0,-0.4,-4,0)"
+         
style="fill:#ff8000;fill-opacity:1;fill-rule:evenodd;stroke:#ff8000;stroke-width:1.00000003pt;stroke-opacity:1"
+         d="M 0,0 5,-5 -12.5,0 5,5 Z"
+         id="path13383"
+         inkscape:connector-curvature="0" />
+    </marker>
+    <marker
+       inkscape:stockid="Arrow1Mend"
+       orient="auto"
+       refY="0"
+       refX="0"
+       id="marker5763"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         id="path5761"
+         d="M 0,0 5,-5 -12.5,0 5,5 Z"
+         
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
+         transform="matrix(-0.4,0,0,-0.4,-4,0)"
+         inkscape:connector-curvature="0" />
+    </marker>
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="1.6605596"
+     inkscape:cx="275.35731"
+     inkscape:cy="101.86651"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     units="px"
+     inkscape:window-width="2152"
+     inkscape:window-height="1924"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
+     inkscape:window-maximized="0"
+     inkscape:snap-bbox="true"
+     inkscape:bbox-paths="true"
+     inkscape:bbox-nodes="true"
+     inkscape:pagecheckerboard="true">
+    <inkscape:grid
+       type="xygrid"
+       id="grid4485"
+       empspacing="8"
+       empcolor="#0000ff"
+       empopacity="0.1254902"
+       color="#0000ff"
+       opacity="0.0627451" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata5">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="レイヤー 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(0,-978.51965)">
+    <rect
+       
style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
+       id="rect13915"
+       width="584"
+       height="144"
+       x="0"
+       y="978.51965" />
+    <text
+       id="text4606"
+       y="1075.9337"
+       x="19.000004"
+       
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:24px;font-family:'DejaVu
 Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, 
Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#8b2252;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;str
 [...]
+       xml:space="preserve"><tspan
+         
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:24px;font-family:'DejaVu
 Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, 
Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#8b2252;fill-opacity:1"
+         id="tspan4604"
+         y="1075.9337"
+         x="19.000004"
+         sodipodi:role="line">&quot;The quick brown ${<tspan
+   style="fill:#000000"
+   id="tspan4563">fox()</tspan>} jumps over the lazy ${<tspan
+   style="fill:#000000"
+   id="tspan4566">dog()</tspan>}&quot;</tspan></text>
+    <path
+       sodipodi:nodetypes="cccccccc"
+       inkscape:connector-curvature="0"
+       d="m 200,1084.5197 c 0,4.4183 -3.58172,8 -8,8 h -80.00005 c -4.41828,0 
-7.99995,3.5817 -7.99995,8 m -88.00005,-16 c 0,4.4183 3.581754,8 8.000054,8 H 
96 c 4.4182,0 8,3.5817 8,8"
+       
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
+       id="path4633" />
+    <text
+       id="text4637"
+       y="1116.4796"
+       x="70.353432"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="1116.4796"
+         x="70.353432"
+         id="tspan4635"
+         sodipodi:role="line">string chunk</tspan></text>
+    <path
+       id="path4639"
+       
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
+       d="m 248,1056.3897 c 0,-4.4183 -3.58172,-8 -8,-8 h -8.00005 c 
-4.41828,0 -7.99995,-3.5818 -7.99995,-8 m -24.00005,16 c 0,-4.4183 3.58175,-8 
8.00005,-8 h 8 c 4.4182,0 8,-3.5818 8,-8"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cccccccc" />
+    <text
+       xml:space="preserve"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="168.87584"
+       y="1032.2296"
+       id="text4643"><tspan
+         sodipodi:role="line"
+         id="tspan4641"
+         x="168.87584"
+         y="1032.2296">template expression</tspan></text>
+    <path
+       id="path4645"
+       
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
+       d="m 480,1084.5197 c 0,4.4183 -3.58172,8 -8,8 h -96.00005 c -4.41828,0 
-7.99995,3.5817 -7.99995,8 m -120.00005,-16 c 0,4.4183 3.58175,8 8.00005,8 h 
104 c 4.4182,0 8,3.5817 8,8"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cccccccc" />
+    <path
+       sodipodi:nodetypes="cccccccc"
+       inkscape:connector-curvature="0"
+       d="m 528,1056.3897 c 0,-4.4183 -3.58172,-8 -8,-8 h -8.00005 c 
-4.41828,0 -7.99995,-3.5818 -7.99995,-8 m -24,16 c 0,-4.4183 3.58175,-8 
8.00005,-8 h 6.00005 c 4.4182,0 9.9999,-3.5818 9.9999,-8"
+       
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
+       id="path4647" />
+    <path
+       sodipodi:nodetypes="ccccccc"
+       inkscape:connector-curvature="0"
+       d="m 559.99995,1084.5197 c 0,4.4183 -3.58172,8 -8,8 v 0 c -4.41828,0 
-7.99995,3.5817 -7.99995,8 m -14.00005,-16 c 0,4.4183 3.58175,8 8,8 4.41825,0 
6.00005,3.5817 6.00005,8"
+       
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
+       id="path4649" />
+    <text
+       xml:space="preserve"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="335.02167"
+       y="1116.4796"
+       id="text4653"><tspan
+         sodipodi:role="line"
+         id="tspan4651"
+         x="335.02167"
+         y="1116.4796">string chunk</tspan></text>
+    <text
+       id="text4657"
+       y="1114.0197"
+       x="516.02167"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="1114.0197"
+         x="516.02167"
+         id="tspan4655"
+         sodipodi:role="line">string chunk</tspan></text>
+    <text
+       id="text4661"
+       y="1032.2296"
+       x="449.87582"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="1032.2296"
+         x="449.87582"
+         id="tspan4659"
+         sodipodi:role="line">template expression</tspan></text>
+    <path
+       id="path9031"
+       
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
+       d="m 560,1021.3897 c 0,-4.4183 -3.58172,-8 -8,-8 H 295.99995 c 
-4.41828,0 -7.99995,-3.5818 -7.99995,-8 m -272.00005,16 c 0,-4.4183 3.581754,-8 
8.000054,-8 H 280 c 4.4182,0 8,-3.5818 8,-8"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cccccccc" />
+    <text
+       id="text9035"
+       y="997.76978"
+       x="255.49001"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="997.76978"
+         x="255.49001"
+         id="tspan9033"
+         sodipodi:role="line">string template</tspan></text>
+  </g>
+</svg>
diff --git a/doc/string_properties.png b/doc/string_properties.png
new file mode 100644
index 0000000000..c7a83810ed
Binary files /dev/null and b/doc/string_properties.png differ
diff --git a/doc/string_properties.svg b/doc/string_properties.svg
new file mode 100644
index 0000000000..abb0c04053
--- /dev/null
+++ b/doc/string_properties.svg
@@ -0,0 +1,362 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="510"
+   height="270"
+   viewBox="0 0 510 270.00002"
+   version="1.1"
+   id="svg8"
+   inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+   sodipodi:docname="string_properties.svg"
+   inkscape:export-xdpi="192"
+   inkscape:export-ydpi="192">
+  <defs
+     id="defs2">
+    <marker
+       inkscape:stockid="Arrow1Mend"
+       orient="auto"
+       refY="0"
+       refX="0"
+       id="marker5503"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         inkscape:connector-curvature="0"
+         id="path5501"
+         d="M 0,0 5,-5 -12.5,0 5,5 Z"
+         
style="fill:#ff8000;fill-opacity:1;fill-rule:evenodd;stroke:#ff8000;stroke-width:1.00000003pt;stroke-opacity:1"
+         transform="matrix(-0.4,0,0,-0.4,-4,0)" />
+    </marker>
+    <marker
+       inkscape:isstock="true"
+       style="overflow:visible"
+       id="marker5494"
+       refX="0"
+       refY="0"
+       orient="auto"
+       inkscape:stockid="Arrow1Mend">
+      <path
+         transform="matrix(-0.4,0,0,-0.4,-4,0)"
+         
style="fill:#ff8000;fill-opacity:1;fill-rule:evenodd;stroke:#ff8000;stroke-width:1.00000003pt;stroke-opacity:1"
+         d="M 0,0 5,-5 -12.5,0 5,5 Z"
+         id="path5492"
+         inkscape:connector-curvature="0" />
+    </marker>
+    <marker
+       inkscape:isstock="true"
+       style="overflow:visible"
+       id="marker4802"
+       refX="0"
+       refY="0"
+       orient="auto"
+       inkscape:stockid="Arrow1Mend"
+       inkscape:collect="always">
+      <path
+         transform="matrix(-0.4,0,0,-0.4,-4,0)"
+         
style="fill:#ff8000;fill-opacity:1;fill-rule:evenodd;stroke:#ff8000;stroke-width:1.00000003pt;stroke-opacity:1"
+         d="M 0,0 5,-5 -12.5,0 5,5 Z"
+         id="path4800"
+         inkscape:connector-curvature="0" />
+    </marker>
+    <marker
+       inkscape:isstock="true"
+       style="overflow:visible"
+       id="marker11187"
+       refX="0"
+       refY="0"
+       orient="auto"
+       inkscape:stockid="Arrow1Mend">
+      <path
+         transform="matrix(-0.4,0,0,-0.4,-4,0)"
+         
style="fill:#ff8000;fill-opacity:1;fill-rule:evenodd;stroke:#ff8000;stroke-width:1.00000003pt;stroke-opacity:1"
+         d="M 0,0 5,-5 -12.5,0 5,5 Z"
+         id="path11185"
+         inkscape:connector-curvature="0" />
+    </marker>
+    <marker
+       inkscape:stockid="Arrow1Mend"
+       orient="auto"
+       refY="0"
+       refX="0"
+       id="marker5763"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         id="path5761"
+         d="M 0,0 5,-5 -12.5,0 5,5 Z"
+         
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
+         transform="matrix(-0.4,0,0,-0.4,-4,0)"
+         inkscape:connector-curvature="0" />
+    </marker>
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="2"
+     inkscape:cx="221.87375"
+     inkscape:cy="161.89411"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     units="px"
+     inkscape:window-width="2152"
+     inkscape:window-height="1924"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
+     inkscape:window-maximized="0"
+     inkscape:snap-bbox="true"
+     inkscape:bbox-paths="true"
+     inkscape:bbox-nodes="true"
+     inkscape:pagecheckerboard="true"
+     inkscape:snap-global="false"
+     fit-margin-left="0"
+     fit-margin-top="0"
+     fit-margin-right="0"
+     fit-margin-bottom="0">
+    <inkscape:grid
+       type="xygrid"
+       id="grid4485"
+       empspacing="8"
+       empcolor="#0000ff"
+       empopacity="0.1254902"
+       color="#0000ff"
+       opacity="0.0627451"
+       originx="0"
+       originy="-48.5" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata5">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="レイヤー 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(0,-804.01965)">
+    <rect
+       
style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
+       id="rect13915"
+       width="510"
+       height="270"
+       x="0"
+       y="804.01965" />
+    <text
+       xml:space="preserve"
+       
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:24px;font-family:'DejaVu
 Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, 
Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;str
 [...]
+       x="197"
+       y="846.76184"
+       id="text4615"><tspan
+         sodipodi:role="line"
+         x="197"
+         y="846.76184"
+         id="tspan4613"
+         
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:24px;font-family:'DejaVu
 Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, 
Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#8b2252;fill-opacity:1">&quot;&quot;&quot;</tspan><tspan
+         sodipodi:role="line"
+         x="197"
+         y="870.76184"
+         
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:24px;font-family:'DejaVu
 Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, 
Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#8b2252;fill-opacity:1"
+         id="tspan4617">  The quick brown</tspan><tspan
+         sodipodi:role="line"
+         x="197"
+         y="894.76184"
+         
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:24px;font-family:'DejaVu
 Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, 
Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#8b2252;fill-opacity:1"
+         id="tspan4621">  ${</tspan><tspan
+         sodipodi:role="line"
+         x="197"
+         y="918.76184"
+         
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:24px;font-family:'DejaVu
 Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, 
Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1"
+         id="tspan4625">    fox()</tspan><tspan
+         sodipodi:role="line"
+         x="197"
+         y="942.76184"
+         
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:24px;font-family:'DejaVu
 Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, 
Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#8b2252;fill-opacity:1"
+         id="tspan4630">  } </tspan><tspan
+         sodipodi:role="line"
+         x="197"
+         y="966.76184"
+         
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:24px;font-family:'DejaVu
 Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, 
Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#8b2252;fill-opacity:1"
+         id="tspan4636">  jumps over the lazy</tspan><tspan
+         sodipodi:role="line"
+         x="197"
+         y="990.76184"
+         
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:24px;font-family:'DejaVu
 Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, 
Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#8b2252;fill-opacity:1"
+         id="tspan4652">  <tspan
+   style="fill:#a0522d;fill-opacity:1"
+   id="tspan5601">$dog</tspan></tspan><tspan
+         sodipodi:role="line"
+         x="197"
+         y="1014.7618"
+         
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:24px;font-family:'DejaVu
 Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, 
Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#8b2252;fill-opacity:1"
+         id="tspan4654">  &quot;&quot;&quot;</tspan></text>
+    <text
+       xml:space="preserve"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#0080ff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="415.44"
+       y="924.72968"
+       id="text4658"><tspan
+         sodipodi:role="line"
+         id="tspan4656"
+         x="415.44"
+         y="924.72968">syntax-multiline t</tspan></text>
+    <text
+       id="text4662"
+       y="816.01965"
+       x="132.69"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#0080ff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="816.01965"
+         x="132.69"
+         id="tspan4660"
+         sodipodi:role="line">syntax-table (15) (generic string 
delimiters)</tspan></text>
+    <path
+       sodipodi:nodetypes="cc"
+       inkscape:connector-curvature="0"
+       id="path4664"
+       d="m 202,834.51965 v -16"
+       
style="fill:none;fill-rule:evenodd;stroke:#0080ff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
 />
+    <text
+       xml:space="preserve"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#0080ff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="200.85812"
+       y="1034.6997"
+       id="text4668"><tspan
+         sodipodi:role="line"
+         id="tspan4666"
+         x="200.85812"
+         y="1034.6997">syntax-table (15)</tspan></text>
+    <path
+       
style="fill:none;fill-rule:evenodd;stroke:#0080ff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="m 240,1026.5197 v -16.0001"
+       id="path4670"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cc" />
+    <text
+       xml:space="preserve"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#0080ff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="256.85812"
+       y="890.69965"
+       id="text4674"><tspan
+         sodipodi:role="line"
+         id="tspan4672"
+         x="256.85812"
+         y="890.69965">syntax-table (15)</tspan></text>
+    <path
+       
style="fill:none;fill-rule:evenodd;stroke:#0080ff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="m 232,890.51965 h 21"
+       id="path4676"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cc" />
+    <path
+       sodipodi:nodetypes="cc"
+       inkscape:connector-curvature="0"
+       id="path4678"
+       d="m 223,938.51965 h 30.00001"
+       
style="fill:none;fill-rule:evenodd;stroke:#0080ff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
 />
+    <path
+       
style="fill:none;fill-rule:evenodd;stroke:#0080ff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="m 216,984.76965 -20,-3.75"
+       id="path4680"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cc" />
+    <text
+       id="text4686"
+       y="938.69965"
+       x="256.85812"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#0080ff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="938.69965"
+         x="256.85812"
+         id="tspan4684"
+         sodipodi:role="line">syntax-table (15)</tspan></text>
+    <text
+       xml:space="preserve"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:12px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#0080ff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="195.37062"
+       y="982.94965"
+       id="text4690"><tspan
+         sodipodi:role="line"
+         id="tspan4688"
+         x="195.37062"
+         y="982.94965"
+         
style="text-align:end;text-anchor:end">kotlin-property--interpolation</tspan><tspan
+         sodipodi:role="line"
+         x="195.37062"
+         y="994.94965"
+         id="tspan5599"
+         style="text-align:end;text-anchor:end">(matching-data covering the 
identifier)</tspan></text>
+    <path
+       inkscape:connector-curvature="0"
+       id="path5488"
+       d="m 230,899.51965 -8,29"
+       
style="fill:none;fill-rule:evenodd;stroke:#ff8000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker5494)"
 />
+    <path
+       
style="fill:none;fill-rule:evenodd;stroke:#ff8000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker4802)"
+       d="m 220,929.06085 0.22166,-30.0824"
+       id="path5490"
+       inkscape:connector-curvature="0" />
+    <text
+       id="text6016"
+       y="900.01965"
+       x="185.26071"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:12px;font-family:Sans;text-align:end;letter-spacing:0px;word-spacing:0px;text-anchor:end;fill:#0080ff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         
style="line-height:12px;text-align:end;text-anchor:end;fill:#0080ff;fill-opacity:1"
+         y="900.01965"
+         x="185.26071"
+         sodipodi:role="line"
+         id="tspan6012">kotlin-property--matching-bracket</tspan><tspan
+         
style="line-height:12px;text-align:end;text-anchor:end;fill:#0080ff;fill-opacity:1"
+         id="tspan6014"
+         y="912.01965"
+         x="185.26071"
+         sodipodi:role="line">(location of the matching bracket)</tspan></text>
+    <path
+       inkscape:connector-curvature="0"
+       id="path6018"
+       d="m 189.75,894.51965 c 10.07697,-22.41984 32.08788,-21.72824 
40.83579,-8.9948"
+       
style="fill:none;fill-rule:evenodd;stroke:#0080ff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       sodipodi:nodetypes="cc" />
+    <path
+       inkscape:connector-curvature="0"
+       id="path6020"
+       d="m 189,906.51965 27,24"
+       
style="fill:none;fill-rule:evenodd;stroke:#0080ff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       sodipodi:nodetypes="cc" />
+    <path
+       sodipodi:nodetypes="cccccccc"
+       inkscape:connector-curvature="0"
+       d="m 397,834.51965 c 4.41828,0 8,3.58172 8,8 v 72.00005 c 0,4.41828 
3.58173,7.99995 8,7.99995 m -16,87.50005 c 4.41828,0 8,-3.5817 8,-8 v -71.50005 
c 0,-4.4182 3.58173,-8 8,-8"
+       
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#0080ff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
+       id="path6022" />
+    <text
+       id="text6026"
+       y="1059.6997"
+       x="68.690002"
+       
style="font-style:normal;font-weight:normal;font-size:10px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="1059.6997"
+         x="68.690002"
+         id="tspan6024"
+         sodipodi:role="line">Those properties are put by 
syntax-propertize-function (kotlin-mode--syntax-propertize).</tspan></text>
+  </g>
+</svg>
diff --git a/kotlin-mode-lexer.el b/kotlin-mode-lexer.el
new file mode 100644
index 0000000000..2548ff06af
--- /dev/null
+++ b/kotlin-mode-lexer.el
@@ -0,0 +1,362 @@
+;;; kotlin-mode-lexer.el --- Major mode for kotlin, lexer -*- lexical-binding: 
t; -*-
+
+;; Copyright © 2019 taku0
+
+;; Author: taku0 (http://github.com/taku0)
+;; Keywords: languages
+;; Package-Requires: ((emacs "24.3"))
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;  Lexical level routines.
+
+;;; Code:
+
+(require 'rx)
+(require 'cl-lib)
+(require 'eieio)
+
+;; Terminology:
+;;   https://kotlinlang.org/docs/reference/basic-types.html#string-templates
+;;   See also doc/string.png.
+;;
+;;   String template:
+;;     A string containing expressions to be evaluated and inserted into the
+;;     string at run time.
+;;     Example: "1 + 1 = ${1 + 1}" is evaluated to "1 + 1 = 2" at run time.
+;;
+;;   Template expression:
+;;     An expression between ${ and } inside a string.
+;;     Suppose a string "aaa${ foo() }bbb${ bar() }ccc",
+;;     `foo()' and `bar()' are template expressions.
+;;
+;;   String chunk:
+;;     A part of single-line/multiline string delimited with quotation marks
+;;     or template expressions.
+;;     Suppose a string "aaa${ foo() }bbb${ bar() }ccc",
+;;     "aaa${, }bbb${, and }ccc" are string chunks.
+;;
+;;     This is not a official term; used only in kotlin-mode.
+
+;;; Text properties
+
+;; See also doc/string_properties.png.
+;;
+;; Some properties are put by `syntax-propertize-function', that is
+;; `kotlin-mode--syntax-propertize'.
+;;
+;; The beginning of and end of strings, character literals, backquoted
+;; identifiers are marked with text property '(syntax-table (15)),
+;; which indicates generic string delimiters.  Both single-line
+;; strings and multiline strings are marked with it. The brackets
+;; surrounding template expressions are also marked with
+;; '(syntax-table (15)). The property helps font-lock and the
+;; tokenizer to recognize strings.
+;;
+;; The entire string including template expressions, character
+;; literal, backquoted identifiers are marked with text property
+;; '(syntax-multiline t).  The property is used by
+;; `kotlin-mode--syntax-propertize-extend-region' to avoid scanning
+;; from the middle of strings.
+;;
+;; The brackets surrounding template expressions have text property
+;; '(kotlin-property--matching-bracket POS), where POS is the position
+;; of the matching bracket.  Strictly speaking, the POS on the closing
+;; bracket refers to the dollar sign before the opening
+;; parenthesis. The property speeds up the indentation logic.
+
+(defun kotlin-mode--syntax-propertize-extend-region (start end)
+  "Return region to be propertized.
+
+The returned region contains the region (START . END).
+If the region is not modified, return nil.
+Intended for `syntax-propertize-extend-region-functions'."
+  (syntax-propertize-multiline start end))
+
+(defun kotlin-mode--syntax-propertize (start end)
+  "Update text properties for strings.
+
+Mark the beginning of and the end of single-line/multiline
+strings, character literals, backquoted identifiers between the
+position START and END as general string delimiters.
+
+Intended for `syntax-propertize-function'."
+  (remove-text-properties start end
+                          '(syntax-table
+                            nil
+                            syntax-multiline
+                            nil
+                            kotlin-property--matching-bracket
+                            nil
+                            kotlin-property--interpolation
+                            nil))
+  (let* ((chunk (kotlin-mode--chunk-after (syntax-ppss start))))
+    (cond
+     ((kotlin-mode--chunk-multiline-string-p chunk)
+      (kotlin-mode--syntax-propertize-end-of-string end "\"\"\""))
+
+     ((kotlin-mode--chunk-single-line-string-p chunk)
+      (kotlin-mode--syntax-propertize-end-of-string end "\""))
+
+     ((kotlin-mode--chunk-character-literal-p chunk)
+      (kotlin-mode--syntax-propertize-end-of-string end "'"))
+
+     ((kotlin-mode--chunk-backquoted-identifier-p chunk)
+      (kotlin-mode--syntax-propertize-end-of-string end "`"))
+
+     ((kotlin-mode--chunk-comment-p chunk)
+      (goto-char (kotlin-mode--chunk-start chunk))
+      (forward-comment (point-max)))))
+
+  (kotlin-mode--syntax-propertize-scan end 0))
+
+(defun kotlin-mode--syntax-propertize-scan (end nesting-level)
+  "Update text properties for strings.
+
+Mark the beginning of and the end of single-line/multiline
+strings and character literals between the current position and
+END as general string delimiters.
+
+Assuming the cursor is not on strings, character-literal,
+backquoted identifier, nor comments.
+
+If NESTING-LEVEL is non-zero, nesting of brackets are tracked and
+the scan stops where the level becomes zero."
+  (let ((found-matching-bracket nil)
+        (pattern (rx (or "\"\"\"" "\"" "//" "/*" "{" "}" "'" "`"))))
+    (while (and (not found-matching-bracket)
+                (< (point) end)
+                (search-forward-regexp pattern end t))
+      (cond
+       ((member (match-string-no-properties 0) '("\"\"\"" "\"" "'" "`"))
+        (let ((start (match-beginning 0))
+              (quotation (match-string-no-properties 0)))
+          (put-text-property start (1+ start)
+                             'syntax-table
+                             (string-to-syntax "|"))
+          (kotlin-mode--syntax-propertize-end-of-string end quotation)
+          (put-text-property start (point) 'syntax-multiline t)
+
+          (when (equal quotation "`")
+            ;; Backquotes cannot be escaped. So declares the backslashes in
+            ;; the identifier are not a escape-syntax characters.
+            (put-text-property (1+ start) (1- (point))
+                               'syntax-table
+                               (string-to-syntax "|")))))
+
+       ((equal "//" (match-string-no-properties 0))
+        (goto-char (match-beginning 0))
+        (forward-comment (point-max)))
+
+       ((equal "/*" (match-string-no-properties 0))
+        (goto-char (match-beginning 0))
+        (forward-comment (point-max)))
+
+       ((and (equal "{" (match-string-no-properties 0))
+             (/= nesting-level 0))
+        (setq nesting-level (1+ nesting-level)))
+
+       ((and (equal "}" (match-string-no-properties 0))
+             (/= nesting-level 0))
+        (setq nesting-level (1- nesting-level))
+        (when (= nesting-level 0)
+          (setq found-matching-bracket t)))))
+    (unless found-matching-bracket
+      (goto-char end))
+    found-matching-bracket))
+
+(defun kotlin-mode--syntax-propertize-end-of-string (end quotation)
+  "Move point to the end of single-line/multiline string.
+
+Assuming the cursor is on a string, a character literal, or a backquoted
+identifier.
+If the string go beyond END, stop there.
+The string should be terminated with QUOTATION."
+  (if (and (< (point) end)
+           (search-forward-regexp
+            (rx-to-string
+             `(or ,quotation
+                  "${"
+                  (and "$" (or
+                            (and (char alpha "_") (* (char alnum "_")))
+                            (and "`" (+ (not (any "`\n"))) "`")))))
+            end t))
+      (cond
+       ((and (equal quotation (match-string-no-properties 0))
+             (or (equal quotation "`")  ; backquotes cannot be escaped
+                 (not (kotlin-mode--escaped-p (match-beginning 0)))))
+        (put-text-property (1- (point)) (point)
+                           'syntax-table
+                           (string-to-syntax "|")))
+       ((and (equal "${" (match-string-no-properties 0))
+             (member quotation '("\"\"\"" "\""))
+             ;; Dollar signs cannot be escaped, so we don't need to check it.
+             )
+        ;; Found an template expression. Skips the expression.
+        ;; We cannot use `scan-sexps' because multiline strings are not yet
+        ;; propertized.
+        (let ((pos-after-open-bracket (point))
+              (start
+               (save-excursion
+                 (backward-char) ;; {
+                 (backward-char) ;; $
+                 (point))))
+          ;; Declares the open bracket is a generic string delimiter.
+          (put-text-property
+           (1- pos-after-open-bracket) pos-after-open-bracket
+           'syntax-table
+           (string-to-syntax "|"))
+          (when (kotlin-mode--syntax-propertize-scan end 1)
+            ;; Found the matching bracket. Going further.
+            ;; Declares the close bracket is a generic string delimiter.
+            (put-text-property (1- (point)) (point)
+                               'syntax-table
+                               (string-to-syntax "|"))
+            ;; Records the positions.
+            (put-text-property (1- (point)) (point)
+                               'kotlin-property--matching-bracket
+                               start)
+            (put-text-property start pos-after-open-bracket
+                               'kotlin-property--matching-bracket
+                               (1- (point)))
+            (kotlin-mode--syntax-propertize-end-of-string end quotation))))
+       ((match-string-no-properties 0)
+        (put-text-property (match-beginning 0) (1+ (match-beginning 0))
+                           'kotlin-property--interpolation
+                           (match-data))
+        (kotlin-mode--syntax-propertize-end-of-string end quotation))
+       (t
+        (kotlin-mode--syntax-propertize-end-of-string end quotation)))
+    (goto-char end)))
+
+(defun kotlin-mode--escaped-p (position)
+  "Return t if the POSITION in a string is escaped.
+
+A position is escaped if it is proceeded by odd number of backslashes.
+Return nil otherwise."
+  (let ((p position)
+        (backslash-count 0))
+    (while (eq (char-before p) ?\\)
+      (setq backslash-count (1+ backslash-count))
+      (setq p (1- p)))
+    (= (mod backslash-count 2) 1)))
+
+
+;;; Comment or string chunks
+
+(defclass kotlin-mode--chunk ()
+  ((type :initarg :type
+         :type symbol
+         :accessor kotlin-mode--chunk-type
+         :documentation "The type of the chunk.
+
+Valid values:
+- single-line-string
+- multiline-string
+- single-line-comment
+- multiline-comment
+- character-literal
+- backquoted-identifier")
+   (start :initarg :start
+          :type number
+          :accessor kotlin-mode--chunk-start
+          :documentation "The start position of the chunk."))
+  "String-chunks, comments, character literals, or backquoted identifiers.
+
+It have the type and the start position.")
+
+(defun kotlin-mode--chunk-comment-p (chunk)
+  "Return non-nil if the CHUNK is a comment."
+  (and chunk
+       (memq (kotlin-mode--chunk-type chunk)
+             '(single-line-comment multiline-comment))))
+
+(defun kotlin-mode--chunk-string-p (chunk)
+  "Return non-nil if the CHUNK is a string."
+  (and chunk
+       (memq (kotlin-mode--chunk-type chunk)
+             '(single-line-string multiline-string))))
+
+(defun kotlin-mode--chunk-single-line-comment-p (chunk)
+  "Return non-nil if the CHUNK is a single-line comment."
+  (and chunk (eq (kotlin-mode--chunk-type chunk) 'single-line-comment)))
+
+(defun kotlin-mode--chunk-multiline-comment-p (chunk)
+  "Return non-nil if the CHUNK is a multiline comment."
+  (and chunk (eq (kotlin-mode--chunk-type chunk) 'multiline-comment)))
+
+(defun kotlin-mode--chunk-single-line-string-p (chunk)
+  "Return non-nil if the CHUNK is a single-line string."
+  (and chunk (eq (kotlin-mode--chunk-type chunk) 'single-line-string)))
+
+(defun kotlin-mode--chunk-multiline-string-p (chunk)
+  "Return non-nil if the CHUNK is a multiline string."
+  (and chunk (eq (kotlin-mode--chunk-type chunk) 'multiline-string)))
+
+(defun kotlin-mode--chunk-character-literal-p (chunk)
+  "Return non-nil if the CHUNK is a character literal."
+  (and chunk (eq (kotlin-mode--chunk-type chunk) 'character-literal)))
+
+(defun kotlin-mode--chunk-backquoted-identifier-p (chunk)
+  "Return non-nil if the CHUNK is a backquoted identifier."
+  (and chunk (eq (kotlin-mode--chunk-type chunk) 'backquoted-identifier)))
+
+(defun kotlin-mode--chunk-after (&optional parser-state)
+  "Return the chunk at the cursor.
+
+If the cursor is outside of strings and comments, return nil.
+
+If PARSER-STATE is given, it is used instead of (syntax-ppss)."
+  (save-excursion
+    (when (number-or-marker-p parser-state)
+      (goto-char parser-state))
+    (when (or (null parser-state) (number-or-marker-p parser-state))
+      (setq parser-state (save-excursion (syntax-ppss parser-state))))
+    (cond
+     ((nth 3 parser-state)
+      ;; Syntax category "|" is attached to both single-line and multiline
+      ;; string delimiters.  So (nth 3 parser-state) may be t even for
+      ;; single-line string delimiters.
+      (if (save-excursion (goto-char (nth 8 parser-state))
+                          (looking-at "\"\"\""))
+          (make-instance 'kotlin-mode--chunk
+                         :type 'multiline-string
+                         :start (nth 8 parser-state))
+        (make-instance 'kotlin-mode--chunk
+                       :type 'single-line-string
+                       :start (nth 8 parser-state))))
+     ((eq (nth 4 parser-state) t)
+      (make-instance 'kotlin-mode--chunk
+                     :type 'single-line-comment
+                     :start (nth 8 parser-state)))
+     ((nth 4 parser-state)
+      (make-instance 'kotlin-mode--chunk
+                     :type 'multiline-comment
+                     :start (nth 8 parser-state)))
+     ((and (eq (char-before) ?/) (eq (char-after) ?/))
+      (make-instance 'kotlin-mode--chunk
+                     :type 'single-line-comment
+                     :start (1- (point))))
+     ((and (eq (char-before) ?/) (eq (char-after) ?*))
+      (make-instance 'kotlin-mode--chunk
+                     :type 'multiline-comment
+                     :start (1- (point))))
+     (t
+      nil))))
+
+(provide 'kotlin-mode-lexer)
+
+;;; kotlin-mode-lexer.el ends here
diff --git a/kotlin-mode.el b/kotlin-mode.el
index 320fff191c..00ef157363 100644
--- a/kotlin-mode.el
+++ b/kotlin-mode.el
@@ -31,6 +31,8 @@
 (require 'cl)
 (require 'eieio)
 
+(require 'kotlin-mode-lexer)
+
 (defgroup kotlin nil
   "A Kotlin major mode."
   :group 'languages)
@@ -308,36 +310,12 @@
     (kotlin-mode--match-interpolation 0 font-lock-variable-name-face t))
   "Default highlighting expression for `kotlin-mode'")
 
-(defun kotlin-mode--syntax-propertize-interpolation ()
-  (let* ((pos (match-beginning 0))
-         (context (save-excursion
-                    (save-match-data (syntax-ppss pos)))))
-    (when (nth 3 context)
-      (put-text-property pos
-                         (1+ pos)
-                         'kotlin-property--interpolation
-                         (match-data)))))
-
-(defun kotlin-mode--syntax-propertize-function (start end)
-  (let ((case-fold-search))
-    (goto-char start)
-    (remove-text-properties start end '(kotlin-property--interpolation))
-    (funcall
-     (syntax-propertize-rules
-      ((let ((identifier '(or
-                           (and alpha (* alnum))
-                           (and "`" (+ (not (any "`\n"))) "`"))))
-         (rx-to-string
-          `(or (group "${" ,identifier "}")
-               (group "$" ,identifier))))
-       (0 (ignore (kotlin-mode--syntax-propertize-interpolation)))))
-     start end)))
-
 (defun kotlin-mode--match-interpolation (limit)
-  (let ((pos (next-single-char-property-change (point)
-                                               'kotlin-property--interpolation
-                                               nil
-                                               limit)))
+  (let ((pos (next-single-char-property-change
+              (point)
+              'kotlin-property--interpolation
+              nil
+              limit)))
     (when (and pos (> pos (point)))
       (goto-char pos)
       (let ((value (get-text-property pos 'kotlin-property--interpolation)))
@@ -540,7 +518,11 @@
   "Major mode for editing Kotlin."
 
   (setq font-lock-defaults '((kotlin-mode--font-lock-keywords) nil nil))
-  (setq-local syntax-propertize-function 
#'kotlin-mode--syntax-propertize-function)
+  (setq-local parse-sexp-lookup-properties t)
+  (add-hook 'syntax-propertize-extend-region-functions
+            #'kotlin-mode--syntax-propertize-extend-region
+            nil t)
+  (setq-local syntax-propertize-function #'kotlin-mode--syntax-propertize)
   (set (make-local-variable 'comment-start) "//")
   (set (make-local-variable 'comment-padding) 1)
   (set (make-local-variable 'comment-start-skip) "\\(//+\\|/\\*+\\)\\s *")
diff --git a/test/kotlin-mode-test.el b/test/kotlin-mode-test.el
index 5329d00afa..0dd7e27748 100644
--- a/test/kotlin-mode-test.el
+++ b/test/kotlin-mode-test.el
@@ -2,9 +2,7 @@
 (setq-default indent-tabs-mode nil)
 (setq-default tab-width 4)
 
-(load-file "kotlin-mode.el")
-
-;(require 'kotlin-mode)
+(require 'kotlin-mode)
 
 (ert-deftest kotlin-mode--top-level-indent-test ()
   (with-temp-buffer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]