소스 검색

zkas: Implement Uint32 type.

parazyd 4 년 전
부모
커밋
389602e253
3개의 변경된 파일17개의 추가작업 그리고 3개의 파일을 삭제
  1. 6 3
      zkas/src/lexer.rs
  2. 9 0
      zkas/src/parser.rs
  3. 2 0
      zkas/src/types.rs

+ 6 - 3
zkas/src/lexer.rs

@@ -129,11 +129,16 @@ impl<'a> Lexer<'a> {
                 continue
             }
 
-            if in_string && is_letter(c) {
+            if in_string && (is_letter(c) || is_digit(c)) {
                 strbuf.push(c);
                 continue
             }
 
+            if in_symbol && is_digit(c) {
+                symbuf.push(c);
+                continue
+            }
+
             if c == '"' && !in_string {
                 if in_symbol {
                     self.error(format!("Illegal char `{}` for symbol", c), lineno, column);
@@ -265,8 +270,6 @@ fn is_letter(ch: char) -> bool {
     ('a'..='z').contains(&ch) || ('A'..='Z').contains(&ch) || ch == '_'
 }
 
-/*
 fn is_digit(ch: char) -> bool {
     ('0'..'9').contains(&ch)
 }
-*/

+ 9 - 0
zkas/src/parser.rs

@@ -421,6 +421,15 @@ impl Parser {
                     });
                 }
 
+                "Uint32" => {
+                    ret.push(Witness {
+                        name: k.to_string(),
+                        typ: Type::Uint32,
+                        line: v.0.line,
+                        column: v.0.column,
+                    });
+                }
+
                 x => {
                     self.error(format!("`{}` is an illegal witness type", x), v.1.line, v.1.column);
                 }

+ 2 - 0
zkas/src/types.rs

@@ -14,5 +14,7 @@ pub enum Type {
 
     MerklePath = 0x20,
 
+    Uint32 = 0x30,
+
     Dummy = 0xff,
 }