TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Are There Generalized Transpilers?

2 pointsby passer_byerover 5 years ago
I have a client who has tens on thousands of legacy Base SAS programs for calculating Current Expected Credit Losses (CCEL) models. Base SAS is a commercial, interpreted language used widely in financial services for reporting and risk analysis. New hires coming into the firm mainly know Python and few know SAS. They would like to convert their exusting SAS programs into Python 3 scripts.<p>One obvious approach is to recode by hand the existing logic into Python. However, this is not a scalable approach.<p>I would like to know if there are existing tools, like a generalized transpiler that parses language X into language Y.<p>https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Source-to-source_compiler<p>I have a reasonable understanding on mapping common Base SAS language constructions into Python. See:<p>www.pythonforsasusers.com<p>Absent such a generalized tool, what advice do you have to help automate such an effort?

2 comments

verdvermover 5 years ago
You&#x27;ll first have to parse the SAS code, then output python or some other intermediate form.<p>Does an open source parser exist?<p>Golang did a C to Go transpile, there are some articles and maybe a talk on it out there. It likely won&#x27;t be 100% perfect, so you will need tests to verify correctness.<p>I have a tool that isn&#x27;t open source yet, but it could be quite useful if you can get SAS to an AST in json or other data format. Hit me up if you&#x27;d be interested in talking about that option.
评论 #22021259 未加载
eesmithover 5 years ago
Tell them that you can&#x27;t do it.<p>The project you describe is complicated. SAS is not a simple language. For example, how do you plan to map GOTO into Python? <a href="https:&#x2F;&#x2F;support.sas.com&#x2F;documentation&#x2F;cdl&#x2F;en&#x2F;imlug&#x2F;64248&#x2F;HTML&#x2F;default&#x2F;viewer.htm#imlug_langref_sect126.htm" rel="nofollow">https:&#x2F;&#x2F;support.sas.com&#x2F;documentation&#x2F;cdl&#x2F;en&#x2F;imlug&#x2F;64248&#x2F;HTM...</a> .<p>Here&#x27;s part of a resume of someone who wrote a SAS parser as part of a job. Between 2013 and 2016:<p>&gt; Wrote a SAS parser (C++&#x2F;ANTLR). SAS is a 70s language not at all written in conformance with modern computer language practices. Among its many ‘challenges’, the worst is that keywords can also be used as variable names (thus you can define variables IF, ELSE, THEN and have a legal SAS statement like “IF ELSE=IF THEN IF=ELSE ELSE THEN=IF;”) So standard compiler theory &#x2F; a classical lex&#x2F;yacc approach won’t work because lex&#x2F;yacc assumes that reserved words aren’t used as variable&#x2F;function names. I wrote a parser that successfully builds an Abstract Syntax Tree (from which symbol tables and more can be extracted). Successfully tested against a test bed of 180 representative SAS programs taken from industry production environments.<p>Note that it took several years!<p>Your client has 10,000+ SAS programs. They likely exercise a lot of odd corners of the language. They&#x27;ll want some strong assurances that the conversion is done correctly, as this is business logic.<p>Based on the way you asked the question, I&#x27;m certain that this is not something you can easily take on. You don&#x27;t seem to know much about language parsers or enough about the SAS language.<p>Instead, pay someone to do it who already has those skills. Looking around (and with absolutely no knowledge or experience in the topic) I found <a href="https:&#x2F;&#x2F;dullesresearch.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;dullesresearch.com&#x2F;</a> which says:<p>&gt; Automatically Convert SAS to Python and Java Instantaneous, 100% accurate.<p>&gt; Migrate off of SAS to Open Source &#x2F; Avoid manual rewriting of code &#x2F; Eliminate human errors<p>There are almost certainly others.<p>So my suggestion to help automate such an effort is to pay someone else to do it for you.<p>Find out how much they charge, what their guarantee is. Then figure out what your client wants. See if they are compatible. If so, charge your client +15% for overhead, you work with the other organization, and you&#x27;re done.
评论 #22023949 未加载