This document discusses PEG.js, a JavaScript parser generator. It begins with an agenda that includes understanding PEG.js, how to use it, and making a domain-specific language (DSL) and parser. The document then covers how parsers are generally made, what PEG.js is, trying out some simple PEG grammars, and making a DSL for conditional logic. Key points include that PEG.js uses Parsing Expression Grammar to easily generate parsers without needing a separate lexer, how to write grammars and generate parsers with PEG.js, and an example of developing a DSL and parser for conditional logic configuration files.
Use PEG to Write a Programming Language ParserYodalee
PEG is a replacement to CFG. It is more powerful and can be more precise. In this slide I give a short introduction to PEG, the concept behind a programming language. Finally I write a parser for our programming language simple.
C++ for Java Developers (JavaZone Academy 2018)Patricia Aas
Introduction to Modern C++ for programmers with a Java background. Maps key C++ concepts to Java concepts and dives into how C++ programmers deal with and think about memory. This intersection is interesting whether you are learning or teaching C++.
Avec la version 9 sortie en septembre 2017, Java appuie sur la pédale ! Le rythme des livraisons passe à une version majeure tous les 6 mois. Java 10 est sorti en mars, prochaine version en septembre. Java 10 apporte le 'var' et l'inférence de type pour les variables locales. D'autres nouveautés sont en préparation : les constantes dynamiques, les classes de données, un nouveau switch à base de lambda, des interfaces fermées, de nouvelles choses du coté des génériques et bien plus encore.
Cela viendra-t-il en 11, 12, 15 ? Ne spéculons pas, mais quand ces nouveautés seront prêtes, elles sortiront en quelques mois. On se propose de présenter ces nouveautés, celles qui sont presque prêtes, celles qui seront prêtes bientôt, et celles qui ne seront pas prêtes avant un moment. Quels seront les impacts sur le langage, sur la JVM et donc sur les performances ? Que cela va-t-il nous apporter au quotidien, en tant que développeurs ? Quels seront les nouveaux patterns ? Voici le programme de cette présentation, avec des slides, du code, de la joie et de la bonne humeur !
C++ for Java Developers (SwedenCpp Meetup 2017)Patricia Aas
Introduction to Modern C++ for programmers with a Java background. Maps key concepts to Java concepts and dives into how C++ programmers deal with and think about memory. This intersection is interesting whether you are learning or teaching C++.
Secure Programming Practices in C++ (NDC Security 2018)Patricia Aas
This talk is for programmers wishing to feel more comfortable navigating the C++ landscape. We will explore the programming culture that has developed around the C++ language. Specifically, we will look at programming patterns that navigate around or through some of the dangerous parts of the C++ language. The goal is to build a set of programming practices based in the “smaller and cleaner language” inside C++. And by doing so, we will also build an awareness around code constructs that can potentially “blows your whole leg off”.
Use PEG to Write a Programming Language ParserYodalee
PEG is a replacement to CFG. It is more powerful and can be more precise. In this slide I give a short introduction to PEG, the concept behind a programming language. Finally I write a parser for our programming language simple.
C++ for Java Developers (JavaZone Academy 2018)Patricia Aas
Introduction to Modern C++ for programmers with a Java background. Maps key C++ concepts to Java concepts and dives into how C++ programmers deal with and think about memory. This intersection is interesting whether you are learning or teaching C++.
Avec la version 9 sortie en septembre 2017, Java appuie sur la pédale ! Le rythme des livraisons passe à une version majeure tous les 6 mois. Java 10 est sorti en mars, prochaine version en septembre. Java 10 apporte le 'var' et l'inférence de type pour les variables locales. D'autres nouveautés sont en préparation : les constantes dynamiques, les classes de données, un nouveau switch à base de lambda, des interfaces fermées, de nouvelles choses du coté des génériques et bien plus encore.
Cela viendra-t-il en 11, 12, 15 ? Ne spéculons pas, mais quand ces nouveautés seront prêtes, elles sortiront en quelques mois. On se propose de présenter ces nouveautés, celles qui sont presque prêtes, celles qui seront prêtes bientôt, et celles qui ne seront pas prêtes avant un moment. Quels seront les impacts sur le langage, sur la JVM et donc sur les performances ? Que cela va-t-il nous apporter au quotidien, en tant que développeurs ? Quels seront les nouveaux patterns ? Voici le programme de cette présentation, avec des slides, du code, de la joie et de la bonne humeur !
C++ for Java Developers (SwedenCpp Meetup 2017)Patricia Aas
Introduction to Modern C++ for programmers with a Java background. Maps key concepts to Java concepts and dives into how C++ programmers deal with and think about memory. This intersection is interesting whether you are learning or teaching C++.
Secure Programming Practices in C++ (NDC Security 2018)Patricia Aas
This talk is for programmers wishing to feel more comfortable navigating the C++ landscape. We will explore the programming culture that has developed around the C++ language. Specifically, we will look at programming patterns that navigate around or through some of the dangerous parts of the C++ language. The goal is to build a set of programming practices based in the “smaller and cleaner language” inside C++. And by doing so, we will also build an awareness around code constructs that can potentially “blows your whole leg off”.
ITT 2014 - Eric Lafortune - ProGuard, Optimizer and Obfuscator in the Android...Istanbul Tech Talks
Eric presents ProGuard - the open-source optimizer and obfuscator that is integrated in the Android SDK. ProGuard reduces the size of applications, improves their performance, and makes them more difficult to reverse-engineer. Eric presents some typical results on what to expect from ProGuard, discuss the latest developments and provide some background that should help mobile developers get the best out of ProGuard.
Using Jenkins for Continuous Integration of Perl components OSD2011 Jonas Brømsø
Lightning talk presentation of Perl setup for Jenkins Continuous Integration platform. Notes and more information available at: https://logiclab.jira.com/wiki/display/OPEN/Continuous+Integration
C# is here to stay, it is time to embrace one of the most popular languages of the future and learn what is coming. In this talk we will look at how C# has evolved over time, and why it is definitely here to stay!
Explores how to write a tic-tac-toe API that meets some interesting static typing constraints. Specifically, programs using the API may fail to compile, depending on the state of play in the game, such as trying to call move() with an already completed game board. The real theme of the presentation is not so much solving the tic-tac-toe problem but, rather, pushing static typing to its limits (and some might argue beyond its useful limits—you will have to judge for yourself).
Thoughts On Learning A New Programming LanguagePatricia Aas
How should we teach a new language to folks that already know how to program?
How do we use what we already know to leapfrog the learning process?
Based on my personal experience and snippets of natural language theory, we will try to explore the cheats and pitfalls when learning a new programming language, but also dig into how we can make it easier.
Did you think C# was already the perfect programming language? Did you think there was no work left on refining the language?
In this session I’ll walk through what’s new in C# 6.0, how the new open-source compiler helped and why we have an awesome time ahead!
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...Tsundere Chen
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime -Part 2
This is the slide for PyCon TW 2017 Day 3 PyPy's approach to construct domain-specific language runtime's Slide, and this is part 2, Part 1 is jserv's work, refer to his slide
Les slides du Tools in Action que j'ai donné à Devoxx France 2019.
Le JDK est open source et son développement aussi. L'ensemble des nouveautés vit sur des branches Mercurial qui peuvent être téléchargées et compilées à la demande. Cela permet de jouer avec des fonctionnalités encore en chantier, de regarder comment les nouvelles syntaxes fonctionneront, bref, de jouer avec un JDK du futur, qui n'existera peut-être jamais. L'objet de ce tools in action est simple : montrer comment tout ceci fonctionne, de l'installation d'une machine Ubuntu à l'exécution d'un JDK recompilé maison.
Lambdas and Streams Master Class Part 2José Paumard
These are the slides of the talk we made with Stuart Marks at Devoxx Belgium 2018. This second part covers the Stream API, reduction and the Collector API.
What is the state of lambda expressions in Java 11? Lambda expressions are the major feature of Java 8, having an impact on most of the API, including the Streams and Collections API. We are now living the Java 11 days; new features have been added and new patterns have emerged. This highly technical Deep Dive session will visit all these patterns, the well-known ones and the new ones, in an interactive hybrid of lecture and laboratory. We present a technique and show how it helps solve a problem. We then present another problem, and give you some time to solve it yourself. Finally, we present a solution, and open for questions, comments, and discussion. Bring your laptop set up with JDK 11 and your favorite IDE, and be prepared to think!
ITT 2014 - Eric Lafortune - ProGuard, Optimizer and Obfuscator in the Android...Istanbul Tech Talks
Eric presents ProGuard - the open-source optimizer and obfuscator that is integrated in the Android SDK. ProGuard reduces the size of applications, improves their performance, and makes them more difficult to reverse-engineer. Eric presents some typical results on what to expect from ProGuard, discuss the latest developments and provide some background that should help mobile developers get the best out of ProGuard.
Using Jenkins for Continuous Integration of Perl components OSD2011 Jonas Brømsø
Lightning talk presentation of Perl setup for Jenkins Continuous Integration platform. Notes and more information available at: https://logiclab.jira.com/wiki/display/OPEN/Continuous+Integration
C# is here to stay, it is time to embrace one of the most popular languages of the future and learn what is coming. In this talk we will look at how C# has evolved over time, and why it is definitely here to stay!
Explores how to write a tic-tac-toe API that meets some interesting static typing constraints. Specifically, programs using the API may fail to compile, depending on the state of play in the game, such as trying to call move() with an already completed game board. The real theme of the presentation is not so much solving the tic-tac-toe problem but, rather, pushing static typing to its limits (and some might argue beyond its useful limits—you will have to judge for yourself).
Thoughts On Learning A New Programming LanguagePatricia Aas
How should we teach a new language to folks that already know how to program?
How do we use what we already know to leapfrog the learning process?
Based on my personal experience and snippets of natural language theory, we will try to explore the cheats and pitfalls when learning a new programming language, but also dig into how we can make it easier.
Did you think C# was already the perfect programming language? Did you think there was no work left on refining the language?
In this session I’ll walk through what’s new in C# 6.0, how the new open-source compiler helped and why we have an awesome time ahead!
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...Tsundere Chen
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime -Part 2
This is the slide for PyCon TW 2017 Day 3 PyPy's approach to construct domain-specific language runtime's Slide, and this is part 2, Part 1 is jserv's work, refer to his slide
Les slides du Tools in Action que j'ai donné à Devoxx France 2019.
Le JDK est open source et son développement aussi. L'ensemble des nouveautés vit sur des branches Mercurial qui peuvent être téléchargées et compilées à la demande. Cela permet de jouer avec des fonctionnalités encore en chantier, de regarder comment les nouvelles syntaxes fonctionneront, bref, de jouer avec un JDK du futur, qui n'existera peut-être jamais. L'objet de ce tools in action est simple : montrer comment tout ceci fonctionne, de l'installation d'une machine Ubuntu à l'exécution d'un JDK recompilé maison.
Lambdas and Streams Master Class Part 2José Paumard
These are the slides of the talk we made with Stuart Marks at Devoxx Belgium 2018. This second part covers the Stream API, reduction and the Collector API.
What is the state of lambda expressions in Java 11? Lambda expressions are the major feature of Java 8, having an impact on most of the API, including the Streams and Collections API. We are now living the Java 11 days; new features have been added and new patterns have emerged. This highly technical Deep Dive session will visit all these patterns, the well-known ones and the new ones, in an interactive hybrid of lecture and laboratory. We present a technique and show how it helps solve a problem. We then present another problem, and give you some time to solve it yourself. Finally, we present a solution, and open for questions, comments, and discussion. Bring your laptop set up with JDK 11 and your favorite IDE, and be prepared to think!
Go 1.10 Release Party, featuring what's new in Go 1.10 and a few deep dives into how Go works.
Presented at the PDX Go Meetup on April 24th, 2018.
https://www.meetup.com/PDX-Go/events/248938586/
The GPars (Groovy Parallel Systems) project provides multiple abstractions for concurrent, parallel programming in Groovy and Java. Rather than dealing directly with threads, synchronization, and locks, or even the java.util.concurrent classes added in Java 5, the project allows you to think in terms of actors, data flows, or composable asynchronous functions (to name a few).
In this talk, I covered the basics of GPars, including what it's like to learn to use it. Although I've done a fair amount of concurrent programming, I've just started using GPars. As such, this talk should be suitable for Groovy beginners.
Golang basics for Java developers - Part 1Robert Stern
A short overview of Golang with Java comparison.
Part 1 of the series "Microservice development with Golang".
Contains hints and example links for potential Gophers
Conférence des Geeks Anonymes sur " le langage Go ", par Thomas Hayen le 23 septembre 2020.
Cette conférence est disponible en vidéo sur Youtube : https://youtu.be/AlGGneVGTJk
Code formatting is an opinionated beast. It always has been a matter of taste, and it always will be a matter of taste. This is the reason, why professional formatting tools, such as Eclipse JDT, offer a gazillion number of options. Which is still not sufficient enough. After all, you can override them inline with tag-comments to make the formatter shut up. Can't we do better than that? What if we could use machine learning techniques to detect the preferred code style that was use in a codebase so far? Turns out, we can.
The Antlr Codebuff project (https://github.com/antlr/codebuff) offers a generic formatter for pretty much any given language. As long as a grammar file exists, existing source can be analyzed to learn about the rules that have been applied while writing the code. Those can than be used to pretty print newly written code. No configuration required. And existing sources will stay as nicely formatted as they are. In the end, the primary purpose of code formatting is not to re-arrange all the keywords, but to make the source layout consistent.
In this talk, we will demonstrate the usage of the codebuff project and how it can be used to format the sources of your repo in a consistent way. We'll also show some other gems that have been revealed when toying around with the technology.
Mobile App Development Company In Noida | Drona InfotechDrona Infotech
Looking for a reliable mobile app development company in Noida? Look no further than Drona Infotech. We specialize in creating customized apps for your business needs.
Visit Us For : https://www.dronainfotech.com/mobile-application-development/
Transform Your Communication with Cloud-Based IVR SolutionsTheSMSPoint
Discover the power of Cloud-Based IVR Solutions to streamline communication processes. Embrace scalability and cost-efficiency while enhancing customer experiences with features like automated call routing and voice recognition. Accessible from anywhere, these solutions integrate seamlessly with existing systems, providing real-time analytics for continuous improvement. Revolutionize your communication strategy today with Cloud-Based IVR Solutions. Learn more at: https://thesmspoint.com/channel/cloud-telephony
AI Genie Review: World’s First Open AI WordPress Website CreatorGoogle
AI Genie Review: World’s First Open AI WordPress Website Creator
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-genie-review
AI Genie Review: Key Features
✅Creates Limitless Real-Time Unique Content, auto-publishing Posts, Pages & Images directly from Chat GPT & Open AI on WordPress in any Niche
✅First & Only Google Bard Approved Software That Publishes 100% Original, SEO Friendly Content using Open AI
✅Publish Automated Posts and Pages using AI Genie directly on Your website
✅50 DFY Websites Included Without Adding Any Images, Content Or Doing Anything Yourself
✅Integrated Chat GPT Bot gives Instant Answers on Your Website to Visitors
✅Just Enter the title, and your Content for Pages and Posts will be ready on your website
✅Automatically insert visually appealing images into posts based on keywords and titles.
✅Choose the temperature of the content and control its randomness.
✅Control the length of the content to be generated.
✅Never Worry About Paying Huge Money Monthly To Top Content Creation Platforms
✅100% Easy-to-Use, Newbie-Friendly Technology
✅30-Days Money-Back Guarantee
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
#AIGenieApp #AIGenieBonus #AIGenieBonuses #AIGenieDemo #AIGenieDownload #AIGenieLegit #AIGenieLiveDemo #AIGenieOTO #AIGeniePreview #AIGenieReview #AIGenieReviewandBonus #AIGenieScamorLegit #AIGenieSoftware #AIGenieUpgrades #AIGenieUpsells #HowDoesAlGenie #HowtoBuyAIGenie #HowtoMakeMoneywithAIGenie #MakeMoneyOnline #MakeMoneywithAIGenie
Atelier - Innover avec l’IA Générative et les graphes de connaissancesNeo4j
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Allez au-delà du battage médiatique autour de l’IA et découvrez des techniques pratiques pour utiliser l’IA de manière responsable à travers les données de votre organisation. Explorez comment utiliser les graphes de connaissances pour augmenter la précision, la transparence et la capacité d’explication dans les systèmes d’IA générative. Vous partirez avec une expérience pratique combinant les relations entre les données et les LLM pour apporter du contexte spécifique à votre domaine et améliorer votre raisonnement.
Amenez votre ordinateur portable et nous vous guiderons sur la mise en place de votre propre pile d’IA générative, en vous fournissant des exemples pratiques et codés pour démarrer en quelques minutes.
Do you want Software for your Business? Visit Deuglo
Deuglo has top Software Developers in India. They are experts in software development and help design and create custom Software solutions.
Deuglo follows seven steps methods for delivering their services to their customers. They called it the Software development life cycle process (SDLC).
Requirement — Collecting the Requirements is the first Phase in the SSLC process.
Feasibility Study — after completing the requirement process they move to the design phase.
Design — in this phase, they start designing the software.
Coding — when designing is completed, the developers start coding for the software.
Testing — in this phase when the coding of the software is done the testing team will start testing.
Installation — after completion of testing, the application opens to the live server and launches!
Maintenance — after completing the software development, customers start using the software.
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Crescat
Crescat is industry-trusted event management software, built by event professionals for event professionals. Founded in 2017, we have three key products tailored for the live event industry.
Crescat Event for concert promoters and event agencies. Crescat Venue for music venues, conference centers, wedding venues, concert halls and more. And Crescat Festival for festivals, conferences and complex events.
With a wide range of popular features such as event scheduling, shift management, volunteer and crew coordination, artist booking and much more, Crescat is designed for customisation and ease-of-use.
Over 125,000 events have been planned in Crescat and with hundreds of customers of all shapes and sizes, from boutique event agencies through to international concert promoters, Crescat is rigged for success. What's more, we highly value feedback from our users and we are constantly improving our software with updates, new features and improvements.
If you plan events, run a venue or produce festivals and you're looking for ways to make your life easier, then we have a solution for you. Try our software for free or schedule a no-obligation demo with one of our product specialists today at crescat.io
Artificia Intellicence and XPath Extension FunctionsOctavian Nadolu
The purpose of this presentation is to provide an overview of how you can use AI from XSLT, XQuery, Schematron, or XML Refactoring operations, the potential benefits of using AI, and some of the challenges we face.
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Łukasz Chruściel
No one wants their application to drag like a car stuck in the slow lane! Yet it’s all too common to encounter bumpy, pothole-filled solutions that slow the speed of any application. Symfony apps are not an exception.
In this talk, I will take you for a spin around the performance racetrack. We’ll explore common pitfalls - those hidden potholes on your application that can cause unexpected slowdowns. Learn how to spot these performance bumps early, and more importantly, how to navigate around them to keep your application running at top speed.
We will focus in particular on tuning your engine at the application level, making the right adjustments to ensure that your system responds like a well-oiled, high-performance race car.
GraphSummit Paris - The art of the possible with Graph TechnologyNeo4j
Sudhir Hasbe, Chief Product Officer, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Software Engineering, Software Consulting, Tech Lead, Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Transaction, Spring MVC, OpenShift Cloud Platform, Kafka, REST, SOAP, LLD & HLD.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
Enterprise Resource Planning System includes various modules that reduce any business's workload. Additionally, it organizes the workflows, which drives towards enhancing productivity. Here are a detailed explanation of the ERP modules. Going through the points will help you understand how the software is changing the work dynamics.
To know more details here: https://blogs.nyggs.com/nyggs/enterprise-resource-planning-erp-system-modules/
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
2. 2013 / 5 / 30
Scope
Page 2
This MTG Target
Understand What’s PEG.js
Know How to Use PEG.js
Make New DSL and Parser
3. 2013 / 5 / 30
Agenda
Page 3
Table of Contents
1.How to make parser
2. What’s PEG.js
3. Try to used to be PEG
4. Let’s make DSL
5.Applications
4. 2013 / 5 / 30
Agenda
Page 4
Table of Contents
1.How to make parser
2. What’s PEG.js
3. Try to used to be PEG
4. Let’s make DSL
5.Applications
5. 2013 / 5 / 30 Page 5
1. How to make parser
1. Lexical Analysis(字句解析)
2. Syntactic Parsing(構文解析)
3. Semantic Analysis(意味解析)
4. Intermidiate Code Generation(中間コード生成)
5. Code Optimization(コード最適化)
6. Code Generation(コード生成)
General Step of Processing with Compiler
Parser
6. 2013 / 5 / 30 Page 6
1. How to make parser
1. Lexical Analysis(字句解析)
2. Syntactic Parsing(構文解析)
3. Semantic Analysis(意味解析)
Analysis for Make Parser
Make strings(minimum unit of string has semantic) from characters
Make tree structure from strings which result of Lexical Analysis
Type Check
※ A string of Lexical Analysis is called “Token”.
7. 2013 / 5 / 30 Page 7
1. How to make parser
1. Lexical Analysis
position_x = position_x + 2.0 * time
Identifier : position_x
Substitution Symbol : =
Identifier : position_x
Addition Symbol : +
Number : 2.0
Multiple Symbol : *
Identifier : time
8. 2013 / 5 / 30 Page 8
1. How to make parser
2. Syntactic Parsing
Identifier : position_x Substitution Symbol : =
Identifier : position_x Addition Symbol : +
Number : 2.0 Multiple Symbol : *
Identifier : time
Substitution Symbol
Identifier
position_x
Expression
ExpressionExpression
Expression Expression
Identifier
position_x
Number
2.0
Identifier
time
=
+
*
9. 2013 / 5 / 30 Page 9
1. How to make parser
3. Semantic Analysis
Substitution Symbol
Identifier
position_x
Expression
ExpressionExpression
Expression Expression
Identifier
position_x
Number Identifier
=
+
Correct Case : Real Number * Integer Number
Wrong Case : Real Number * Function Pointer
2.0 time
*
10. 2013 / 5 / 30
Agenda
Page 10
Table of Contents
1.How to make parser
2. What’s PEG.js
3. Try to used to be PEG
4. Let’s make DSL
5.Applications
11. 2013 / 5 / 30 Here comes
your footer
2. What‘s PEG.js?
Parser Generator for JavaScript
Use PEG
(Parsing Expression Grammar)
Easy to try with the web page
Outline of PEG.js
http://pegjs.majda.cz/
12. 2013 / 5 / 30 Here comes
your footer
2. What‘s PEG.js?
PEG(Parsing Expression Grammar) is one of grammar for artificial language.
Focus point is how input will be analyzed.
What‘s PEG
Ex) Simple Expression Grammar which Has Four Arithmetic Operations
expression <- addexp
addexp <- multiexp (“+” multiexp / “-” multiexp)*
multiexp <- number (“*” number / “/” number)*
number <- [0-9]+
Accept : 2*3+6/2-5*3 -> multiexp + multiexp – multiexp -> ・・・
Decline : (1+1)*3+6/2-(7-2)*3 -> ?*3+6/2-?*3 -> can’t recognize…
13. 2013 / 5 / 30 Here comes
your footer
2. What‘s PEG.js?
• Nothing Confusion
• Different : “a b / a”, “a / a b”
• Easy to use compared with CFG
• Don’t need to implement
scanner (Lexical Analyzer)
• Don’t Express Left Recursive
PEG vs CFG(Context Free Grammar)
• Confusion Existing
• Same : “a b | a”, “a | a b”
• Need to implement scanner
• Can Express Left Recursive
PEG CFG
14. 2013 / 5 / 30 Page 14
2. What‘s PEG.js?
1. Make Grammar with PEG
2. Generate Parser with “pegjs” Command
3. Use the Parser Loaded as a Library
Step of Make Parser with PEG.js
vim filename.pegjs
Pegjs filename.pegjs parser.js
<script src=“./parser.js” type=“text/javascript”></script>
<script type=“text/javascript”>
parser.parse(“something”);
16. 2013 / 5 / 30 Page 16
2. What‘s PEG.js?
1. Make Grammar with PEG
2. Generate Parser with “pegjs” Command
3. Use the Parser Loaded as a Library
Let’s use PEG.js a little bit
$ vim ffirst.pegjs
start = addexp
addexp = integer ("+" integer / "-" integer)*
integer = [0-9]+
$ ./node_modules/pegjs/bin/pegjs first.pegjs parser.js
$ vim parser.js
1st line: module.export = … -> var parser = …
$ vim index.html
<script type=“text/javascript” src=“./parser.js”></script>
<script type=“text/javascript”>
alert(parser.parse(“1+2+3-5”));
</script>
17. 2013 / 5 / 30
Agenda
Page 17
Table of Contents
1.How to make parser
2. What’s PEG.js
3. Try to used to be PEG
4. Let’s make DSL
5.Applications
18. 2013 / 5 / 30 Page 18
3.Try to used to be PEG
PEG.js Online Version (http://pegjs.majda.cz/online)
19. 2013 / 5 / 30 Page 19
3. Try to used to be PEG
Very Simple PEG.js Grammar(calc : integer)
Grammar
Test Input
Test Input Result
start = integer
integer = digits:[0-9]+ { return parseInt(digits.join(“”), 10); }
123456789
123456789
20. 2013 / 5 / 30 Page 20
3. Try to used to be PEG
Very Simple PEG.js Grammar(calc : add two integer)
Grammar
Test Input
Test Input Result
start = target1:integer "+" target2:integer { return target1+target2; }
integer = digits:[0-9]+ { return parseInt(digits.join(""), 10); }
81+19
100
21. 2013 / 5 / 30 Page 21
3. Try to used to be PEG
Very Simple PEG.js Grammar(calc : add and minus two integer)
Grammar
Test Input
Test Input Result
start
= target1:integer "+" target2:integer { return target1+target2; }
/ target1:integer "-" target2:integer { return target1-target2; }
integer = digits:[0-9]+ { return parseInt(digits.join(""), 10); }
100-19
81
22. 2013 / 5 / 30 Page 22
3. Try to used to be PEG
Very Simple PEG.js Grammar(calc : add and minus integers)
Grammar
Test Input
Test Input Result
start = expression
expression
= ope1:integer "+" ope2:expression { return ope1+ope2; }
/ ope1:integer "-" ope2:expression { return ope1-ope2; }
/ ope:integer { return ope; }
integer = digits:[0-9]+ { return parseInt(digits.join(""), 10); }
1+2+3+4+5-6+7-8+9-10
9
23. 2013 / 5 / 30 Page 23
3. Try to used to be PEG
Very Simple PEG.js Grammar(calc : four arithmetic)
Grammar
Test Input
Test Input Result
start = expression
expression
= ope1:integer "+" ope2:expression { return ope1+ope2; }
/ ope1:integer "-" ope2:expression { return ope1-ope2; }
/ ope1:integer "*" ope2:expression { return ope1*ope2; }
/ ope1:integer "/" ope2:expression { return ope1/ope2; }
/ ope:integer { return ope; }
integer = digits:[0-9]+ { return parseInt(digits.join(""), 10); }
2*3/2
3
24. 2013 / 5 / 30 Page 24
3. Try to used to be PEG
Very Simple PEG.js Grammar(calc : four arithmetic with priority)
Grammar
Test Input
Test Input Result
start = expression
expression = ope1:multiple "+" ope2:expression { return ope1+ope2; }
/ ope1:multiple "-" ope2:expression { return ope1-ope2; }
/ ope:multiple { return ope; }
multiple = ope1:integer "*" ope2:multiple { return ope1*ope2; }
/ ope1:integer "/" ope2:multiple { return ope1/ope2; }
/ ope:integer { return ope; }
integer = digits:[0-9]+ { return parseInt(digits.join(""), 10); }
2*3/2+8/4
5