grammar

Parse::RecDescent grammar not working as expected

◇◆丶佛笑我妖孽 提交于 2020-02-24 08:56:12
问题 All I managed to get working is STRING, PARAMS, VARIABLE and FUNCNAME There seems to be a problem with FUNCTION, but I just can't see it. use strict; use Parse::RecDescent; $::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error $::RD_WARN = 1; # Enable warnings. This will warn on unused rules &c. $::RD_HINT = 1; # Give out hints to help fix problems. my $grammar = <<'_GRAMMAR_'; SCRIPT : INSTRUCTION(s /;/) INSTRUCTION: FUNCTION | VARIABLE "=" FUNCTION FUNCTION : FUNCNAME "[

Parse::RecDescent grammar not working as expected

拈花ヽ惹草 提交于 2020-02-24 08:56:07
问题 All I managed to get working is STRING, PARAMS, VARIABLE and FUNCNAME There seems to be a problem with FUNCTION, but I just can't see it. use strict; use Parse::RecDescent; $::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error $::RD_WARN = 1; # Enable warnings. This will warn on unused rules &c. $::RD_HINT = 1; # Give out hints to help fix problems. my $grammar = <<'_GRAMMAR_'; SCRIPT : INSTRUCTION(s /;/) INSTRUCTION: FUNCTION | VARIABLE "=" FUNCTION FUNCTION : FUNCNAME "[

Differentiate a block from an object initializer

倾然丶 夕夏残阳落幕 提交于 2020-02-19 12:35:15
问题 This is more a theoretical question than a practical one. It's about the parsing of some code delimited by curly braces. Here are two examples of object initializers : f({}); ({a:3}) Here are two examples of blocks : ;{} {a:3;} In practice, it seems that {...} makes a block apart if the precedent code requires an expression. But I've never seen such a rule explicit or made obvious in the ECMAScript specification and I'm not even sure it's true. Is there a definitive non ambiguous reference

Differentiate a block from an object initializer

北城余情 提交于 2020-02-19 12:35:14
问题 This is more a theoretical question than a practical one. It's about the parsing of some code delimited by curly braces. Here are two examples of object initializers : f({}); ({a:3}) Here are two examples of blocks : ;{} {a:3;} In practice, it seems that {...} makes a block apart if the precedent code requires an expression. But I've never seen such a rule explicit or made obvious in the ECMAScript specification and I'm not even sure it's true. Is there a definitive non ambiguous reference

AS3 Grammar: Most accurate

房东的猫 提交于 2020-01-31 05:12:19
问题 I'm looking for an accurate AS3 grammar (format in not an issue, but I presume ANTLR will feature the most) to use for a practice grammar I'm making. What is the most accurate grammar available for AS3? 回答1: I think this one is pretty accurate if you are looking for an ANTLR grammar: AS3.g This grammar has been originally developed a couple of years ago by Martin Schnable and then extended for the Meta-AS project. There are of course other ActionScript 3 parsers available as well, but they do

How to modify parsing grammar to allow assignment and non-assignment statements?

丶灬走出姿态 提交于 2020-01-24 15:46:11
问题 So the question is about the grammar below. I'm working on a mini-interpreted language for fun (we learned about some compiler design in class, so I want to take it to the next level and try something on my own). I'm stuck trying to make the non-terminal symbol Expr . Statement ::= Expr SC Expr ::= /* I need help here */ Assign ::= Name EQUAL Expr AddSub ::= MulDiv {(+|-) AddSub} MulDiv ::= Primary {(*|/) MulDiv} Primary ::= INT | FLOAT | STR | LP Expr RP | Name Name ::= ID {. Name} Expr has

How to write a bison grammar for WDI?

我的梦境 提交于 2020-01-24 15:38:06
问题 I need some help in bison grammar construction. From my another question: I'm trying to make a meta-language for writing markup code (such as xml and html) which can be directly embedded into C/C++ code. Here is a simple sample written in this language, I call it WDI (Web Development Interface): /* * Simple wdi/html sample source code */ #include <mySite> string name = "myName"; string toCapital(string str); html { head { title { mySiteTitle; } link(rel="stylesheet", href="style.css"); } body

Parse function call with PyParsing

妖精的绣舞 提交于 2020-01-23 10:47:12
问题 I'm trying to parse a simple language. The trouble comes with parsing function calls. I'm trying to tell it that a function call is an expression followed by left parenthesis, argument list, and right parenthesis. I have something like this: expr = Forward() iden = Word(alphas+'_', alphanums+'_') integer = Word(nums) binop = operatorPrecedence(expr, ...) # irrevelant call = expr + Literal('(') + delimitedList(expr) + Literal(')') expr << call | integer | iden The problem is obvious: expr is

Is there a way or an algorithm to convert DCG into normal definite clauses in Prolog?

不想你离开。 提交于 2020-01-21 07:15:33
问题 I am a newbie in Prolog, and I am trying to understand how a grammar can be translated into a normal definite clause from a DCG. I understood that DCG notation is just syntactic sugar for normal definite clauses in Prolog. I started to depict some similarities between the normal definite grammars, and the DCGs, but failed to apply the same pattern, so I am asking is there some rules that I am missing or an algorithm of conversion that might work. Here is the grammar that I am working on, and

Speech Recognition with free speech

淺唱寂寞╮ 提交于 2020-01-16 03:30:06
问题 I need help. I want to make an application that will recognize what I am saying and do stuff that I say. For example: If I say open [notepad] , where [notepad] can be any application name, it needs to open notepad. I think I need to use both Grammar and DictationGrammar , but I don't know how. Please help me. Thanks. My code now looks like this: string WelcomeSentence = "Hello sir, how are you today"; SpeechSynthesizer sSynth = new SpeechSynthesizer(); PromptBuilder pBuilder = new