Perl 6 - the future is here, just unevenly distributed

IRC log for #marpa, 2014-09-19

| Channels | #marpa index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:14 jeffreykegler joined #marpa
09:05 pczarn joined #marpa
11:49 rns joined #marpa
11:50 rns left #marpa
14:23 ilbot3 joined #marpa
14:23 Topic for #marpa is now Start here: http://savage.net.au/Marpa.html - Pastebin: http://scsys.co.uk:8002/marpa - Jeffrey's Marpa site: http://jeffreykegler.github.io/Marpa-web-site/ - IRC log: http://irclog.perlgeek.de/marpa/today
14:23 marpaja helllo
14:23 marpaja im trying to make a parser for a template language
14:24 marpaja and i have no idea where to start
14:24 marpaja whats the best way to handle "if" conditions ?
14:25 lwa Hello marpaja! Do you have previous experience with parsing, or is this the first time you're writing a parser?
14:28 marpaja first time
14:29 marpaja well i made one with antlr 8 years ago and i dont remember anything
14:30 marpaja maybe there is some example around the web on how to do this ?
14:31 lwa I would suggest that you (re-)familiarize yourself with parsing using a simpler language. Arithmetic expressions such as "2 + 4 * 3" are a good start (notice that you have to handle precedence). JSON is a very simple real-world language you can write a parser for.
14:32 marpaja ok
14:32 marpaja will take your advice
14:33 lwa I'd like to help you with your actual problem, but "the best way to handle if conditions" is a very vague question. What exactly did you mean by that?
14:34 marpaja let me write an example
14:38 marpaja http://paste.scsys.co.uk/424425
14:38 marpaja i have these sort of things, which are parsed by other language
14:39 marpaja my intent is to write a marpa parse to suggest backend replacement
14:39 marpaja i would need to parse that sort of language
14:39 marpaja and make it renter
14:39 marpaja render*
14:39 marpaja do you think marpa is a good choice ?
14:41 lwa Marpa can handle it. Do you have an existing parser that can read the code of the host programming language? (What language is that?)
14:41 marpaja its apache java velocity
14:43 lwa meh, never heard of it. Does it have a specification or formal grammar? If so, you could translate it to Marpa's syntax
14:43 marpaja it sucks
14:43 marpaja =p
14:43 marpaja let me try to find
14:44 marpaja http://velocity.apache.org/engine/releases/velocity-1.4/specification.html
14:48 lwa That is a nice BNF grammar, but it does not match the code you pasted. It seems the “specification” is a bit outdated.
14:49 marpaja hmmm
14:49 marpaja maybe my example was bad
14:49 marpaja let me fix it
14:49 marpaja sorry
14:53 marpaja http://paste.scsys.co.uk/424429
14:53 marpaja there
14:54 marpaja but yes the specification is out dated
14:54 aredridel joined #marpa
14:56 lwa that looks more like something resembling that grammar. Well, if you want to parse it, you'll eventually have to write a full grammar. That outdated specification could be a starting point, but you can't translate it 1:1
14:56 lwa What is the purpose of your parser? Translating the template to a Java method?
14:56 marpaja ok
14:57 marpaja the purpose is to take java out
14:57 marpaja and replace with perl
14:57 marpaja =))
14:57 marpaja thats my big goal
14:58 marpaja right now that templates are parsed by java
14:59 lwa ah :) … you are of course aware the Perl already has various templating engines? Template Toolkit (http://template-toolkit.org/) is the most common.
14:59 marpaja yes
14:59 marpaja but there is so much crap done in velicity
15:00 marpaja that there is no way to replace current templates
15:00 marpaja so i think the best way would be to parse current templates with perl and make it work just like current java does
15:02 marpaja there is this template alloy which has partial velocity support
15:02 marpaja but our velocity version is a bit different
15:02 lwa It seems Velocity allows you to call methods on variables, so you'd have to also create Perl objects that mimic their Java counterparts. This sounds like a lot of work.
15:02 marpaja so i would need be able to create a marpa parser and replace java backend with perl backend
15:02 marpaja yup
15:03 marpaja but its not that much of work on methods of variables
15:04 marpaja once i master it, i can keep adding functionalities onto marpa parser
15:07 lwa Well, you've certainly set out to do quite a feat. I hope you're successful! I still think starting with simpler languages will be beneficial, so that you get a feel for creating parsers. There's the Marpa Web Site (http://savage.net.au/Marpa.html) which links to a few tutorials; I've written one of them myself.
15:14 marpaja cool
15:15 marpaja much thanks for all the support and your tutorials
15:15 marpaja much much thanks
15:15 marpaja i will indeed make a simpler language
15:15 marpaja to learn the basics
15:18 marpaja this marpa thing seems so powerful
15:18 marpaja i must master it
15:31 lucs_ joined #marpa
15:57 marpaja lwa: are you retired ?
15:57 lwa marpaja: no, I'm a student
15:57 marpaja you are ron savage right ?
15:58 marpaja ah ok
15:58 lwa also, I'm Lukas Atkinson / Amon
15:58 marpaja ohh nice =)
16:01 jeffreykegler joined #marpa
19:19 lwa joined #marpa
20:32 marpaja joined #marpa
20:33 marpaja ellllo
20:34 marpaja could someone tell me whats the problem here pls ?
20:34 marpaja im learning
20:34 marpaja http://paste.scsys.co.uk/424499
20:34 marpaja i want to make marpa parse templates
20:34 marpaja but im starting with basics... atributing to a var and then dump its values
20:35 marpaja any hints is apreciated
20:36 pczarn Hello
20:37 marpaja hi
20:39 marpaja marpa seems so easy
20:39 marpaja simple*
20:39 marpaja obvious
20:39 marpaja and im strugling
20:39 marpaja =p
20:42 pczarn for one, the use of `something` in `attribution` is not good
20:43 pczarn I guess `:start ::= something` will parse only the first statement, right?
20:43 marpaja yea i just figured that
20:43 marpaja i need something+ or something
20:44 pczarn marpaja: as I said, your language can have values in statements, but also statements as values
20:45 marpaja so its wrong
20:46 pczarn so that `var $a = var $b = [xx];;` is valid
20:46 marpaja ahh
20:46 marpaja so wrong :)
20:48 marpaja thanks for the help pczarn
20:49 marpaja is there any example online of how to make a template parser with marpa?
20:49 marpaja with some scopes and many variables names
20:49 marpaja this doesnt enter my head, i have no idae how to implement
20:56 marpaja well i guess i dont need to care about that
20:56 marpaja because everything will be evaluated and returned and composed into the final result
20:56 marpaja correct?
20:57 pczarn I have no idea
20:58 marpaja me neither
20:58 marpaja but will find out
21:29 idiosyncrat joined #marpa
21:30 idiosyncrat marpaja: A suggestion -- start by getting the grammar right, and after that work on the semantics.  In particular ....
21:31 idiosyncrat start your script with  " :default ::= action => [name,values]" ,,,
21:32 idiosyncrat which will cause the value of your parse to be a tree which you can inspect.
21:33 idiosyncrat Also, always start scripts with "lexeme default = latm => 1".  Not doing so leaves you with a less desirable lexer, which is the default for historical reasons.
21:34 idiosyncrat An advantage of Marpa development is clean separation of semantics / parsing / lexing, so that you can tackle them one by one.
23:23 ronsavage joined #marpa
23:25 ronsavage marpaja: I suggest you study https://metacpan.org/release/MarpaX-Demo-JSONParser. Download and you'll see 3 different grammars for JSON in the share/ directory.
23:26 ronsavage We normally put the grammar directly in the code, but that module is a demo, and has multiple grammars, whereas your program will probably have just one.
23:28 ronsavage Likewise, https://metacpan.org/release/MarpaX-Languages-SVG-Parser has multiple grammars, but they are stored inside the Perl module SAXHandler.pm.
23:29 ronsavage The reason I recommend these (apart from the fact that I wrote them and hence am familiar with the code) is they give you a guide as to how to structure your code.
23:31 ronsavage Also the latter module emphasizes - via the data/ directory and scripts/test*.pl - how to set up a set of tests for your grammar

| Channels | #marpa index | Today | | Search | Google Search | Plain-Text | summary