grammar

Shift / reduce conflicts in grammar of arithmetic expression with n-ary sums / products

Parsing binary sums / products are easy, but I'm having troubles defining a grammar that parses a + b * c + d + e as sum(a, prod(b, c), d, e) My initial (naive) attempt generated 61 shift / reduce conflicts. I'm using java cup (but I suppose a solution for any other parser generator would be easily translated). ...

Separate word lists for nouns, verbs, adjectives, etc

Usually word lists are 1 file that contains everything, but are there separately downloadable noun list, verb list, adjective list, etc? I need them for English specifically. ...

Open source machine readable grammar for HTTP/1.1?

Is there an open source machine-readable grammar for HTTP/1.1 requests and responses? Specifically, i'm looking for a grammar that is accepted by one of the popular parser generators (e.g., ANTLR, CUP, BNFC, ...). ...

History of trailing comma in programming language grammars

Many programming languages allow trailing commas in their grammar following the last item in a list. Supposedly this was done to simplify automatic code generation, which is understandable. As an example, the following is a perfectly legal array initialization in Java (JLS 10.6 Array Initializers): int[] a = { 1, 2, 3, }; I'm curious...

ANSI-C grammar - array declarations like [*] et alii

The ANSI C grammar from -link- give me the following rules for array declarations: (1) | direct_declarator '[' type_qualifier_list assignment_expression ']' (2) | direct_declarator '[' type_qualifier_list ']' (3) | direct_declarator '[' assignment_expression ']' (4) | direct_declarator '[' STATIC type_qualifier_list assignment_expre...

how to define a grammar for a programming language

how to define a grammar (context-free) for a new programming language (imperative programming language) that you want to design from scratch. In other words : how do you proceed when you want to create a new programming language from scratch. ...

Creating FIRST and FOLLOW sets for all non-terminals

If somebody could help me with the rules of FIRST and FOLLOW sets that would be awesome. The question is calculate the FOLLOW sets for all of the non-terminals in the following grammar S ::= S b T a E ¦ a T b ¦ c T a c R ::= E T ¦ a E T ::= a c E ¦ epsilon E ::= R ¦ T a d ¦ epsilon I have read the rules of crea...

ANTLR Parser Question

I'm trying to parse a number of text records where elements in a record are separated by a '+' char, and where the entire record is terminated by a '#' char. For example E1+E2+E3+E4+E5+E6# Individual elements can be required or optional. If an element is optional, its value is simply missing. For example, if E2 were missing, the input ...

"Sign In" or "Log in" or "Login"

Possible Duplicate: UI Terminology: Logon vs Login Which is the right one to use - Sign in - Log in - Login Being a non-native English speaker it is difficult to distinguish them. I guess I should have asked at dictionary.com forum but I need a technical answer. ...

Why is this c# snippet legal?

Silly question, but why does the following line compile? int[] i = new int[] {1,}; As you can see, I haven't entered in the second element and left a comma there. Still compiles even though you would expect it not to. ...

Search tool that uses a grammar rather than regular expression?

Are there any search tools that allow you to set up a simple token/grammar parsing system that work similar to regular expressions? What we want to do is search our ColdFusion code for queries that do not have cfqueryparams in them. A regular expression gets a bit tough in this situation because I can't keep track of the start tags whi...

Perl Regex Grammar For ANTLR Use

I need to create a regex parser for a project and I am using ANTLR v3 to do this. I am trying to find an up-to-date, Perl6-like regex grammar. Does anyone have a source? Googling for this has been difficult for some reason. ...

Some software for Java to determine words normal forms.

Hi! Is there any Java open-source software, which can determine words normal forms. I need to develop grammatic class for Apache Solr for Latvian language. My research showed, that there is not any class for latvian grammar for Apache Solr or Apache Lucene, so, i need to develop it by myself. I thought, that it would be convenient, if ...

Can anyone explain this JavaScript grammar(syntax) please?

Hi guys, I'm reading a js file at here, on the very top of this js file you can find the following lines: var gsAgent=navigator.userAgent.toLowerCase(), gsAppVer=navigator.appVersion.toLowerCase(), gsAppName=navigator.appName.toLowerCase(), gbIsOpera=gsAgent.indexOf("opera")>-1, gbIsKHTML=gsAgent.indexOf("khtml")>-1 ||gsAgent.indexOf(...

Java: how to tell if a line in a text file was supposed to be blank?

I'm working on a project in which I have to read in a Grammar file (breaking it up into my data structure), with the goal of being able to generate a random "DearJohnLetter". My problem is that when reading in the .txt file, I don't know how find out whether the file was supposed to be a completely blank line or not, which is detriment...

Parsing a string, Grammar file.

How would I separate the below string into its parts. What I need to separate is each < Word > including the angle brackets from the rest of the string. So in the below case I would end up with several strings 1. "I have to break up with you because " 2. "< reason >" (without the spaces) 3. " . But Let's still " 4. "< disclaimer >" 5. " ...

Should I use proper punctuation for single sentence alert/notification popups?

Is it necessary to use a period for single sentence notification boxes? Even though its considered proper grammar to do so, it just looks ugly and feels too formal. Here are two screenies for comparison (first includes period, second doesn't). ...

Colour instead of color?

I'm working on a game engine in C++ and I have methods like setColour and things that use british grammar. While I was thinking how C++ compilers mostly use the english language (correct me if I'm wrong) and how most APIs use american grammar, should I go with the flow and continue the unofficial standard in the grammar programmer high c...

Parsing tcl arrays in ruby with treetop

I have a bunch of data in (what i think is) a tcl array. Basically it's in the form of {a {b c} d {e f} g}. It's only nested one deep, but isn't always nested, that is to say, a may just be a or it may be {aa bb} or possibly {}, but never {aa {bb cc}}. I want to extract this array so I can use it in ruby. My first thought was, "No probl...

Good grammar for date data type for recursive descent parser LL(1)

I'm building a custom expression parser and evaluator for production environment to provide a limited DSL to the users. The parser itself as the DSL, need to be simple. The parser is going to be built in an exotic language that doesn't support dynamic expression parsing nor has any parser generator tools available. My current decision ...