SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
The LIL Language
What is LIL
What is LIL
 LIL is a small programming language
 LIL stands for Little Interpreted Language
 Focused on being an extension language
 Highly dynamic
 Minimal syntax
 Easy to embed
LIL is small
 A small core set of functions (about 50)
 String handling
 Lists
 Flow control
 etc
 A pair of .c and .h files
 About 3000 lines of C source code
 Could be smaller, but had to be usable :-)
 The ”lil” executable is ~40K (Linux x86)
Extension languages
 A language to write extensions for a host
program
 Extensions depend on the program but most
complex programs can be extended via scripts
 A wizard for an office application
 The logic for a game character
 Responses for web requests in a server
 A text editor script to convert a set of ”#define” lines
to ”case” lines for C code which return a string with
the constant's name without some prefix
 I need this more often than i would want...
LIL is an extension language
 A host can extend the language by providing
new functions
 in LIL everything is done via functions, including
control structures like if, for, while, etc
 a function can execute code passed as a function
argument, set a new local or global variable, create
new execution environments, etc
 Listen to callbacks for I/O, errors, exit requests,
writing and reading to variables, etc
 I/O callbacks can be used to sandbox script
 Variable callbacks can expose host variables
LIL is highly dynamic
 No separate compilation and execution step
 The runtime can be modified at any time
 New variables can be introduced
 New functions can be defined – or redefined
 Functions can be renamed – including natives
 The runtime can be inspected via reflection
 All code and data is stored as strings and
converted to the appropriate type when needed
 Code can be generated and is evaluated lazyly
 String functions can be used with, e.g. lists
LIL has minimal syntax
 Everything follows a simple format:
word1 word2 word3 … wordn
 For commands the first word is the function name
and the rest are the function arguments
 Words are separated by space, but they can
contain special characters and/or be inside
special quotes (single quotes, double quotes,
braces and brackets)
 Words can contain spaces or other special
characters, including – if escaped properly –
characters with a special meaning for LIL
LIL has minimal syntax (cont.)
 Single and double quotes can be used to
include spaces and/or escaping characters
 A command inside [ and ] is executed and its
result is used in place of the […]
 Anything inside { and } is used as-is
 however LIL will count the {s and }s so that they can
be nested
 $ followed by a word evalutes to a variable read
 this can be changed at runtime to do other things
 And that is it. See LIL's readme.txt for details
LIL is easy to embed
 Uses a readable and permissive license: zlib
 Written in C89 with few common C99 features
 Can be used as a shared or static library
 or just drop the lil.c and lil.h pair in your project
 Small API to learn with few simple calls needed
for practical use
 Can be used with C and C++ directly and from
languages which support C shared libraries
 Import LIL is a project that provides bindings for
Free Pascal and .NET (and others in the future)
Some examples
LIL language examples
LIL examples
 Mandatory hello world
print Hello, world
 Notice how quotes are not needed
 Error-try-catch
try { if stuff { error ”Bad stuff” } } { print 
Got an error: [reflect error] }
 Factorial of 10
print [[func {x} { if [expr $x == 1] { return 1 
} { return [expr [[reflect name] [expr $x ­ 1]] 
* $x] }}] 10]
LIL examples (cont.)
# print all known functions with name lengths
# less than five characters
set known­funcs [reflect funcs]
set predicate {[length $x] < 5}
set small­funcs [filter $known­funcs $predicate]
print "Functions with small names:"
foreach $small­funcs {print "  $i"}
C API examples
 Create and destroy a LIL runtime
lil_t lil = lil_new();
/* do stuff here */
lil_free(lil);
 Run some LIL code
lil_free_value(lil_parse(lil,”print hi”,0,0));
 Register a custom function
lil_register(lil, ”newfunc”, fnc_newfunc);
 fnc_newfunc is defined in the next slide
