grammar

Good resources to learn about models of computation?

Out of curiosity, I am trying to identify what model of computation a system I work with is functionally equivalent to, and prove the equivalence. The longer I spend on this problem the more I suspect the system isn't Turing-equivalent. My understanding of Turing Machines and recursively enumerable languages is good but I don't know mu...

LALR(1) empty list of parameters for functions

Hi I have a simple LALR(1) grammar, but I'm encountering a problem. start ::= spec. spec ::= MOD STRING top_stmt. spec ::= top_stmt. top_stmt ::= stmt. top_stmt ::= conditional. stmt ::= expr. stmt ::= assignment. conditional ::= IF stmt_list. expr ::= retval. expr ::= NOT retval. retval ::= access. retval ::= invoke. access ::= ns_ide...

How can I tell Bison I also expect reduce-reduce conflicts?

My C#-ish toy grammar now has its first reduce-reduce conflicts! I'm so proud of me. It seems all right to me, however (I switched off to a GLR parser for the occasion). The problem is, while I know the %expect directive can shut up Bison about shift/reduce conflicts, I can't find the equivalent for reduce/reduce conflicts. So what shou...

Naming a set of method,field,local var, and function

In writing a compiler grammar, I'm trying to come up with a name/label for a set of elements that include pretty much everything with an ident in it: method, field, local var and function I thought "members" first, but vars and functions aren't class members. Any ideas? EDIT: This is higher up than an identifier. Here's how it's use...

English grammar checker engine for .NET?

I am looking for an English grammar checker engine (not spell checker) to be used on server side in .NET and Windows. I found one at wintertree-software.com but it's over $1000. Found these resources 1, 2 on SO. I prefer to use a ready to use engine. Feed it sentences, paragraph or text documents and it spits out grammar suggestions as ...

How to resolve case problems for non-english languages in django admin panel?

I need to resolve problem with word endings in django admin panel. The language I'm using is russian (using utf-8 charset), so some problems occur, for example, there is a problem with the right endings on the "Add" button for some model names. The simplest thing I found is using jQuery to correct endings "on the fly", but this solution ...

Antrl3 conditional tree rewrites

Hello again, Stackoverflow. Continuing on my journey into Antlr (Previous questions may provide additional clues on what I'm trying to achieve! Q1 - How do I make a tree parser and Q2 - Solving LL recursion problem) I've hit yet another roadblock I cannot flathom. Basically (I believe) the expression rule in my grammar needs to either ...

How can my ANTLR lexer match a token made of characters that are subset of another kind of token?

I have what I think is a simple ANTLR question. I have two token types: ident and special_ident. I want my special_ident to match a single letter followed by a single digit. I want the generic ident to match a single letter, optionally followed by any number of letters or digits. My (incorrect) grammar is below: expr : special_...

How can I execute an ANTLR parser action for each item in a rule that can match more than one item?

I am trying to write an ANTLR parser rule that matches a list of things, and I want to write a parser action that can deal with each item in the list independently. Some example input for these rules is: $(A1 A2 A3) I'd like this to result in an evaluator that contains a list of three MyIdentEvaluator objects -- one for each of A1, A...

boost::Spirit Grammar for unsorted schema

I have a section of a schema for a model that I need to parse. Lets say it looks like the following. { type = "Standard"; hostname="x.y.z"; port="123"; } The properties are: The elements may appear unordered. All elements that are part of the schema must appear, and no other. All of the elements' synthesised attributes go into...

Will rewriting a multipurpose log file parser to use formal grammars improve maintainability?

TLDR: if I built a multipurpose parser by hand with different code for each format, will it work better in the long run using one chunk of parser code and an ANTLR, PyParsing or similar grammar to specify each format? Context: My job involves lots of benchmark log files from ~50 different benchmarks. There are a few in XML, a few HTML,...

Working with ASR by Loquendo on iPhone

Hi All, I am trying to find a way to implement some ASR (Automatic Speak Recognition) functionality in my client's iPhone app. We use the Loquendo API. The API comes with a very long documentation, but, unfortunately, without any code samples except some very basic project that doesn't show all the included functionality. I've spent d...

How to catch words in the middle of sentences with Microsoft SAPI?

Hello, this SAPI grammar catch the word name is the middle of a sentence. <GRAMMAR LANGID="409"> <RULE NAME="SOUNDLOG" TOPLEVEL="ACTIVE"> <OPT> <DICTATION MAX="INF"/> </OPT> <L> <P>name</P> </L> <OPT> <DICTATION MAX="INF"/> </OPT> </RULE> </GRAMM...

Enable/disable grammar rules in Yacc/Bison

Like the title says, I would like to enable/disable certain grammar rules in a yacc or bison grammar file. Is there a way to do so? ...

Interpreting a variable number of tree nodes in ANTLR Tree Grammar

Whilst creating an inline ANTLR Tree Grammar interpreter I have come across an issue regarding the multiplicity of procedure call arguments. Consider the following (faulty) tree grammar definition. procedureCallStatement : ^(PROCEDURECALL procedureName=NAME arguments=expression*) { if(procedureName.equals("foo...

Combined grammar ANTLR option filter

I have a combined grammar (lexer and parser on the same file). How do I set the filter = true to the lexer? Thanks ...

Equal (not a token) in an ANTLR grammar. What does this mean?

What does the construct basename = in the following rule? tabname: (ID'.')? basename = ID ; There is this single occurrence of basename in the grammar. Thanks ...

Writing a grammar in VoiceXML to match # terminated digits or *1 or *2

I an writing a VoiceXML app and i am having a problem. The application listens for DTMF tones only. The user enters a confirmation number followed by #. They can also enter *1 or *2 to speak to customer service, or resend the confirmation message. I am having trouble creating a grammer that will work for this. I've been able to use t...

yacc shift reduce problem

i have what i think is a simple part of my grammar this is getting an error from yacc. i know i need to add a %prec somewhere, but not really sure where. Assignment : Ref '=' Ref | Ref '=' Expression | Ref '=' Value | Ref '=' FunctionCall ; Ref : ID | ID '[' Expression ']' ; Value : ...

What is a good tool for automatically calculating FIRST and FOLLOW sets?

I'm currently in the middle of playing with a BNF grammar that I hope to be able to wrangle into a LL(1) form. However, I've just finished making changes and calculating the new FIRST and FOLLOW sets for the grammar by hand for the third time today and I'm getting tired of it. There has to be a better way! Can someone suggest a tool tha...