formal-languages

Scope of XML languages defined by DTD vs XSD

半世苍凉 提交于 2019-12-04 09:41:14
Does the following propositions hold: For every DTD there is an XSD that defines exactly the same language, and for every XSD there is a DTD that defines exactly the same language. Or put another way: The collection of languages defined by any DTD is exactly the the collection of languages defined by any XSD? Expanding on the question a little: An XML document is basically a large string. A language is a collection of strings. For example, the (infinite) set of all MathML documents is a language, and so is the set of all RSS documents and so on. MathML (RSS, ...) is also a proper subset of the

Why can't I specify the storage class for formal parameters of a function?

萝らか妹 提交于 2019-12-03 14:02:57
When I do as below the code works fine : #include <stdio.h> void test( int a) { printf("a=%d\n",a); } int main() { test(10); return 1; } But when I do #include <stdio.h> void test( auto int a) // Or static int a Or extern int a { printf("a=%d\n",a); } int main() { test(10); return 1; } It generates an error, error: storage class specified for parameter 'a' Why is that error? What happens internally(memory management)? But it works fine without any error when I do: void test( register int a) { printf("a=%d\n",a); } Why is that? First,quoting C11 , chapter 6.7.6.3 The only storage-class

Distance between regular expression

浪尽此生 提交于 2019-12-03 13:31:40
Can we compute a sort of distance between regular expressions ? The idea is to mesure in which way two regular expression are similar. There are a few of metrics you could use: The length of a valid match. Some regexs have a fixed size, some an upper limit and some a lower limit. Compare how similar their lengths or possible lengths are. The characters that match. Any regex will have a set of characters a match can contain (maybe all characters). Compare the set of included characters. Use a large document and see how many matches each regex makes and how many of those are identical. Are you

PDA to accept a language of strings containing more a's than b's

老子叫甜甜 提交于 2019-12-03 08:44:06
Produce a PDA to recognise the following language : the language of strings containing more a's than b's I have been struggling with this question for several days now, I seem to have hit a complete mental block. Would any one be able to provide some guidance or direction to how I can solve this problem? Divyanjali Your problem of "more a's than b's" can be solved by PDA. All you have to do is: When input is a and the stack is either empty or has an a on the top, push a on the stack; pop b , if b is the top. When input is b and the stack is either empty or has an b on the top, push b on the

chomsky hierarchy and programming languages

最后都变了- 提交于 2019-12-03 07:14:54
问题 I'm trying to learn some aspects of the Chomsky Hierarchy which are related to programming languages, and i still have to read the Dragon Book. I've read that most programming languages can be parsed as a context free grammar (CFG). In term of computational power, it equals the one of a pushdown non deterministic automaton. Am I right? If it's true, then how could a CFG hold an unrestricted grammar (UG), which is turing complete? I'm asking because, even if programming languages are described

Writing a formal language parser with Lisp

£可爱£侵袭症+ 提交于 2019-11-30 07:10:37
My company is designing a new domain specific scripting language; I have to implement a parser that translates our brand new programming language into a common scripting language so as to be able to enact it. The usual way I do this is by means of Bison and Flex tools that generate the C/C++ code of the translator. I found other tools, for most of the mainstream programming languages, but none for Lisp . Hasn't Lisp ever been used for that? What is the usual way to write a parser with Lisp ? Note: to me, any Lisp implementation / dialect that could help is ok, I do not have any preference. To

Why do we need prefix, postfix notation

和自甴很熟 提交于 2019-11-29 20:41:43
I know how each of them can be converted to one another but never really understood what their applications are. The usual infix operation is quite readable, but where does it fail which led to inception of prefix and postfix notation Infix notation is easy to read for humans , whereas pre-/postfix notation is easier to parse for a machine. The big advantage in pre-/postfix notation is that there never arise any questions like operator precedence. For example, consider the infix expression 1 # 2 $ 3 . Now, we don't know what those operators mean, so there are two possible corresponding postfix

Writing a formal language parser with Lisp

醉酒当歌 提交于 2019-11-29 09:42:28
问题 My company is designing a new domain specific scripting language; I have to implement a parser that translates our brand new programming language into a common scripting language so as to be able to enact it. The usual way I do this is by means of Bison and Flex tools that generate the C/C++ code of the translator. I found other tools, for most of the mainstream programming languages, but none for Lisp . Hasn't Lisp ever been used for that? What is the usual way to write a parser with Lisp ?

Reading numbers as strings

泪湿孤枕 提交于 2019-11-29 02:05:42
I am new at R programming and I want to read a text file in R. One of the columns, lets say column 7 is numeric and each number represent an ID I want R to read the numbers as if they were strings. And count the number of times each ID appear in the file (such that later I can assign the frequency of each ID to the given ID for latter use) I have tried mydata<-(read.table(filename.txt)) ID=mydata[7] freq=table(ID) This works but it takes the IDs as numbers. Now I have tried freq=table(as.character(ID)) But then it takes the whole column ID as only one string and from summary(freq) I get Number

Why do we need prefix, postfix notation

大憨熊 提交于 2019-11-28 16:46:58
问题 I know how each of them can be converted to one another but never really understood what their applications are. The usual infix operation is quite readable, but where does it fail which led to inception of prefix and postfix notation 回答1: Infix notation is easy to read for humans , whereas pre-/postfix notation is easier to parse for a machine. The big advantage in pre-/postfix notation is that there never arise any questions like operator precedence. For example, consider the infix