Graham Northup 6 vuotta sitten
vanhempi
commit
f2df4b8cc7
  1. 2
      .gitignore
  2. 2434
      Doxyfile
  3. 2
      build.sh
  4. 16
      builtins.c
  5. 302
      conf.py
  6. 7
      doc.sh
  7. 24
      doc/index.rst
  8. 18
      doc/lang/abs_basics.rst
  9. 20
      doc/lang/index.rst
  10. 26
      doc/lang/simple_exprs.rst
  11. 9
      doc/src/ast_h.rst
  12. 15
      doc/src/index.rst
  13. 9
      doc/src/sol_h.rst
  14. 304
      lex.yy.c
  15. 52
      object.c
  16. 0
      old-sol-gdb.py
  17. 8196
      parser.output
  18. 938
      parser.tab.c
  19. 105
      parser.tab.h
  20. 13
      parser.y
  21. 2
      runtime.c
  22. 33
      sol.h
  23. 36
      solrun.c
  24. 353
      state.c
  25. 2
      tokenizer.lex

2
.gitignore

@ -8,3 +8,5 @@ gclog.txt
gcstat.txt
iss*
*.sol
_build
doxyxml

2434
Doxyfile
File diff suppressed because it is too large
Näytä tiedosto

2
build.sh

@ -9,7 +9,7 @@ if [ -z "$CFLAGS" ]; then
# -DDEBUG_GC : Turn on debug GC (all memory allocates/frees go to a file, use gcstat.py to get statistics)
# -DSOL_ICACHE_MIN : Minimum integer to cache in the state
# -DSOL_ICACHE_MAX : Maximum integer to cache in the state (if MAX < MIN, caching is disabled)
CFLAGS="-g"
CFLAGS="-g -DDEBUG_GC"
fi
gcc -c $CFLAGS dsl/seq.c

16
builtins.c

@ -100,6 +100,8 @@ sol_object_t *sol_f_try(sol_state_t *state, sol_object_t *args) {
sol_list_insert(state, ls, 0, zero);
sol_obj_free(zero);
sol_list_insert(state, ls, 2, state->traceback);
sol_obj_free(state->traceback);
state->traceback = NULL;
return ls;
}
sol_list_insert(state, ls, 0, res);
@ -2026,13 +2028,23 @@ sol_object_t *sol_f_astnode_tostring(sol_state_t *state, sol_object_t *args) {
if(!obj->node) {
snprintf(s, 64, "<NULL Stmt>");
} else {
snprintf(s, 64, "<Stmt[%s]>", sol_StmtNames[((stmt_node *)obj->node)->type]);
stmt_t type = ((stmt_node *) obj->node)->type;
if(type < sizeof(sol_StmtNames)/sizeof(char *)) {
snprintf(s, 64, "<Stmt[%s]>", sol_StmtNames[type]);
} else {
snprintf(s, 64, "<Invalid Stmt>");
}
}
} else {
if(!obj->node) {
snprintf(s, 64, "<NULL Expr>");
} else {
snprintf(s, 64, "<Expr[%s]>", sol_ExprNames[((expr_node *)obj->node)->type]);
expr_t type = ((stmt_node *) obj->node)->type;
if(type < sizeof(sol_ExprNames)/sizeof(char *)) {
snprintf(s, 64, "<Expr[%s]>", sol_ExprNames[type]);
} else {
snprintf(s, 64, "<Invalid Expr>");
}
}
}
sol_obj_free(obj);

302
conf.py

@ -0,0 +1,302 @@
# -*- coding: utf-8 -*-
#
# Sol documentation build configuration file, created by
# sphinx-quickstart on Mon Oct 19 11:40:28 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
import shlex
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'breathe',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'doc/index'
# General information about the project.
project = u'Sol'
copyright = u'2015, Grissess et. al.'
author = u'Grissess et. al.'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1a4'
# Breathe's own information about the project.
breathe_projects = {
project: 'doxyxml/xml',
}
breathe_default_project = project
breathe_projects_souce = {
project: '.',
}
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all
# documents.
default_role = 'any'
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
#html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value
#html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
#html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename = 'Soldoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Latex figure (float) alignment
#'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Sol.tex', u'Sol Documentation',
u'Grissess et. al.', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'sol', u'Sol Documentation',
[author], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Sol', u'Sol Documentation',
author, 'Sol', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
# Following are site-local extensions for this project:

7
doc.sh

@ -0,0 +1,7 @@
#!/bin/sh
# Required PyPI packages: sphinx, breathe
# Required ext packages: doxygen
doxygen Doxyfile
sphinx-build -b html . ./_build

24
doc/index.rst

@ -0,0 +1,24 @@
.. Sol documentation master file, created by
sphinx-quickstart on Mon Oct 19 11:40:28 2015.
Welcome to Sol's documentation!
===============================
Sol is an eccentric language modelled on the best of Python and Lua--so it
looks (and performs) a little bit like Javascript! The entire source tree is
fairly small and suitable for static linking, containing just a (featureful)
core runtime and a Bison-Flex parser.
Sol is an interpreted language that uses a reference-counting garbage
collector; it was initially built for `iiag <https://github.com/iiag/iiag>`_,
and can still be found as a working proof-of-concept for integration in its
`legacy "sol" branch <https://github.com/iiag/iiag-legacy/tree/sol/src>`_.
Contents:
.. toctree::
:maxdepth: 2
User's Manual <lang/index>
Developer's Manual <src/index>
genindex

