Is there any ADA parser written in Java? [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am looking to parse ADA code and construct its AST using Java. My belief was that there's a parser written in Java to parse almost every programming language, however after days of research I haven't found anything.
The only promising tool I've found is libadalang (https://github.com/AdaCore/libadalang) by Adacore. However, this only provides api for Ada and Python (although in the readme file Java is mentioned).
Do you have anything to suggest? If there's no direct way of parsing Ada using Java, is any of you familiar with any library that could work as an intermediate? For example, parse Ada using XXX tool and store the AST in a schema (e.g. XML) and then parse the XML using Java?

I'm one of the Libadalang developers, we have indeed planned adding Java bindings at some point, but this is not a high priority item for the moment.
Having a serializer for a common format is something that would be quite easy to add though, especially to the python API were you have full introspection on the tree.
Here is a JSON serializer for the python API of Libadalang:
import json
def node_to_data(self):
if isinstance(self, ASTList):
return [i.to_data() for i in self if i is not None]
else:
return {n: v.to_data()
for n, v in self.iter_fields(with_properties=False)
if v is not None}
def token_to_data(self):
return {"kind": "Token", "token_kind": self.kind, "text": self.text}
ASTNode.to_data = node_to_data
Token.to_data = token_to_data
ASTNode.to_json = lambda self: json.dumps(self.to_data())
I'll add this to the development version of Libadalang soon!

I think I've read that it is possible to call native C libraries from Java.
You could make a C binding to ASIS (Ada Semantic Interface Specification), and then call that from Java.

Related

Why does Java casting have such a strange syntax? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
In Java, when you cast, let’s say, a double to an int, you do this.
int x = (int)(2.5 * 0.4);
In Python, we have this much nicer to read syntax.
x = int(2.5 * 0.4)
Where does this strange form of casting come from? Why is it used?
EDIT:
How is this primarily opinion based? I am looking for factual history on why and where this syntax came from. Please reconsider.
Java's syntax was deliberately and consciously modelled on C (and to a lesser degree) C++ syntax.
Both C and C++ use (<type>) <expr> as the syntax for type casting.
So ...
Where does this strange form of casting come from?
C and C++
Why is it used?
To further the Java design goal of syntactically similarity with C and C++.
This may seem strange to you. However, in the context in which Java was originally designed, the C & C++ languages were dominant. The designers needed to make it easy for C & C++ programmers to transition to Java. If they had ignored this, Java would most likely never have taken off.
Both of those styles have been around for a while: functional and C-like. Given C's prevalence as a code, Java mimicked the style. C++ actually allowed both styles. Python had different goals in choosing its style conventions.
Java was invented at a time when there were a huge number of C programmers in the professional work force, and a slightly smaller number of C++ programmers. The language designers deliberately made the syntax of Java very similar to C and C++, so that this large horde of people would find it easier to learn, and adapt to Java more easily. C-style casting is just one of many syntactic elements in C that Java also uses.

Compute a LaTeX mathematical expression [duplicate]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I need to store a lot of equation and mathematical formula into database for my simulation experimentations, and i think it's better to use some mathML or latex string... but ...
I make some googling request, and i'm very surprised because i don't find any eval library in java or scala to transform string latex or string mathML expression into equation in java / scala. I don't want to eval() very complex equation with solver, my objective is "really" to store and transform simple equation (polynomial, linear) into scala/java language.
Do you have some advice to help me understand if there are other solution to store and parse easily equation or mathematic formula after string evaluation in java or scala language ?
Update 1 :
Finally i find some java library which read et eval() string formula ... If you find anything, i can complete this list with your proposal.
Without parsing of MathML/Latex :
http://www.singularsys.com/jep/ (not open-source)
https://github.com/darius/expr (open-source, young library ?)
http://jeval.sourceforge.net/ (open-source, very old release)
http://projects.congrace.de/exp4j/index.html (open-source, last release 2011, maven repository, developped by #fas)
https://github.com/MarkyVasconcelos/Towel/wiki/Expression (open-source, developped by #marcos-vasconcelos)
math expression parser from my Symja project => cf this post on stackOverflow (Java Math(s) Parsing API)
With experimental Parsing of MathML
jscl-meditor - depository on github Java symbolic computing library and mathematical editor (open-source, last release 2011, great front end and editor, mathML input/output (see tutorial here), great possibilities: polynomial system solving, vectors & matrices, factorization, derivatives, integrals (rational functions), boolean algebra, simplification, java code generation, geometric algebra)
JScience looks like it has some experimental support for MathML being introduced. (cf these post : Parsing mathml document using JScience and MathML and Java)
Class here :
http://jscience.org/experimental/javadoc/org/w3c/dom/mathml/package-tree.html
Thanks
If you want something as sophisticated as I think you are asking for, the only thing that comes to mind that's Java-ecosystem compatible is Clojuratica, and even then you'd have to store the formulae in Mathematica format. (And have a copy of Mathematica.)

What are the orgins of the terms "parse" in java? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
In java I noticed there are methods associated with conversion of strings and those methods sometimes use the word "parse" in the name of the method. For example the static method,
static int parseInt(String str)
is used to convert a string into int. My question is this. Is "parse" short for another word? Is it just a random word or did it come from somewhere else in some other programming context in Java or anywhere else?
From wikipedia:
Parsing or syntactic analysis is the process of analysing a string of symbols, either in natural language or in computer languages, according to the rules of a formal grammar. The term parsing comes from Latin pars (ōrātiōnis), meaning part (of speech).

Unable to parse this kind of string to java [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i have this string of values and don't understand how to get the object array name and values of object items in java.
{
"employees": [
{ "firstName":"Rajesh" , "lastName":"Putta" },
{ "firstName":"Rajesh" , "lastName":"P" },
{ "firstName":"first name" , "lastName":"last name" }
]
}
This is basically a json stirng. Check more about it here:
JSON (JavaScript Object Notation) is a lightweight data-interchange
format. It is easy for humans to read and write. It is easy for
machines to parse and generate. It is based on a subset of the
JavaScript Programming Language, Standard ECMA-262 3rd Edition -
December 1999. JSON is a text format that is completely language
independent but uses conventions that are familiar to programmers of
the C-family of languages, including C, C++, C#, Java, JavaScript,
Perl, Python, and many others. These properties make JSON an ideal
data-interchange language.
You can parse it using a json parser such as
simpleJson
Jackson
GSon
Try these parsers, if you get stuck with the code then share your code and the problem.

Java's BigDecimal.power(BigDecimal exponent): Is there a Java library that does it? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
Java's BigDecimal.pow(int) method only accepts an integer parameter, no BigDecimal parameter.
Is there a library, like Apache's commons-lang, that supports BigDecimal.pow(BigDecimal)? It should be able to do calculate "1.21".pow("0.5") to return "1.1".
There is a Math.BigDecimal implementation of core mathematical functions with source code available from the Cornell University Library here (also you can download the library as a tar.gz). Here is a sample of the library use:
import org.nevec.rjm.*;
import java.math.BigDecimal;
public class test {
public static void main(String... args) {
BigDecimal a = new BigDecimal("1.21");
BigDecimal b = new BigDecimal("0.5");
System.out.println(BigDecimalMath.pow(a, b).toString());
}
}
Prints out:
1.1
Update
The license information is now clear in the May 2015 update:
The full source code is made available under the LGPL v3.0.
Havent used, but saw suanshu.
An open source version in github (https://github.com/nmdev2020/SuanShu).
BigDecimalUtils has a pow() which suits your needs
public static java.math.BigDecimal pow(java.math.BigDecimal a,
java.math.BigDecimal b)
Compute a to the power of b.
The Apfloat library seems to be doing this, check the API docs.
ApcomplexMath.pow(Apcomplex z, Apcomplex w)
Apcomplex is a wrapper class for e.g. a BigDecimal.

Categories

Resources