grammar

Free-form text with custom SRGS based Grammar

末鹿安然 提交于 2019-12-05 20:53:22
I am trying to develop a Voice based application that would accept user input as speech and perform some actions based on the input. This is my first ever venture into this technology and I am learning while developing it. I am using Microsoft SAPI shipped with dotnet 4 to recognize speech. So far, I have learned about the two types of modes it supports. Speech recognition (SR) has two modes of operation: Dictation mode — an unconstrained, free-form speech interpretation mode that uses a built-in grammar provided by the recognizer for a specific language. This is the default recognizer.

Translate ANTLR grammar into XText grammar: how to remove syntactic predicates

本秂侑毒 提交于 2019-12-05 20:25:13
I'm new to both Xtext and ANTLR. I need to translate an ANTLR (.g) grammar into an XTEXT (.xtext) grammar. In the ANTLR grammar there are syntactic predicates which are not supported by Xtext. Is there a way to remove/translate these predicates? Thanks EDIT The ANTLR grammar which I'm trying to translate can be found here: /* * Copyright 2009, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright

Grammar for expressions which disallows outer parentheses

老子叫甜甜 提交于 2019-12-05 20:22:58
I have the following grammar for expressions involving binary operators (| ^ & << >> + - * /): expression : expression BITWISE_OR xor_expression | xor_expression xor_expression : xor_expression BITWISE_XOR and_expression | and_expression and_expression : and_expression BITWISE_AND shift_expression | shift_expression shift_expression : shift_expression LEFT_SHIFT arith_expression | shift_expression RIGHT_SHIFT arith_expression | arith_expression arith_expression : arith_expression PLUS term | arith_expression MINUS term | term term : term TIMES factor | term DIVIDE factor | factor factor :

Parse Variables Using DCG

左心房为你撑大大i 提交于 2019-12-05 20:12:45
I am having trouble parsing sequences that begin with capital letters into variables using Prolog's DCG notation. For instance, if I have the string f a X y Z X and a DCG that parses this string, is there any way to parse each capitalized letter into a unique Prolog variable. E.g., parse Y to a variable and each X to a variable? The intended application would be to build the functor T = f(a,X,y,Z,X) via a DCG rule ending with the statement {T =.. [Head|Args]} Maybe you are looking for term_to_atom/3 : ?- term_to_atom(Term, 'f(a,X,y,Z,X)'). Term = f(a, _G304, y, _G306, _G304). If you are using

ANTLR Implicit Multiplication

纵饮孤独 提交于 2019-12-05 18:12:55
I'm new to ANTLR, and I'm trying to expand upon the example of a simple calculator presented here . Specifically, I've tried adding some simple functions, negative numbers and so on, to familiarize myself with ANTLR. However, I've run into a bit of a problem trying to implement "implicit" multiplication (for example, 3cos(2)sin(2) would be interpreted as 3*cos(2)*sin(2)). I've found a question on Stack Overflow with the same kind of problem ( here ). The general form of the solution to that problem looks like what I'd found on my own, so I'm not sure where my problem lies. My grammar is below.

Parsing python with PLY, how to code the indent and dedent part

北慕城南 提交于 2019-12-05 17:57:47
I was trying to parse the function definition for the python language with PLY. I am encountering issues related to the indentation. For instance for a for statement, I would like to be able to know when the block ends. I read the python grammar here: http://docs.python.org/2/reference/grammar.html And the grammar for this part is: for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT I don't know how to describe the INDENT and DEDENT tokens with PLY. I was trying something like: def t_indentation(t): r' |\t' #some special

boost::Spirit Grammar for unsorted schema

五迷三道 提交于 2019-12-05 17:52:22
I have a section of a schema for a model that I need to parse. Lets say it looks like the following. { type = "Standard"; hostname="x.y.z"; port="123"; } The properties are: The elements may appear unordered. All elements that are part of the schema must appear, and no other. All of the elements' synthesised attributes go into a struct. (optional) The schema might in the future depend on the type field -- i.e., different fields based on type -- however I am not concerned about this at the moment. According to the Spirit forums, the following is the answer. You might want to have a look at the

Shift/reduce conflicts in bison

元气小坏坏 提交于 2019-12-05 17:14:23
问题 I'm new to Bison and I'm having trouble with shift/reduce conflicts... I'm trying to load from file to array data[] : struct _data { char name[50]; char surname[50]; int year; } data[1000]; Here is part of my bison code: %token ID NUM NL EOF %% File : List EOF ; List : Record | List Record ; Record : Name Surname Year NL { count++; } | NL { count++; } | /*empty*/ ; Name : ID { strcpy(data[count].name, yytext); } ; Surname: ID { strcpy(data[count].surname, yytext); } ; Year : NUM { data[count]

Antlr Error Strategy to skip tokens until rule matches again

不羁岁月 提交于 2019-12-05 16:12:31
I tried this solution but it didn't seem to work for me Here's an excerpt from my grammer: module : BEGIN MODULE IDENT STRING module_element* END MODULE ; module_element : element_1 | element_2 | element_3 | ... ; There is a bigger tree below each element. Now when a RecognitionException occurs I want to consume tokens until either the next module_element matches or the parent END MODULE matches. Any hints on how to do this inside a class inheriting from DefaultErrorStrategy? edit: Here is a MCVE: Program.cs namespace AntlrExample { class Program { static void Main(string[] args) { var

Using declaration for type-dependent template name

丶灬走出姿态 提交于 2019-12-05 12:45:43
问题 When CRTP is used inside a template, (or generally when a template parameter is passed as a base class template argument), is it impossible to name the base's member templates in a using declaration? template< typename d > struct base { template< typename > struct ct {}; template< typename > void ft() {} }; template< typename x > struct derived : base< derived< x > > { using derived::base::template ct; // doesn't work using derived::base::ft; // works but can't be used in a template-id }; It