mirror of
https://github.com/ganelson/inform.git
synced 2024-07-08 18:14:21 +03:00
772 lines
21 KiB
Plaintext
772 lines
21 KiB
Plaintext
Test: parse schema from:
|
|
alpha.beta()
|
|
|
|
* (message)
|
|
* (expr)
|
|
IDENTIFIER alpha
|
|
* (expr)
|
|
IDENTIFIER beta
|
|
=========
|
|
Test: parse schema from:
|
|
alpha.beta(x)
|
|
|
|
* (message)
|
|
* (expr)
|
|
IDENTIFIER alpha
|
|
* (expr)
|
|
IDENTIFIER beta
|
|
* (expr)
|
|
IDENTIFIER x
|
|
=========
|
|
Test: parse schema from:
|
|
routine.call(x)
|
|
|
|
* (call-message)
|
|
* (expr)
|
|
IDENTIFIER routine
|
|
* (expr)
|
|
IDENTIFIER x
|
|
=========
|
|
Test: parse schema from:
|
|
(alpha.beta)(x)
|
|
|
|
* (call)
|
|
* (subexpression)
|
|
* (operation) !propertyvalue
|
|
* (expr)
|
|
IDENTIFIER alpha
|
|
* (expr)
|
|
IDENTIFIER beta
|
|
* (expr)
|
|
IDENTIFIER x
|
|
=========
|
|
Test: parse schema from:
|
|
debug_rules = 2; say__p = 1;
|
|
"Rules tracing now switched to ~all~. Type ~rules off~ to switch it off again.";
|
|
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER debug_rules
|
|
* (expr)
|
|
NUMBER 2
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER say__p
|
|
* (expr)
|
|
NUMBER 1
|
|
* (expr) ;
|
|
DQUOTED Rules tracing now switched to "all". Type "rules off" to switch it off again.
|
|
=========
|
|
Test: parse schema from:
|
|
@erase_window -1;
|
|
|
|
* (assembly)
|
|
* (expr)
|
|
OPCODE @erase_window
|
|
* (expr)
|
|
NUMBER -1
|
|
=========
|
|
Test: parse schema from:
|
|
restore Somewhere;
|
|
.Somewhere; print "Here!";
|
|
|
|
* (statement) !restore
|
|
* (expr)
|
|
IDENTIFIER Somewhere
|
|
* (label)
|
|
* (expr)
|
|
IDENTIFIER Somewhere
|
|
* (statement) !print
|
|
* (expr)
|
|
DQUOTED Here!
|
|
=========
|
|
Test: parse schema from:
|
|
"Hello, this
|
|
is a multiline string literal";
|
|
|
|
* (expr) ;
|
|
DQUOTED Hello, this is a multiline string literal
|
|
=========
|
|
Test: parse schema from:
|
|
for (n=0:((n<RE_Subexpressions-->10) && (n<10)): n++)
|
|
print n;
|
|
|
|
* (statement) !for
|
|
* (eval)
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER n
|
|
* (expr)
|
|
NUMBER 0
|
|
* (eval)
|
|
* (subexpression)
|
|
* (operation) !and
|
|
* (subexpression)
|
|
* (operation) !lt
|
|
* (expr)
|
|
IDENTIFIER n
|
|
* (operation) !lookup
|
|
* (expr)
|
|
IDENTIFIER RE_Subexpressions
|
|
* (expr)
|
|
NUMBER 10
|
|
* (subexpression)
|
|
* (operation) !lt
|
|
* (expr)
|
|
IDENTIFIER n
|
|
* (expr)
|
|
NUMBER 10
|
|
* (eval)
|
|
* (operation) !postincrement
|
|
* (expr)
|
|
IDENTIFIER n
|
|
* (code)
|
|
* (statement) !printnumber
|
|
* (expr)
|
|
IDENTIFIER n
|
|
=========
|
|
Test: parse schema from:
|
|
spaces j;
|
|
print (I7_string) str;
|
|
|
|
* (statement) !spaces
|
|
* (expr)
|
|
IDENTIFIER j
|
|
* (call)
|
|
* (expr)
|
|
IDENTIFIER I7_String
|
|
* (expr)
|
|
IDENTIFIER str
|
|
=========
|
|
Test: parse schema from:
|
|
if (i == 1) print "Okay";
|
|
else "*** Arrcpy doesn't support this ***";
|
|
|
|
* (statement) !ifelse
|
|
* (subexpression)
|
|
* (operation) !eq
|
|
* (expr)
|
|
IDENTIFIER i
|
|
* (expr)
|
|
NUMBER 1
|
|
* (code)
|
|
* (statement) !print
|
|
* (expr)
|
|
DQUOTED Okay
|
|
* (code)
|
|
* (expr) ;
|
|
DQUOTED *** Arrcpy doesn't support this ***
|
|
=========
|
|
Test: parse schema from:
|
|
a-1
|
|
|
|
* (operation) !minus
|
|
* (expr)
|
|
IDENTIFIER a
|
|
* (expr)
|
|
NUMBER 1
|
|
=========
|
|
Test: parse schema from:
|
|
do {
|
|
print "Hi!";
|
|
} until (x);
|
|
|
|
* (statement) !do
|
|
* (subexpression)
|
|
* (expr)
|
|
IDENTIFIER x
|
|
* (code)
|
|
* (statement) !print
|
|
* (expr)
|
|
DQUOTED Hi!
|
|
=========
|
|
Test: parse schema from:
|
|
do {
|
|
if (a) return wd;
|
|
} until (a);
|
|
|
|
* (statement) !do
|
|
* (subexpression)
|
|
* (expr)
|
|
IDENTIFIER a
|
|
* (code)
|
|
* (statement) !if
|
|
* (subexpression)
|
|
* (expr)
|
|
IDENTIFIER a
|
|
* (code)
|
|
* (statement) !return
|
|
* (expr)
|
|
IDENTIFIER wd
|
|
=========
|
|
Test: parse schema from:
|
|
do {
|
|
if (line_tdata-->index == wd) return wd;
|
|
index++;
|
|
} until ((line_token-->index == ENDIT_TOKEN) || (((line_token-->index)->0 & $10) == 0));
|
|
|
|
* (statement) !do
|
|
* (subexpression)
|
|
* (operation) !or
|
|
* (subexpression)
|
|
* (operation) !eq
|
|
* (operation) !lookup
|
|
* (expr)
|
|
IDENTIFIER line_token
|
|
* (expr)
|
|
IDENTIFIER index
|
|
* (expr)
|
|
IDENTIFIER ENDIT_TOKEN
|
|
* (subexpression)
|
|
* (operation) !eq
|
|
* (subexpression)
|
|
* (operation) !bitwiseand
|
|
* (operation) !lookupbyte
|
|
* (subexpression)
|
|
* (operation) !lookup
|
|
* (expr)
|
|
IDENTIFIER line_token
|
|
* (expr)
|
|
IDENTIFIER index
|
|
* (expr)
|
|
NUMBER 0
|
|
* (expr)
|
|
HEX_NUMBER $10
|
|
* (expr)
|
|
NUMBER 0
|
|
* (code)
|
|
* (statement) !if
|
|
* (subexpression)
|
|
* (operation) !eq
|
|
* (operation) !lookup
|
|
* (expr)
|
|
IDENTIFIER line_tdata
|
|
* (expr)
|
|
IDENTIFIER index
|
|
* (expr)
|
|
IDENTIFIER wd
|
|
* (code)
|
|
* (statement) !return
|
|
* (expr)
|
|
IDENTIFIER wd
|
|
* (operation) !postincrement
|
|
* (expr)
|
|
IDENTIFIER index
|
|
=========
|
|
Test: parse schema from:
|
|
print "<string ~", (string) o, "~>";
|
|
|
|
* (statement) !print
|
|
* (expr)
|
|
DQUOTED <string "
|
|
* (statement) !printstring
|
|
* (expr)
|
|
IDENTIFIER o
|
|
* (statement) !print
|
|
* (expr)
|
|
DQUOTED ">
|
|
=========
|
|
Test: parse schema from:
|
|
switch (Y) {
|
|
X: print "A ", (string) o;
|
|
}
|
|
|
|
* (statement) !switch
|
|
* (subexpression)
|
|
* (expr)
|
|
IDENTIFIER Y
|
|
* (code)
|
|
* (statement) !case
|
|
* (expr)
|
|
IDENTIFIER X
|
|
* (code)
|
|
* (statement) !print
|
|
* (expr)
|
|
DQUOTED A
|
|
* (statement) !printstring
|
|
* (expr)
|
|
IDENTIFIER o
|
|
=========
|
|
Test: parse schema from:
|
|
#ifdef RANKING_TABLE;
|
|
ANNOUNCE_SCORE_RM('B');
|
|
j = TableRows(RANKING_TABLE);
|
|
for (i=j:i>=1:i--)
|
|
if (score >= TableLookUpEntry(RANKING_TABLE, 1, i)) {
|
|
v = TableLookUpEntry(RANKING_TABLE, 2, i);
|
|
TEXT_TY_Say(v);
|
|
".";
|
|
}
|
|
#endif;
|
|
".";'
|
|
|
|
* (directive) #ifdef
|
|
* (expr)
|
|
IDENTIFIER RANKING_TABLE
|
|
* (call)
|
|
* (expr)
|
|
IDENTIFIER ANNOUNCE_SCORE_RM
|
|
* (expr)
|
|
SQUOTED B
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER j
|
|
* (call)
|
|
* (expr)
|
|
IDENTIFIER TableRows
|
|
* (expr)
|
|
IDENTIFIER RANKING_TABLE
|
|
* (statement) !for
|
|
* (eval)
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER i
|
|
* (expr)
|
|
IDENTIFIER j
|
|
* (eval)
|
|
* (operation) !ge
|
|
* (expr)
|
|
IDENTIFIER i
|
|
* (expr)
|
|
NUMBER 1
|
|
* (eval)
|
|
* (operation) !postdecrement
|
|
* (expr)
|
|
IDENTIFIER i
|
|
* (code)
|
|
* (statement) !if
|
|
* (subexpression)
|
|
* (operation) !ge
|
|
* (expr)
|
|
IDENTIFIER score
|
|
* (call)
|
|
* (expr)
|
|
IDENTIFIER TableLookUpEntry
|
|
* (expr)
|
|
IDENTIFIER RANKING_TABLE
|
|
* (expr)
|
|
NUMBER 1
|
|
* (expr)
|
|
IDENTIFIER i
|
|
* (code)
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER v
|
|
* (call)
|
|
* (expr)
|
|
IDENTIFIER TableLookUpEntry
|
|
* (expr)
|
|
IDENTIFIER RANKING_TABLE
|
|
* (expr)
|
|
NUMBER 2
|
|
* (expr)
|
|
IDENTIFIER i
|
|
* (call)
|
|
* (expr)
|
|
IDENTIFIER TEXT_TY_Say
|
|
* (expr)
|
|
IDENTIFIER v
|
|
* (expr) ;
|
|
DQUOTED .
|
|
* (directive) #endif
|
|
* (expr) ;
|
|
DQUOTED .
|
|
* (expr)
|
|
SQUOTED
|
|
|
|
=========
|
|
Test: parse schema from:
|
|
if (B) if (A) { print "Yes"; }
|
|
print "No";
|
|
|
|
* (statement) !if
|
|
* (subexpression)
|
|
* (expr)
|
|
IDENTIFIER B
|
|
* (code)
|
|
* (statement) !if
|
|
* (subexpression)
|
|
* (expr)
|
|
IDENTIFIER A
|
|
* (code)
|
|
* (statement) !print
|
|
* (expr)
|
|
DQUOTED Yes
|
|
* (statement) !print
|
|
* (expr)
|
|
DQUOTED No
|
|
=========
|
|
Test: parse schema from:
|
|
switch (scope_stage) {
|
|
2: objectloop (obj)
|
|
PlaceInScope(obj, true);
|
|
}
|
|
|
|
* (statement) !switch
|
|
* (subexpression)
|
|
* (expr)
|
|
IDENTIFIER scope_stage
|
|
* (code) <
|
|
* (statement) !case
|
|
* (expr)
|
|
NUMBER 2
|
|
* (code) <
|
|
* (statement) !objectloop
|
|
* (subexpression)
|
|
* (expr)
|
|
IDENTIFIER obj
|
|
* (code)
|
|
* (call)
|
|
* (expr)
|
|
IDENTIFIER PlaceInScope
|
|
* (expr)
|
|
IDENTIFIER obj
|
|
* (expr)
|
|
NUMBER true
|
|
=========
|
|
Test: parse schema from:
|
|
while (token ~= NULL) {
|
|
switch (token-->RE_CCLASS) {
|
|
DISJUNCTION_RE_CC: token-->RE_CONSTRAINT = -1;
|
|
QUANTIFIER_RE_CC: token-->RE_CONSTRAINT = -1;
|
|
}
|
|
if (token-->RE_DOWN) TEXT_TY_RE_EraseConstraints(token-->RE_DOWN);
|
|
token = token-->RE_NEXT;
|
|
}
|
|
|
|
* (statement) !while
|
|
* (subexpression)
|
|
* (operation) !ne
|
|
* (expr)
|
|
IDENTIFIER token
|
|
* (expr)
|
|
IDENTIFIER NULL
|
|
* (code)
|
|
* (statement) !switch
|
|
* (subexpression)
|
|
* (operation) !lookup
|
|
* (expr)
|
|
IDENTIFIER token
|
|
* (expr)
|
|
IDENTIFIER RE_CCLASS
|
|
* (code)
|
|
* (statement) !case
|
|
* (expr)
|
|
IDENTIFIER DISJUNCTION_RE_CC
|
|
* (code)
|
|
* (operation) !store
|
|
* (operation) !lookup
|
|
* (expr)
|
|
IDENTIFIER token
|
|
* (expr)
|
|
IDENTIFIER RE_CONSTRAINT
|
|
* (expr)
|
|
NUMBER -1
|
|
* (statement) !case
|
|
* (expr)
|
|
IDENTIFIER QUANTIFIER_RE_CC
|
|
* (code)
|
|
* (operation) !store
|
|
* (operation) !lookup
|
|
* (expr)
|
|
IDENTIFIER token
|
|
* (expr)
|
|
IDENTIFIER RE_CONSTRAINT
|
|
* (expr)
|
|
NUMBER -1
|
|
* (statement) !if
|
|
* (subexpression)
|
|
* (operation) !lookup
|
|
* (expr)
|
|
IDENTIFIER token
|
|
* (expr)
|
|
IDENTIFIER RE_DOWN
|
|
* (code)
|
|
* (call)
|
|
* (expr)
|
|
IDENTIFIER TEXT_TY_RE_EraseConstraints
|
|
* (operation) !lookup
|
|
* (expr)
|
|
IDENTIFIER token
|
|
* (expr)
|
|
IDENTIFIER RE_DOWN
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER token
|
|
* (operation) !lookup
|
|
* (expr)
|
|
IDENTIFIER token
|
|
* (expr)
|
|
IDENTIFIER RE_NEXT
|
|
=========
|
|
Test: parse schema from:
|
|
if (b) print 1; else print 2;
|
|
|
|
* (statement) !ifelse
|
|
* (subexpression)
|
|
* (expr)
|
|
IDENTIFIER b
|
|
* (code)
|
|
* (statement) !printnumber
|
|
* (expr)
|
|
NUMBER 1
|
|
* (code)
|
|
* (statement) !printnumber
|
|
* (expr)
|
|
NUMBER 2
|
|
=========
|
|
Test: parse schema from:
|
|
a: if (b) print 1; else print 2;
|
|
|
|
* (statement) !case
|
|
* (expr)
|
|
IDENTIFIER a
|
|
* (code) <
|
|
* (statement) !ifelse
|
|
* (subexpression)
|
|
* (expr)
|
|
IDENTIFIER b
|
|
* (code)
|
|
* (statement) !printnumber
|
|
* (expr)
|
|
NUMBER 1
|
|
* (code)
|
|
* (statement) !printnumber
|
|
* (expr)
|
|
NUMBER 2
|
|
=========
|
|
Test: parse schema from:
|
|
print_ret "This is ", (char) X, ".";
|
|
|
|
* (statement) !print
|
|
* (expr)
|
|
DQUOTED This is
|
|
* (statement) !printchar
|
|
* (expr)
|
|
IDENTIFIER X
|
|
* (statement) !print
|
|
* (expr)
|
|
DQUOTED .
|
|
* (statement) !print
|
|
* (expr)
|
|
DQUOTED
|
|
|
|
* (statement) !return
|
|
* (expr)
|
|
NUMBER 1
|
|
=========
|
|
Test: parse schema from:
|
|
@jl y 0 ?X;
|
|
@jl y 0 ?~X;
|
|
@jl y 0 ?rtrue;
|
|
@jl y 0 ?rfalse;
|
|
@jl y 0 ?~rtrue;
|
|
@jl y 0 ?~rfalse;
|
|
|
|
* (assembly)
|
|
* (expr)
|
|
OPCODE @jl
|
|
* (expr)
|
|
IDENTIFIER y
|
|
* (expr)
|
|
NUMBER 0
|
|
* (expr)
|
|
ASM_LABEL X
|
|
* (assembly)
|
|
* (expr)
|
|
OPCODE @jl
|
|
* (expr)
|
|
IDENTIFIER y
|
|
* (expr)
|
|
NUMBER 0
|
|
* (expr)
|
|
NEGASM_LABEL X
|
|
* (assembly)
|
|
* (expr)
|
|
OPCODE @jl
|
|
* (expr)
|
|
IDENTIFIER y
|
|
* (expr)
|
|
NUMBER 0
|
|
* (expr)
|
|
ASM_LABEL rtrue
|
|
* (assembly)
|
|
* (expr)
|
|
OPCODE @jl
|
|
* (expr)
|
|
IDENTIFIER y
|
|
* (expr)
|
|
NUMBER 0
|
|
* (expr)
|
|
ASM_LABEL rfalse
|
|
* (assembly)
|
|
* (expr)
|
|
OPCODE @jl
|
|
* (expr)
|
|
IDENTIFIER y
|
|
* (expr)
|
|
NUMBER 0
|
|
* (expr)
|
|
NEGASM_LABEL rtrue
|
|
* (assembly)
|
|
* (expr)
|
|
OPCODE @jl
|
|
* (expr)
|
|
IDENTIFIER y
|
|
* (expr)
|
|
NUMBER 0
|
|
* (expr)
|
|
NEGASM_LABEL rfalse
|
|
=========
|
|
Test: parse schema from:
|
|
switch (token-->RE_CCLASS) {
|
|
|
|
! Should never happen
|
|
|
|
CHOICE_RE_CC: return "internal error";
|
|
|
|
! Mode switches
|
|
|
|
SENSITIVITY_RE_CC:
|
|
if (token-->RE_PAR1) mode_flags = mode_flags | CIS_MFLAG;
|
|
else mode_flags = mode_flags & (~CIS_MFLAG);
|
|
outcome = true;
|
|
|
|
! Zero-length positional markers
|
|
|
|
ALWAYS_RE_CC:
|
|
outcome = true;
|
|
NEVER_RE_CC:
|
|
START_RE_CC:
|
|
if (ipos == 0) outcome = true;
|
|
END_RE_CC:
|
|
if (BlkValueRead(txt, ipos) == 0) outcome = true;
|
|
SOMETIMES_RE_CC:
|
|
outcome = true;
|
|
}
|
|
|
|
* (statement) !switch
|
|
* (subexpression)
|
|
* (operation) !lookup
|
|
* (expr)
|
|
IDENTIFIER token
|
|
* (expr)
|
|
IDENTIFIER RE_CCLASS
|
|
* (code)
|
|
* (statement) !case
|
|
* (expr)
|
|
IDENTIFIER CHOICE_RE_CC
|
|
* (code)
|
|
* (statement) !return
|
|
* (expr)
|
|
DQUOTED internal error
|
|
* (statement) !case
|
|
* (expr)
|
|
IDENTIFIER SENSITIVITY_RE_CC
|
|
* (code)
|
|
* (statement) !ifelse
|
|
* (subexpression)
|
|
* (operation) !lookup
|
|
* (expr)
|
|
IDENTIFIER token
|
|
* (expr)
|
|
IDENTIFIER RE_PAR1
|
|
* (code)
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER mode_flags
|
|
* (operation) !bitwiseor
|
|
* (expr)
|
|
IDENTIFIER mode_flags
|
|
* (expr)
|
|
IDENTIFIER CIS_MFLAG
|
|
* (code)
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER mode_flags
|
|
* (operation) !bitwiseand
|
|
* (expr)
|
|
IDENTIFIER mode_flags
|
|
* (subexpression)
|
|
* (operation) !bitwisenot
|
|
* (expr)
|
|
IDENTIFIER CIS_MFLAG
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER outcome
|
|
* (expr)
|
|
NUMBER true
|
|
* (statement) !case
|
|
* (expr)
|
|
IDENTIFIER ALWAYS_RE_CC
|
|
* (code)
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER outcome
|
|
* (expr)
|
|
NUMBER true
|
|
* (statement) !case
|
|
* (expr)
|
|
IDENTIFIER NEVER_RE_CC
|
|
* (code)
|
|
* (statement) !case
|
|
* (expr)
|
|
IDENTIFIER START_RE_CC
|
|
* (code)
|
|
* (statement) !if
|
|
* (subexpression)
|
|
* (operation) !eq
|
|
* (expr)
|
|
IDENTIFIER ipos
|
|
* (expr)
|
|
NUMBER 0
|
|
* (code)
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER outcome
|
|
* (expr)
|
|
NUMBER true
|
|
* (statement) !case
|
|
* (expr)
|
|
IDENTIFIER END_RE_CC
|
|
* (code)
|
|
* (statement) !if
|
|
* (subexpression)
|
|
* (operation) !eq
|
|
* (call)
|
|
* (expr)
|
|
IDENTIFIER BlkValueRead
|
|
* (expr)
|
|
IDENTIFIER txt
|
|
* (expr)
|
|
IDENTIFIER ipos
|
|
* (expr)
|
|
NUMBER 0
|
|
* (code)
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER outcome
|
|
* (expr)
|
|
NUMBER true
|
|
* (statement) !case
|
|
* (expr)
|
|
IDENTIFIER SOMETIMES_RE_CC
|
|
* (code)
|
|
* (operation) !store
|
|
* (expr)
|
|
IDENTIFIER outcome
|
|
* (expr)
|
|
NUMBER true
|
|
=========
|
|
Test: parse schema from:
|
|
print (char) 'a';
|
|
print (char) ''';
|
|
|
|
* (statement) !printchar
|
|
* (expr)
|
|
SQUOTED a
|
|
* (statement) !printchar
|
|
* (expr)
|
|
SQUOTED '
|
|
=========
|