18
doc/lang/abs_basics.rst

@ -0,0 +1,18 @@
Absolute Basics
===============
This chapter is intended to give you just enough orientation of the Sol language to read the examples to follow.
Sol has just one comment type, and it is a line comment; it is preceded by two dashes (--), and appears as follows::
-- This is a comment
--Whitespace to the right is recommended, but not required.
-- Anything to the right of the dashes until the end of the line is completely ignored by the parser.
Interactively, and in many examples, the `prepr` `function <functions>` is used to print convenient forms of the value or values given to it as parameters::
prepr(1) -- Outputs "1" (without enclosing quotes) to stdout
prepr(13.3) -- Outputs "13.3" to stdout"
prepr("hi!") -- Outputs '"hi!"' (without enclosing single quotes) to stdout
Alternatively, the `interpreter` will print the resulting value of any evaluation entered at its prompt.

20
doc/lang/index.rst

@ -0,0 +1,20 @@
Language Reference
==================
The Sol language is an interpreted language with fair syntactic similarity to
Lua and Python, but has enough quirks that some constructs might not be clear.
This guide should be considered definitive to the syntax of the language, but
you should be aware that the namespace under which the language is run may
differ between applications, and that you should consult those applications'
manuals for more information. Only under the basic interpreter (`solrun.c`, or
`sol` from the command line), the `standard library <stdlib>` is well
defined.
.. toctree::
abs_basics
simple_exprs
control_flow
lists_maps
functions
stdlib

26
doc/lang/simple_exprs.rst

@ -0,0 +1,26 @@
Simple Expressions
==================
Literals
--------
A *literal* is a leaf in an expression; it is a value in the source of a Sol program which evaluates to itself. Literals in Sol come in exactly four flavors:
* Integer literals, represented by contiguous digits, possibly preceded by a
negation, like `0`, `123456`, `-314159`, and the like.
* Floating point literals, represented by a pair of contiguous digits separated
by one radix mark, again possibly preceded by a negation, like `1.0`,
`-0.256`, `999.9`, and the like.
* String literals, bound on either side by a single or double quote (they must
match), and containing every interim character (including newline), like
`"hello world"`, `'this string has two backslashes: \\'`, and the like.
Naturally, a string may not contain its own terminator, though it can be
introduced by concatenating strings with different terminators.
* The special literal `None`, a value only ever equal to itself and which
cannot be reassigned by the user program. It is frequently used to represent
the absence of a value, such as the value of a function which does not
explicitly return a value.
The following source fragment demonstrates some of the literals::
a = 123

9
doc/src/ast_h.rst

