Skip to content

Commit

Permalink
added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tarptaeya committed Jul 11, 2019
1 parent 6cf703b commit 7b56e49
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions examples/comment.truck
@@ -0,0 +1,7 @@
/* this is a comment */

/*
* but comments cannot be nested
*/

println(/* value 1 */ 10 + /* value 2 */ 20)
8 changes: 8 additions & 0 deletions truck/lexer.py
Expand Up @@ -36,6 +36,14 @@ def next(self):

current = self.source[self.index]

if current == '/' and self.source[self.index + 1] == '*':
self.index += 2
while not (current == '*' and self.source[self.index + 1] == '/'):
self.index += 1
current = self.source[self.index]
self.index += 2
return self.next()

if current in self.symbols:
self.value = current
self.index += 1
Expand Down
8 changes: 6 additions & 2 deletions vim/syntax/truck.vim
Expand Up @@ -33,9 +33,13 @@ syntax match truckOpreator "\v\*"
syntax match truckOpreator "\v\/"
highlight link truckOperator Operator

syntax match truckString "\v\".*\""
syntax match truckString "\v\'.*\'"
syntax region truckString start=/\v"/ skip=/\v\\./ end=/\v"/
syntax region truckString start=/\v'/ skip=/\v\\./ end=/\v'/
highlight link truckString String

syntax match truckNumber "\v\d+"
highlight link truckNumber Number

syntax region truckComment start=/\v\/\*/ end=/\v\*\//
highlight link truckComment Comment

0 comments on commit 7b56e49

Please sign in to comment.