This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if(cond) { | |
| raise Exception("something went wrong") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SIValue toUpper(SIValue v) { | |
| SIType actual_type = SI_TYPE(v); | |
| if(actual_type != SI_STRING) { | |
| const char *actual_type_str = SIType_ToString(actual_type); | |
| raise("Type mismatch: expected string but was %s", actual_type_str); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void f(void) { | |
| void *a = NULL; | |
| void *b = NULL; | |
| void *c = NULL; | |
| a = malloc(32); | |
| //... | |
| if(cond1) goto cleanup; | |
| b = malloc(64); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void f(void) { | |
| void *a = NULL; | |
| void *b = NULL; | |
| void *c = NULL; | |
| a = malloc(32); | |
| //... | |
| if(cond1) { | |
| free(a) | |
| return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uint64_t dictStringHash(const void *key) { | |
| return dictGenHashFunction(key, strlen(key)); | |
| } | |
| void *dictStringDup(void *privdata, const void *key) { | |
| DICT_NOTUSED(privdata); | |
| size_t key_len = strlen(key); | |
| char *copy = malloc((key_len + 1) * sizeof(char)); | |
| strcpy(copy, key); | |
| copy[key_len] = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // (exp) | |
| arithmetic_expression ::= LEFT_PARENTHESIS arithmetic_expression RIGHT_PARENTHESIS. | |
| // exp + exp | |
| arithmetic_expression ::= arithmetic_expression binary_operator arithmetic_expression. | |
| // func(exp) | |
| arithmetic_expression ::= STRING LEFT_PARENTHESIS arithmetic_expression_list RIGHT_PARENTHESIS. | |
| // 9 | |
| arithmetic_expression ::= value. | |
| // friend.age | |
| arithmetic_expression ::= variable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Evaluate(root) { | |
| if(node_is_const(root)) { | |
| return root.value; | |
| } | |
| for(child in root) { | |
| evaluate(child); | |
| } | |
| return root.op(root.children); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exp: exp op exp | |
| exp: '(' exp ')' | |
| exp: number | |
| op: + | |
| - | |
| * | |
| / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exp: exp op exp | |
| exp: '(' exp ')' | |
| exp: number | |
| op: + | |
| - | |
| * | |
| / |
NewerOlder