kouamano / RECURSIVE-SYSTEM

test for recursive operation
3 stars 1 forks source link

{}部のエスケープ(c_tq) #103

Open kouamano opened 3 years ago

kouamano commented 3 years ago

jsikブランチでコード改修(仮)済み jsikブランチでテスト テスト後に他のブランチに反映

kouamano commented 3 years ago

(base) kouamano@x86_64-apple-darwin13 RECURSIVE-SYSTEM % git branch

  cq
  cq_debug
* jsik

(base) kouamano@x86_64-apple-darwin13 RECURSIVE-SYSTEM % ./branch.diff

==cq==
> VS. cq_debug
>> self
>> Readme
>> source code
>> converter
>> test code
>> compile
> VS. jsik
>> self
>> Readme
>> source code
diff --git a/C-functions_imex.h b/C-functions_imex.h
index 95dda42..a6944c3 100644
--- a/C-functions_imex.h
+++ b/C-functions_imex.h
@@ -348,6 +348,45 @@ void skip_dim()
    } while(ch == '[');
 }

+void skip_op()
+{
+   int DLM_ACC;
+
+   do {
+       append_char(ch);            // '{'
+       next_char();
+
+       DLM_ACC = 1;
+
+       while(ch != EOF && DLM_ACC > 0) {
+           if(ch == '"') {
+               skip_double_quote();
+           } else {
+               switch(ch) {
+               case '{':
+                   DLM_ACC++;
+                   break;
+               case '}':
+                   DLM_ACC--;
+                   break;
+               // case '\\':
+               //  append_char(ch);
+               //  next_char();
+               //  break;
+               default:
+                   break;
+               }
+
+               append_char(ch);
+               next_char();
+           }
+       }
+       if(DLM_ACC > 0) {
+           error("syntax error");      // EOF before closing ']'
+       }
+   } while(ch == '{');
+}
+
 void next_token()
 {
    null_node_allowed = ON;     // null node flag
@@ -387,6 +426,9 @@ void next_token()
            case '[':
                skip_dim();     // skip to closing ']'
                break;
+           case '{':
+               skip_op();      // skip to closing '}'
+               break;
            case LF :           // ignore LF, TAB
            case TAB :
                next_char();
>> converter
>> test code
>> compile