grammar

if statement in R can only have one line?

依然范特西╮ 提交于 2019-11-29 02:52:11
问题 I was trying a tiny code with if statement, although it is very simple,but there is something I really confused here is the code n<-857 while(n!=1){ if(n<=0) print("please input a positive integer") else if(n%%2==0) n<-n/2 print(n) else n<-3*n+1 print(n) } as we see above,when running this code in R, there comes the error,but if I change the if statement like this if(n<=0) print("please input a positive integer") else if(n%%2==0) n<-n/2 else n<-3*n+1 it is ok ,my question is that can we only

How do assembly languages work?

拥有回忆 提交于 2019-11-29 02:46:59
问题 I'm very curious how assembly languages work- I remain general because I'm not talking only about intel x86 assembly (although it's the only one I'm remotely familiar with). To be a bit more clear... mov %eax,%ebx How does the computer know what an instruction like "mov" does? How does it know that eax and ebx are registers? Do people write grammars for assembly languages? How do they write this? I imagine nothing is stopping someone from writing an assembly language that substitutes the mov

Objective-C standards document

北城以北 提交于 2019-11-29 01:53:56
问题 I'm a C and C++ programmer trying to get started with Objective-C. I'm really bewildered, though, by the apparent total absence of a standards document for the language and standard library. I can understand that there's no ISO standard, but is there no reference document at all? And how is it that nobody seems very concerned about this state of affairs? (Admittedly, it's hard to Google for such a thing, because "reference", "document", and "standard" are all overloaded terms. So it's

Parsing grammars using OCaml

∥☆過路亽.° 提交于 2019-11-29 01:30:40
问题 I have a task to write a (toy) parser for a (toy) grammar using OCaml and not sure how to start (and proceed with) this problem. Here's a sample Awk grammar: type ('nonterm, 'term) symbol = N of 'nonterm | T of 'term;; type awksub_nonterminals = Expr | Term | Lvalue | Incrop | Binop | Num;; let awksub_grammar = (Expr, function | Expr -> [[N Term; N Binop; N Expr]; [N Term]] | Term -> [[N Num]; [N Lvalue]; [N Incrop; N Lvalue]; [N Lvalue; N Incrop]; [T"("; N Expr; T")"]] | Lvalue -> [[T"$"; N

C grammar in GCC source code

青春壹個敷衍的年華 提交于 2019-11-29 01:21:20
问题 I'm looking for the C grammar in GCC source code, more specifically for the grammar in the yacc/bison form. 回答1: Found the C grammar in Yacc specification in the GCC version 3.3 in the file "c-parse.y" 回答2: You will not find a C grammar yacc/bison file within the current GCC source code. It was done in the past, before the egcs fork stuff. I cannot give you the exact version and location, but i can tell you that it should be in the 2.x release The current version of GCC has its own C parser

Open Source Grammar Checker [closed]

随声附和 提交于 2019-11-28 23:05:47
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . For an online project I'm working on, I am looking for a open source grammar checker. I have searched Google, with some good results (http://www.link.cs.cmu.edu/link/, etc), but I am wondering what all of you think about this topic. I need this to be able to be used online, versus desktop based, but this is the

Is there a fast algorithm to determine the godel number of a term of a context free language?

℡╲_俬逩灬. 提交于 2019-11-28 20:47:02
Suppose we have a simple grammar specification. There is a way to enumerate terms of that grammar that guarantees that any finite term will have a finite position, by iterating it diagonally . For example, for the following grammar: S ::= add add ::= mul | add + mul mul ::= term | mul * term term ::= number | ( S ) number ::= digit | digit number digit ::= 0 | 1 | ... | 9 You can enumerate terms like that: 0 1 0+0 0*0 0+1 (0) 1+0 0*1 0+0*0 00 ... etc My question is: is there a way to do the opposite? That is, to take a valid term of that grammar, say, 0+0*0 , and find its position on such

Finding meaningful sub-sentences from a sentence

 ̄綄美尐妖づ 提交于 2019-11-28 18:01:24
Is there a way to to find all the sub-sentences of a sentence that still are meaningful and contain at least one subject, verb, and a predicate/object? For example, if we have a sentence like "I am going to do a seminar on NLP at SXSW in Austin next month". We can extract the following meaningful sub-sentences from this sentence: "I am going to do a seminar", "I am going to do a seminar on NLP", "I am going to do a seminar on NLP at SXSW", "I am going to do a seminar at SXSW", "I am going to do a seminar in Austin", "I am going to do a seminar on NLP next month", etc. Please note that there is

Is there a standard C++ grammar?

浪尽此生 提交于 2019-11-28 16:52:27
Does the standard specify the official C++ grammar? I searched, but did not find it anywhere. Also, I wish to read a bit about C++ grammar in detail, like which category of grammars it falls in, etc. Any links pointing me in the right direction would be helpful. By category, I mean taken from here . James McNellis Yes, it does. The grammar is described in detail throughout the standard and is summarized in Appendix A: Grammar Summary (it's Appendix A in both the C++03 standard and the C++0x final committee draft). You can purchase the C++03 standard or you can download the C++0x FCD (it's

What is the difference between LR, SLR, and LALR parsers?

别说谁变了你拦得住时间么 提交于 2019-11-28 15:02:14
What is the actual difference between LR, SLR, and LALR parsers? I know that SLR and LALR are types of LR parsers, but what is the actual difference as far as their parsing tables are concerned? And how to show whether a grammar is LR, SLR, or LALR? For an LL grammar we just have to show that any cell of the parsing table should not contain multiple production rules. Any similar rules for LALR, SLR, and LR? For example, how can we show that the grammar S --> Aa | bAc | dc | bda A --> d is LALR(1) but not SLR(1)? EDIT (ybungalobill) : I didn't get a satisfactory answer for what's the difference