0

Considering the Wavefront obj file format where this syntax fits in the Chomsky hierarchy and why ? I'm also not sure if PEG grammars are being considered in the kind of classification made by Chomsky and if an obj is a real example of a PEG grammar .

to formalize this: what kind of grammar and parser I need in order to read an obj file ?

user2485710
  • 231
  • 2
  • 7
  • why the downvote, I'm asking for help in order to define the family of grammars to which the obj file format belongs to. – user2485710 Jun 16 '14 at 22:56
  • You've got an [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). You don't know how to do something, you're trying to ask about that, but you really need to read and ask about the fundamentals. There are many such questions on P.SE such as [What is the responsibility or benefit of a Tokenizer?](http://programmers.stackexchange.com/questions/240255/). You likely need to do a bit more research yourself on the subject and make sure you explain the [question and your understanding](http://meta.programmers.stackexchange.com/questions/6559/) to its fullest. –  Jun 17 '14 at 00:08
  • @MichaelT I didn't even knew that the thing I was looking for was called "tokenizer"; in my experience if you read 10 articles about this you will find 10 mix of different words with slightly different meaning each single time. It's kinda frustrating for a newcomer when you read something that is supposed to be technical and you just realize that is probably not even properly written. For example the comment I wrote under the answer from ratchet-freak was about this kind of confusion . I did my researches, the problem is that I just got even more confused. – user2485710 Jun 17 '14 at 00:18

1 Answers1

1

Depends on how you look at it.

The syntax (line per line first few chars show what the line is) is simple and a regular language.

The kicker is how to verify the f lines, however when you are parsing you have a turing machine at your disposal and you should just focus on the regular part and step in with the higher level where needed.

ratchet freak
  • 25,706
  • 2
  • 62
  • 97
  • ... so ... you mean starting from ... ? Can you make an example with ragel or something like that ? I don't understand what you mean with "simple and a regular language" maybe a real world example may help. – user2485710 Jun 16 '14 at 23:11
  • 1
    @user2485710 you are asking about the Chomsky hierarchy... do you know what a regular language is? –  Jun 16 '14 at 23:19
  • @MichaelT that wikipedia article doesn't talk about Turing machines until the last and biggest set of grammars. Apparently regular grammars do not need a Turing machine according to the information that I read from there. Is there a simpler a more effective way to put this ? A simpler definition ? – user2485710 Jun 16 '14 at 23:24
  • @user2485710 Remember that in the hierarchy each grammar can recognize all languages in the lower tier grammar (context free can recognize regular for example) usually using some ridiculously simple construct that you can easily hook into with the higher level trickery – ratchet freak Jun 16 '14 at 23:34
  • @user2485710 the line itself is a rather basic regular language... what you do with the parts that you pull out with the regular language requires a full on turing machine to look up symbols from elsewhere in the file (or possibly doing multiple passes). –  Jun 16 '14 at 23:35
  • @MichaelT can you be more specific ? I understand that you are kinda referring to lexers and parsers, so a parser requires a Turing machine but a lexer ... ? an automata is enough for a lexer ? is ragel ok to start with ? – user2485710 Jun 16 '14 at 23:40
  • @MichaelT I'm also a little bit confused because there are articles that mix the words tokenizer, scanner and lexer, and sometimes even parser, but I think that at this point I'm starting to define things a little bit better, I'm still waiting for that bit of information about what you are referring to. – user2485710 Jun 17 '14 at 00:04