Skip to content

REALLY update the demo this time #1198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ matrix:
# Set in the settings page of your repository, as a secure variable
github-token: $WEBSITE_GITHUB_TOKEN
keep-history: true
on:
branch: release

- name: WASM online demo
language: rust
Expand All @@ -109,6 +111,8 @@ matrix:
# Set in the settings page of your repository, as a secure variable
github-token: $WEBSITE_GITHUB_TOKEN
keep-history: true
on:
branch: release

- name: Code Coverage
language: python
Expand Down
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Dockerfile.wasm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ COPY parser parser
COPY bytecode bytecode
COPY compiler compiler
COPY wasm/lib wasm/lib
COPY Lib Lib

RUN cd wasm/lib/ && wasm-pack build --release

Expand Down
13 changes: 8 additions & 5 deletions parser/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct Node {
}
*/

#[allow(clippy::large_enum_variant)]
#[derive(Debug, PartialEq)]
pub enum Top {
Program(Program),
Expand Down Expand Up @@ -41,7 +42,6 @@ pub struct Located<T> {
pub type Statement = Located<StatementType>;

/// Abstract syntax tree nodes for python statements.
#[allow(clippy::large_enum_variant)]
#[derive(Debug, PartialEq)]
pub enum StatementType {
Break,
Expand Down Expand Up @@ -100,8 +100,8 @@ pub enum StatementType {
},
For {
is_async: bool,
target: Expression,
iter: Expression,
target: Box<Expression>,
iter: Box<Expression>,
body: Vec<Statement>,
orelse: Option<Vec<Statement>>,
},
Expand All @@ -125,7 +125,7 @@ pub enum StatementType {
FunctionDef {
is_async: bool,
name: String,
args: Parameters,
args: Box<Parameters>,
body: Vec<Statement>,
decorator_list: Vec<Expression>,
returns: Option<Expression>,
Expand Down Expand Up @@ -217,7 +217,7 @@ pub enum ExpressionType {
name: String,
},
Lambda {
args: Parameters,
args: Box<Parameters>,
body: Box<Expression>,
},
IfExpression {
Expand Down Expand Up @@ -293,6 +293,7 @@ pub struct Parameters {

#[derive(Debug, PartialEq, Default)]
pub struct Parameter {
pub location: Location,
pub arg: String,
pub annotation: Option<Box<Expression>>,
}
Expand All @@ -308,6 +309,7 @@ pub enum ComprehensionKind {

#[derive(Debug, PartialEq)]
pub struct Comprehension {
pub location: Location,
pub target: Expression,
pub iter: Expression,
pub ifs: Vec<Expression>,
Expand All @@ -321,6 +323,7 @@ pub struct Keyword {

#[derive(Debug, PartialEq)]
pub struct ExceptHandler {
pub location: Location,
pub typ: Option<Expression>,
pub name: Option<String>,
pub body: Vec<Statement>,
Expand Down
20 changes: 14 additions & 6 deletions parser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,15 @@ mod tests {
Ok(vec![as_statement(ast::Expression {
location: ast::Location::new(1, 1),
node: ast::ExpressionType::Lambda {
args: ast::Parameters {
args: Box::new(ast::Parameters {
args: vec![
ast::Parameter {
location: ast::Location::new(1, 8),
arg: String::from("x"),
annotation: None,
},
ast::Parameter {
location: ast::Location::new(1, 11),
arg: String::from("y"),
annotation: None,
}
Expand All @@ -249,7 +251,7 @@ mod tests {
kwarg: ast::Varargs::None,
defaults: vec![],
kw_defaults: vec![],
},
}),
body: Box::new(ast::Expression {
location: ast::Location::new(1, 16),
node: ast::ExpressionType::Binop {
Expand Down Expand Up @@ -308,8 +310,9 @@ mod tests {
node: ast::StatementType::FunctionDef {
is_async: false,
name: String::from("__init__"),
args: ast::Parameters {
args: Box::new(ast::Parameters {
args: vec![ast::Parameter {
location: ast::Location::new(2, 15),
arg: String::from("self"),
annotation: None,
}],
Expand All @@ -318,7 +321,7 @@ mod tests {
kwarg: ast::Varargs::None,
defaults: vec![],
kw_defaults: vec![],
},
}),
body: vec![ast::Statement {
location: ast::Location::new(3, 3),
node: ast::StatementType::Pass,
Expand All @@ -332,13 +335,15 @@ mod tests {
node: ast::StatementType::FunctionDef {
is_async: false,
name: String::from("method_with_default"),
args: ast::Parameters {
args: Box::new(ast::Parameters {
args: vec![
ast::Parameter {
location: ast::Location::new(4, 26),
arg: String::from("self"),
annotation: None,
},
ast::Parameter {
location: ast::Location::new(4, 32),
arg: String::from("arg"),
annotation: None,
}
Expand All @@ -348,7 +353,7 @@ mod tests {
kwarg: ast::Varargs::None,
defaults: vec![make_string("default", 4, 37)],
kw_defaults: vec![],
},
}),
body: vec![ast::Statement {
location: ast::Location::new(5, 3),
node: ast::StatementType::Pass,
Expand Down Expand Up @@ -377,6 +382,7 @@ mod tests {
element: mk_ident("x", 1, 2),
}),
generators: vec![ast::Comprehension {
location: ast::Location::new(1, 4),
target: mk_ident("y", 1, 8),
iter: mk_ident("z", 1, 13),
ifs: vec![],
Expand All @@ -400,6 +406,7 @@ mod tests {
}),
generators: vec![
ast::Comprehension {
location: ast::Location::new(1, 4),
target: ast::Expression {
location: ast::Location::new(1, 8),
node: ast::ExpressionType::Tuple {
Expand All @@ -410,6 +417,7 @@ mod tests {
ifs: vec![],
},
ast::Comprehension {
location: ast::Location::new(1, 19),
target: mk_ident("a", 1, 23),
iter: mk_ident("b", 1, 28),
ifs: vec![
Expand Down
Loading