C API examples (cont.)
/* myfunc native function */
LILCALLBACK lil_value_t fnc_myfunc(
    lil_t lil,         /* lil runtime */
    size_t argc,       /* number of arguments */
    lil_value_t* argv) /* arguments array */
{
    size_t i;
    printf(”I've got %i arguments:”, (int)argc);
    for (i=0; i<argc; i++)
        printf(”  '%s'n”,
            lil_to_string(argv[i]));
    return lil_alloc_string(”myfunc result!”);
}
print ”That was it”
That was it
More information
 LIL at github: https://github.com/badsector/lil
 Latest source code
 Wiki
 Issue db
 The readme.txt file in LIL's source code
 Everything about LIL
 Syntax
 Reference
 Import LIL: https://github.com/badsector/implil
 Bindings for Free Pascal, .NET and maybe others

Weitere ähnliche Inhalte

Was ist angesagt?

Symbolic Debugging with DWARF
Symbolic Debugging with DWARFSymbolic Debugging with DWARF
Symbolic Debugging with DWARFSamy Bahra
 
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...Edureka!
 
Design and Deployment of Enterprise Wirlesss Networks
Design and Deployment of Enterprise Wirlesss NetworksDesign and Deployment of Enterprise Wirlesss Networks
Design and Deployment of Enterprise Wirlesss NetworksCisco Mobility
 
Troubleshooting Wireless LANs with Centralized Controllers
Troubleshooting Wireless LANs with Centralized ControllersTroubleshooting Wireless LANs with Centralized Controllers
Troubleshooting Wireless LANs with Centralized ControllersCisco Mobility
 
Introduction to Software Engineering
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software EngineeringMajane Padua
 
Wi fi protected access
Wi fi protected accessWi fi protected access
Wi fi protected accessLopamudra Das
 

Was ist angesagt? (12)

Symbolic Debugging with DWARF
Symbolic Debugging with DWARFSymbolic Debugging with DWARF
Symbolic Debugging with DWARF
 
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...
 
Requirement Engineering
Requirement EngineeringRequirement Engineering
Requirement Engineering
 
Customizing iso 9126 quality model for evaluation of b2 b applications
Customizing iso 9126 quality model for evaluation of b2 b applicationsCustomizing iso 9126 quality model for evaluation of b2 b applications
Customizing iso 9126 quality model for evaluation of b2 b applications
 
Case tools
Case toolsCase tools
Case tools
 
SE chapter 5
SE chapter 5SE chapter 5
SE chapter 5
 
Design and Deployment of Enterprise Wirlesss Networks
Design and Deployment of Enterprise Wirlesss NetworksDesign and Deployment of Enterprise Wirlesss Networks
Design and Deployment of Enterprise Wirlesss Networks
 
Troubleshooting Wireless LANs with Centralized Controllers
Troubleshooting Wireless LANs with Centralized ControllersTroubleshooting Wireless LANs with Centralized Controllers
Troubleshooting Wireless LANs with Centralized Controllers
 
Introduction to Software Engineering
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software Engineering
 
Software development life cycle
Software development life cycleSoftware development life cycle
Software development life cycle
 
Wi fi protected access
Wi fi protected accessWi fi protected access
Wi fi protected access
 
Qt Application Programming with C++ - Part 1
Qt Application Programming with C++ - Part 1Qt Application Programming with C++ - Part 1
Qt Application Programming with C++ - Part 1
 

Ähnlich wie LIL Presentation

The IoT Academy training part2 AI Architecture
The IoT Academy training part2 AI ArchitectureThe IoT Academy training part2 AI Architecture
The IoT Academy training part2 AI ArchitectureThe IOT Academy
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaSynesso
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftTalentica Software
 
c# usage,applications and advantages
c# usage,applications and advantages c# usage,applications and advantages
c# usage,applications and advantages mohamed drahem
 
Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Muhammad Haseeb Shahid
 
Ch07 Programming for Security Professionals
Ch07 Programming for Security ProfessionalsCh07 Programming for Security Professionals
Ch07 Programming for Security Professionalsphanleson
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_pythongunanandJha2
 
presentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptpresentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptMohitChaudhary637683
 
358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1sumitbardhan
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Espen Brækken
 
Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...IndicThreads
 
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...Apple’s New Swift Programming Language Takes Flight With New Enhancements And...
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...Azilen Technologies Pvt. Ltd.
 
Welcome to the .Net
Welcome to the .NetWelcome to the .Net
Welcome to the .NetAmr Shawky
 
New c sharp4_features_part_vi
New c sharp4_features_part_viNew c sharp4_features_part_vi
New c sharp4_features_part_viNico Ludwig
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3aminmesbahi
 
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHBhavsingh Maloth
 
Python Programming Basics for begginners
Python Programming Basics for begginnersPython Programming Basics for begginners
Python Programming Basics for begginnersAbishek Purushothaman
 

Ähnlich wie LIL Presentation (20)

The IoT Academy training part2 AI Architecture
The IoT Academy training part2 AI ArchitectureThe IoT Academy training part2 AI Architecture
The IoT Academy training part2 AI Architecture
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thrift
 
c# usage,applications and advantages
c# usage,applications and advantages c# usage,applications and advantages
c# usage,applications and advantages
 
Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)
 
Advanced C
Advanced C Advanced C
Advanced C
 
Ch07 Programming for Security Professionals
Ch07 Programming for Security ProfessionalsCh07 Programming for Security Professionals
Ch07 Programming for Security Professionals
 
8844632.ppt
8844632.ppt8844632.ppt
8844632.ppt
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_python
 
presentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptpresentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.ppt
 
