Forums

Cannot find a method "Highlight" with arg type "NameSpace"

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Cannot find a method "Highlight" with arg type "NameSpace"

Postby RIGHT_THEN » Sat Feb 26, 2011 9:59 pm

Gentlemen

After parsing file i get a CobraModule i tried to run
Code: Select all
cm1.WriteHtmlHighlightedFileTo(Environment.CurrentDirectory);
on it . that went fine
untill i added namespace to the code file. Error reported is the subject of this post

""" 
mistakes and corrections are intentionally done to
see how would parser respond.
when we put namespace,
Cannot find a method "Highlight" with arg type "NameSpace"
is given by HtmlSource().
"""
namespace Yamamoto

class Main1
"""
I am a Class

"""
def main is shared
"""
i am a method

"""
a as int = 2 # this is a
b = 3 # this is b
z = 4
b = 4 + z
z = a + b
a = z + b
x is string = 'yellow'
print a, b, c
System.Console.writeLine("hello again")
print 'hello'
print 'x'
System.Console.writeLine("hello again")
print 'hello'
print 'x'

def add( num1 , num2 ) as int is shared
return num1 + num2

am i doing something fundamentally wrong or something needs fixing in cobra
and why are doc strings not allowed for namespaces when they are allowed for classes.

also writeDeepString does not report the doc string of the module and class it does of method
i suggest that module level and class level doc-strings be provisioned into Writedeepstring()

Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: Cannot find a method "Highlight" with arg type "NameSpac

Postby Charles » Sun Feb 27, 2011 1:01 am

-- The highlighter had a bug regarding namespaces. Now fixed. Thanks for the report.

-- Regarding doc strings in namespaces: It's common for namespaces to appear many times. You could easily have 20 classes, each in its own file, with a "namespace" declaration in each one. It's not clear how they should be documented then. If there is more than one doc string do they get appended? Replaced? What order?

-- .writeDeepString is for the purpose of debugging the compiler and it seemed that I never needed the doc string when doing so. I still prefer to leave them out. Do you really need that?
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Cannot find a method "Highlight" with arg type "NameSpac

Postby RIGHT_THEN » Sun Feb 27, 2011 3:14 am

Thanks Charles

For fixing it,

Here are few questions

1) can cobra simply convert the code form itself to C# without checking and using reflection
2) at what stage cobra knows exactly what certain ID stands for. i mean its type because there is
duck typing here. and tokenizer does not show the type of ducks.


as far as how to deal with namespace docstrings since it is for the same namespace no order
is required it can be appended as one finds them
"""
1) filename
comment
2) filename
comment
3) so forth ..
"""

-- .writeDeepString is for the purpose of debugging the compiler and it seemed that I never needed the doc string when doing so. I still prefer to leave them out. Do you really need that?


i mentioned it thinking that it could be a bug or unintentionally leftout feature. i can get them
through tokens so no i would not press you for that. let them be as they were.

Thanking_you
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: Cannot find a method "Highlight" with arg type "NameSpac

Postby Charles » Sun Feb 27, 2011 9:56 am

-- The C# code generator assumes that the previous phases of the compiler have executed and passed without error. It would certainly fail if that were not the case.

-- Regarding when the compiler knows what an id stands for:

--- For interface level stuff such as the return type of a method, or the base class of a given class, that would be after "bind interface".

--- For the code inside of methods and properties, that would be after "bind implementation".

--- But that is only for static types. You mentioned duck typing, which I call "dynamic". In that case, only the run-time knows for sure in the general case. Although you could try to do code analysis to determine such things without running the program.

-- As a reminder, for a local var like this:
i = 0

The type is inferred to be static, not dynamic. The local var "i" will always be an "int". Cobra gets much of its speed by favoring static typing like this.

-- Regarding namespace doc strings, you may want to add a ticket. Click "Wiki" which takes you to "Trac" and add a ticket, if you like.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Cannot find a method "Highlight" with arg type "NameSpac

Postby hopscc » Tue Apr 03, 2012 2:48 am

Patch and tests for allowing docstr on namespaces on ticket:277
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Cannot find a method "Highlight" with arg type "NameSpac

Postby Charles » Mon Apr 23, 2012 6:21 pm

Applied. Thanks.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 48 guests