language-theory

Can someone give a simple but non-toy example of a context-sensitive grammar? [closed]

这一生的挚爱 提交于 2019-11-29 10:34:36
问题 I'm trying to understand context-sensitive grammars, and I understand why languages like {ww | w is a string} {a n b n c n | a,b,c are symbols} are not context free, but what I'd like to know if a language similar to the untyped lambda calculus is context sensitive. I'd like to see an example of a simple, but non-toy (I consider the above toy examples), example of a context-sensitive grammar that can, for some production rule, e.g., tell whether or not some string of symbols is in scope

what exactly is a “register machine”?

不问归期 提交于 2019-11-28 20:05:13
问题 From http://code.google.com/p/unladen-swallow/wiki/ProjectPlan I quote: "Using a JIT will also allow us to move Python from a stack-based machine to a register machine, which has been shown to improve performance in other similar languages (Ierusalimschy et al, 2005; Shi et al, 2005)." In college I built a simple compiler for a language with recursive procedures - which maintained stack frames for each procedure called - so that they can be called recursively and so that parameters and return

Is HTML a context-free language?

一世执手 提交于 2019-11-28 03:39:52
Reading some related questions made me think about the theoretical nature of HTML. I'm not talking about XHTML-like code here. I'm talking about stuff like this crazy piece of markup, which is perfectly valid HTML(!) <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html<head> <title// <p ltr<span id=p></span</p> </> So given the enormous complexity that SGML injects here, is HTML a context-free language? Is it a formal language anyway? With a grammar? What about HTML5? I'm new to the concept of formal languages, so please bear with me. And yes, I have read the wikipedia article ;) Context

Is HTML a context-free language?

一个人想着一个人 提交于 2019-11-27 05:10:23
问题 Reading some related questions made me think about the theoretical nature of HTML. I'm not talking about XHTML-like code here. I'm talking about stuff like this crazy piece of markup, which is perfectly valid HTML(!) <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html<head> <title// <p ltr<span id=p></span</p> </> So given the enormous complexity that SGML injects here, is HTML a context-free language? Is it a formal language anyway? With a grammar? What about HTML5? I'm new to the

often used seldom defined terms: lvalue

依然范特西╮ 提交于 2019-11-26 22:14:55
What is an lvalue? An lvalue is a value that can be assigned to: lvalue = rvalue; It's short for "left value" or "lefthand value" and it's basically just the value on the left of the = sign, i.e. the value you assign something to. As an example of what is not an lvalue (i.e rvalue only): printf("Hello, world!\n") = 100; // WTF? That code doesn't work because printf() (a function that returns an int ) cannot be an lvalue, only an rvalue. It's traditionally the left side of the "=" operator. However, with time, meaning of "lvalue"/"rvalue" changed. C++ added the term of a "non-modifiable lvalue"

Can all iterative algorithms be expressed recursively?

孤街醉人 提交于 2019-11-26 16:05:41
If not, is there a good counter example that shows an iterative algorithm for which there exists no recursive counterpart? If it is the case that all iterative algorithms can be expressed recursively, are there cases in which this is more difficult to do? Also, what role does the programming language play in all this? I can imagine that Scheme programmers have a different take on iteration (= tail-recursion) and stack usage than Java-only programmers. There's a simple ad hoc proof for this. Since you can build a Turing complete language using strictly iterative structures and a Turning

Learning Resources on Parsers, Interpreters, and Compilers [closed]

被刻印的时光 ゝ 提交于 2019-11-26 15:47:19
I've been wanting to play around with writing my own language for a while now (ostensibly for the learning experience) and as such need to be relatively grounded in the construction of Parsers, Interpreters, and Compilers. So: Does anyone know of any good resources on constructing Parsers, Interpreters, and Compilers? EDIT: I'm not looking for compiler-compilers/parser-compilers such as Lex, Yacc and Bison... The best paper I ever read on compilers is dated 1964 "META II a syntax-oriented compiler writing language" by Val Schorre. ( http://doi.acm.org/10.1145/800257.808896 ) In 10 pages, he

often used seldom defined terms: lvalue

我与影子孤独终老i 提交于 2019-11-26 08:16:47
问题 What is an lvalue? 回答1: An lvalue is a value that can be assigned to: lvalue = rvalue; It's short for "left value" or "lefthand value" and it's basically just the value on the left of the = sign, i.e. the value you assign something to. As an example of what is not an lvalue (i.e rvalue only): printf("Hello, world!\n") = 100; // WTF? That code doesn't work because printf() (a function that returns an int ) cannot be an lvalue, only an rvalue. 回答2: It's traditionally the left side of the "="

What is the exact problem with multiple inheritance?

百般思念 提交于 2019-11-26 06:43:30
I can see people asking all the time whether multiple inheritance should be included into the next version of C# or Java. C++ folks, who are fortunate enough to have this ability, say that this is like giving someone a rope to eventually hang themselves. What’s the matter with multiple inheritance? Are there any concrete samples? benjismith The most obvious problem is with function overriding. Let's say have two classes A and B , both of which define a method doSomething . Now you define a third class C , which inherits from both A and B , but you don't override the doSomething method. When

What is the exact problem with multiple inheritance?

夙愿已清 提交于 2019-11-26 01:13:47
问题 I can see people asking all the time whether multiple inheritance should be included into the next version of C# or Java. C++ folks, who are fortunate enough to have this ability, say that this is like giving someone a rope to eventually hang themselves. What’s the matter with multiple inheritance? Are there any concrete samples? 回答1: The most obvious problem is with function overriding. Let's say have two classes A and B , both of which define a method doSomething . Now you define a third