lawrancej / CompilerKit

Compiler construction library in C.
GNU Lesser General Public License v2.1
55 stars 33 forks source link

Nice to have a concatenation based on strings #21

Closed lawrancej closed 12 years ago

lawrancej commented 12 years ago

compilerkit_concatenation_new(compilerkit_symbol_new('a'), compilerkit_concatenation_new(compilerkit_symbol_new('b'), compilerkit_symbol_new('c'))

compilerkit_string_concatenation_new("abc");

aghon commented 12 years ago

I'll take this one.

Nomose

lawrancej commented 12 years ago

A good way to proceed:

  1. Write a function prototype inside include/CompilerKit/convenience.h: GObject _compilerkit_string_concatenationnew(gunichar);
  2. Implement that function inside src/convenience.c For inspiration, look at compilerkit_alternation_vlist_new in src/alternation.c. You'll be doing something similar: you'll iterate through the string and construct symbols for each character and build a concatenation around it.
  3. Write a test for compilerkit_string_concatenation_new inside tests/convenience-test.c
  4. Modify visitor demo to use your new function.
aghon commented 12 years ago

Okay. Thanks professor