@ -0,0 +1,9 @@
Internal Definitions (ast.h)
============================
For historical reasons, this header file is called "ast.h"--the definitions of
the AST nodes are not namespace-safe (they aren't prefixed with `sol_`), and so
this file is not generally meant to be included by end users unless strictly
required.
.. doxygenfile:: ast.h

15
doc/src/index.rst

@ -0,0 +1,15 @@
Source Documentation
====================
This section of the documentation is intended for integrators looking to
incorporate Sol into one of their projects, and for developers looking to
extend, maintain, or port Sol.
Many of the pages in this section are automatically documented from source file
comments; if you are writing or rewriting this documentation, please consult
the documentation on "doxygenfile".
.. toctree::
sol_h
ast_h

9
doc/src/sol_h.rst

@ -0,0 +1,9 @@
User Includes (sol.h)
=====================
This header file includes all the standard functionality of Sol in such a way
that user applications can safely call into the library. All types and
functions exported from here are prefixed with `sol_` (possibly further
prefixed by a number of underscores), so as to minimize namespace collision.
.. doxygenfile:: sol.h

304
lex.yy.c

@ -141,7 +141,15 @@ typedef unsigned int flex_uint32_t;
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
@ -361,8 +369,8 @@ static void yy_fatal_error (yyconst char msg[] );
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;
#define YY_NUM_RULES 62
#define YY_END_OF_BUFFER 63
#define YY_NUM_RULES 63
#define YY_END_OF_BUFFER 64
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@ -370,21 +378,21 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_accept[113] =
static yyconst flex_int16_t yy_accept[119] =
{ 0,
0, 0, 63, 62, 61, 30, 62, 58, 22, 24,
62, 52, 53, 20, 18, 57, 19, 54, 21, 2,
55, 56, 42, 31, 43, 59, 59, 50, 51, 26,
59, 59, 59, 59, 59, 59, 59, 59, 59, 48,
25, 49, 27, 61, 41, 0, 3, 28, 37, 0,
4, 23, 34, 32, 0, 33, 35, 1, 2, 47,
44, 40, 45, 46, 59, 59, 39, 59, 59, 11,
59, 59, 59, 59, 5, 10, 59, 59, 59, 38,
29, 36, 0, 60, 1, 59, 59, 59, 59, 16,
9, 59, 59, 59, 59, 17, 59, 59, 7, 12,
59, 6, 59, 14, 59, 59, 8, 59, 13, 59,
15, 0
0, 0, 64, 63, 62, 31, 63, 59, 23, 25,
63, 53, 54, 21, 19, 58, 20, 55, 22, 2,
56, 57, 43, 32, 44, 60, 60, 51, 52, 27,
60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
49, 26, 50, 28, 62, 42, 0, 3, 29, 38,
0, 4, 24, 35, 33, 0, 34, 36, 1, 2,
48, 45, 41, 46, 47, 60, 60, 40, 60, 60,
11, 60, 60, 60, 60, 5, 10, 60, 60, 60,
60, 39, 30, 37, 0, 61, 1, 60, 60, 60,
60, 17, 9, 60, 60, 60, 60, 60, 18, 60,
60, 7, 12, 60, 60, 6, 60, 15, 60, 60,
60, 8, 60, 13, 14, 60, 16, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
@ -400,9 +408,9 @@ static yyconst flex_int32_t yy_ec[256] =
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
26, 1, 27, 28, 24, 1, 29, 30, 31, 32,
33, 34, 24, 35, 36, 24, 37, 38, 24, 39,
40, 24, 24, 41, 42, 43, 44, 24, 45, 24,
24, 24, 46, 47, 48, 49, 1, 1, 1, 1,
33, 34, 24, 35, 36, 24, 37, 38, 39, 40,
41, 24, 24, 42, 43, 44, 45, 24, 46, 24,
24, 24, 47, 48, 49, 50, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -419,93 +427,97 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1
} ;
static yyconst flex_int32_t yy_meta[50] =
static yyconst flex_int32_t yy_meta[51] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 1, 1,
1, 1, 1, 2, 2, 1, 1, 1, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 1, 1, 1, 1
2, 2, 2, 2, 2, 2, 1, 1, 1, 1
} ;
static yyconst flex_int16_t yy_base[117] =
static yyconst flex_int16_t yy_base[123] =
{ 0,
0, 0, 130, 131, 48, 107, 123, 131, 131, 44,
118, 131, 131, 41, 104, 131, 39, 131, 103, 39,
131, 131, 37, 102, 42, 0, 83, 131, 131, 100,
80, 80, 79, 29, 16, 35, 85, 82, 81, 131,
40, 131, 131, 68, 131, 110, 131, 131, 131, 105,
131, 91, 131, 131, 109, 131, 131, 93, 57, 131,
131, 131, 131, 131, 0, 71, 131, 76, 69, 0,
65, 74, 64, 65, 0, 0, 60, 69, 65, 131,
131, 131, 97, 131, 81, 65, 68, 53, 62, 0,
0, 63, 42, 46, 46, 0, 46, 46, 0, 0,
40, 0, 47, 0, 40, 39, 0, 33, 0, 43,
0, 131, 87, 89, 70, 91
0, 0, 136, 137, 49, 113, 129, 137, 137, 45,
124, 137, 137, 42, 110, 137, 40, 137, 109, 40,
137, 137, 38, 108, 43, 0, 88, 137, 137, 106,
85, 85, 84, 23, 27, 35, 95, 90, 87, 86,
137, 35, 137, 137, 68, 137, 115, 137, 137, 137,
110, 137, 96, 137, 137, 114, 137, 137, 98, 58,
137, 137, 137, 137, 137, 0, 75, 137, 81, 73,
0, 69, 79, 68, 69, 0, 0, 69, 63, 73,
69, 137, 137, 137, 101, 137, 85, 69, 72, 56,
66, 0, 0, 67, 67, 51, 55, 56, 0, 56,
56, 0, 0, 59, 48, 0, 49, 0, 41, 51,
39, 0, 33, 0, 0, 44, 0, 137, 83, 85,
71, 87
} ;
static yyconst flex_int16_t yy_def[117] =
static yyconst flex_int16_t yy_def[123] =
{ 0,
112, 1, 112, 112, 112, 112, 113, 112, 112, 112,
114, 112, 112, 112, 112, 112, 112, 112, 112, 112,
112, 112, 112, 112, 112, 115, 115, 112, 112, 112,
115, 115, 115, 115, 115, 115, 115, 115, 115, 112,
112, 112, 112, 112, 112, 113, 112, 112, 112, 114,
112, 112, 112, 112, 116, 112, 112, 112, 112, 112,
112, 112, 112, 112, 115, 115, 112, 115, 115, 115,
115, 115, 115, 115, 115, 115, 115, 115, 115, 112,
112, 112, 116, 112, 112, 115, 115, 115, 115, 115,
115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
115, 0, 112, 112, 112, 112
118, 1, 118, 118, 118, 118, 119, 118, 118, 118,
120, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 121, 121, 118, 118, 118,
121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
118, 118, 118, 118, 118, 118, 119, 118, 118, 118,
120, 118, 118, 118, 118, 122, 118, 118, 118, 118,
118, 118, 118, 118, 118, 121, 121, 118, 121, 121,
121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
121, 118, 118, 118, 122, 118, 118, 121, 121, 121,
121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
121, 121, 121, 121, 121, 121, 121, 0, 118, 118,
118, 118
} ;
static yyconst flex_int16_t yy_nxt[181] =
static yyconst flex_int16_t yy_nxt[188] =
{ 0,
4, 5, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 26, 31,
32, 33, 34, 35, 26, 36, 26, 26, 26, 26,
37, 26, 38, 26, 39, 40, 41, 42, 43, 44,
44, 48, 52, 55, 58, 73, 59, 60, 61, 74,
56, 80, 53, 63, 64, 49, 71, 72, 75, 44,
44, 65, 58, 76, 59, 111, 110, 109, 108, 107,
106, 105, 104, 103, 102, 101, 81, 46, 46, 50,
50, 83, 83, 100, 99, 98, 97, 96, 85, 84,
95, 94, 93, 92, 91, 90, 89, 88, 87, 86,
85, 84, 82, 51, 47, 79, 78, 77, 70, 69,
68, 67, 66, 62, 57, 54, 51, 47, 45, 112,
3, 112, 112, 112, 112, 112, 112, 112, 112, 112,
112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
112, 112, 112, 112, 112, 112, 112, 112, 112, 112
32, 33, 34, 35, 26, 36, 26, 37, 26, 26,
26, 38, 26, 39, 26, 40, 41, 42, 43, 44,
45, 45, 49, 53, 56, 59, 82, 60, 61, 62,
72, 57, 73, 54, 64, 65, 50, 74, 76, 45,
45, 75, 66, 59, 77, 60, 117, 116, 115, 114,
113, 112, 83, 47, 47, 51, 51, 85, 85, 111,
110, 109, 108, 107, 106, 105, 104, 103, 102, 101,
100, 99, 87, 86, 98, 97, 96, 95, 94, 93,
92, 91, 90, 89, 88, 87, 86, 84, 52, 48,
81, 80, 79, 78, 71, 70, 69, 68, 67, 63,
58, 55, 52, 48, 46, 118, 3, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118
} ;
static yyconst flex_int16_t yy_chk[181] =
static yyconst flex_int16_t yy_chk[188] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 5,
5, 10, 14, 17, 20, 35, 20, 23, 23, 35,
17, 41, 14, 25, 25, 10, 34, 34, 36, 44,
44, 115, 59, 36, 59, 110, 108, 106, 105, 103,
101, 98, 97, 95, 94, 93, 41, 113, 113, 114,
114, 116, 116, 92, 89, 88, 87, 86, 85, 83,
79, 78, 77, 74, 73, 72, 71, 69, 68, 66,
58, 55, 52, 50, 46, 39, 38, 37, 33, 32,
31, 30, 27, 24, 19, 15, 11, 7, 6, 3,
112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
112, 112, 112, 112, 112, 112, 112, 112, 112, 112
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
5, 5, 10, 14, 17, 20, 42, 20, 23, 23,
34, 17, 34, 14, 25, 25, 10, 35, 36, 45,
45, 35, 121, 60, 36, 60, 116, 113, 111, 110,
109, 107, 42, 119, 119, 120, 120, 122, 122, 105,
104, 101, 100, 98, 97, 96, 95, 94, 91, 90,
89, 88, 87, 85, 81, 80, 79, 78, 75, 74,
73, 72, 70, 69, 67, 59, 56, 53, 51, 47,
40, 39, 38, 37, 33, 32, 31, 30, 27, 24,
19, 15, 11, 7, 6, 3, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118
} ;
static yy_state_type yy_last_accepting_state;
@ -597,7 +609,7 @@ static void update_loc(YYLTYPE *yylloc, char *yytext){
<STRING>. { str_putc(*yytext); }
*/
#line 601 "lex.yy.c"
#line 613 "lex.yy.c"
#define INITIAL 0
@ -686,7 +698,12 @@ static int input (void );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
@ -827,7 +844,7 @@ YY_DECL
#line 85 "tokenizer.lex"
#line 831 "lex.yy.c"
#line 848 "lex.yy.c"
while ( 1 ) /* loops until end-of-file is reached */
{
@ -854,13 +871,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 113 )
if ( yy_current_state >= 119 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_base[yy_current_state] != 131 );
while ( yy_base[yy_current_state] != 137 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@ -949,256 +966,261 @@ YY_RULE_SETUP
case 13:
YY_RULE_SETUP
#line 111 "tokenizer.lex"
{ return RETURN; }
{ return LAMBDA; }
YY_BREAK
case 14:
YY_RULE_SETUP
#line 113 "tokenizer.lex"
{ return BREAK; }
{ return RETURN; }
YY_BREAK
case 15:
YY_RULE_SETUP
#line 115 "tokenizer.lex"
{ return CONTINUE; }
{ return BREAK; }
YY_BREAK
case 16:
YY_RULE_SETUP
#line 117 "tokenizer.lex"
{ return END; }
{ return CONTINUE; }
YY_BREAK
case 17:
YY_RULE_SETUP
#line 119 "tokenizer.lex"
{ return NONE; }
{ return END; }
YY_BREAK
case 18:
YY_RULE_SETUP
#line 121 "tokenizer.lex"
{ return PLUS; }
{ return NONE; }
YY_BREAK
case 19:
YY_RULE_SETUP
#line 123 "tokenizer.lex"
{ return MINUS; }
{ return PLUS; }
YY_BREAK
case 20:
YY_RULE_SETUP
#line 125 "tokenizer.lex"
{ return STAR; }
{ return MINUS; }
YY_BREAK
case 21:
YY_RULE_SETUP
#line 127 "tokenizer.lex"
{ return SLASH; }
{ return STAR; }
YY_BREAK
case 22:
YY_RULE_SETUP
#line 129 "tokenizer.lex"
{ return PERCENT; }
{ return SLASH; }
YY_BREAK
case 23:
YY_RULE_SETUP
#line 131 "tokenizer.lex"
{ return DSTAR; }
{ return PERCENT; }
YY_BREAK
case 24:
YY_RULE_SETUP
#line 133 "tokenizer.lex"
{ return BAND; }
{ return DSTAR; }
YY_BREAK
case 25:
YY_RULE_SETUP
#line 135 "tokenizer.lex"
{ return BOR; }
{ return BAND; }
YY_BREAK
case 26:
YY_RULE_SETUP
#line 137 "tokenizer.lex"
{ return BXOR; }
{ return BOR; }
YY_BREAK
case 27:
YY_RULE_SETUP
#line 139 "tokenizer.lex"
{ return BNOT; }
{ return BXOR; }
YY_BREAK
case 28:
YY_RULE_SETUP
#line 141 "tokenizer.lex"
{ return LAND; }
{ return BNOT; }
YY_BREAK
case 29:
YY_RULE_SETUP
#line 143 "tokenizer.lex"
{ return LOR; }
{ return LAND; }
YY_BREAK
case 30:
YY_RULE_SETUP
#line 145 "tokenizer.lex"
{ return LNOT; }
{ return LOR; }
YY_BREAK
case 31:
YY_RULE_SETUP
#line 147 "tokenizer.lex"
{ return ASSIGN; }
{ return LNOT; }
YY_BREAK
case 32:
YY_RULE_SETUP
#line 149 "tokenizer.lex"
{ return ASSIGNPLUS; }
{ return ASSIGN; }
YY_BREAK
case 33:
YY_RULE_SETUP
#line 151 "tokenizer.lex"
{ return ASSIGNMINUS; }
{ return ASSIGNPLUS; }
YY_BREAK
case 34:
YY_RULE_SETUP
#line 153 "tokenizer.lex"
{ return ASSIGNSTAR; }
{ return ASSIGNMINUS; }
YY_BREAK
case 35:
YY_RULE_SETUP
#line 155 "tokenizer.lex"
{ return ASSIGNSLASH; }
{ return ASSIGNSTAR; }
YY_BREAK
case 36:
YY_RULE_SETUP
#line 157 "tokenizer.lex"
{ return ASSIGNDSTAR; }
{ return ASSIGNSLASH; }
YY_BREAK
case 37:
YY_RULE_SETUP
#line 159 "tokenizer.lex"
{ return ASSIGNBAND; }
{ return ASSIGNDSTAR; }
YY_BREAK
case 38:
YY_RULE_SETUP
#line 161 "tokenizer.lex"
{ return ASSIGNBOR; }
{ return ASSIGNBAND; }
YY_BREAK
case 39:
YY_RULE_SETUP
#line 163 "tokenizer.lex"
{ return ASSIGNBXOR; }
{ return ASSIGNBOR; }
YY_BREAK
case 40:
YY_RULE_SETUP
#line 165 "tokenizer.lex"
{ return EQUAL; }
{ return ASSIGNBXOR; }
YY_BREAK
case 41:
YY_RULE_SETUP
#line 167 "tokenizer.lex"
{ return NEQUAL; }
{ return EQUAL; }
YY_BREAK
case 42:
YY_RULE_SETUP
#line 169 "tokenizer.lex"
{ return LESS; }
{ return NEQUAL; }
YY_BREAK
case 43:
YY_RULE_SETUP
#line 171 "tokenizer.lex"
{ return GREATER; }
{ return LESS; }
YY_BREAK
case 44:
YY_RULE_SETUP
#line 173 "tokenizer.lex"
{ return LESSEQ; }
{ return GREATER; }
YY_BREAK
case 45:
YY_RULE_SETUP
#line 175 "tokenizer.lex"
{ return GREATEREQ; }
{ return LESSEQ; }
YY_BREAK
case 46:
YY_RULE_SETUP
#line 177 "tokenizer.lex"
{ return RSHIFT; }
{ return GREATEREQ; }
YY_BREAK
case 47:
YY_RULE_SETUP
#line 179 "tokenizer.lex"
{ return LSHIFT; }
{ return RSHIFT; }
YY_BREAK
case 48:
YY_RULE_SETUP
#line 181 "tokenizer.lex"
{ return LBRACE; }
{ return LSHIFT; }
YY_BREAK
case 49:
YY_RULE_SETUP
#line 183 "tokenizer.lex"
{ return RBRACE; }
{ return LBRACE; }
YY_BREAK
case 50:
YY_RULE_SETUP
#line 185 "tokenizer.lex"
{ return LBRACKET; }
{ return RBRACE; }
YY_BREAK
case 51:
YY_RULE_SETUP
#line 187 "tokenizer.lex"
{ return RBRACKET; }
{ return LBRACKET; }
YY_BREAK
case 52:
YY_RULE_SETUP
#line 189 "tokenizer.lex"
{ return LPAREN; }
{ return RBRACKET; }
YY_BREAK
case 53:
YY_RULE_SETUP
#line 191 "tokenizer.lex"
{ return RPAREN; }
{ return LPAREN; }
YY_BREAK
case 54:
YY_RULE_SETUP
#line 193 "tokenizer.lex"
{ return DOT; }
{ return RPAREN; }
YY_BREAK
case 55:
YY_RULE_SETUP
#line 195 "tokenizer.lex"
{ return COLON; }
{ return DOT; }
YY_BREAK
case 56:
YY_RULE_SETUP
#line 197 "tokenizer.lex"
{ return SEMICOLON; }
{ return COLON; }
YY_BREAK
case 57:
YY_RULE_SETUP
#line 199 "tokenizer.lex"
{ return COMMA; }
{ return SEMICOLON; }
YY_BREAK
case 58:
YY_RULE_SETUP
#line 201 "tokenizer.lex"
{ return POUND; }
{ return COMMA; }
YY_BREAK
case 59:
YY_RULE_SETUP
#line 203 "tokenizer.lex"
{ *yylval = (void *) strdup(yytext); return IDENT; }
{ return POUND; }
YY_BREAK
case 60:
/* rule 60 can match eol */
YY_RULE_SETUP
#line 205 "tokenizer.lex"
/* Skip comments */
{ *yylval = (void *) strdup(yytext); return IDENT; }
YY_BREAK
case 61:
/* rule 61 can match eol */
YY_RULE_SETUP
#line 207 "tokenizer.lex"
/* Skip whitespace */
/* Skip comments */
YY_BREAK
case 62:
/* rule 62 can match eol */
YY_RULE_SETUP
#line 209 "tokenizer.lex"
/* Skip whitespace */
YY_BREAK
case 63:
YY_RULE_SETUP
#line 211 "tokenizer.lex"
ECHO;
YY_BREAK
#line 1202 "lex.yy.c"
#line 1224 "lex.yy.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@ -1491,7 +1513,7 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 113 )
if ( yy_current_state >= 119 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@ -1519,11 +1541,11 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 113 )
if ( yy_current_state >= 119 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 112);
yy_is_jam = (yy_current_state == 118);
return yy_is_jam ? 0 : yy_current_state;
}
@ -2193,7 +2215,7 @@ void yyfree (void * ptr )
#define YYTABLES_NAME "yytables"
#line 209 "tokenizer.lex"
#line 210 "tokenizer.lex"

52
object.c

@ -64,6 +64,10 @@ sol_object_t *sol_new_singlet(sol_state_t *state, const char *name) {
return sol_incref(res); // XXX Segfault
}
sol_object_t *sol_f_singlet_free(sol_state_t *state, sol_object_t *singlet) {
free(singlet->str);
}
// And, now, for the rest of the checked stuff...
void sol_init_object(sol_state_t *state, sol_object_t *obj) {
@ -334,24 +338,27 @@ sol_object_t *sol_map_mcell(sol_state_t *state, sol_object_t *map, sol_object_t
dsl_free_seq_iter(iter);
sol_obj_free(list);
if(res) {
return res;
return sol_incref(res);
}
return sol_incref(state->None);
}
int sol_map_has(sol_state_t *state, sol_object_t *map, sol_object_t *key) {
sol_object_t *mcell = sol_map_mcell(state, map, key);
int res = sol_is_none(state, mcell);
if(sol_is_none(state, mcell)) sol_decref(mcell);
int res = !sol_is_none(state, mcell);
sol_decref(mcell);
return res;
}
sol_object_t *sol_map_get(sol_state_t *state, sol_object_t *map, sol_object_t *key) {
sol_object_t *mcell = sol_map_mcell(state, map, key);
sol_object_t *mcell = sol_map_mcell(state, map, key), *ret;
if(sol_is_none(state, mcell)) {
return mcell;
ret = mcell;
} else {
ret = mcell->val;
}
return sol_incref(mcell->val);
sol_obj_free(mcell);
return sol_incref(ret);
}
sol_object_t *sol_map_get_name(sol_state_t *state, sol_object_t *map, char *name) {
@ -376,6 +383,7 @@ void sol_map_set(sol_state_t *state, sol_object_t *map, sol_object_t *key, sol_o
mcell->val = sol_incref(val);
sol_obj_free(temp);
}
sol_obj_free(mcell);
}
void sol_map_set_name(sol_state_t *state, sol_object_t *map, char *name, sol_object_t *val) {
@ -391,6 +399,7 @@ void sol_map_set_existing(sol_state_t *state, sol_object_t *map, sol_object_t *k
mcell->val = sol_incref(val);
sol_obj_free(temp);
}
sol_obj_free(mcell);
}
sol_object_t *sol_map_copy(sol_state_t *state, sol_object_t *map) {
@ -399,17 +408,19 @@ sol_object_t *sol_map_copy(sol_state_t *state, sol_object_t *map) {
void sol_map_merge(sol_state_t *state, sol_object_t *dest, sol_object_t *src) {
dsl_seq_iter *iter = dsl_new_seq_iter(src->seq);
if(!dsl_seq_iter_is_invalid(iter)) do {
sol_map_set(state, dest, AS_OBJ(dsl_seq_iter_at(iter))->key, AS_OBJ(dsl_seq_iter_at(iter))->val);
} while(dsl_seq_iter_next(iter));
while(!dsl_seq_iter_is_invalid(iter)) {
sol_map_set(state, dest, AS_OBJ(dsl_seq_iter_at(iter))->key, AS_OBJ(dsl_seq_iter_at(iter))->val);
dsl_seq_iter_next(iter);
}
dsl_free_seq_iter(iter);
}
void sol_map_merge_existing(sol_state_t *state, sol_object_t *dest, sol_object_t *src) {
dsl_seq_iter *iter = dsl_new_seq_iter(src->seq);
if(!dsl_seq_iter_is_invalid(iter)) do {
sol_map_set_existing(state, dest, AS_OBJ(dsl_seq_iter_at(iter))->key, AS_OBJ(dsl_seq_iter_at(iter))->val);
} while(dsl_seq_iter_next(iter));
while(!dsl_seq_iter_is_invalid(iter)) {
sol_map_set_existing(state, dest, AS_OBJ(dsl_seq_iter_at(iter))->key, AS_OBJ(dsl_seq_iter_at(iter))->val);
dsl_seq_iter_next(iter);
}
dsl_free_seq_iter(iter);
}
@ -434,9 +445,13 @@ sol_object_t *sol_f_map_free(sol_state_t *state, sol_object_t *map) {
sol_object_t *sol_f_mcell_free(sol_state_t *state, sol_object_t *mcell) {
if(mcell->key) {
sol_obj_free(mcell->key);
} else {
printf("WARNING: Freed mcell with NULL key\n");
}
if(mcell->val) {
sol_obj_free(mcell->val);
} else {
printf("WARNING: Freed mcell with NULL value\n");
}
return mcell;
}
@ -480,6 +495,19 @@ sol_object_t *sol_new_cdata(sol_state_t *state, void *cdata, sol_ops_t *ops) {
return res;
}
sol_object_t *sol_f_astnode_free(sol_state_t *state, sol_object_t *node) {
switch(node->type) {
case SOL_STMT:
st_free((stmt_node *) node->node);
break;
case SOL_EXPR:
ex_free((expr_node *) node->node);
break;
}
return node;
}
sol_object_t *sol_new_buffer(sol_state_t *state, void *buffer, ssize_t sz, sol_owntype_t own, sol_freefunc_t freef, sol_movefunc_t movef) {
sol_object_t *res = sol_alloc_object(state);
res->type = SOL_BUFFER;

0
sol-gdb.py → old-sol-gdb.py

8196
parser.output
File diff suppressed because it is too large
Näytä tiedosto

938
parser.tab.c
File diff suppressed because it is too large
Näytä tiedosto

105
parser.tab.h

@ -1,8 +1,8 @@
/* A Bison parser, made by GNU Bison 3.0.4. */
/* A Bison parser, made by GNU Bison 3.0.2. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -53,56 +53,57 @@ extern int yydebug;
IN = 263,
DO = 264,
FUNC = 265,
RETURN = 266,
BREAK = 267,
CONTINUE = 268,
END = 269,
NONE = 270,
IDENT = 271,
INT = 272,
FLOAT = 273,
STRING = 274,
PLUS = 275,
MINUS = 276,
STAR = 277,
SLASH = 278,
PERCENT = 279,
DSTAR = 280,
BAND = 281,
BOR = 282,
BXOR = 283,
BNOT = 284,
LAND = 285,
LOR = 286,
LNOT = 287,
ASSIGN = 288,
ASSIGNPLUS = 289,
ASSIGNMINUS = 290,
ASSIGNSTAR = 291,
ASSIGNSLASH = 292,
ASSIGNDSTAR = 293,
ASSIGNBAND = 294,
ASSIGNBOR = 295,
ASSIGNBXOR = 296,
EQUAL = 297,
NEQUAL = 298,
LESS = 299,
GREATER = 300,
LESSEQ = 301,
GREATEREQ = 302,
RSHIFT = 303,
LSHIFT = 304,
LBRACE = 305,
RBRACE = 306,
LPAREN = 307,
RPAREN = 308,
LBRACKET = 309,
RBRACKET = 310,
DOT = 311,
COLON = 312,
SEMICOLON = 313,
COMMA = 314,
POUND = 315
LAMBDA = 266,
RETURN = 267,
BREAK = 268,
CONTINUE = 269,
END = 270,
NONE = 271,
IDENT = 272,
INT = 273,
FLOAT = 274,
STRING = 275,
PLUS = 276,
MINUS = 277,
STAR = 278,
SLASH = 279,
PERCENT = 280,
DSTAR = 281,
BAND = 282,
BOR = 283,
BXOR = 284,
BNOT = 285,
LAND = 286,
LOR = 287,
LNOT = 288,
ASSIGN = 289,
ASSIGNPLUS = 290,
ASSIGNMINUS = 291,
ASSIGNSTAR = 292,
ASSIGNSLASH = 293,
ASSIGNDSTAR = 294,
ASSIGNBAND = 295,
ASSIGNBOR = 296,
ASSIGNBXOR = 297,
EQUAL = 298,
NEQUAL = 299,
LESS = 300,
GREATER = 301,
LESSEQ = 302,
GREATEREQ = 303,
RSHIFT = 304,
LSHIFT = 305,
LBRACE = 306,
RBRACE = 307,
LPAREN = 308,
RPAREN = 309,
LBRACKET = 310,
RBRACKET = 311,
DOT = 312,
COLON = 313,
SEMICOLON = 314,
COMMA = 315,
POUND = 316
};
#endif

13
parser.y

@ -13,7 +13,7 @@
%token IF THEN ELSE
%token WHILE FOR IN DO
%token FUNC RETURN BREAK CONTINUE
%token FUNC LAMBDA RETURN BREAK CONTINUE
%token END NONE
%token IDENT
%token INT FLOAT STRING
@ -342,6 +342,17 @@ funcdecl_expr:
AS_EX($$)->funcdecl->args = $3;
AS_EX($$)->funcdecl->body = $5;
}
| LAMBDA LPAREN ident_list RPAREN expr END {
$$ = NEW_EX();
AS_EX($$)->type = EX_FUNCDECL;
AS_EX($$)->funcdecl = NEW(funcdecl_node);
AS_EX($$)->funcdecl->name = NULL;
AS_EX($$)->funcdecl->args = $3;
AS_EX($$)->funcdecl->body = NEW_ST();
AS_EX($$)->funcdecl->body->type = ST_RET;
AS_EX($$)->funcdecl->body->ret = NEW(ret_node);
AS_EX($$)->funcdecl->body->ret->ret = $5;
}
| index_expr { $$ = $1; }
;

2
runtime.c

@ -480,7 +480,7 @@ sol_object_t *sol_eval_inner(sol_state_t *state, expr_node *expr, jmp_buf jmp) {
return res;
break;
}
printf("WARNING: Unhandled expression returning None");
printf("WARNING: Unhandled expression (type %d) returning None\n", expr->type);
return sol_incref(state->None);
}

33
sol.h

@ -9,8 +9,8 @@
#include <stdarg.h>
#include "dsl/dsl.h"
#define VERSION "0.1a3"
#define HEXVER 0x0001A03
#define VERSION "0.1a4"
#define HEXVER 0x0001A04
#ifndef SOL_ICACHE_MIN
#define SOL_ICACHE_MIN -128
@ -457,7 +457,17 @@ int sol_map_has(sol_state_t *, sol_object_t *, sol_object_t *);
sol_object_t *sol_map_get(sol_state_t *, sol_object_t *, sol_object_t *);
sol_object_t *sol_map_get_name(sol_state_t *, sol_object_t *, char *);
void sol_map_set(sol_state_t *, sol_object_t *, sol_object_t *, sol_object_t *);
#define sol_map_borrow(state, map, key, object) do {\
sol_object_t *_obj = (object);\
sol_map_set((state), (map), (key), _obj);\
sol_obj_free(_obj);\
} while(0)
void sol_map_set_name(sol_state_t *, sol_object_t *, char *, sol_object_t *);
#define sol_map_borrow_name(state, map, str, object) do {\
sol_object_t *_obj = (object);\
sol_map_set_name((state), (map), (str), _obj);\
sol_obj_free(_obj);\
} while(0)
void sol_map_set_existing(sol_state_t *, sol_object_t *, sol_object_t *, sol_object_t *);
sol_object_t *sol_map_copy(sol_state_t *, sol_object_t *);
void sol_map_merge(sol_state_t *, sol_object_t *, sol_object_t *);
@ -486,12 +496,17 @@ size_t sol_stream_fread(sol_state_t *, sol_object_t *, char *, size_t, size_t);
size_t sol_stream_fwrite(sol_state_t *, sol_object_t *, char *, size_t, size_t);
char *sol_stream_fgets(sol_state_t *, sol_object_t *, char *, size_t);
int sol_stream_fputc(sol_state_t *, sol_object_t *, int);
#define sol_printf(state, ...) sol_stream_printf(state, sol_get_stdout(state), __VA_ARGS__)
#define sol_vprintf(state, ...) sol_stream_vprintf(state, sol_get_stdout(state), __VA_ARGS__)
#define sol_scanf(state, ...) sol_stream_scanf(state, sol_get_stdin(state, __VA_ARGS__)
#define sol_fread(state, ...) sol_stream_fread(state, sol_get_stdin(state), __VA_ARGS__)
#define sol_fwrite(state, ...) sol_stream_fwrite(state, sol_get_stdout(state), __VA_ARGS__)
#define sol_putchar(state, ...) sol_stream_fputc(state, sol_get_stdout(state), __VA_ARGS__)
#define _sol_io_on(state, op, strname, ...) do {\
sol_object_t *str = sol_get_##strname(state);\
sol_stream_##op((state), str, __VA_ARGS__);\
sol_obj_free(str);\
} while(0)
#define sol_printf(state, ...) _sol_io_on(state, printf, stdout, __VA_ARGS__)
#define sol_vprintf(state, ...) _sol_io_on(state, vprintf, stdout, __VA_ARGS__)
#define sol_scanf(state, ...) _sol_io_on(state, scanf, stdin, __VA_ARGS__)
#define sol_fread(state, ...) _sol_io_on(state, fread, stdin, __VA_ARGS__)
#define sol_fwrite(state, ...) _sol_io_on(state, fwrite, stdout, __VA_ARGS__)
#define sol_putchar(state, ...) _sol_io_on(state, fputc, stdout, __VA_ARGS__)
int sol_stream_feof(sol_state_t *, sol_object_t *);
int sol_stream_ferror(sol_state_t *, sol_object_t *);