Skip to content

Commit

Permalink
minor formatting; remove Ast.Cond arg from Ast.TernaryExpr
Browse files Browse the repository at this point in the history
--HG--
branch : com.mozilla.es4.smlnj
extra : convert_revision : 57ed1d8260ae2f4e474c6da55e02c394ea8f98d8
  • Loading branch information
jeffdyer committed May 8, 2007
1 parent 80fa985 commit 46c70b3
Show file tree
Hide file tree
Showing 7 changed files with 603 additions and 621 deletions.
107 changes: 52 additions & 55 deletions ast.sml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ type NUMERIC_MODE =
roundingMode: Decimal.ROUNDING_MODE,
precision: int }

datatype TRIOP =
Cond

datatype BINTYPEOP =
Cast
| Is
Expand Down Expand Up @@ -144,14 +141,14 @@ datatype PRAGMA =
instanceType: TYPE_EXPR } (* InstanceType *)

and CTOR =
Ctor of
{ settings: HEAD,
Ctor of {
settings: HEAD,
superArgs: EXPR list,
func: FUNC }

and FUNC =
Func of
{ name: FUNC_NAME,
Func of {
name: FUNC_NAME,
fsig: FUNC_SIG,
isNative: bool,
block: BLOCK,
Expand All @@ -169,8 +166,8 @@ datatype PRAGMA =
| TypeDefn of TYPE_DEFN

and FUNC_SIG =
FunctionSignature of
{ typeParams: IDENT list,
FunctionSignature of {
typeParams: IDENT list,
params: BINDINGS,
paramTypes: TYPE_EXPR list,
defaults: EXPR list,
Expand Down Expand Up @@ -203,19 +200,19 @@ datatype PRAGMA =
SpecialType of SPECIAL_TY
| UnionType of TYPE_EXPR list
| ArrayType of TYPE_EXPR list
| TypeName of IDENT_EXPR
| TypeName of IDENT_EXPR (* STATIC_IDENT_EXPR *)
| ElementTypeRef of (TYPE_EXPR * int)
| FieldTypeRef of (TYPE_EXPR * IDENT)
| FunctionType of FUNC_TYPE
| ObjectType of FIELD_TYPE list
| AppType of
{ base: TYPE_EXPR,
| AppType of {
base: TYPE_EXPR,
args: TYPE_EXPR list }
| NullableType of
{ expr:TYPE_EXPR,
| NullableType of {
expr:TYPE_EXPR,
nullable:bool }
| InstanceType of
{ name: NAME,
| InstanceType of {
name: NAME,
typeParams: IDENT list,
ty: TYPE_EXPR,
isDynamic: bool }
Expand All @@ -224,8 +221,8 @@ datatype PRAGMA =
and STMT =
EmptyStmt
| ExprStmt of EXPR
| InitStmt of
{ kind: VAR_DEFN_TAG,
| InitStmt of {
kind: VAR_DEFN_TAG,
ns: EXPR option,
prototype: bool,
static: bool,
Expand All @@ -247,34 +244,33 @@ datatype PRAGMA =
| WhileStmt of WHILE_STMT
| DoWhileStmt of WHILE_STMT
| ForStmt of FOR_STMT
| IfStmt of
{ cnd: EXPR,
| IfStmt of {
cnd: EXPR,
thn: STMT,
els: STMT }
| WithStmt of
{ obj: EXPR,
| WithStmt of {
obj: EXPR,
ty: TYPE_EXPR,
body: STMT }
| TryStmt of
{ block: BLOCK,
catches: CATCH_CLAUSE
list,
| TryStmt of {
block: BLOCK,
catches: CATCH_CLAUSE list,
finally: BLOCK option }

| SwitchStmt of (* FIXME: needs HEAD, DEFNS for defns hoisted from body *)
{ mode: NUMERIC_MODE option,
| SwitchStmt of { (* FIXME: needs HEAD, DEFNS for defns hoisted from body *)
mode: NUMERIC_MODE option,
cond: EXPR,
labels: IDENT list,
cases: CASE list }
| SwitchTypeStmt of
{ cond: EXPR,
| SwitchTypeStmt of {
cond: EXPR,
ty: TYPE_EXPR,
cases: TYPE_CASE list }
| Dxns of
{ expr: EXPR }
| DXNStmt of {
expr: EXPR }

and EXPR =
TernaryExpr of (TRIOP * EXPR * EXPR * EXPR)
TernaryExpr of (EXPR * EXPR * EXPR)
| BinaryExpr of (BINOP * EXPR * EXPR)
| BinaryTypeExpr of (BINTYPEOP * EXPR * TYPE_EXPR)
| ExpectedTypeExpr of (TYPE_EXPR * EXPR)
Expand All @@ -284,21 +280,26 @@ datatype PRAGMA =
| YieldExpr of EXPR option
| SuperExpr of EXPR option
| LiteralExpr of LITERAL
| CallExpr of
{ func: EXPR,
| CallExpr of {
func: EXPR,
actuals: EXPR list }
| ApplyTypeExpr of
{ expr: EXPR, (* apply expr to type list *)
| ApplyTypeExpr of {
expr: EXPR, (* apply expr to type list *)
actuals: TYPE_EXPR list }
| LetExpr of
{ defs: BINDINGS,
| LetExpr of {
defs: BINDINGS,
body: EXPR,
head: HEAD option }
| NewExpr of
{ obj: EXPR,
| NewExpr of {
obj: EXPR,
actuals: EXPR list }
| ObjectRef of { base: EXPR, ident: IDENT_EXPR, pos: POS option }
| LexicalRef of { ident: IDENT_EXPR, pos: POS option }
| ObjectRef of {
base: EXPR,
ident: IDENT_EXPR,
pos: POS option }
| LexicalRef of {
ident: IDENT_EXPR,
pos: POS option }
| SetExpr of (ASSIGNOP * EXPR * EXPR)
| ListExpr of EXPR list
| InitExpr of (INIT_TARGET * HEAD * INITS) (* HEAD is for temporaries *)
Expand Down Expand Up @@ -375,11 +376,11 @@ datatype PRAGMA =
| TypeVarFixture
| TypeFixture of TYPE_EXPR
| MethodFixture of
{ func: FUNC,
ty: TYPE_EXPR,
readOnly: bool, (* ES3 funcs are r/w methods with ty=Ast.Special Ast.Any *)
override: bool,
final: bool }
{ func: FUNC,
ty: TYPE_EXPR,
readOnly: bool, (* ES3 funcs are r/w methods with ty=Ast.Special Ast.Any *)
override: bool,
final: bool }
| ValFixture of
{ ty: TYPE_EXPR,
readOnly: bool }
Expand All @@ -402,10 +403,6 @@ withtype
{ name: IDENT,
ty: TYPE_EXPR }

and TYPED_IDENT =
{ name: IDENT,
ty: TYPE_EXPR option }

and FUNC_TYPE =
{ typeParams: IDENT list,
params: TYPE_EXPR list,
Expand Down Expand Up @@ -444,8 +441,8 @@ withtype
dynamic: bool,
final: bool,
params: IDENT list,
extends: IDENT_EXPR option,
implements: IDENT_EXPR list,
extends: IDENT_EXPR option, (* STATIC_IDENT_EXPR *)
implements: IDENT_EXPR list, (* STATIC_IDENT_EXPR list *)
classDefns: DEFN list,
instanceDefns: DEFN list,
instanceStmts: STMT list,
Expand All @@ -456,7 +453,7 @@ withtype
ns: EXPR option,
nonnullable: bool,
params: IDENT list,
extends: IDENT_EXPR list,
extends: IDENT_EXPR list, (* STATIC_IDENT_EXPR list *)
block: BLOCK }

and TYPE_DEFN =
Expand Down
8 changes: 4 additions & 4 deletions defn.sml
Original file line number Diff line number Diff line change
Expand Up @@ -1790,8 +1790,8 @@ and defExpr (env:ENV)
fun sub e = defExpr env e
in
case expr of
Ast.TernaryExpr (t, e1, e2, e3) =>
Ast.TernaryExpr (t, sub e1, sub e2, sub e3)
Ast.TernaryExpr (e1, e2, e3) =>
Ast.TernaryExpr (sub e1, sub e2, sub e3)

| Ast.BinaryExpr (b, e1, e2) =>
let
Expand Down Expand Up @@ -2346,8 +2346,8 @@ and defStmt (env:ENV)
cases = cases}, List.concat hoisted)
end

| Ast.Dxns { expr } =>
(Ast.Dxns { expr = defExpr env expr },[])
| Ast.DXNStmt { expr } =>
(Ast.DXNStmt { expr = defExpr env expr },[])
end

and defStmts (env) (stmts:Ast.STMT list)
Expand Down
2 changes: 1 addition & 1 deletion eval.sml
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ and evalExpr (regs:Mach.REGS)
| Ast.LetExpr {defs, body, head} =>
evalLetExpr regs (valOf head) body

| Ast.TernaryExpr (Ast.Cond, aexpr, bexpr, cexpr) =>
| Ast.TernaryExpr (aexpr, bexpr, cexpr) =>
evalCondExpr regs aexpr bexpr cexpr

| Ast.BinaryExpr (bop, aexpr, bexpr) =>
Expand Down
6 changes: 3 additions & 3 deletions parser.sml
Original file line number Diff line number Diff line change
Expand Up @@ -2578,7 +2578,7 @@ and conditionalExpression (ts,ALLOWLIST,b) =
let
val (ts6,nd6) = assignmentExpression(ts5,ALLOWLIST,b)
in
(ts6, Ast.TernaryExpr (Ast.Cond, nd2, nd4, nd6))
(ts6, Ast.TernaryExpr (nd2, nd4, nd6))
end
| _ => error ["unknown token in conditionalExpression"]
end
Expand All @@ -2604,7 +2604,7 @@ and conditionalExpression (ts,ALLOWLIST,b) =
let
val (ts6,nd6) = assignmentExpression(ts5,NOLIST,b)
in
(ts6, Ast.TernaryExpr (Ast.Cond, nd2, nd4, nd6))
(ts6, Ast.TernaryExpr (nd2, nd4, nd6))
end
| _ => error ["unknown token in conditionalExpression"]
end
Expand Down Expand Up @@ -4702,7 +4702,7 @@ and defaultXmlNamespaceStatement (ts) =
let
val (ts1,nd1) = nonAssignmentExpression ((tl (tl (tl (tl ts)))),ALLOWLIST,ALLOWIN)
in
(ts1,Ast.Dxns {expr=nd1})
(ts1,Ast.DXNStmt {expr=nd1})
end
| _ => error ["unknown token in defaultXmlNamespaceStatement"]
end
Expand Down
Loading

0 comments on commit 46c70b3

Please sign in to comment.