Charles,
Does writeDeepString() or something else tell the scope of stms and variables declared,
i can see that functions/methods have parentbox set to enclosing class is there something
similar for variables and statements. so that one does not have to figure it out programmatically
but gets straight answers.
AssignExpr-sh what does sh mean in the before mentioned word it is there with everything like
IdentifierExpr-sh
NameSpace-sh etc,etc..
ThankingYou
RIGHT_THEN
Forums
WriteDeepString And scope of variables
5 posts
• Page 1 of 1
Re: WriteDeepString And scope of variables
Look for
I dont get the '-sh' suffix either
.compiler.curBoxMember
# and
.compiler.curBox
I dont get the '-sh' suffix either
- hopscc
- Posts: 632
- Location: New Plymouth, Taranaki, New Zealand
Re: WriteDeepString And scope of variables
hopscc is correct on the properties that give you the scope.
When converting nodes to strings there are 3 suffixes to indicate which string conversion you are looking at:
de - deep
sh - shallow
mi - minimal
You can find these in Node._toString in Node.Cobra.
When converting nodes to strings there are 3 suffixes to indicate which string conversion you are looking at:
de - deep
sh - shallow
mi - minimal
You can find these in Node._toString in Node.Cobra.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: WriteDeepString And scope of variables
Gentlemen
thanks for suggestion but
compiler.curBox and all the cur`s are not working for me
i am uploading two files below and not writing code here for fear of loseing Formatting
one file is C# file in which i try to Parse cobra file it gets parsed i can get WriteDeepString To
work and am trying to see what someother functions might output.
second file is the simple Cobra file i am trying to parse to keep it simple so that i can understand the parsed output.
would it be allright for you to demostrate a working example of how to get compiler.cur`s to work
write it even in Cobra if you find it convienient i will translate it to C#.
Thanking You
RIGHT_THEN
thanks for suggestion but
compiler.curBox and all the cur`s are not working for me
i am uploading two files below and not writing code here for fear of loseing Formatting
one file is C# file in which i try to Parse cobra file it gets parsed i can get WriteDeepString To
work and am trying to see what someother functions might output.
second file is the simple Cobra file i am trying to parse to keep it simple so that i can understand the parsed output.
would it be allright for you to demostrate a working example of how to get compiler.cur`s to work
write it even in Cobra if you find it convienient i will translate it to C#.
Thanking You
RIGHT_THEN
- Attachments
-
- TextFile2.cobra
- cobra code
- (287 Bytes) Downloaded 331 times
-
- CsharpFile.cs
- containging C# code
- (2.16 KiB) Downloaded 345 times
- RIGHT_THEN
- Posts: 99
Re: WriteDeepString And scope of variables
Our comments about .curBox and .curBoxMember were for if you were hacking on the compiler directly, like implementing a node's _bindImp for example. If you're "outside the compiler looking in" then you will want to use the visitor pattern to go through the nodes. There is an existing example of this in CobraWorkspace/Source/DocGenerator.cobra which you can also read online in the Trac source browser.
As you are visiting the nodes, you can record the current class/interface/struct (called a "box" in the compiler source code) and/or the current method, etc. Something like:
Interestingly, the Visitor class is part of the Cobra library and you could probably use it from C#. Or you can roll your own, possibly looking at the Visitor source as an example.
If you have further questions, let us know.
As you are visiting the nodes, you can record the current class/interface/struct (called a "box" in the compiler source code) and/or the current method, etc. Something like:
class MyVisitor inherits Visitor
# ...
get methodName as String is override
return 'visit'
pro curBox as Box?
def visit(box as Box)
.curBox = box # .curBox can be used in subsequent methods
.dispatch(box.decls)
# ...
Interestingly, the Visitor class is part of the Cobra library and you could probably use it from C#. Or you can roll your own, possibly looking at the Visitor source as an example.
If you have further questions, let us know.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 56 guests