Over the years, "regex" pattern matching has been getting more and more powerful to the point where I wonder: is it really just context-sensitive-grammar matching? Is it a variation/extension of context-free-grammar matching? Where is it right now and why don't we just call it that instead of the old, restrictive "regular expression"?
...
hi..can anyone let me know if there is any software to convert Chomsky normal form to Backus–Naur Form and vice versa?
...
I had a work for the university which basically said:
"Demonstrates that the non-regular language L={0^n 1^n : n natural} had no infinite regular sublanguages."
I demonstrated this by contradiction. I basically said that there is a language S which is a sublanguage of L and it is a regular language. Since the possible Regular expre...
I'm trying to write a CFG over the alphabet Σ = {a,b} for all words starting and ending with the same number of a's, with at least one b in the middle.
Now I understand the basic concept of CFG, variables, production rules, etc. Unfortunately I've run out of ideas for writing the aforementioned CFG. All I've got so far is
S → aYXYa
X →...
I've been wondering for long why there doesn't seem to be any parsers for, say, BNF, that behave like regexps in various libraries.
Sure, there's things like ANTLR, Yacc and many others that generate code which, in turn, can parse a CFG, but there doesn't seem to be a library that can do that without the intermediate step.
I'm interest...
Does anyone know how to split a string on a character taking into account its escape sequence?
For example, if the character is ':', "a:b" is split into two parts ("a" and "b"), whereas "a\:b" is not split at all.
I think this is hard (impossible?) to do with regular expressions.
Thank you in advance,
Kedar
...
Hi,
I would like a utility which I can give a piece of text (in a text box) and experiment with a parser grammar (through editing a BNF of similar) and token structure while I can see how the parse tree would look (and if it's not able to parse the text using my current grammar, I would see where it halted).
The key word is interactivi...
Or, to be a little more precise: which programming languages are defined by a context-free grammar?
From what I gather C++ is not context-free due to things like macros and templates. My gut tells me that functional languages might be context free, but I don't have any hard data to back that up with.
Extra rep for concise examples :-)
...
I'm trying to write a regular expression engine. I'd like to write a recursive descent parser by hand. What would a context-free grammar without left recursion for the language of regular expressions (not the languages that can be described by regular expressions) look like? Would it be easiest to re-factor out the syntactic sugar, i.e. ...
I am writing a simulator, and would like to run studies by invoking a lot of instances of the simulator, using different sets of command-line arguments. I have read this question and several others, and they seem close, but I'm actually not looking for random data fulfilling a particular regex, I would like the set of all strings that m...
I'm studying for a finite automata & grammars test and I'm stuck with this question:
Construct a grammar that generates L:
L = {a^n b^m c^m+n|n>=0, m>=0}
I believe my productions should go along this lines:
S->aA | aB
B->bB | bC
C->cC | c Here's where I have doubts
How can my production for C remember the numbers of m a...
http://www.cs.chalmers.se/Cs/Research/Language-technology/BNFC/
how should I write my labeled BNF to get BNFC to generate a INI parser for me?
I have only gotten so far o__O!
entrypoints File ;
comment "#" ;
token ID ( letter | digit | ["-_'"] )+ ;
Ini. File ::= [Section] ;
Sect. Section ::= "[" ID "]" [Statement] ;
Bind. Statement...
I've recently being trying to teach myself how parsers (for languages/context-free grammars) work, and most of it seems to be making sense, except for one thing. I'm focusing my attention in particular on LL(k) grammars, for which the two main algorithms seem to be the LL parser (using stack/parse table) and the Recursive Descent parser ...
Here's the grammar, which is supposed to describe a language of nested braces with commas as delimiters:
L ::= {L} | L,L |
A few more examples of strings I'd expect the grammar to accept and reject:
Accept:
{,{,,{,}},,{,}}
{{{{}}}}
{,{}}
Reject:
{}{}
{,{}{}}
{{},{}
...
I want to parse a search string similar to that provided by Gmail using Perl. An example input would be "tag:thing by:{user1 user2} {-tag:a by:user3}". I want to put it into a tree structure, such as
{and => [
"tag:thing",
{or => [
"by:user1",
"by:user2",
]},
{or => [
{not => "tag:a"},
"by:use...
This isn't a programming question, but I don't know of any good places on the Internets to ask computer science questions. Sorry if this is too off-topic.
I'm reviewing some old CS material and I'm stuck on the following:
Let L = { x in {a,b}* | x has an equal number of a's and b's}
I know this is a context free language because I ca...
I'm contemplating the idea of implementing a XML translator using a compiler generator, based on the W3C's XML 1.1 spec, which includes a complete EBNF grammar.
More precisely, I plan to use Qi-YACC because I want to learn this tool. It will be my first foray into using any compiler-compiler.
The first kind of translation I'm planning ...
In a book chapter about compilers, there's the following grammar definition and example code.
...
statement: whileStatement
| ifStatement
| ... // Other statement possibilities
| '{' statementSequence '}'
whileStatement: 'while' '(' expression ')' statement
ifStatement: ... // Definition of "if"
statemen...
Does anyone know of online course / university lectures that comprise a typical compiler course? I've had theory of computing but unfortunately my school didn't offer a course in compiler construction.
I know there are lectures out there; I was hoping for recommendations for particularly good offerings.
Also, are there books for new...
Given an alphabet of 1s I want to parse addition of the form
1^k + 1^j = 1^k+j
This is pretty easy to represent with a pushdown automaton simply by pushing a 1 on to the stack on each of the first two 1s, and then popping on the last set of 1s. However, I can't seem to figure out how to represent this as a context free grammar, which...