diff --git a/misc/ATOMS b/misc/ATOMS index 9904f2e8d..5379e305a 100644 --- a/misc/ATOMS +++ b/misc/ATOMS @@ -15,9 +15,10 @@ A AfLocal N "AF_LOCAL" A AfUnix N "AF_UNIX" A Alarm F "$alarm" A Alias N "alias" -A All N "all" +A All N "all" A AltNot N "not" -A Any N "any" +A Answer N "answer" +A Any N "any" A Append N "append" A Arg N "arg" A Array F "$array" @@ -135,6 +136,7 @@ A ExecuteInMod F "$execute_in_mod" A ExecuteWithin F "$execute_within" A ExecuteWoMod F "$execute_wo_mod" A Exist N "exist" +A Exit N "exit" A ExistenceError N "existence_error" A ExoClause F "$exo_clause" A ExpectedNumber N "expected_number_syntax" @@ -289,7 +291,8 @@ A PrivateProcedure N "private_procedure" A Procedure N "procedure" A Profile F "$profile" A Prolog N "prolog" -A Qly N "qly" +A ProtectStack F "$protect_stack" +A Qly N "qly" A Query N "?-" A Queue N "queue" A Quiet N "quiet" @@ -479,6 +482,7 @@ F EmptyCurlyBrackets EmptyCurlyBrackets 2 F Eq Eq 2 F Error Error 2 F EvaluationError EvaluationError 1 +F Exception Exception 1 F Execute2InMod ExecuteWoMod 2 F ExecuteInMod ExecuteInMod 2 F ExecuteWithin ExecuteWithin 1 @@ -521,6 +525,7 @@ F Portray Portray 1 F PrintMessage PrintMessage 2 F Procedure Procedure 5 F PrologConstraint Prolog 2 +F ProtectStack ProtectStack 1 F Query Query 1 F RecordedWithKey RecordedWithKey 6 F RDiv RDiv 2 diff --git a/misc/HEAPFIELDS b/misc/HEAPFIELDS index e2a439128..9c853199f 100644 --- a/misc/HEAPFIELDS +++ b/misc/HEAPFIELDS @@ -90,7 +90,8 @@ ATOMS #ifdef EUROTRA Term TermDollarU MkAT AtomDollarU #endif - +Term TermAnswer MkAT AtomAnswer +z //modules Term USER_MODULE MkAT AtomUser Term IDB_MODULE MkAT AtomIDB @@ -147,24 +148,25 @@ struct pred_entry *PredTrue MkPred AtomTrue 0 PROLOG_MODULE #ifdef COROUTINING struct pred_entry *WakeUpCode MkPred AtomWakeUpGoal 2 PROLOG_MODULE #endif -struct pred_entry *PredGoalExpansion MkPred FunctorGoalExpansion USER_MODULE -struct pred_entry *PredMetaCall MkPred FunctorMetaCall PROLOG_MODULE -struct pred_entry *PredTraceMetaCall MkPred FunctorTraceMetaCall PROLOG_MODULE struct pred_entry *PredDollarCatch MkPred FunctorCatch PROLOG_MODULE -struct pred_entry *PredRecordedWithKey MkPred FunctorRecordedWithKey PROLOG_MODULE -struct pred_entry *PredLogUpdClause MkPred FunctorDoLogUpdClause PROLOG_MODULE -struct pred_entry *PredLogUpdClauseErase MkPred FunctorDoLogUpdClauseErase PROLOG_MODULE -struct pred_entry *PredLogUpdClause0 MkPred FunctorDoLogUpdClause PROLOG_MODULE -struct pred_entry *PredStaticClause MkPred FunctorDoStaticClause PROLOG_MODULE -struct pred_entry *PredThrow MkPred FunctorThrow PROLOG_MODULE -struct pred_entry *PredHandleThrow MkPred FunctorHandleThrow PROLOG_MODULE -struct pred_entry *PredIs MkPred FunctorIs PROLOG_MODULE -struct pred_entry *PredSafeCallCleanup MkPred FunctorSafeCallCleanup PROLOG_MODULE -struct pred_entry *PredRestoreRegs MkPred FunctorRestoreRegs PROLOG_MODULE -struct pred_entry *PredCommentHook MkPred FunctorCommentHook PROLOG_MODULE #ifdef YAPOR struct pred_entry *PredGetwork MkPred AtomGetwork 0 PROLOG_MODULE #endif /* YAPOR */ +struct pred_entry *PredGoalExpansion MkPred FunctorGoalExpansion USER_MODULE +struct pred_entry *PredHandleThrow MkPred FunctorHandleThrow PROLOG_MODULE +struct pred_entry *PredIs MkPred FunctorIs PROLOG_MODULE +struct pred_entry *PredLogUpdClause MkPred FunctorDoLogUpdClause PROLOG_MODULE +struct pred_entry *PredLogUpdClauseErase MkPred FunctorDoLogUpdClauseErase PROLOG_MODULE +struct pred_entry *PredLogUpdClause0 MkPred FunctorDoLogUpdClause PROLOG_MODULE +struct pred_entry *PredMetaCall MkPred FunctorMetaCall PROLOG_MODULE +struct pred_entry *PredProtectStack MkPred FunctorProtectStack PROLOG_MODULE +struct pred_entry *PredRecordedWithKey MkPred FunctorRecordedWithKey PROLOG_MODULE +struct pred_entry *PredRestoreRegs MkPred FunctorRestoreRegs PROLOG_MODULE +struct pred_entry *PredSafeCallCleanup MkPred FunctorSafeCallCleanup PROLOG_MODULE +struct pred_entry *PredStaticClause MkPred FunctorDoStaticClause PROLOG_MODULE +struct pred_entry *PredThrow MkPred FunctorThrow PROLOG_MODULE +struct pred_entry *PredTraceMetaCall MkPred FunctorTraceMetaCall PROLOG_MODULE +struct pred_entry *PredCommentHook MkPred FunctorCommentHook PROLOG_MODULE struct pred_entry *PredProcedure MkLogPred FunctorProcedure PROLOG_MODULE /* low-level tracer */ diff --git a/misc/buildatoms b/misc/buildatoms index 7aba1cc13..e21914062 100644 --- a/misc/buildatoms +++ b/misc/buildatoms @@ -13,29 +13,39 @@ main :- warning(Warning), - file_filter_with_init('misc/ATOMS','H/heap/tatoms.h',gen_fields, Warning, ['tatoms.h']), - file_filter_with_init('misc/ATOMS','H/heap/iatoms.h',gen_decl, Warning, ['iatoms.h']), - file_filter_with_init('misc/ATOMS','H/heap/ratoms.h',gen_rcov, Warning, ['ratoms.h']). + file_filter_with_init('misc/ATOMS','H/generated/tatoms.h',gen_fields, Warning, ['tatoms.h']), + file_filter_with_init('misc/ATOMS','H/generated/iatoms.h',gen_decl, Warning, ['iatoms.h']), + file_filter_with_init('misc/ATOMS','H/generated/ratoms.h',gen_rcov, Warning, ['ratoms.h']). -warning('~n /* This file, ~a, was generated automatically by \"yap -L misc/buildatoms\"~n please do not update, update misc/ATOMS instead */~n~n'). +warning('~n /* This file, ~a, was generated automatically by \"yap -L misc/buildatoms\"~n {lease do not update, update misc/ATOMS instead */~n~n'). gen_fields(Inp,Out) :- split_unquoted(Inp," ",["A",Atom,_,_]), !, - append([" Atom Atom",Atom,"_;\n#define Atom",Atom," Yap_heap_regs->Atom",Atom,"_\n", - "#define Term",Atom," MkAtomTerm( Yap_heap_regs->Atom",Atom,"_ )"],Out). + ( Atom = [C|_], code_type(C, alpha), Atom \= "Trail" + -> + append(["Atom Atom",Atom,"; Term Term",Atom,";"], Out) + ; + append(["Atom Atom",Atom,";"], Out) + ). %gen_fields(Inp,Out) :- % split_unquoted(Inp," ",["A",Atom,_]), !, % append([" Atom Atom_",Atom,"_;\n#define Atom_",Atom," Yap_heap_regs->Atom_",Atom,"_"],Out). gen_fields(Inp,Out) :- split_unquoted(Inp," ",["F",Name,_,_]), !, - append([" Functor Functor",Name,"_;\n#define Functor",Name," Yap_heap_regs->Functor",Name,"_"],Out). + append([" Functor Functor",Name,";\n"],Out). +% append([" Functor Functor",Name,"_;\n#define Functor",Name," Yap_heap_regs->Functor",Name,"_"],Out). %gen_fields(Inp,Out) :- % split_unquoted(Inp," ",["F",Name,Arity]), !, % append([" Functor Functor_",Name,Arity,"_;\n#define Functor_",Name,Arity," Yap_heap_regs->Functor_",Name,Arity,"_"],Out). gen_rcov(Inp,Out) :- split_unquoted(Inp," ",["A",Atom,_,_]), !, - append([" Atom",Atom," = AtomAdjust(Atom",Atom,");"],Out). + ( Atom = [C|_], code_type(C, alpha), Atom \= "Trail" + -> + append([" Atom",Atom," = AtomAdjust(Atom",Atom,"); Term",Atom," = MkAtomTerm(Atom",Atom,");"],Out) + ; + append([" Atom",Atom," = AtomAdjust(Atom",Atom,");"],Out) + ). %gen_rcov(Inp,Out) :- % split_unquoted(Inp," ",["A",Atom,_]), !, % append([" Atom_",Atom," = AtomAdjust(Atom_",Atom,");"],Out). @@ -48,10 +58,20 @@ gen_rcov(Inp,Out) :- gen_decl(Inp,Out) :- split_unquoted(Inp," ",["A",Atom,"N",String]), !, - append([" Atom",Atom," = Yap_LookupAtom(",String,");"],Out). + ( Atom = [C|_], code_type(C, alpha), Atom \= "Trail" + -> + append([" Atom",Atom," = Yap_LookupAtom(",String,"); Term",Atom," = MkAtomTerm(Atom",Atom,");"],Out) + ; + append([" Atom",Atom," = Yap_LookupAtom(",String,");"],Out) + ). gen_decl(Inp,Out) :- split_unquoted(Inp," ",["A",Atom,"F",String]), !, - append([" Atom",Atom," = Yap_FullLookupAtom(",String,");"],Out). + ( Atom = [C|_], code_type(C, alpha), Atom \= "Trail" + -> + append([" Atom",Atom," = Yap_FullLookupAtom(",String,"); Term",Atom," = MkAtomTerm(Atom",Atom,");"],Out) + ; + append([" Atom",Atom," = Yap_FullLookupAtom(",String,");"],Out) + ). %gen_decl(Inp,Out) :- % split_unquoted(Inp," ",["A",Atom,String]), String = [0'",0'$|_], !, % append([" Atom_",Atom," = Yap_FullLookupAtom(",String,");"],Out). diff --git a/misc/editors/AtTmSuCo/Syntax/Prolog.YAML-tmLanguage b/misc/editors/AtTmSuCo/Syntax/Prolog.YAML-tmLanguage new file mode 100644 index 000000000..b7f256e75 --- /dev/null +++ b/misc/editors/AtTmSuCo/Syntax/Prolog.YAML-tmLanguage @@ -0,0 +1,488 @@ +comment: + This Source Code Form is subject to the terms of the Mozilla Public License, + v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain + the license from this directory, + - + - + - This file is based on the Prolog grammar files for Sublime, + by Patrick Schmidt, for TextMate, Michael Sheets at TexMate, and + for atom.io, maintained by Jake Prather and colleagues. It also + refers to the impressive Logtalk editing support, + developed by Paulo Moura and the Logtalk community. + I also used the excellent Matt Morrison's + Python and Matthew Alexander's Swift language files. + Thanks! + - + - The goals were: + * support atom.io, vscode, Sublime, and TextMate + * support YAP Prolog files: yap and yss suffixes + * improved reading for online documentation + * structured editing, so that as much actual Prolog + * syntax as possible is available. + - + The language will support more than what it should. It may + also support less than it should. + + - Implementation: I use Sublime YAML format (property lists). + Sublime generates the TM format, from there you cn use atm + to convert to atom, and the VScode format. +fileTypes: [yap, yss, prolog, pl, pro, P] +firstLineMatch: ^(#!/.*\byap|\%.*prolog.*) +foldingStartMarker: ^(([a-z]\w*|\'\$\w\')\(|\s*\(|\s*\/\*) +foldingStopMarker: (\)|\.|\*\/)\s*$ +name: Prolog +scopeName: source.prolog +uuid: f6546674-e459-11e5-8f80-60f81db5ed04 + +patterns: + +- include: '#comments' + +- begin: ^(:-)\s*(([a-z]\w*:)?([a-z]\w*|\'\$\w*\'))(?=(\(|\s)) + # directives are terms of the form ":- directive arguments + end: (\.)(\s|$) + beginCaptures: + '1': {name: keyword.control.directive.begin.prolog} + '2': {name: entity.directivesss.prolog} + endCaptures: + '2': {name: keyword.control.directive.end.prolog} + name: meta.directive.prolog + patterns: + - {include: '#functor'} + - {include: '#atom'} + - {include: '#variable'} + - {include: '#constants'} + - match: . + +- begin: ^\s*(([a-z]\w*)(:))?([a-z]\w*|\'\$\w*\')\( + beginCaptures: + '0': {name: meta.clause.prolog.head} + '2': {name: entity.name.module.clause.prolog} + '3': {name: keyword.control.module.prolog} + '4': {name: entity.name.predicate.prolog} + end: ((\.)(\s|$)) + endCaptures: + '2': {name: keyword.control.clause.end.prolog} + name: meta.clause.prolog + patterns: + - {include: '#clause_head_arguments'} + - {include: '#clause_body'} + +- begin: ^\s*(([a-z]\w*)(:))?([a-z]\w*|\'\$\w*\')\s* + beginCaptures: + '0': {name: meta.clause.prolog.head} + '2': {name: entity.name.module.clause.prolog} + '3': {name: keyword.control.module.prolog} + '4': {name: entity.name.predicate.prolog} + end: ((\.)(\s|$)) + endCaptures: + '2': {name: keyword.control.clause.end.prolog} + name: meta.clause.prolog + patterns: + - {include: '#clause_body'} + +repository: + + clause_head_arguments: + begin: (?<=\() + end: (\))\s*(?=(:-|-->|\.)) + name: meta.clause.prolog.head + patterns: + - include: '#args' + + clause_body: + begin: (:-|-->) + beginCaptures: + '1': {name: keyword.control.clause.neck.prolog} + end: (?=((\.)(\s|$))) + name: meta.clause.prolog.body + patterns: + - include: '#conj' + - include: '#conj' + - include: '#base_call' + + conj: + name: meta.clause.body.conjunction + begin: \, + beginCaptures: + '0': {name: keyword.control.and.prolog} + end: (?=(\,|\)|\}|\]|\.)) + patterns: + - include: '#disj' + - include: '#conj' + - include: '#base_call' + + disj: + name: meta.clause.disjunction + begin: ((\;)|(->)) + beginCaptures: + '2': {name: keyword.control.or.prolog} + '3': { name: keyword.control.if.prolog } + end: \s*(?=(\,|\;|\.|\)|\}|\|\.\])) + patterns: + - include: '#disj' + - include: '#base_call' + + op_infix: + match: (same|\^|\*\*|rem|mod|\>\>| + \<\<|\/\/|\/|\*|xor|div|rdiv|\#| + ><|\\\/|\/\\|\\-|\\+|:|as|>=|=<| + >|<|=\\=|=:=|\\=@=|=@=|@>=|@=<|@>|@<| + \\==|==|=\.\.|is|\\=|=|->|\;|\,|\||-->|\?-) + name: keyword.control.op.infix.prolog + + op_prefix: + match: (spy|nospy|block|\\|\-|\+|not|\\\+|uncutable| + table|discontiguous|module_transparent|meta_predicate|multifile| + public|mode|volatile|initialization|thread_local| + dynamic|\?-|\?-) + name: keyword.control.op.prefix.prolog + + crlbrackets: + name: curly.brackets + begin: (\{) + end: (\}) + patterns: + - include: '#comments' + - match: \s*\,\s* + - include: '#term' + + sqrbrackets: + name: sqr.brackets + begin: (\[) + end: (\]) + patterns: + - include: '#comments' + - match: \s*(\,|\|)\s* + - include: '#term' + + args: + name: meta.term.arguments + patterns: + - include: '#term' + - match: \, + + term: + name: meta.term.prolog + patterns: + - include: '#comments' + - include: '#op_infix' + - include: '#op_prefix' + - {include: '#atom'} + - {include: '#variable'} + - {include: '#constants'} + - include: '#brackets' + - include: '#sqrbrackets' + - include: '#crlbrackets' + - match: \s + + atom: + patterns: + - {match: '\[\]', name: constant.other.atom.emptylist.prolog} + - {match: '\b[a-z]\w*\b', name: support.atom.simple.prolog} + - begin: (?