grammar

Where can I find a formal grammar for the Perl programming language?

戏子无情 提交于 2019-12-03 10:05:54
I understand that the Perl syntax is ambiguous and that its disambiguation is non-trivial ( sometimes involving execution of code during the compile phase ). Regardless, does Perl have a formal grammar (albeit ambiguous and/or context-sensitive)? From perlfaq7 Can I get a BNF/yacc/RE for the Perl language? There is no BNF, but you can paw your way through the yacc grammar in perly.y in the source distribution if you're particularly brave. The grammar relies on very smart tokenizing code, so be prepared to venture into toke.c as well. In the words of Chaim Frenkel: "Perl's grammar can not be

How to split an NLP parse tree to clauses (independent and subordinate)?

早过忘川 提交于 2019-12-03 09:49:46
问题 Given an NLP parse tree like (ROOT (S (NP (PRP You)) (VP (MD could) (VP (VB say) (SBAR (IN that) (S (NP (PRP they)) (ADVP (RB regularly)) (VP (VB catch) (NP (NP (DT a) (NN shower)) (, ,) (SBAR (WHNP (WDT which)) (S (VP (VBZ adds) (PP (TO to) (NP (NP (PRP$ their) (NN exhilaration)) (CC and) (NP (FW joie) (FW de) (FW vivre))))))))))))) (. .))) Original sentence is "You could say that they regularly catch a shower, which adds to their exhilaration and joie de vivre." How could the clauses be

Grammar Writing Tools [closed]

只愿长相守 提交于 2019-12-03 09:26:52
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I am trying to write a grammar in EBNF (barring a really good reason, it has to be EBNF) and am looking for a couple of utilities for it - if there's a GUI interface that can make one, that would be great, but the thing I'm looking for most is something that can check the grammar, for instance to see if it is

Some NLP stuff to do with grammar, tagging, stemming, and word sense disambiguation in Python

半世苍凉 提交于 2019-12-03 08:27:56
问题 Background (TLDR; provided for the sake of completion) Seeking advice on an optimal solution to an odd requirement. I'm a (literature) student in my fourth year of college with only my own guidance in programming. I'm competent enough with Python that I won't have trouble implementing solutions I find (most of the time) and developing upon them, but because of my newbness, I'm seeking advice on the best ways I might tackle this peculiar problem. Already using NLTK, but differently from the

Verify correct use of “a” and “an” in English texts - Python [closed]

不想你离开。 提交于 2019-12-03 07:56:59
I want to create a program that reads text from a file and points out when "a" and "an" is used incorrect. The general rule as far as I know is that "an" is used when the next words starts with a vowel. But it should also take into consideration that there are exceptions which also should be read from a file. Could someone give me some tips and tricks on how I should get started with this. Functions or so that could help. I would be very glad :-) I'm quite new to Python. jfs Here's a solution where correctness is defined as: an comes before a word that starts with a vowel sound, otherwise a

Using Parsec to parse regular expressions

浪子不回头ぞ 提交于 2019-12-03 07:45:19
I'm trying to learn Parsec by implementing a small regular expression parser. In BNF, my grammar looks something like: EXP : EXP * | LIT EXP | LIT I've tried to implement this in Haskell as: expr = try star <|> try litE <|> lit litE = do c <- noneOf "*" rest <- expr return (c : rest) lit = do c <- noneOf "*" return [c] star = do content <- expr char '*' return (content ++ "*") There are some infinite loops here though (e.g. expr -> star -> expr without consuming any tokens) which makes the parser loop forever. I'm not really sure how to fix it though, because the very nature of star is that it

Python ast to dot graph

一个人想着一个人 提交于 2019-12-03 07:44:03
问题 I'm analyzing the AST generated by python code for "fun and profit", and I would like to have something more graphical than "ast.dump" to actually see the AST generated. In theory is already a tree, so it shouldn't be too hard to create a graph, but I don't understand how I could do it. ast.walk seems to walk with a BFS strategy, and the visitX methods I can't really see the parent or I don't seem to find a way to create a graph... It seems like the only way is to write my own DFS walk

How to know if two words have the same base?

心已入冬 提交于 2019-12-03 07:10:20
问题 I want to know, in several languages, if two words are: either the same word, or the grammatical variants of the same word. For example: had and has has the same base: in both cases, it's the verb have , city and cities has the same base. went and gone has the same base. Is there a way to use the Microsoft Word API to not just spell check text, but also normalize a word to a base or, at least, determine if two words have the same base? If not, what are the (free or paid) libraries (not web

Combined unparser/parser generator

时光总嘲笑我的痴心妄想 提交于 2019-12-03 07:08:14
问题 Is there a parser generator that also implements the inverse direction, i.e. unparsing domain objects (a.k.a. pretty-printing) from the same grammar specification? As far as I know, ANTLR does not support this. 回答1: I have implemented a set of Invertible Parser Combinators in Java and Kotlin. A parser is written pretty much in LL-1 style and it provides a parse- and a print-method where the latter provides the pretty printer. You can find the project here: https://github.com/searles/parsing

POSIX sh EBNF grammar

别等时光非礼了梦想. 提交于 2019-12-03 06:58:18
Is there an existing POSIX sh grammar available or do I have to figure it out from the specification directly? Note I'm not so much interested in a pure sh; an extended but conformant sh is also more than fine for my purposes. The POSIX standard defines the grammar for the POSIX shell. The definition includes an annotated Yacc grammar. As such, it can be converted to EBNF more or less mechanically. If you want a 'real' grammar, then you have to look harder. Choose your 'real shell' and find the source and work out what the grammar is from that. Note that EBNF is not used widely. It is of