grammar

Circular Dependency Grammar

I am using treetop to construct a grammar but am having problems with what seems to be a circular dependency. Note: this is not really a treetop question, but more of a question with loading files. Consider the following structure: test.rb lib/A.treetop lib/B.treetop lib/AB.treetop lib/all.rb And the sources for the files # test.rb ...

What is the name of the character that designates literals when lexing an input sequence?

I want to know what is the 'terminology name' of the character that designates a start of a literal in a lexing process. For example: a string starts and ends with an " character. a regular expression literal - with an / character. ...

how do i throw exceptions with meaningful messages with a scala combination parser?

I'd like to throw an exception when the language doesn't conform to the grammar for a scala combination parser. Here's an example of a rule: def record: Parser[Record] = "-" ~ opt(recordLabel) ~ repsep(column, ",") ^^ { case "-" ~ label ~ columns => new Record(label, columns) } Let's say in the repsep(column, ",") part, they accid...

Grammar production class implementation in C#

Grammar by definition contains productions, example of very simple grammar: E -> E + E E -> n I want to implement Grammar class in c#, but I'm not sure how to store productions, for example how to make difference between terminal and non-terminal symbol. i was thinking about: struct Production { String Left; // for example E...

What is the difference between readonly property and function in .net?

Apart from an architectural point of view, i'm wondering if there is any difference in .net between a readonly property and a function. Are properties only conceptual wrappers around functions? Private m_Property As String Public ReadOnly Property PropertyGet() As String Get Return m_Property End Get...

Help with context-free grammar of lots of literal text with some special syntax

How do you make a context free grammar that analyzes mostly literal text (spaces, characters, symbols, etc.) while also looking for expressions of the form ${...} or $someCommand{...}? Note if it finds "I got $10 today", it should not do anything special with it. Is it possible? ...

Grammar, language, are we closer to real spoken languages?

As a developer I had to jump from a programming language to another. They all still have something in common. But after that I started to look at a Spanish grammar book, and there were plenty of terms I knew in Computer Science classes. After that I read a little about Semantic web, and so on and so forth. Do you consider there are more...

How to efficiently implement an immutable graph of heterogenous immutable objects in C++?

I am writing a programming language text parser, out of curiosity. Say i want to define an immutable (at runtime) graph of tokens as vertices/nodes. These are naturally of different type - some tokens are keywords, some are identifiers, etc. However they all share the common trait where each token in the graph points to another. This pro...

recognize Ruby code in Treetop grammar

I'm trying to use Treetop to parse an ERB file. I need to be able to handle lines like the following: <% ruby_code_here %> <%= other_ruby_code %> Since Treetop is written in Ruby, and you write Treetop grammars in Ruby, is there already some existing way in Treetop to say "hey, look for Ruby code here, and give me its breakdown" with...