syme 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +53 -0
- data/README +22 -0
- data/Rakefile +89 -0
- data/bin/syme +89 -0
- data/lib/syme.rb +2 -0
- data/lib/syme/bootstrap.rb +4 -0
- data/lib/syme/bootstrap/compiler.rb +0 -0
- data/lib/syme/bootstrap/library.rb +0 -0
- data/lib/syme/bootstrap/parser.rb +49 -0
- data/lib/syme/bootstrap/syntax.rb +1 -0
- data/lib/syme/bootstrap/syntax/exception.rb +5 -0
- data/lib/syme/version.rb +14 -0
- metadata +96 -0
data/LICENSE
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
The implementation of Newspeak on the Rubinius VM is licensed as follows:
|
2
|
+
|
3
|
+
Copyright (c) 2010 Brian Ford. All rights reserved.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person
|
6
|
+
obtaining a copy of this software and associated documentation
|
7
|
+
files (the "Software"), to deal in the Software without
|
8
|
+
restriction, including without limitation the rights to use,
|
9
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the
|
11
|
+
Software is furnished to do so, subject to the following
|
12
|
+
conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
19
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
21
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
22
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
23
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
24
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
25
|
+
|
26
|
+
================================================================================
|
27
|
+
|
28
|
+
The following is license information found at http://newspeaklanguage.org/
|
29
|
+
|
30
|
+
Code developed by Cadence is licensed under the Apache 2.0 license, and all
|
31
|
+
such files or classes bear the following copyright and licensing notice:
|
32
|
+
|
33
|
+
Copyright 2008 Cadence Design Systems, Inc.
|
34
|
+
|
35
|
+
Licensed under the Apache License, Version 2.0 (the ”License”); you may not
|
36
|
+
use this file except in compliance with the License. You may obtain a copy of
|
37
|
+
the License at http://www.apache.org/licenses/LICENSE-2.0
|
38
|
+
|
39
|
+
Code that is part of Squeak is licensed under the Squeak license:
|
40
|
+
|
41
|
+
Licensed under the Squeak License (the ”License”); you may not use this file
|
42
|
+
except in compliance with the License. You may obtain a copy of the License
|
43
|
+
at http://www.squeak.org/SqueakLicense/
|
44
|
+
|
45
|
+
(note that in a Squeak or Newspeak image, Squeak classes do not usually come
|
46
|
+
with an explicit copyright and license)
|
47
|
+
|
48
|
+
Code that has been individually contributed will have its copyright and
|
49
|
+
licensing terms described in the class comment in the image, and in the
|
50
|
+
individual source files.
|
51
|
+
|
52
|
+
The preferred license for individual contributions going forward is the MIT
|
53
|
+
license.
|
data/README
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
What is Newspeak?
|
2
|
+
|
3
|
+
Newspeak is a programming language in the Smalltalk/Self tradition by Gilad
|
4
|
+
Bracha, Peter Ahe, Vassili Bykov, Eliot Miranda, Bill Maddox, and Yaron
|
5
|
+
Kashai. See http://newspeaklanguage.org/.
|
6
|
+
|
7
|
+
Newspeak is still an experimental language. Consequently, documentation for
|
8
|
+
Newspeak is incomplete. A reference implementation runs in the Squeak system.
|
9
|
+
There appear to be two primary references:
|
10
|
+
|
11
|
+
"The Newspeak Programming Platform" May 6, 2008
|
12
|
+
"Newspeak Programming Language Draft Specification v0.05" Dec 11, 2009
|
13
|
+
|
14
|
+
|
15
|
+
What is Syme?
|
16
|
+
|
17
|
+
Syme is an implementation of Newspeak that runs on the Rubinius VM.
|
18
|
+
|
19
|
+
Rather than use the existing Newspeak parser, a bootstrap parser and compiler
|
20
|
+
using Ruby are being written. The disadvantage of this is the effort to ensure
|
21
|
+
that the parser matches the current implementation. The advantage is a
|
22
|
+
bootstrap system for Newspeak independent of Squeak/Smalltalk.
|
data/Rakefile
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'rake/gempackagetask'
|
2
|
+
|
3
|
+
task :default => :spec
|
4
|
+
|
5
|
+
desc "Run the specs (default)"
|
6
|
+
task :spec => :build do
|
7
|
+
sh "mspec spec"
|
8
|
+
end
|
9
|
+
|
10
|
+
C = RbConfig::CONFIG
|
11
|
+
CC = ENV['CC'] || C['CC']
|
12
|
+
CFLAGS = ENV['CFLAGS'] || C['CFLAGS']
|
13
|
+
LDSHARED = ENV['LDSHARED'] || C['LDSHARED']
|
14
|
+
LDFLAGS = ENV['LDFLAGS'] || C['LDFLAGS']
|
15
|
+
dlext = C['DLEXT']
|
16
|
+
|
17
|
+
parser_d = File.expand_path "../lib/syme/bootstrap/parser/ext", __FILE__
|
18
|
+
parser_g = parser_d + "/parser.g"
|
19
|
+
parser_c = parser_d + "/parser.c"
|
20
|
+
parser_o = parser_d + "/parser.o"
|
21
|
+
parser_e = parser_d + "/parser.#{dlext}"
|
22
|
+
|
23
|
+
greg = File.expand_path "../tools/greg", __FILE__
|
24
|
+
|
25
|
+
file parser_c => [greg, parser_g] do |t|
|
26
|
+
sh "tools/greg #{t.prerequisites.last} > #{t.name}"
|
27
|
+
end
|
28
|
+
|
29
|
+
file parser_o => parser_c do |t|
|
30
|
+
sh "#{CC} -o #{t.name} -I#{C['rubyhdrdir']} #{CFLAGS} -c #{t.prerequisites.first}"
|
31
|
+
end
|
32
|
+
|
33
|
+
file parser_e => parser_o do |t|
|
34
|
+
sh "#{LDSHARED} -o #{t.name} #{LDFLAGS} #{t.prerequisites.first}"
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Generate the parser source"
|
38
|
+
task :parser => parser_c
|
39
|
+
|
40
|
+
desc "Build the parser extension"
|
41
|
+
task :build => [:parser, parser_e]
|
42
|
+
|
43
|
+
desc "Clean the parser extension files"
|
44
|
+
task :clean do
|
45
|
+
rm_f Dir[parser_d + "/{parser.c,*.o,*.#{dlext}}"]
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Build greg parser generator"
|
49
|
+
task :greg => greg
|
50
|
+
|
51
|
+
file greg do
|
52
|
+
sh "#{CC} -O3 -DNDEBUG -o tools/greg tools/greg.c tools/compile.c tools/tree.c -Itools"
|
53
|
+
end
|
54
|
+
|
55
|
+
spec = Gem::Specification.new do |s|
|
56
|
+
require File.expand_path('../lib/syme/version', __FILE__)
|
57
|
+
|
58
|
+
s.name = "syme"
|
59
|
+
s.version = Syme::VERSION.to_s
|
60
|
+
|
61
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
62
|
+
|
63
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
64
|
+
s.authors = ["Brian Ford"]
|
65
|
+
s.date = %q{2010-11-06}
|
66
|
+
s.email = %q{brixen@gmail.com}
|
67
|
+
s.has_rdoc = true
|
68
|
+
s.extra_rdoc_files = %w[ README LICENSE ]
|
69
|
+
s.executables = ["syme"]
|
70
|
+
s.files = FileList[ '{bin,lib,spec}/**/*.{yaml,txt,rb}', 'Rakefile', *s.extra_rdoc_files ]
|
71
|
+
s.homepage = %q{http://github.com/brixen/syme}
|
72
|
+
s.require_paths = ["lib"]
|
73
|
+
s.rubygems_version = %q{1.3.5}
|
74
|
+
s.summary = "Syme is an interpretation of Newspeak on the Rubinius VM."
|
75
|
+
s.description = <<EOS
|
76
|
+
Newspeak is a programming language in the Smalltalk/Self tradition by
|
77
|
+
Gilad Bracha, Peter Ahe, Vassili Bykov, Eliot Miranda, Bill Maddox,
|
78
|
+
and Yaron Kashai. See http://newspeaklanguage.org/.
|
79
|
+
|
80
|
+
Syme is an implementation of Newspeak that runs on the Rubinius VM.
|
81
|
+
EOS
|
82
|
+
|
83
|
+
s.rdoc_options << '--title' << 'Syme Gem' <<
|
84
|
+
'--main' << 'README' <<
|
85
|
+
'--line-numbers'
|
86
|
+
s.add_dependency 'mspec', '~> 1.5.0'
|
87
|
+
end
|
88
|
+
|
89
|
+
Rake::GemPackageTask.new(spec){ |pkg| pkg.gem_spec = spec }
|
data/bin/syme
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
#!/usr/bin/env rbx
|
2
|
+
#
|
3
|
+
# vim: filetype=ruby
|
4
|
+
|
5
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
6
|
+
|
7
|
+
require 'syme'
|
8
|
+
|
9
|
+
class SymeScript
|
10
|
+
def initialize
|
11
|
+
@evals = []
|
12
|
+
@ast = false
|
13
|
+
@sexp = false
|
14
|
+
@script = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def options(argv=ARGV)
|
18
|
+
options = Rubinius::Options.new "Usage: syme [options] [script]", 20
|
19
|
+
|
20
|
+
options.on "-", "Read and evaluate code from STDIN" do
|
21
|
+
@evals << STDIN.read
|
22
|
+
end
|
23
|
+
|
24
|
+
options.on "-c", "FILE", "Check the syntax of FILE" do |f|
|
25
|
+
begin
|
26
|
+
begin
|
27
|
+
Syme::Parser.new.parse_file f
|
28
|
+
rescue Syme::Syntax::SyntaxError => e
|
29
|
+
e.render
|
30
|
+
exit 1
|
31
|
+
end
|
32
|
+
|
33
|
+
puts "Syntax OK"
|
34
|
+
exit 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
options.on "-A", "Print the AST" do
|
39
|
+
@ast = true
|
40
|
+
end
|
41
|
+
|
42
|
+
options.on "-S", "Print the S-expression" do
|
43
|
+
@sexp = true
|
44
|
+
end
|
45
|
+
|
46
|
+
options.on "-e", "CODE", "Execute CODE" do |e|
|
47
|
+
@evals << e
|
48
|
+
end
|
49
|
+
|
50
|
+
options.on "-h", "--help", "Display this help" do
|
51
|
+
puts options
|
52
|
+
exit 0
|
53
|
+
end
|
54
|
+
|
55
|
+
options.doc ""
|
56
|
+
|
57
|
+
rest = options.parse(argv)
|
58
|
+
@script ||= rest.first
|
59
|
+
end
|
60
|
+
|
61
|
+
def evals
|
62
|
+
return if @evals.empty?
|
63
|
+
end
|
64
|
+
|
65
|
+
def script
|
66
|
+
return unless @script
|
67
|
+
|
68
|
+
if File.exists? @script
|
69
|
+
|
70
|
+
Syme::CodeLoader.execute_file @script
|
71
|
+
else
|
72
|
+
STDERR.puts "Unable to find '#{@script}' to run"
|
73
|
+
exit 1
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def repl
|
78
|
+
return if @script
|
79
|
+
end
|
80
|
+
|
81
|
+
def main
|
82
|
+
options
|
83
|
+
evals
|
84
|
+
script
|
85
|
+
repl
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
SymeScript.new.main
|
data/lib/syme.rb
ADDED
File without changes
|
File without changes
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Syme
|
2
|
+
class Parser
|
3
|
+
def initialize
|
4
|
+
@error_position = 0
|
5
|
+
end
|
6
|
+
|
7
|
+
# The #parse_string method is defined in the parser C extension.
|
8
|
+
|
9
|
+
def parse(string)
|
10
|
+
@string = string
|
11
|
+
ast = parse_string string
|
12
|
+
show_syntax_error unless ast
|
13
|
+
ast
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse_file(name)
|
17
|
+
string = IO.read name
|
18
|
+
parse string
|
19
|
+
end
|
20
|
+
|
21
|
+
# Parsing callbacks
|
22
|
+
|
23
|
+
def show_syntax_error
|
24
|
+
error_line = nil
|
25
|
+
count = 0
|
26
|
+
|
27
|
+
@string.each_line do |line|
|
28
|
+
count += line.size
|
29
|
+
if count > @error_position
|
30
|
+
error_line = line
|
31
|
+
break
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
message = <<-EOM
|
36
|
+
|
37
|
+
#{error_line.chomp}
|
38
|
+
#{" " *(error_line.size - (count - @error_position))}^
|
39
|
+
EOM
|
40
|
+
raise Syntax::SyntaxError, message
|
41
|
+
end
|
42
|
+
|
43
|
+
def syntax_error(pos)
|
44
|
+
@error_position = pos
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
require 'syme/bootstrap/parser/ext/parser'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'syme/bootstrap/syntax/exception'
|
data/lib/syme/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: syme
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Brian Ford
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-11-06 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: mspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 5
|
30
|
+
- 0
|
31
|
+
version: 1.5.0
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
description: |
|
35
|
+
Newspeak is a programming language in the Smalltalk/Self tradition by
|
36
|
+
Gilad Bracha, Peter Ahe, Vassili Bykov, Eliot Miranda, Bill Maddox,
|
37
|
+
and Yaron Kashai. See http://newspeaklanguage.org/.
|
38
|
+
|
39
|
+
Syme is an implementation of Newspeak that runs on the Rubinius VM.
|
40
|
+
|
41
|
+
email: brixen@gmail.com
|
42
|
+
executables:
|
43
|
+
- syme
|
44
|
+
extensions: []
|
45
|
+
|
46
|
+
extra_rdoc_files:
|
47
|
+
- README
|
48
|
+
- LICENSE
|
49
|
+
files:
|
50
|
+
- lib/syme/bootstrap/compiler.rb
|
51
|
+
- lib/syme/bootstrap/library.rb
|
52
|
+
- lib/syme/bootstrap/parser.rb
|
53
|
+
- lib/syme/bootstrap/syntax/exception.rb
|
54
|
+
- lib/syme/bootstrap/syntax.rb
|
55
|
+
- lib/syme/bootstrap.rb
|
56
|
+
- lib/syme/version.rb
|
57
|
+
- lib/syme.rb
|
58
|
+
- Rakefile
|
59
|
+
- README
|
60
|
+
- LICENSE
|
61
|
+
has_rdoc: true
|
62
|
+
homepage: http://github.com/brixen/syme
|
63
|
+
licenses: []
|
64
|
+
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options:
|
67
|
+
- --title
|
68
|
+
- Syme Gem
|
69
|
+
- --main
|
70
|
+
- README
|
71
|
+
- --line-numbers
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
version: "0"
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
requirements: []
|
89
|
+
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 1.3.6
|
92
|
+
signing_key:
|
93
|
+
specification_version: 2
|
94
|
+
summary: Syme is an interpretation of Newspeak on the Rubinius VM.
|
95
|
+
test_files: []
|
96
|
+
|