How do I get the output of Erlang's preprocessor? - erlang

I've got a weird macro that I'm debugging and I can't seem to figure out how to get the output of the preprocessor. I'm looking for the equivalent of GCC's -save-temps. I've tried passing dpp to compile:file/2, but it seems to generate a parse tree, not preprocessed Erlang.
compile:file("t.erl", 'E'). as mentioned by Anton is great, but doesn't help with macros that cause syntax errors. Lacking a way to debug complicated macros, I'm leaning toward doing my metaprogramming by writing programs that generate code.

Try one of these:
compile:file("t.erl", 'P').
compile:file("t.erl", 'E').

Related

How to deobfuscate this?

I obfuscated this script using some site
But i'm wondering how to deobfuscate it? can someone help me?
i tried using most decompilers and a lot of ways but none has worked
local howtoDEOBFUSCATEthis_Illll='2d2d341be85c64062f4287f90df25edffd08ec003b5d9491e1db542a356f64a488a1015c2a6b6d4596f2fa74fd602d30b0ecb05f4d768cd9b54d8463b39729eb1fe84630c0f8983f1a0087681fe4f2b322450ce07b
something like that for an example.
the whole script: https://pastebin.com/raw/fDGKYrH7
First reformat into a sane layout. a newline before every local and end will do a lot. Then indenting the functions that become visible is pretty easy.
After that use search replace to inline constants. For example: local howtoDEOBFUSCATEthis_IlIlIIlIlIlI=8480; means you can replace every howtoDEOBFUSCATEthis_IlIlIIlIlIlI with 8480. Though be careful about assignments to it. If there are any then it's better to rename the variable something sensible.
If an identifier has no match you can delete the statement.
Eventually you get to functions that are actually used.
Looking at the code it seems to be an interpreter implementation. I believe it's a lua interpreter
Which means that you'll need to verify that and decompile what the interpreter executes.

IronPython compile() does not accept AST object

In the documentation it says, 'source' can be either str or AST object
When trying to compile my ast root:
dl = compile(newRoot, '<string>', 'eval')
I get this Exception:
expected str, got Module
I am using the last version of IronPython.
Is there an idea why this does not work? all the examples I found seem to do it this way with no issues.
Is there a workaround to compile an AST object?
Thanks!!!!
PD: I found this issue but seems to have no activity: http://ironpython.codeplex.com/workitem/32526
First off, IronPython does not support this.
It's actually quite hard to support in IronPython (and I didn't know it needed to be supported until today). IronPython's _ast module is a wrapper around its own AST, and currently only implements conversion from IronPython AST => CPython AST, but not the reverse. It's a fair bit of (honestly, quite tedious) work, so I'm not sure when it will get fixed.
If there's a popular program or library that's broken because of this that moves it up the priority list, and patches are always welcome.

Emacs: Using a major-mode's font-locking only for mmm-mode

I've got MMM-mode set up to edit .html.erb files, but indentation does not work in the ruby sections, and all the different electric behaviours of ruby-mode do the wrong thing. I've changed this sub-mode from ruby-moode to fundamental-mode, and it works much better.
I want to still use ruby-mode's font-locking though, is this possible/easy? Any hints on where to start.
Elisp is comfortable to me, but I don't have too much time right now to dig too deeply myself. Hopefully someone will have a snippet?
I see you haven't yet found an answer. Dunno whether it will be better for this, but you might consider using MuMaMo instead of MMM.
To answer the question, you would define a major mode deriving from fundamental-mode, and in its body just copy the font-lock-related lines from the ruby-mode definition body, the ones setting font-lock- variables and also syntax-propertize-function. Naturally , you need to (require 'ruby-mode) somewhere.
But for .html.erb files I can now recommend using mmm-erb, which was not available when this question was asked.

Simple preprocessor for latex: detect whether you are an included file or being compiled stand-alone

I work on a huge script in \latex.
I want to be able to compile each of the chapters as stand-alone, because it is easier for hacking sessions with Latex.
On the other hand, I would like to maintain a document which encompasses the whole script so far written.
I do not know how to maintain both these documents without permanently annoying overhead, as a tex-file can either be written stand-alone or to be included.
It would be great help to have something a Latex-preprocessor available that is capable of C-like #define and #ifdef-#else-#endif statements. This would facilitate writing to a great extent. Do you know whether something like this exists in latex, or how can you do something equivalent? Google hasn't supplied me with a satisfying answer to this.
EDIT:
Some remarks in order to avoid misunderstandings: I am aware of the very simple built-in TEX-preprocessor, but these commands don't work properly as I expected. Hence a reference to these will not help me out.
The chapters in my script shall look something like this (Pseudo-Code)
IF being_just_included defined
%No header here, and document has already begun
ELSE
\input{common_header.tex} %Header things all my documents use
\begin{document}
ENDIF
%%% Lots of stuff
IF being_just_included defined
%Nothing to do here
ELSE
\end{document}
END IF
In contrast, my complete script source file should look like this
\input{common_header.tex}
DEFINE being_just_included
\begin{document}
\input{preamble.tex}
\input{first_chapter.tex}
\input{second_chapter.tex}
\input{third_chapter.tex}
\end{document}
Could you post a code which performs something like this?
Thank you very much for this package and the hint to the forum.
After some time I've figured out there exists a tex preprocessor, which is similar to the CPP. Maybe not well-engineered, but it serves my purpose quite well.
The magic lines are:
\def\justbeingincluded{justbeingincluded}
\ifx\justbeingincluded\undefined
\fi
to be used appropiatly within the respective source files.
One way of doing this is to use the standalone package, intended for this specific purpose.
You may also care to browse through, and perhaps join, TeX and Friends.

In rails.vim why do I get "E345 can't find file in path" errors?

I've been learning Ruby/Rails with vim. Tim Pope's rails.vim seems like a really good tool to traverse files with, but I keep getting these pesky "E345 can't find file in path" errors. I'm not vim expert yet, so the solution isn't obvious. Additionally, I've tried this and it doesn't apply to my problem.
As an example of the problem. I have a method format_name defined in app/helpers/application_helper.rb and it is used in app/helpers/messages_helper.rb. Within the latter file I put my cursor over the usage of format_name and then hit gf and I get that error. Similar disfunction with commands like ]f and [f
However, it works sometimes. I was able to gf from user to the app/models/user.rb
Ideas?
I think that is a limitation of rails.vim. It does not support “finding” bare methods. Supporting something like that would require one of the following:
an exhaustive search of all the source files for each “find” request
(which could be expensive with large projects),
“dumb” indexing of method names
(e.g. Exuberant Ctags and gControl-]; see :help g_CTRL-]), or
smart enough parsing of the code to make a good guess where the method might be defined
(which is hard to do properly).
If you know where the method is, you can extend many of the navigation commands with a method name:
:Rhelper application#format_name
But, you do not have to type all of that in. Assuming the cursor is on format_name you can probably just type:RhTabspaceappTab#Control-R Control-W (see :help c_CTRL-R_CTRL-W).

Resources