358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex
 
Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...
 
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...Apple’s New Swift Programming Language Takes Flight With New Enhancements And...
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...
 
Welcome to the .Net
Welcome to the .NetWelcome to the .Net
Welcome to the .Net
 
F# 101
F# 101F# 101
F# 101
 
New c sharp4_features_part_vi
New c sharp4_features_part_viNew c sharp4_features_part_vi
New c sharp4_features_part_vi
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3
 
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
 
Python Programming Basics for begginners
Python Programming Basics for begginnersPython Programming Basics for begginners
Python Programming Basics for begginners
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Kürzlich hochgeladen (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

LIL Presentation

  • 2. What is LIL  LIL is a small programming language  LIL stands for Little Interpreted Language  Focused on being an extension language  Highly dynamic  Minimal syntax  Easy to embed
  • 3. LIL is small  A small core set of functions (about 50)  String handling  Lists  Flow control  etc  A pair of .c and .h files  About 3000 lines of C source code  Could be smaller, but had to be usable :-)  The ”lil” executable is ~40K (Linux x86)
  • 4. Extension languages  A language to write extensions for a host program  Extensions depend on the program but most complex programs can be extended via scripts  A wizard for an office application  The logic for a game character  Responses for web requests in a server  A text editor script to convert a set of ”#define” lines to ”case” lines for C code which return a string with the constant's name without some prefix  I need this more often than i would want...
  • 5. LIL is an extension language  A host can extend the language by providing new functions  in LIL everything is done via functions, including control structures like if, for, while, etc  a function can execute code passed as a function argument, set a new local or global variable, create new execution environments, etc  Listen to callbacks for I/O, errors, exit requests, writing and reading to variables, etc  I/O callbacks can be used to sandbox script  Variable callbacks can expose host variables
  • 6. LIL is highly dynamic  No separate compilation and execution step  The runtime can be modified at any time  New variables can be introduced  New functions can be defined – or redefined  Functions can be renamed – including natives  The runtime can be inspected via reflection  All code and data is stored as strings and converted to the appropriate type when needed  Code can be generated and is evaluated lazyly  String functions can be used with, e.g. lists
  • 7. LIL has minimal syntax  Everything follows a simple format: word1 word2 word3 … wordn  For commands the first word is the function name and the rest are the function arguments  Words are separated by space, but they can contain special characters and/or be inside special quotes (single quotes, double quotes, braces and brackets)  Words can contain spaces or other special characters, including – if escaped properly – characters with a special meaning for LIL
  • 8. LIL has minimal syntax (cont.)  Single and double quotes can be used to include spaces and/or escaping characters  A command inside [ and ] is executed and its result is used in place of the […]  Anything inside { and } is used as-is  however LIL will count the {s and }s so that they can be nested  $ followed by a word evalutes to a variable read  this can be changed at runtime to do other things  And that is it. See LIL's readme.txt for details
  • 9. LIL is easy to embed  Uses a readable and permissive license: zlib  Written in C89 with few common C99 features  Can be used as a shared or static library  or just drop the lil.c and lil.h pair in your project  Small API to learn with few simple calls needed for practical use  Can be used with C and C++ directly and from languages which support C shared libraries  Import LIL is a project that provides bindings for Free Pascal and .NET (and others in the future)
  • 11. LIL examples  Mandatory hello world print Hello, world  Notice how quotes are not needed  Error-try-catch try { if stuff { error ”Bad stuff” } } { print  Got an error: [reflect error] }  Factorial of 10 print [[func {x} { if [expr $x == 1] { return 1  } { return [expr [[reflect name] [expr $x ­ 1]]  * $x] }}] 10]
  • 13. C API examples  Create and destroy a LIL runtime lil_t lil = lil_new(); /* do stuff here */ lil_free(lil);  Run some LIL code lil_free_value(lil_parse(lil,”print hi”,0,0));  Register a custom function lil_register(lil, ”newfunc”, fnc_newfunc);  fnc_newfunc is defined in the next slide
  • 14. C API examples (cont.) /* myfunc native function */ LILCALLBACK lil_value_t fnc_myfunc(     lil_t lil,         /* lil runtime */     size_t argc,       /* number of arguments */     lil_value_t* argv) /* arguments array */ {     size_t i;     printf(”I've got %i arguments:”, (int)argc);     for (i=0; i<argc; i++)         printf(”  '%s'n”,             lil_to_string(argv[i]));     return lil_alloc_string(”myfunc result!”); }
  • 15. print ”That was it” That was it
  • 16. More information  LIL at github: https://github.com/badsector/lil  Latest source code  Wiki  Issue db  The readme.txt file in LIL's source code  Everything about LIL  Syntax  Reference  Import LIL: https://github.com/badsector/implil  Bindings for Free Pascal, .NET and maybe others