grammar

Speech Recognition API without Grammar C#

一个人想着一个人 提交于 2019-11-29 15:01:03
I am developing a program where 99% of the time i can use a set Grammar in the standard Microsoft Speech Recognition to detect words being said. However in a few circumstances, i need the user to say something. This is never going to be predictable. So is there a way to do this with the MS speech recognition? And are there any other speech recognition API's out there (for free), that can handle non-preset words? There is a class called DictationGrammar that allows you to recognize dictated speech. It also supports a "dictation context" - so you can specify that the dictated text should start

Does typedef in C/C++ really create a NEW type by combining the compound type (e.g. int*)?

不打扰是莪最后的温柔 提交于 2019-11-29 14:20:00
recently I found typedef in my code works really different than what I proposed. An example like this: typedef int *ptype; ptype v1 = 0, v2 = 0; The result: both v1 and v2 were defined as a pointer to int type. But if you simply replace ptype by int * in the second sentence as int *v1 = 0, v2 = 0; or int* v1 = 0, v2 =0; , only v1 will be the pointer and v2 is normal int . It seems typedef does not do a simple replacement. What's more, when it comes to complicate modifier like: typedef int *ptype; const ptype v3 = 0; The result will be: v3 is a const pointer, not a pointer to the const int if

Antlr4 unexpectedly stops parsing expression

时光总嘲笑我的痴心妄想 提交于 2019-11-29 12:13:14
I'm developing a simple calculator with the formula grammar: grammar Formula ; expr : <assoc=right> expr POW expr # pow | MINUS expr # unaryMinus | PLUS expr # unaryPlus | expr PERCENT # percent | expr op=(MULTIPLICATION|DIVISION) expr # multiplyDivide | expr op=(PLUS|MINUS) expr # addSubtract | ABS '(' expr ')' # abs | '|' expr '|' # absParenthesis | MAX '(' expr ( ',' expr )* ')' # max | MIN '(' expr ( ',' expr )* ')' # min | '(' expr ')' # parenthesis | NUMBER # number | '"' COLUMN '"' # column ; MULTIPLICATION: '*' ; DIVISION: '/' ; PLUS: '+' ; MINUS: '-' ; PERCENT: '%' ; POW: '^' ; ABS:

How to control error handling and synchronization in Antlr 4 / c#

点点圈 提交于 2019-11-29 12:05:08
I'm using Antlr 4 with c# target. Here is a subset of my grammar: /* * Parser Rules */ text : term+ EOF; term : a1 a2 a3; a1: .... ... ... I want to accept valid data blocks as (term)s, when error exists I want to search for the next valid term and print out the whole text which caused the error for user to analyze manually. How to synchronize input to the next valid term? and How to get the ignored text? You will need to create your own implementation of IAntlrErrorStrategy for this, and then set the Parser.ErrorHandler property to an instance of your error strategy. The documentation for the

Why can't a LL grammar be left-recursive?

主宰稳场 提交于 2019-11-29 11:21:45
问题 In the dragon book , LL grammar is defined as follows: A grammar is LL if and only if for any production A -> a|b , the following two conditions apply. FIRST(a) and FIRST(b) are disjoint. This implies that they cannot both derive EMPTY If b can derive EMPTY , then a cannot derive any string that begins with FOLLOW(A) , that is FIRST(a) and FOLLOW(A) must be disjoint. And I know that LL grammar can't be left recursive, but what is the formal reason? I guess left-recursive grammar will

How to match any symbol in ANTLR parser (not lexer)?

孤者浪人 提交于 2019-11-29 10:37:54
How to match any symbol in ANTLR parser (not lexer)? Where is the complete language description for ANTLR4 parsers? UPDATE Is the answer is "impossible"? You first need to understand the roles of each part in parsing: The lexer: this is the object that tokenizes your input string. Tokenizing means to convert a stream of input characters to an abstract token symbol (usually just a number). The parser: this is the object that only works with tokens to determine the structure of a language. A language (written as one or more grammar files) defines the token combinations that are valid. As you can

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

C11 grammar ambiguity between _Atomic type specifier and qualifier

拜拜、爱过 提交于 2019-11-29 09:35:59
I'm trying to write a lex/yacc grammar for C11 based off of N1570. Most of my grammar is copied verbatim from the informative syntax summary, but some yacc conflicts arose. I've managed to resolve all of them except for one: there seems to be some ambiguity between when '_Atomic' is used as a type specifier and when it's used as a type qualifier. In the specifier form, _Atomic is followed immediately by parentheses, so I'm assuming it has something to do with C's little-used syntax which allows declarators to be in parentheses, thus allowing parentheses to immediately follow a qualifier. But

How is the Python grammar used internally?

孤者浪人 提交于 2019-11-29 07:35:07
问题 I'm trying to get a deeper understanding of how Python works, and I've been looking at the grammar shown at http://docs.python.org/3.3/reference/grammar.html. I notice it says you would have to change parsermodule.c also, but truthfully I'm just not following what's going on here. I understand that a grammar is a specification for how to read the language, but...I can't even tell what this is written in. It looks almost like Python but then it isn't. I'm looking to get a better understanding

Removing left recursion

邮差的信 提交于 2019-11-29 07:08:52
The following grammar has left recursion E= E+T|T T= T*F|F F= a|b|c How to remove it? Is there any general procedure for it? Yes, there is a general procedure, see e.g. wikipedia . E = TE' E'= (e) | +TE' T = FT' T'= (e) | *FT' F = a | b | c It should be mentioned that this alters the associativity of + and * from left to right. That is, where before a + b + c was parsed as (a + b) + c , it is now parsed as a + (b + c) . This is not a problem for addition and multiplication, but it would be a problem for subtraction and division, for example. Wikipedia article has more detail on the left