grammar

How is the Python grammar used internally?

大城市里の小女人 提交于 2019-11-30 06:53:25
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 of this specification and how it is used internally by Python to....do things. What depends on it (the

Objective-C standards document

无人久伴 提交于 2019-11-30 04:38:19
I'm a C and C++ programmer trying to get started with Objective-C. I'm really bewildered, though, by the apparent total absence of a standards document for the language and standard library. I can understand that there's no ISO standard, but is there no reference document at all? And how is it that nobody seems very concerned about this state of affairs? (Admittedly, it's hard to Google for such a thing, because "reference", "document", and "standard" are all overloaded terms. So it's possible that I've just missed something critical.) This question gets close to asking the same thing: Where

Parsing grammars using OCaml

爷,独闯天下 提交于 2019-11-30 03:57:12
I have a task to write a (toy) parser for a (toy) grammar using OCaml and not sure how to start (and proceed with) this problem. Here's a sample Awk grammar: type ('nonterm, 'term) symbol = N of 'nonterm | T of 'term;; type awksub_nonterminals = Expr | Term | Lvalue | Incrop | Binop | Num;; let awksub_grammar = (Expr, function | Expr -> [[N Term; N Binop; N Expr]; [N Term]] | Term -> [[N Num]; [N Lvalue]; [N Incrop; N Lvalue]; [N Lvalue; N Incrop]; [T"("; N Expr; T")"]] | Lvalue -> [[T"$"; N Expr]] | Incrop -> [[T"++"]; [T"--"]] | Binop -> [[T"+"]; [T"-"]] | Num -> [[T"0"]; [T"1"]; [T"2"]; [T

C grammar in GCC source code

℡╲_俬逩灬. 提交于 2019-11-30 03:51:10
I'm looking for the C grammar in GCC source code, more specifically for the grammar in the yacc/bison form. Found the C grammar in Yacc specification in the GCC version 3.3 in the file "c-parse.y" You will not find a C grammar yacc/bison file within the current GCC source code. It was done in the past, before the egcs fork stuff. I cannot give you the exact version and location, but i can tell you that it should be in the 2.x release The current version of GCC has its own C parser GCC of version 4.3 did not contain explicitly written C grammar. Parsing and semantical analysis were performed

Converting ambiguous grammar to unambiguous

拈花ヽ惹草 提交于 2019-11-30 03:30:35
I did not understand how a unambiguous grammar is derived from a ambiguous grammar? Consider the example on site: Example . How was the grammar derived is confusing to me. Can anyone please guide me ? The example has two grammars: Ambiguous: E → E + E | E ∗ E | (E) | a Unambiguous: E → E + T | T T → T ∗ F | F F → (E) | a The unambiguous grammar was derived from the ambiguous one using information not specified in the ambiguous grammar: The operator '*' binds tighter than the operator '+'. Both the operators '*' and '+' are left associative. Without the external information, there is no way to

Open Source Grammar Checker [closed]

社会主义新天地 提交于 2019-11-30 02:08:22
For an online project I'm working on, I am looking for a open source grammar checker. I have searched Google, with some good results ( http://www.link.cs.cmu.edu/link/ , etc), but I am wondering what all of you think about this topic. I need this to be able to be used online, versus desktop based, but this is the only real specification I have. If it has a built-in spell checker, that would be a plus, but I can always use another project for that purpose. Thanks for any help. LanguageTool should fit the bill: http://www.languagetool.org/ try polishmywriting.com (now afterthedeadline.com) I

Is the grammars in Java7 spec really equivalent?

风流意气都作罢 提交于 2019-11-30 02:06:28
问题 The grammar in chapter 18 of JLS v7 seem to differ from the constructs elsewhere in the documentation, but to me there seem to be differences. Specifically in chapter 15 the rules are: RelationalExpression: ShiftExpression RelationalExpression < ShiftExpression RelationalExpression > ShiftExpression RelationalExpression <= ShiftExpression RelationalExpression >= ShiftExpression RelationalExpression instanceof ReferenceType which makes foo instanceof Bar a RelationalExpression (and therefore

Is Web Speech API Grammar exposed to developers?

☆樱花仙子☆ 提交于 2019-11-29 23:19:38
问题 I am currently doing some RnD on Webkit Speech Recognition and I wanted to create an application specific grammar file. According W3C definition I wrote the following code. But it doesnt seem to show improved results in recognition for these words. Can you kindly provide some help with this.? var recognition = new webkitSpeechRecognition(); recognition.grammars.addFromUri("voice/api_grammar/weight.grxml"); The grammar file is a simple file which looked like the following. <?xml version="1.0"

Efficient Context-Free Grammar parser, preferably Python-friendly

筅森魡賤 提交于 2019-11-29 22:26:17
I am in need of parsing a small subset of English for one of my project, described as a context-free grammar with (1-level) feature structures ( example ) and I need to do it efficiently . Right now I'm using NLTK 's parser which produces the right output but is very slow. For my grammar of ~450 fairly ambiguous non-lexicon rules and half a million lexical entries, parsing simple sentences can take anywhere from 2 to 30 seconds, depending it seems on the number of resulting trees. Lexical entries have little to no effect on performance. Another problem is that loading the (25MB) grammar

Parsing SPARQL queries

谁都会走 提交于 2019-11-29 22:02:10
问题 I need to test for a certain structural property of a couple million SPARQL queries, and for that I need the structure of the WHERE statement. I'm currently trying to use fyzz to do this, but unfortunately its documentation is not very useful. Parsing queries is easy, the problem is that i haven't been able to recover the structure of the statement. For example: >>> from fyzz import parse >>> a=parse("SELECT * WHERE {?x a ?y . {?x a ?z}}") >>> b=parse("SELECT * WHERE {?x a ?y OPTIONAL {?x a