grammar

Keyword or keyphrase spotting with Sphinx4

夙愿已清 提交于 2020-01-11 03:41:07
问题 I am currently trying to make my java code (using eclipse) perform some function if a certain thing is said. I am using the Sphinx4 libraries and this is what I currently have: What I would like it to do is at the line where it says: IF (TRUE) someFunction(); is to run the function if my speech is Hello Computer, Hello Jarvis, Good Morning Computer, or Good Morning Jarvis. Or in other words, run the function if the speech matches the "public < greet >" line of code in the .gram file. Even

ANTLR4 mutual left recursion grammar

醉酒当歌 提交于 2020-01-10 05:45:06
问题 I have read many questions here on StackOverflow about mutual left-recursion issues in LL(k) parsers. I found the general algorithm for removing left-recursion: A : Aa | b ; becomes A : bR ; R : (aA)? ; However, I cannot figure out how to apply it to my situation. I have left_exp: IDENT | exp DOT IDENT ; exp : handful | of | other rules | left_exp ; The "handful of other rules" all contain regular recursion, such as exp : exp PLUS exp , etc. and have no issues. The issue is with left_exp and

right linear context free grammar

好久不见. 提交于 2020-01-07 06:38:28
问题 I've a problem. I have to write right linear context free grammar with alphapet={0,1} where the numbers of 0 will be even and the numbers od 1 will be odd. I tried write sth. but it's doesn't work. s --> [1],a. s --> [0],b. a --> []. a --> [1],c. a --> [0],b. c --> [1],k. c --> [0],b. b --> [0],k. b --> [1],d. d --> [1],b. d --> [0],c. k --> []. k --> s. Grammar should accept even amount of 0s and odd amount of 1s. Grammar context free is right linear when A->wB or A->w where w is any word

ANTLR3 grammar does not match rule with predicate

这一生的挚爱 提交于 2020-01-06 04:16:29
问题 I have a combined grammar where I need to provide for two identifier lexer rules. Both identifiers can be used at the same time. Identifier1 comes before Identifer2 in grammar. First identifier is static, whereas second identifier rule changes on the basis of some flag.(Using predicate). I want the second identifier to match in parser rules. But as both identifiers may match some common inputs, It does not fall on identifer2. I have created small grammar to make it understandable. Grammar is

Prolog Looping Redo's

限于喜欢 提交于 2020-01-06 01:33:07
问题 I am trying to write a small program in Prolog(gnu) that will take user input and give true or false to the question "Is this a valid sentence in this grammar?" I have had a lot of trouble finding solid documentation on Prolog, and if anyone has a reliable source that would be appreciated. From what I have found, this code for the most part should work. When I try to trace the execution, I get strange results that I do not understand. The test case I am working with now is when the user

AntlrWorks & language grammar errors

放肆的年华 提交于 2020-01-05 07:50:12
问题 Working on a game project that involves a scripting language that I want to interpret into a virtual machine code that can be executed directly. I've included the grammar below. All the lexer rules are displaying properly in the syntax diagram, but when I click on the bodies of any of the parser rules, I get "Cannot display rule "X" because start state is not found" for a given parser rule X. I'm not really sure why ANTLR is complaining about not having a start state. The grammar should

Does .parse anchor or :sigspace first in a Perl 6 rule?

拜拜、爱过 提交于 2020-01-04 09:12:10
问题 I have two questions. Is the behavior I show correct, and if so, is it documented somewhere? I was playing with the grammar TOP method. Declared as a rule , it implies beginning- and end-of-string anchors along with :sigspace : grammar Number { rule TOP { \d+ } } my @strings = '137', '137 ', ' 137 '; for @strings -> $string { my $result = Number.parse( $string ); given $result { when Match { put "<$string> worked!" } when Any { put "<$string> failed!" } } } With no whitespace or trailing

Parse single quoted string using Marpa:r2 perl

跟風遠走 提交于 2020-01-04 06:03:21
问题 How to parse single quoted string using Marpa:r2? In my below code, the single quoted strings appends '\' on parsing. Code: use strict; use Marpa::R2; use Data::Dumper; my $grammar = Marpa::R2::Scanless::G->new( { default_action => '[values]', source => \(<<'END_OF_SOURCE'), lexeme default = latm => 1 :start ::= Expression # include begin Expression ::= Param Param ::= Unquoted | ('"') Quoted ('"') | (') Quoted (') :discard ~ whitespace whitespace ~ [\s]+ Unquoted ~ [^\s\/\(\),&:\"~]+ Quoted

Parse single quoted string using Marpa:r2 perl

安稳与你 提交于 2020-01-04 06:03:10
问题 How to parse single quoted string using Marpa:r2? In my below code, the single quoted strings appends '\' on parsing. Code: use strict; use Marpa::R2; use Data::Dumper; my $grammar = Marpa::R2::Scanless::G->new( { default_action => '[values]', source => \(<<'END_OF_SOURCE'), lexeme default = latm => 1 :start ::= Expression # include begin Expression ::= Param Param ::= Unquoted | ('"') Quoted ('"') | (') Quoted (') :discard ~ whitespace whitespace ~ [\s]+ Unquoted ~ [^\s\/\(\),&:\"~]+ Quoted

Partial grammar for counting class count

社会主义新天地 提交于 2020-01-04 02:27:18
问题 I need to count the number of classes in correct C# source file. I wrote the following grammar: grammar CSharpClassGrammar; options { language=CSharp2; } @parser::namespace { CSharpClassGrammar.Generated } @lexer::namespace { CSharpClassGrammar.Generated } @header { using System; using System.Collections.Generic; } @members { private List<string> _classCollector = new List<string>(); public List<string> ClassCollector { get { return _classCollector; } } } /*-----------------------------------