Переглянути джерело

contrib/zk: Add new things in vim and vis lexers.

Luther Blissett 4 роки тому
батько
коміт
90407fa4f2
2 змінених файлів з 17 додано та 6 видалено
  1. 14 3
      contrib/zk.lua
  2. 3 3
      contrib/zk.vim

+ 14 - 3
contrib/zk.lua

@@ -15,11 +15,20 @@ local comment = token(l.COMMENT, '#' * l.nonnewline_esc^0)
 local dq_str = P('U')^-1 * l.delimited_range('"', true)
 local string = token(l.STRING, dq_str)
 
+-- Numbers.
+local number = token(l.NUMBER, l.integer)
+
 -- Keywords.
 local keyword = token(l.KEYWORD, word_match{
   'constant', 'contract', 'circuit',
 })
 
+-- Constants.
+local constant = token(l.CONSTANT, word_match{
+	'true', 'false',
+	'VALUE_COMMIT_VALUE', 'VALUE_COMMIT_RANDOM', 'NULLIFIER_K',
+})
+
 -- Types.
 local type = token(l.TYPE, word_match{
   'EcPoint', 'EcFixedPoint', 'EcFixedPointBase', 'EcFixedPointShort',
@@ -33,8 +42,8 @@ local instruction = token('instruction', word_match{
   'ec_add', 'ec_mul', 'ec_mul_base', 'ec_mul_short',
   'ec_get_x', 'ec_get_y',
   'base_add', 'base_mul', 'base_sub', 'greater_than',
-  'poseidon_hash', 'calculate_merkle_root',
-  'constrain_instance',
+  'poseidon_hash', 'merkle_root', 'constrain_instance',
+  'range_check', 'less_than', 'witness_base',
 })
 
 -- Identifiers.
@@ -46,9 +55,11 @@ local operator = token(l.OPERATOR, S('(){}=;,'))
 M._rules = {
   {'whitespace', ws},
   {'comment', comment},
-  {'string', string},
   {'keyword', keyword},
   {'type', type},
+  {'constant', constant},
+  {'string', string},
+  {'number', number},
   {'instruction', instruction},
   {'identifier', identifier},
   {'operator', operator},

+ 3 - 3
contrib/zk.vim

@@ -21,9 +21,9 @@ syn keyword zkasType
 syn keyword zkasInstruction
     \ ec_add ec_mul ec_mul_base ec_mul_short
     \ ec_get_x ec_get_y
-    \ base_add base_mul base_sub greater_than
-    \ poseidon_hash calculate_merkle_root
-    \ constrain_instance
+    \ base_add base_mul base_sub
+    \ poseidon_hash merkle_root constrain_instance
+    \ range_check less_than witness_base
 
 syn region zkasString start='"' end='"' contained