Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Parsing Source code String into a IASTNODe (or IAStTranslationUnit)

You would need to wrap your code fragment into additional code to make it compilable. After that you can parse it into a separate translation unit, examine its contents and use the interesting fragment as a foundation for changing the original translation unit.

-sergey

On Wed, Sep 16, 2015 at 12:01 PM, Krishna Narasimhan <krishna.nm86@xxxxxxxxx> wrote:
I know how the code is modified. I have a lot of other modifications present. 

But, I would like to be able to parse a string into an _expression_ and replace the existing limit _expression_ with this new _expression_ . The string is part of a user input and I know before hand that this is an _expression_. 


But I was not able to use them without encountering a parse error.



On Wed, Sep 16, 2015 at 8:57 PM, Sergey Prigogin <eclipse.sprigogin@xxxxxxxxx> wrote:
You can look at the code of existing refactorings to see how they modify the code.

-sergey

On Wed, Sep 16, 2015 at 11:40 AM, Krishna Narasimhan <krishna.nm86@xxxxxxxxx> wrote:
I want to dynamically construct an _expression_ that should replace the existing limit of the loop

So the usecase is like this

1) Get the limit of the loop. Lets say its "10" (The for statement is simple in this case (for int i = 0; i < limit; i++)

Now I want to replace it with for( int = 0; i < limit/float_v::size; i ++)

On Wed, Sep 16, 2015 at 8:33 PM, Sergey Prigogin <eclipse.sprigogin@xxxxxxxxx> wrote:
A translation unit can only be parsed as a whole. What exactly are you trying to do?

-sergey

On Wed, Sep 16, 2015 at 11:25 AM, Krishna Narasimhan <krishna.nm86@xxxxxxxxx> wrote:
Hello,
    Is there a way to parse a string back into a node or a translation unit. For example, something like 15/type_x::Size

where type_x is a user defined type and Size is a property of that type.




_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev



--
-----------------------------------------------------
I dare do all that may become a man; Who dares do more, is none - Macbeth, twelfh night!
Regards
       Krishna

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev



--
-----------------------------------------------------
I dare do all that may become a man; Who dares do more, is none - Macbeth, twelfh night!
Regards
       Krishna

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top