language-design

Adding a language to the AVM2

半腔热情 提交于 2019-12-10 15:51:27
问题 I'm interested in making a language to run on the AVM2 and I'm looking for advice on where to start. I do realize that this is by no means a trivial task, but I would like to give it a try and at the very least learn more about implementing a language along the way. I have messed around with ANTLR and have been reading up on syntax issues for language development. What I'm looking for is advice on a path to take or useful references/books. For instance I would like to generate (script

Extended Backus–Naur Form order of operations

笑着哭i 提交于 2019-12-10 15:44:03
问题 I am creating a formal spec for a very simple rule language, very simple. I want to use EBNF as this is a standard but I can't figure out how to specify order of operations. Here is the specification so far. rule = statement, { (‘AND’|’OR’), statement}; variable = ‘$’,alphabetic character, {alphabetic character | digit}; statement = variable, [ ‘count’,[white space ],’>’,[white space],number ]; alphabetic character = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M"

Why is -1 the result of coercing True to an integer in VB6?

泪湿孤枕 提交于 2019-12-10 13:08:19
问题 In VB6, coercing True to an integer yields the value -1. Why is this so? What is the reasoning behind this? In most other programming languages (C/C++, Java, Perl, Python, etc.), true becomes 1 when coerced into an integer. In boolean algebra, the value 1 is used to represent true/on. Why does VB6 do it differently? I do see a certain elegant symmetry in the fact that a bitwise-not of -1 (True) will yield 0 (False), and vice-versa (because of -1's representation being all 1s in two's

writing parser of a simple language

空扰寡人 提交于 2019-12-10 12:06:52
问题 I'm trying to design a simple language is similar to lips, schema. I have written its lexer(tokenizer). I can seperate into operators, identifiers etc. But I try now writing parser. For this, just one example is enough for me. Can someone give me an example in java code just for the example? Besides, everyone mentions of usage antlr. Can someone who attempts to use antlr show an example using my example in this question? – EXP -> EXPI | EXPB – EXPI -> (+ EXPI EXPI) | (- EXPI EXPI) | (* EXPI

Why is 'super' a keyword rather than a method in Ruby?

偶尔善良 提交于 2019-12-10 03:14:31
问题 In Ruby, super is a keyword rather than a method. Why was it designed this way? Ruby's design tends toward implementing as much as possible as methods; keywords are usually reserved for language features that have their own grammar rules. super , however, looks and acts like a method call. (I know it would be cumbersome to implement super in pure Ruby, since it would have to parse the method name out of caller , or use a trace_func. This alone wouldn't prevent it from being a method, because

Should References in Object-Oriented Programming Languages be Non-Nullable by Default? [closed]

ⅰ亾dé卋堺 提交于 2019-12-10 03:00:55
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . Null pointers have been described as the "billion dollar mistake". Some languages have reference types which can't be assigned the

Why does Rust check array bounds at runtime, when (most) other checks occur at compile time?

耗尽温柔 提交于 2019-12-10 02:39:47
问题 Reading the basic introduction: If you try to use a subscript that is not in the array, you will get an error: array access is bounds-checked at run-time. Why does Rust check array bounds at runtime, when it seems most other checks occur at compile time? 回答1: Because checking indices at compile time is not feasible in the general case. Reasoning about the possible values of arbitrary variables is somewhere between hard and impossible even for small programs. Nobody wants to have to: formally

Is it possible to create C# language modifications as did LINQ?

狂风中的少年 提交于 2019-12-10 01:42:56
问题 I've been looking quite a bit at Mr. Skeet's blog on how to re-implement LINQ. In particular, he states that the code: var list = (from person in people where person.FirstName.StartsWith("J") orderby person.Age select person.LastName) .ToList(); is translated to methods that are extension methods that are provided by the LINQ library: people.Where(person => person.FirstName.StartsWith("J")) .OrderBy(person => person.Age) .Select(person => person.LastName) BY THE COMPILER. My question is, how

What is “override-equivalence” and how is it related to @Override?

一笑奈何 提交于 2019-12-10 00:52:21
问题 Reading the Javadoc for the @Override annotation, I came across the following rule: If a method is annotated with this annotation type compilers are required to generate an error message unless at least one of the following conditions hold: The method does override or implement a method declared in a supertype. The method has a signature that is override-equivalent to that of any public method declared in Object. I'm clear on the first point, but I'm unsure about the second one. What does it

Emulating Prolog backtracking in F#

≯℡__Kan透↙ 提交于 2019-12-09 18:15:20
问题 I am currently involved in a project to develop an application able to consider a set of nodes and connections and find the shortest path (a common and well-known issue) between two nodes (on allowed connections). Well I don't really have to build an application from zero, but just need to "convert" a Prolog pre-existing application in f#. I thought I bit about it and finally asked myself one question: "Instead of developing a special purpose solution and implementing new algorithms