Help needed in writing C#-based compiler
hi all
I need help in writing compiler in C#
my project is called "Amuera", the language is spanish-based, and so far it only has interpreter.
most of the code is in compilr.com, so that you can compile the exe there to get familiriazed with the system
Please join interesting and fun project!
best regards
iltelko
I'd want to have some users for my project. Now the program has small editor which would be fun to use or to alter. I
I try to recruit people, yes. sorry to post to this forum but im not sure where should I ask these questions. have more, tons of specific questions, I should ask them later.
But I ask the most newest one right now:
I cannot print Scandinavian characters, although I am using UTF-8, I changed the property relating to this in the Console object. I am reading ConsoleKeyInfo from Console.ReadKey and it give me the char what was printed. But the problem is that when I print scandinavian characters (Console.Write), it is printed wrong. It shows 2 characters instead of 1 right one. Is it somehow related to character encoding? I know there are UTF8 and UTF16 character encodings.
I am not sure could the Encoding.UTF8.GetString help with this. Should I encode the read char somehow?
Console.Readkey doc by MS, do not help to explain what encoding the char has when it is read: http://msdn.microsoft.com/en-us/library/471w8d85.aspx
I am puzzled, can you help me?
best regards
ilkka
If I'm not mistaken, which I'm usually not, Console.Readkey reads just one key entry from the input. The actual data being parsed is a 32 bit integer representation of the key being pressed. What you will handle is an object of the type ConsoleKeyInfo.
System.ConsoleKey is an Enum that provides the numeric values using the key's name. For instance, if you press the 'A' key on your keyboard, the program will recieve ConsoleKey.A, on the other hand, if you press 'Tab' your program will recieve ConsoleKey.Tab.
If you don't have visual studio, I'd suggest writing a quick program that will display the textual name of the key that you press, as some key names are slightly different than what we might expect.
As always, to display the textual value of an enum variable:
enum values { a, b, c, d }
values Val;
string EnumName = Enum.GetName(typeof(values), Val);
That is the basis of getting an enum's name as a string for printing.
thank you, it get me a little closer to the solution.
now I can identify the key pressed, when I want to show scandinavian characters.
but I cannot still show scandinavian characters, because Console supports only UTF-8 character encoding. and I am stunned how to make it work.
best regards
ilkka
System.Console.OutputEncoding
and
System.Console.InputEncoding
However it only provides for:
ASCIIEncoding, UnicodeEncoding, UTF32Encoding, UTF7Encoding, and UTF8Encoding
Here's an alternative for you:
If you are able to display your special characters in a textbox...instead of writing it as a console application, write it as a winforms application, with two textboxes.
Divide the screen with a table and make the second row have a height of 23pixels. Set the tables dock attribute to fille. Put one textbox in the first row and set it's dock attribute to fill and make it multiline. You can also set it's background color to black and it's font color to green or white to simulate a dos window if you like. Put the second textbox in the second row and set it's dock attribute to fill but leave it's multiline attribute to false. now, set the top textbox to readonly and set the bottom textbox to fire an event when the enter key is pressed. In this manner, you have a simulated dos window in which you can run and display your output in whatever format you like. Alternatively instead of using a textbox in the first row, you could use a richtextbox so that you can use rtf encoding to colorize it and control it's font and format. I tend to not use the richtextbox, instead I use a webbrowser extension so that I can format my output in html, I think it's much easier to work with.
Very interesting idea. Never thought about it.
it is good also because windows.forms is supported also in Mono.
I try to find a solution for characters problem, because I have lots of code created for console and I dont yet want to restructure it to Windows.Forms
I kind of have an idea to use Mono's GTK# but it needs separate package to be installed. so that you could use gtk or windows.forms and GUI itself would be specified in XUL. Xaml would be more advanced, I know.
I have some code which creates GTK# GUI from XUL, but the problem
is that it only works in linux Mono. or it works in windows, but you need to install something.
thank you for your idea!
best regards,
ilkka
Hi!
Do you need any specific help with the project? Or just looking to recruit :)
-----------------
Tim Speed
Compilr Developer and CTO