MCPcopy
hub / github.com/GetmeUK/ContentTools / _Parser

Function _Parser

external/scripts/content-edit.js:870–1000  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

868
869 _Parser = (function() {
870 function _Parser() {
871 this.fsm = new FSM.Machine(this);
872 this.fsm.setInitialState(CHAR_OR_ENTITY_OR_TAG);
873 this.fsm.addTransitionAny(CHAR_OR_ENTITY_OR_TAG, null, function(c) {
874 return this._pushChar(c);
875 });
876 this.fsm.addTransition('<', CHAR_OR_ENTITY_OR_TAG, OPENNING_OR_CLOSING_TAG);
877 this.fsm.addTransition('&', CHAR_OR_ENTITY_OR_TAG, ENTITY);
878 this.fsm.addTransitions(ENTITY_CHARS, ENTITY, null, function(c) {
879 return this.entity += c;
880 });
881 this.fsm.addTransition(';', ENTITY, CHAR_OR_ENTITY_OR_TAG, function() {
882 this._pushChar("&" + this.entity + ";");
883 return this.entity = '';
884 });
885 this.fsm.addTransitions([' ', '\n'], OPENNING_OR_CLOSING_TAG);
886 this.fsm.addTransitions(ALPHA_CHARS, OPENNING_OR_CLOSING_TAG, OPENING_TAG, function() {
887 return this._back();
888 });
889 this.fsm.addTransition('/', OPENNING_OR_CLOSING_TAG, CLOSING_TAG);
890 this.fsm.addTransitions([' ', '\n'], OPENING_TAG);
891 this.fsm.addTransitions(ALPHA_CHARS, OPENING_TAG, TAG_NAME_OPENING, function() {
892 return this._back();
893 });
894 this.fsm.addTransitions([' ', '\n'], CLOSING_TAG);
895 this.fsm.addTransitions(ALPHA_CHARS, CLOSING_TAG, TAG_NAME_CLOSING, function() {
896 return this._back();
897 });
898 this.fsm.addTransitions(TAG_NAME_CHARS, TAG_NAME_OPENING, null, function(c) {
899 return this.tagName += c;
900 });
901 this.fsm.addTransitions([' ', '\n'], TAG_NAME_OPENING, ATTR_OR_TAG_END);
902 this.fsm.addTransition('/', TAG_NAME_OPENING, TAG_OPENING_SELF_CLOSING, function() {
903 return this.selfClosing = true;
904 });
905 this.fsm.addTransition('>', TAG_NAME_OPENING, CHAR_OR_ENTITY_OR_TAG, function() {
906 return this._pushTag();
907 });
908 this.fsm.addTransitions([' ', '\n'], TAG_OPENING_SELF_CLOSING);
909 this.fsm.addTransition('>', TAG_OPENING_SELF_CLOSING, CHAR_OR_ENTITY_OR_TAG, function() {
910 return this._pushTag();
911 });
912 this.fsm.addTransitions([' ', '\n'], ATTR_OR_TAG_END);
913 this.fsm.addTransition('/', ATTR_OR_TAG_END, TAG_OPENING_SELF_CLOSING, function() {
914 return this.selfClosing = true;
915 });
916 this.fsm.addTransition('>', ATTR_OR_TAG_END, CHAR_OR_ENTITY_OR_TAG, function() {
917 return this._pushTag();
918 });
919 this.fsm.addTransitions(ALPHA_CHARS, ATTR_OR_TAG_END, ATTR_NAME, function() {
920 return this._back();
921 });
922 this.fsm.addTransitions(TAG_NAME_CHARS, TAG_NAME_CLOSING, null, function(c) {
923 return this.tagName += c;
924 });
925 this.fsm.addTransitions([' ', '\n'], TAG_NAME_CLOSING, TAG_NAME_MUST_CLOSE);
926 this.fsm.addTransition('>', TAG_NAME_CLOSING, CHAR_OR_ENTITY_OR_TAG, function() {
927 return this._popTag();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected