syntax

comma (,) in C Macro Definition

巧了我就是萌 提交于 2020-01-13 13:13:06
问题 I've never seen this syntax before. #define SNS(s) (s),(sizeof(s)-1) The way i'm reading this is that SNS(s) = sizeof(s)-1 . What is the comma doing? Is it necessary? int ft_display_fatal(const char *err, unsigned len, int fd, int rcode) { UNUSED(write(fd, err, len)); return (rcode); } Main return (ft_display_fatal(SNS("File name missing.\n"), 2, 1)); 回答1: Macros are just text replacement, so they can expand to just about anything you want. In this case, the macro is being used to expand into

What are Context-Free Grammars and Backus Naur Form?

廉价感情. 提交于 2020-01-13 13:08:52
问题 Can someone please explain in layman's terms: what a context-free grammar is? what Backus Naur Form is? How to use this notation? How to do string derivation? How to describe language syntax? 回答1: A context-free grammar (CFG) G is a quadruple (V, Σ, R, S) where V: a set of non-terminal symbols Σ: a set of terminals (V ∩ Σ = Ǿ) R: a set of rules (R: V → (V U Σ)*) S: a start symbol Example of CFG: V = {q, f,} Σ = {0, 1} R = {q → 11q, q → 00f, f → 11f, f → ε} S=q (R= {q → 11q | 00f, f → 11f | ε

MVC3 Razor Syntax troubles

杀马特。学长 韩版系。学妹 提交于 2020-01-13 08:28:07
问题 I'm trying to make a very simple view using Razor syntax in MVC3, but it seems I can't get the syntax right. I have a simple table like this <table> <tr> @{ var counter = 0; } @foreach (var category in ViewBag.Categories) { counter++; <td> <input type="checkbox" checked="checked" name="@("category" + category.Code)" /> @category.Description </td> if (counter % 2 == 0) { </tr> <tr> } } </tr> </table> When I insert the and inside the if-statement, I receive this error The using block is missing

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:

风流意气都作罢 提交于 2020-01-13 02:10:26
06-Jan-2020 09:00:59.623 严重 [http-nio-8000-exec-25] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [SpringMVC] in context with path [/TeachingEvaluationSystem] threw exception [Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'index' at line 7 ### The error may exist in file [C:\Users

How to syntax highlight for Org-mode inline source code src_lang{}?

核能气质少年 提交于 2020-01-12 14:53:28
问题 Is there a way to syntax highlight Org-mode inline source code which is marked with src_ruby{Array.new} ? Does Org-mode has default option for this ? Or Is there other method to do this ? 回答1: UPDATE: the correct answer to this particular question is following https://stackoverflow.com/a/28059832/462601 . Answer presented here is related to this question Syntax highlighting within #+begin_src block in emacs orgmode not working You mean like syntax-highlighting source blocks in buffer? #+BEGIN

Differences between regex types

自闭症网瘾萝莉.ら 提交于 2020-01-12 07:03:14
问题 I'm reading the GNU find 's man page and stumbling upon this switch: -regextype type Changes the regular expression syntax understood by -regex and -iregex tests which occur later on the command line. Currently- implemented types are emacs (this is the default), posix-awk, posix- basic, posix-egrep and posix-extended. What's the difference between those regex syntaxes? I'm more familiar with Ruby's regex, so what type of regex should I use with find ? 回答1: Regular expressions are implemented

Java Lombok: Omitting one field in @AllArgsConstructor?

三世轮回 提交于 2020-01-12 03:55:07
问题 If I specify @AllArgsConstructor using Lombok , it will generate a constructor for setting all the declared (not final, not static) fields. Is it possible to omit some field and this leave generated constructor for all other fields? 回答1: No that is not possible. There is a feature request to create a @SomeArgsConstructor where you can specify a list of involved fields. Full disclosure: I am one of the core Project Lombok developers. 回答2: Alternatively you could use @RequiredArgsConstructor .

indexed object dot notation method gives scalar property

孤者浪人 提交于 2020-01-11 18:51:58
问题 I'm seeing an issue when I try and reference an object property after having used a dot notation to apply a method. it only occurs when I try to index the initial object classdef myclassexample properties data end methods function obj = procData(obj) if numel(obj)>1 for i = 1:numel(obj) obj(i) = obj(i).procData; end return end %do some processing obj.data = abs(obj.data); end end end then assigning the following A = myclassexample; A(1).data= - -1; A(2).data = -2; when calling the whole array

indexed object dot notation method gives scalar property

偶尔善良 提交于 2020-01-11 18:50:48
问题 I'm seeing an issue when I try and reference an object property after having used a dot notation to apply a method. it only occurs when I try to index the initial object classdef myclassexample properties data end methods function obj = procData(obj) if numel(obj)>1 for i = 1:numel(obj) obj(i) = obj(i).procData; end return end %do some processing obj.data = abs(obj.data); end end end then assigning the following A = myclassexample; A(1).data= - -1; A(2).data = -2; when calling the whole array

Associativity of “in” in Python?

我是研究僧i 提交于 2020-01-11 15:05:46
问题 I'm making a Python parser, and this is really confusing me: >>> 1 in [] in 'a' False >>> (1 in []) in 'a' TypeError: 'in <string>' requires string as left operand, not bool >>> 1 in ([] in 'a') TypeError: 'in <string>' requires string as left operand, not list How exactly does "in" work in Python, with regards to associativity, etc.? Why do no two of these expressions behave the same way? 回答1: 1 in [] in 'a' is evaluated as (1 in []) and ([] in 'a') . Since the first condition ( 1 in [] ) is